diff options
author | dims <dims@13f79535-47bb-0310-9956-ffa450edef68> | 2008-06-17 00:23:01 +0000 |
---|---|---|
committer | dims <dims@13f79535-47bb-0310-9956-ffa450edef68> | 2008-06-17 00:23:01 +0000 |
commit | bdd0a41aed7edf21ec2a65cfa17a86af2ef8c48a (patch) | |
tree | 38a92061c0793434c4be189f1d70c3458b6bc41d /tags/java-M1-20060518/java/sca/model |
Move Tuscany from Incubator to top level.
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@668359 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'tags/java-M1-20060518/java/sca/model')
104 files changed, 7278 insertions, 0 deletions
diff --git a/tags/java-M1-20060518/java/sca/model/LICENSE.txt b/tags/java-M1-20060518/java/sca/model/LICENSE.txt new file mode 100644 index 0000000000..d645695673 --- /dev/null +++ b/tags/java-M1-20060518/java/sca/model/LICENSE.txt @@ -0,0 +1,202 @@ + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/tags/java-M1-20060518/java/sca/model/README.txt b/tags/java-M1-20060518/java/sca/model/README.txt new file mode 100644 index 0000000000..9b26d1690a --- /dev/null +++ b/tags/java-M1-20060518/java/sca/model/README.txt @@ -0,0 +1,35 @@ +Apache Tuscany M1 build (May, 2006) +=================================== + +http://incubator.apache.org/tuscany/ + +Tuscany is an effort undergoing incubation at the Apache Software Foundation +(ASF), sponsored by the Web Services PMC. + +Incubation is required of all newly accepted projects until a further review +indicates that the infrastructure, communications, and decision making process +have stabilized in a manner consistent with other successful ASF projects. + +While incubation status is not necessarily a reflection of the completeness or +stability of the code, it does indicate that the project has yet to be fully +endorsed by the ASF. + + +Support +------- + +Any problem with this release can be reported to the Tuscany mailing list +or in the JIRA issue tracker. + +Mailing list subscription: + tuscany-dev-subscribe@ws.apache.org + +Jira: + http://issues.apache.org/jira/browse/Tuscany + + +Thank you for using Tuscany! + + +The Tuscany Team. + diff --git a/tags/java-M1-20060518/java/sca/model/pom.xml b/tags/java-M1-20060518/java/sca/model/pom.xml new file mode 100644 index 0000000000..c1b74166aa --- /dev/null +++ b/tags/java-M1-20060518/java/sca/model/pom.xml @@ -0,0 +1,77 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + * Copyright (c) 2005-2006 The Apache Software Foundation or its licensors, as applicable. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + --> +<project> + <parent> + <groupId>org.apache.tuscany</groupId> + <artifactId>tuscany-sca</artifactId> + <version>incubating-M1</version> + </parent> + <modelVersion>4.0.0</modelVersion> + <artifactId>tuscany-model</artifactId> + <name>Tuscany Assembly Model</name> + <description>Data model for the Assembly model defined by the SCA specification.</description> + <version>incubating-M1</version> + + <dependencies> + <dependency> + <groupId>org.osoa</groupId> + <artifactId>sca-api</artifactId> + <version>${pom.version}</version> + <scope>compile</scope> + </dependency> + <dependency> + <groupId>org.apache.tuscany</groupId> + <artifactId>tuscany-common</artifactId> + <version>${pom.version}</version> + <scope>compile</scope> + </dependency> + + <dependency> + <groupId>commonj</groupId> + <artifactId>sdo-api</artifactId> + <version>incubating-M1</version> + <scope>compile</scope> + </dependency> + <dependency> + <groupId>org.apache.tuscany</groupId> + <artifactId>tuscany-sdo-impl</artifactId> + <version>incubating-M1</version> + <scope>compile</scope> + </dependency> + + <dependency> + <groupId>wsdl4j</groupId> + <artifactId>wsdl4j</artifactId> + <version>1.5.2</version> + <scope>compile</scope> + </dependency> + + <dependency> + <groupId>asm</groupId> + <artifactId>asm</artifactId> + <version>2.2</version> + <scope>compile</scope> + </dependency> + + <dependency> + <groupId>junit</groupId> + <artifactId>junit</artifactId> + <version>3.8.1</version> + <scope>test</scope> + </dependency> + </dependencies> +</project> diff --git a/tags/java-M1-20060518/java/sca/model/src/main/java/org/apache/tuscany/model/ModelRuntimeException.java b/tags/java-M1-20060518/java/sca/model/src/main/java/org/apache/tuscany/model/ModelRuntimeException.java new file mode 100644 index 0000000000..e167882786 --- /dev/null +++ b/tags/java-M1-20060518/java/sca/model/src/main/java/org/apache/tuscany/model/ModelRuntimeException.java @@ -0,0 +1,42 @@ +/** + * + * Copyright 2005 The Apache Software Foundation or its licensors, as applicable. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package org.apache.tuscany.model; + +import org.apache.tuscany.common.TuscanyRuntimeException; + +/** + * The root runtime exception for the model. + * + * @version $Rev$ $Date$ + */ +@SuppressWarnings({"serial"}) +public abstract class ModelRuntimeException extends TuscanyRuntimeException { + + public ModelRuntimeException() { + super(); + } + + public ModelRuntimeException(String message) { + super(message); + } + + public ModelRuntimeException(String message, Throwable cause) { + super(message, cause); + } + + public ModelRuntimeException(Throwable cause) { + super(cause); + } + +} diff --git a/tags/java-M1-20060518/java/sca/model/src/main/java/org/apache/tuscany/model/assembly/AssemblyContext.java b/tags/java-M1-20060518/java/sca/model/src/main/java/org/apache/tuscany/model/assembly/AssemblyContext.java new file mode 100644 index 0000000000..48aed5f35a --- /dev/null +++ b/tags/java-M1-20060518/java/sca/model/src/main/java/org/apache/tuscany/model/assembly/AssemblyContext.java @@ -0,0 +1,64 @@ +/** + * + * Copyright 2005 The Apache Software Foundation or its licensors, as applicable. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.tuscany.model.assembly; + +import org.apache.tuscany.common.resource.ResourceLoader; +import org.apache.tuscany.model.assembly.loader.AssemblyModelLoader; + +import commonj.sdo.helper.TypeHelper; + +/** + * Context object supplied by visitors that are processing the model. + */ +public interface AssemblyContext { + + /** + * Returns a factory that can be used to create other model objects + * + * @return a factory for model objects + */ + AssemblyFactory getAssemblyFactory(); + + /** + * Returns a loader for resources in the application environment. + * + * @return a loader for resources in the system environment + */ + ResourceLoader getApplicationResourceLoader(); + + /** + * Returns a loader that can be used to load sub-models. + * + * @return a loader for sub-models + */ + AssemblyModelLoader getAssemblyLoader(); + + /** + * Returns an SDO type helper. + * + * @return an SDO type helper + */ + TypeHelper getTypeHelper(); + + /** + * Returns the Web application module URI + * + * @return the module name of the Web app + */ + String getWebAppName(); + +} diff --git a/tags/java-M1-20060518/java/sca/model/src/main/java/org/apache/tuscany/model/assembly/AssemblyFactory.java b/tags/java-M1-20060518/java/sca/model/src/main/java/org/apache/tuscany/model/assembly/AssemblyFactory.java new file mode 100644 index 0000000000..efbc6bffa4 --- /dev/null +++ b/tags/java-M1-20060518/java/sca/model/src/main/java/org/apache/tuscany/model/assembly/AssemblyFactory.java @@ -0,0 +1,260 @@ +/** + * + * Copyright 2005 The Apache Software Foundation or its licensors, as applicable. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.tuscany.model.assembly; + +import javax.xml.namespace.QName; + +import org.apache.tuscany.model.types.java.JavaServiceContract; +import org.apache.tuscany.model.types.wsdl.WSDLServiceContract; + +/** + * The Factory for the assembly model. Provides a create method for each non-abstract class of the model. + */ +public interface AssemblyFactory { + + /** + * Returns a new SimpleComponent. + * + * @return a new SimpleComponent + */ + AtomicComponent createSimpleComponent(); + + /** + * Returns a new ComponentType. + * + * @return a new ComponentType + */ + ComponentType createComponentType(); + + /** + * Returns a new EntryPoint. + * + * @return a new EntryPoint + */ + EntryPoint createEntryPoint(); + + /** + * Returns a new ExternalService. + * + * @return a new ExternalService + */ + ExternalService createExternalService(); + + /** + * Returns a new JavaServiceContract. + * + * @return a new JavaServiceContract + */ + JavaServiceContract createJavaServiceContract(); + + /** + * Returns a new Module. + * + * @return a new Module + */ + Module createModule(); + + /** + * Returns a new ModuleComponent. + * + * @return a new ModuleComponent + */ + ModuleComponent createModuleComponent(); + + /** + * Returns a new ModuleFragment. + * + * @return a new ModuleFragment + */ + ModuleFragment createModuleFragment(); + + /** + * Returns a new Reference. + * + * @return a new Reference + */ + Reference createReference(); + + /** + * Returns a new ConfiguredReference. + * + * @return a new ConfiguredReference + */ + ConfiguredReference createConfiguredReference(); + + /** + * Returns a new Service. + * + * @return a new Service + */ + Service createService(); + + /** + * Returns a new ConfiguredService. + * + * @return a new ConfiguredService + */ + ConfiguredService createConfiguredService(); + + /** + * Returns a new Subsystem. + * + * @return a new Subsystem + */ + Subsystem createSubsystem(); + + /** + * Returns a new Property. + * + * @return a new Property + */ + Property createProperty(); + + /** + * Returns a new ConfiguredProperty. + * + * @return a new ConfiguredProperty + */ + ConfiguredProperty createConfiguredProperty(); + + /** + * Returns a new WSDLServiceContract. + * + * @return a new WSDLServiceContract + */ + WSDLServiceContract createWSDLServiceContract(); + + /** + * Create a new ServiceURI from the given uri string. + * + * @param uri the URI for the service + * @return a new ServiceURI created from the supplied URI + */ + ServiceURI createServiceURI(String uri); + + /** + * Creates a new ServiceURI from a module component and a service name. + * + * @param moduleComponent the module component exposing the service + * @param serviceName the name of the service exposed by the module + * @return a new ServiceURI for the exposed service + */ + ServiceURI createServiceURI(ModuleComponent moduleComponent, String serviceName); + + /** + * Creates a new ServiceURI from a module component and configured port. + * + * @param moduleComponent the module component exposing the service + * @param part the part that is providing the service + * @param configuredPort the port on the part + * @return a new serviceURI for the exposed service + */ + ServiceURI createServiceURI(ModuleComponent moduleComponent, Part part, ConfiguredPort configuredPort); + + ServiceURI createServiceURI(ModuleComponent moduleComponent, String partName, String serviceName); + + /** + * Create a qname from a URI + * + * @param uri + * @return a new qname + */ + QName createQName(String uri); + + /** + * Create a wire + * + * @return an new wire + */ + Wire createWire(); + + /** + * Helper method for creating a reference. + * + * @param name the name of the reference + * @param service the Java type of the service + * @return a Reference + */ + Reference createReference(String name, Class<?> service); + + /** + * Helper method for creating a reference. + * + * @param name the name of the reference + * @param service the Java type of the service + * @param multiplicity the multiplicity of the reference + * @return a Reference + */ + Reference createReference(String name, Class<?> service, Multiplicity multiplicity); + + /** + * Helper method for creating a configured reference. + * + * @param name the name of the reference + * @param targets the targets for the reference + * @return a ConfiguredReference + */ + ConfiguredReference createConfiguredReference(String name, String... targets); + + /** + * Helper method for creating an EntryPoint wired to a single target. + * + * @param entryPointName the name of the entry point + * @param serviceContract the service contract the EntryPoint should expose + * @param binding the binding the EntryPoint should use + * @param targetName the target the EntryPoint exposes + * @return an EntryPoint that exposes the supplied service and is wired to the target + */ + EntryPoint createEntryPoint(String entryPointName, ServiceContract serviceContract, Binding binding, String targetName); + + /** + * Helper method for creating an EntryPoint wired to a single target. + * + * @param entryPointName the name of the entry point + * @param configuredService the configured service to expose + * @param binding the binding the EntryPoint should use + * @param configuredReference a configured reference to the target + * @return an EntryPoint that exposes the supplied service using the supplied bindng and which is wired + * using the supplied reference + */ + EntryPoint createEntryPoint(String entryPointName, ConfiguredService configuredService, Binding binding, ConfiguredReference configuredReference); + + /** + * Helper method for creating a simple Property. + * + * @param name the property name + * @param type the Java type of the property + * @return a Property with the supplied name and type + */ + Property createProperty(String name, Class<?> type); + + /** + * Returns a new ImportWSDL model object. + * + * @return a new ImportWSDL model object + */ + ImportWSDL createImportWSDL(); + + /** + * Returns a new ImportWSDL model object initialized with the supplied values. + * + * @param location the location where the WSDL definition can be found + * @param namespace the namespace URI for this import + * @return a new ImportWSDL model object + */ + ImportWSDL createImportWSDL(String location, String namespace); +} diff --git a/tags/java-M1-20060518/java/sca/model/src/main/java/org/apache/tuscany/model/assembly/AssemblyInitializationException.java b/tags/java-M1-20060518/java/sca/model/src/main/java/org/apache/tuscany/model/assembly/AssemblyInitializationException.java new file mode 100644 index 0000000000..69a7854df9 --- /dev/null +++ b/tags/java-M1-20060518/java/sca/model/src/main/java/org/apache/tuscany/model/assembly/AssemblyInitializationException.java @@ -0,0 +1,46 @@ +/** + * + * Copyright 2005 The Apache Software Foundation or its licensors, as applicable. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.tuscany.model.assembly; + +import org.apache.tuscany.model.ModelRuntimeException; + +/** + * Denotes an exception initializing an assembly model artifact. + * + * @version $Rev$ $Date$ + */ +public class AssemblyInitializationException extends ModelRuntimeException { + private static final long serialVersionUID = 747289653378365323L; + + public AssemblyInitializationException() { + super(); + } + + public AssemblyInitializationException(String message) { + super(message); + } + + public AssemblyInitializationException(String message, Throwable cause) { + super(message, cause); + } + + public AssemblyInitializationException(Throwable cause) { + super(cause); + } + +} + diff --git a/tags/java-M1-20060518/java/sca/model/src/main/java/org/apache/tuscany/model/assembly/AssemblyObject.java b/tags/java-M1-20060518/java/sca/model/src/main/java/org/apache/tuscany/model/assembly/AssemblyObject.java new file mode 100644 index 0000000000..d25f114902 --- /dev/null +++ b/tags/java-M1-20060518/java/sca/model/src/main/java/org/apache/tuscany/model/assembly/AssemblyObject.java @@ -0,0 +1,45 @@ +/** + * + * Copyright 2005 The Apache Software Foundation or its licensors, as applicable. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.tuscany.model.assembly; + +/** + * Base interface for all assembly model objects providing methods for managing the model itself. + */ +public interface AssemblyObject { + + /** + * Initialize this model object. + * + * @param modelContext context providing access to the environment in which this model is being used + * @throws AssemblyInitializationException if an error ocurrs initializing the artifact + */ + void initialize(AssemblyContext modelContext) throws AssemblyInitializationException; + + /** + * Freeze this model object preventing any additional changes. + */ + void freeze(); + + /** + * Accept a visitor + * + * @param visitor a visitor that is visiting the model + * @return true if processing is complete and the visitor should stop traversing the model + */ + boolean accept(AssemblyVisitor visitor); + +} diff --git a/tags/java-M1-20060518/java/sca/model/src/main/java/org/apache/tuscany/model/assembly/AssemblyVisitor.java b/tags/java-M1-20060518/java/sca/model/src/main/java/org/apache/tuscany/model/assembly/AssemblyVisitor.java new file mode 100644 index 0000000000..f153b9b4f6 --- /dev/null +++ b/tags/java-M1-20060518/java/sca/model/src/main/java/org/apache/tuscany/model/assembly/AssemblyVisitor.java @@ -0,0 +1,32 @@ +/** + * + * Copyright 2005 The Apache Software Foundation or its licensors, as applicable. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.tuscany.model.assembly; + +/** + * A visitor that traverses the model performing some operation. + */ +public interface AssemblyVisitor { + + /** + * Visit the given model object. + * + * @param modelObject the assembly model object to visit + * @return true if processing is complete + */ + boolean visit(AssemblyObject modelObject); + +} diff --git a/tags/java-M1-20060518/java/sca/model/src/main/java/org/apache/tuscany/model/assembly/AtomicComponent.java b/tags/java-M1-20060518/java/sca/model/src/main/java/org/apache/tuscany/model/assembly/AtomicComponent.java new file mode 100644 index 0000000000..0c98bbbe95 --- /dev/null +++ b/tags/java-M1-20060518/java/sca/model/src/main/java/org/apache/tuscany/model/assembly/AtomicComponent.java @@ -0,0 +1,25 @@ +/** + * + * Copyright 2005 The Apache Software Foundation or its licensors, as applicable. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.tuscany.model.assembly; + + +/** + * An atomic component, specifically not an {@link Composite}. + */ +public interface AtomicComponent extends Component<AtomicImplementation> { +} +
\ No newline at end of file diff --git a/tags/java-M1-20060518/java/sca/model/src/main/java/org/apache/tuscany/model/assembly/AtomicImplementation.java b/tags/java-M1-20060518/java/sca/model/src/main/java/org/apache/tuscany/model/assembly/AtomicImplementation.java new file mode 100644 index 0000000000..4d0703186b --- /dev/null +++ b/tags/java-M1-20060518/java/sca/model/src/main/java/org/apache/tuscany/model/assembly/AtomicImplementation.java @@ -0,0 +1,28 @@ +/** + * + * Copyright 2005 The Apache Software Foundation or its licensors, as applicable. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.tuscany.model.assembly; + + +/** + * The implementation for a specific atomic component instance. + * This interface will typically be extended by component type implementations to indicate the + * specific implementation to be used by a runtime and to allow for additional runtime configuration + * properties. + */ +public interface AtomicImplementation extends Implementation { + +} diff --git a/tags/java-M1-20060518/java/sca/model/src/main/java/org/apache/tuscany/model/assembly/Binding.java b/tags/java-M1-20060518/java/sca/model/src/main/java/org/apache/tuscany/model/assembly/Binding.java new file mode 100644 index 0000000000..51becc29c2 --- /dev/null +++ b/tags/java-M1-20060518/java/sca/model/src/main/java/org/apache/tuscany/model/assembly/Binding.java @@ -0,0 +1,40 @@ +/** + * + * Copyright 2005 The Apache Software Foundation or its licensors, as applicable. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.tuscany.model.assembly; + + +/** + * The binding of an entry point or external service to a transport. + * This model object will typically be extended by binding implementations to allow + * specification of binding/transport specific information. + */ +public interface Binding extends AssemblyObject { + /** + * Returns the binding URI. + * @return the binding uri + * TODO do we need this? + */ + String getURI(); + + /** + * Sets binding URI. + * @param value the binding uri + * TODO do we need this? + */ + void setURI(String value); + +} diff --git a/tags/java-M1-20060518/java/sca/model/src/main/java/org/apache/tuscany/model/assembly/Component.java b/tags/java-M1-20060518/java/sca/model/src/main/java/org/apache/tuscany/model/assembly/Component.java new file mode 100644 index 0000000000..b8d566f1d6 --- /dev/null +++ b/tags/java-M1-20060518/java/sca/model/src/main/java/org/apache/tuscany/model/assembly/Component.java @@ -0,0 +1,81 @@ +/** + * + * Copyright 2005 The Apache Software Foundation or its licensors, as applicable. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.tuscany.model.assembly; + +import java.util.List; + + +/** + * A component is a configured instance of a generic {@link Implementation}. + */ +public interface Component<I extends Implementation> extends Part { + + /** + * Returns the Implementation for this configured instance. + * @return the Implementation for this configured instance + */ + I getImplementation(); + + /** + * Sets the Implementation for this configured instance + * @param value the Implementation for this configured instance + */ + void setImplementation(I value); + + /** + * Returns a list of configured property values for this configured instance. + * These values will be used to initialize the component when it is activated. + * @return a list of ConfiguredProperty values + */ + List<ConfiguredProperty> getConfiguredProperties(); + + /** + * Returns the ConfiguredProperty value for the specified property. + * + * @param name the name of the Property + * @return the configured property value for the named property + */ + ConfiguredProperty getConfiguredProperty(String name); + + /** + * Returns the configured references for the configured instance. + * + * @return the configured references for the configured instance + */ + List<ConfiguredReference> getConfiguredReferences(); + + /** + * Returns the ConfiguredReference value for the specified reference. + * @param name the name of the Property + * @return the configured reference value for the named reference + */ + ConfiguredReference getConfiguredReference(String name); + + /** + * Returns the configured services for the configured instance. + * @return the configured services for the configured instance + */ + List<ConfiguredService> getConfiguredServices(); + + /** + * Returns the ConfiguredService value for the specified property. + * @param name the name of the Property + * @return the configured service value for the named service + */ + ConfiguredService getConfiguredService(String name); + +} diff --git a/tags/java-M1-20060518/java/sca/model/src/main/java/org/apache/tuscany/model/assembly/ComponentType.java b/tags/java-M1-20060518/java/sca/model/src/main/java/org/apache/tuscany/model/assembly/ComponentType.java new file mode 100644 index 0000000000..58ac9bc9de --- /dev/null +++ b/tags/java-M1-20060518/java/sca/model/src/main/java/org/apache/tuscany/model/assembly/ComponentType.java @@ -0,0 +1,66 @@ +/** + * + * Copyright 2005 The Apache Software Foundation or its licensors, as applicable. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.tuscany.model.assembly; + +import java.util.List; + + +/** + * A logical definition of a type of component separate from any specific implementation. + */ +public interface ComponentType extends Extensible { + + /** + * Returns a list of services exposed by this component type. + * @return a list of services exposed by this component type + */ + List<Service> getServices(); + + /** + * Returns the specfied service if exposed by this component type. + * @param name the name of the service + * @return the service identified by the supplied name, or null if there is no service with that name + */ + Service getService(String name); + + /** + * Returns the list of references this component type consumes. + * @return the list of references this component type consumes + */ + List<Reference> getReferences(); + + /** + * Returns the specified reference. + * @param name the name of the reference + * @return the reference identified by the supplied name, or null if there is no reference with that name + */ + Reference getReference(String name); + + /** + * Returns the list of properties that can be used to configure components with this component type. + * @return the list of properties that can be used to configure components with this component type + */ + List<Property> getProperties(); + + /** + * Returns the specified property + * @param name the name of the property + * @return the property with the supplied name, or null if there is no property with that name + */ + Property getProperty(String name); + +} diff --git a/tags/java-M1-20060518/java/sca/model/src/main/java/org/apache/tuscany/model/assembly/Composite.java b/tags/java-M1-20060518/java/sca/model/src/main/java/org/apache/tuscany/model/assembly/Composite.java new file mode 100644 index 0000000000..09f51945bb --- /dev/null +++ b/tags/java-M1-20060518/java/sca/model/src/main/java/org/apache/tuscany/model/assembly/Composite.java @@ -0,0 +1,94 @@ +/** + * + * Copyright 2005 The Apache Software Foundation or its licensors, as applicable. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.tuscany.model.assembly; + +import java.util.List; + +/** + * A model object that describes a container for parts. + */ +public interface Composite extends Implementation { + + /** + * Returns the name of the composite. + * @return the name of the composite + */ + String getName(); + + /** + * Sets the name of the composite. + * @param name the name of the composite + */ + void setName(String name); + + /** + * Returns the named part. + * @param name + */ + Part getPart(String name); + + /** + * Returns all entry points contained in this composite. + * @return a list of all EntryPoint model objects contained in this composite + */ + List<EntryPoint> getEntryPoints(); + + /** + * Returns all components contained in this composite. + * @return a list of all Component model objects contained in this composite + */ + List<Component> getComponents(); + + /** + * Returns all external services contained in this composite. + * @return a list of all ExternalService model objects contained in this composite + */ + List<ExternalService> getExternalServices(); + + /** + * Returns the wires contained in this composite. + */ + List<Wire> getWires(); + + /** + * Returns the WSDL imports declared in this composite. + */ + List<ImportWSDL> getWSDLImports(); + + /** + * Returns the WSDL imports for the given namespace. + * @param namespace + */ + List<ImportWSDL> getWSDLImports(String namespace); + + /** + * Returns the configured service at the given address. + * @param address + */ + ConfiguredService getConfiguredService(ServiceURI address); + + /** + * Returns the implementation class. + */ + Class<?> getImplementationClass(); + + /** + * Sets the implementation class. + */ + void setImplementationClass(Class<?> value); + +} diff --git a/tags/java-M1-20060518/java/sca/model/src/main/java/org/apache/tuscany/model/assembly/CompositeComponent.java b/tags/java-M1-20060518/java/sca/model/src/main/java/org/apache/tuscany/model/assembly/CompositeComponent.java new file mode 100644 index 0000000000..c78fe28ff5 --- /dev/null +++ b/tags/java-M1-20060518/java/sca/model/src/main/java/org/apache/tuscany/model/assembly/CompositeComponent.java @@ -0,0 +1,35 @@ +/** + * + * Copyright 2005 The Apache Software Foundation or its licensors, as applicable. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.tuscany.model.assembly; + +/** + * Specialization of Component that represents a configured {@link Module}. + */ +public interface CompositeComponent<I extends Composite> extends Component<I> { + + /** + * Returns the uri that uniquely identifies this module component. + * @return the uri that uniquely identifies this module component + */ + String getURI(); + + /** + * Sets the uri that uniquely identifies this module component. + * @param uri the uri that uniquely identifies this module component + */ + void setURI(String uri); +} diff --git a/tags/java-M1-20060518/java/sca/model/src/main/java/org/apache/tuscany/model/assembly/ConfiguredPort.java b/tags/java-M1-20060518/java/sca/model/src/main/java/org/apache/tuscany/model/assembly/ConfiguredPort.java new file mode 100644 index 0000000000..7f562e99d9 --- /dev/null +++ b/tags/java-M1-20060518/java/sca/model/src/main/java/org/apache/tuscany/model/assembly/ConfiguredPort.java @@ -0,0 +1,63 @@ +/** + * + * Copyright 2005 The Apache Software Foundation or its licensors, as applicable. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.tuscany.model.assembly; + + +/** + * Represents a configured port (e.g. a configured reference or configured service). + */ +public interface ConfiguredPort<P extends Port> extends AssemblyObject, ProxyFactoryHolder { + + /** + * Returns the name of the port being configured. + * + * @return the name of the port being configured + */ + String getName(); + + /** + * Set the name of the port being configured. + * + * @param name the name of the port being configured + */ + void setName(String name); + + /** + * Returns the port that is being configured. + * @return the port that is being configured + */ + P getPort(); + + /** + * Sets the port that is being configured. + * @param port the port that is being configured + */ + void setPort(P port); + + /** + * Returns the part containing this port. + * @return the part that contains this port + */ + Part getPart(); + + /** + * Sets the configured part containing this port. + * @param part the configured part containing this port. + */ + void setPart(Part part); + +} diff --git a/tags/java-M1-20060518/java/sca/model/src/main/java/org/apache/tuscany/model/assembly/ConfiguredProperty.java b/tags/java-M1-20060518/java/sca/model/src/main/java/org/apache/tuscany/model/assembly/ConfiguredProperty.java new file mode 100644 index 0000000000..0d3a3e5011 --- /dev/null +++ b/tags/java-M1-20060518/java/sca/model/src/main/java/org/apache/tuscany/model/assembly/ConfiguredProperty.java @@ -0,0 +1,74 @@ +/** + * + * Copyright 2005 The Apache Software Foundation or its licensors, as applicable. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.tuscany.model.assembly; + +/** + * The configured value of a {@link Property}. + */ +public interface ConfiguredProperty extends AssemblyObject { + + //FIXME remove the name attribute? + /** + * Returns the name of the property being configured. + * @return the name of the property being configured + */ + String getName(); + + /** + * Set the name of the property being configured. + * @param name the name of the property being configured + */ + void setName(String name); + + /** + * Returns the {@link Property} whose value is being set. + * @return the {@link Property} whose value is being set + */ + Property getProperty(); + + /** + * Sets the {@link Property} whose value is being set. + * @param property the {@link Property} whose value is being set + */ + void setProperty(Property property); + + /** + * Returns the value being set for this usage of the {@link Property}. + * @return the value being set for this usage of the {@link Property} + */ + Object getValue(); + + /** + * Sets the value being set for this usage of the {@link Property}. + * @param value the value being set for this usage of the {@link Property} + */ + void setValue(Object value); + + /** + * Returns the override option that determines if any configuration for this property + * that is contained in this composite can be overridden by configuration supplied from outside. + */ + OverrideOption getOverrideOption(); + + /** + * Set the override option that determines if any configuration for this property + * that is contained in this composite can be overridden by configuration supplied from outside. + * + * @param value the option that determines how property configuration can be overriden + */ + void setOverrideOption(OverrideOption value); +} diff --git a/tags/java-M1-20060518/java/sca/model/src/main/java/org/apache/tuscany/model/assembly/ConfiguredReference.java b/tags/java-M1-20060518/java/sca/model/src/main/java/org/apache/tuscany/model/assembly/ConfiguredReference.java new file mode 100644 index 0000000000..22cb734869 --- /dev/null +++ b/tags/java-M1-20060518/java/sca/model/src/main/java/org/apache/tuscany/model/assembly/ConfiguredReference.java @@ -0,0 +1,44 @@ +/** + * + * Copyright 2005 The Apache Software Foundation or its licensors, as applicable. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.tuscany.model.assembly; + +import java.util.List; + +/** + * A configured reference associated with a particular usage. + * Each configuredReference represents a configured version of an logical + * reference defined in the ComponentType. If the logical reference + * has a multiplicity greater than 1 (0..n or 1..n) then the configured + * reference many have multiple targets. + */ +public interface ConfiguredReference extends ConfiguredPort<Reference> { + + /** + * List of URIs for the targets of this reference. + * + * @return the list of URIs for the targets of this reference + */ + List<String> getTargets(); + + /** + * Returns the list of configured services that are wired to this configured reference. + * + * @return the list of configured services that are wired to this configured reference + */ + List<ConfiguredService> getTargetConfiguredServices(); + +} diff --git a/tags/java-M1-20060518/java/sca/model/src/main/java/org/apache/tuscany/model/assembly/ConfiguredService.java b/tags/java-M1-20060518/java/sca/model/src/main/java/org/apache/tuscany/model/assembly/ConfiguredService.java new file mode 100644 index 0000000000..696250ea44 --- /dev/null +++ b/tags/java-M1-20060518/java/sca/model/src/main/java/org/apache/tuscany/model/assembly/ConfiguredService.java @@ -0,0 +1,25 @@ +/** + * + * Copyright 2005 The Apache Software Foundation or its licensors, as applicable. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.tuscany.model.assembly; + + +/** + * A configured service associated with a particular usage. + */ +public interface ConfiguredService extends ConfiguredPort<Service> { + +} diff --git a/tags/java-M1-20060518/java/sca/model/src/main/java/org/apache/tuscany/model/assembly/ContextFactoryHolder.java b/tags/java-M1-20060518/java/sca/model/src/main/java/org/apache/tuscany/model/assembly/ContextFactoryHolder.java new file mode 100644 index 0000000000..20259f245d --- /dev/null +++ b/tags/java-M1-20060518/java/sca/model/src/main/java/org/apache/tuscany/model/assembly/ContextFactoryHolder.java @@ -0,0 +1,34 @@ +/** + * + * Copyright 2005 The Apache Software Foundation or its licensors, as applicable. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.tuscany.model.assembly; + +/** + * A model object that can hold a runtime context factory object. + */ +public interface ContextFactoryHolder { + + /** + * Sets the context factory + */ + void setContextFactory(Object contextFactory); + + /** + * Returns the context factory + */ + Object getContextFactory(); + +} diff --git a/tags/java-M1-20060518/java/sca/model/src/main/java/org/apache/tuscany/model/assembly/EntryPoint.java b/tags/java-M1-20060518/java/sca/model/src/main/java/org/apache/tuscany/model/assembly/EntryPoint.java new file mode 100644 index 0000000000..a90b89c4f5 --- /dev/null +++ b/tags/java-M1-20060518/java/sca/model/src/main/java/org/apache/tuscany/model/assembly/EntryPoint.java @@ -0,0 +1,67 @@ +/** + * + * Copyright 2005 The Apache Software Foundation or its licensors, as applicable. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.tuscany.model.assembly; + +import java.util.List; + + +/** + * An entry point exposed by its containing {@link Composite}. + * References from outside the composite can only be connected to its entry points. + */ +public interface EntryPoint extends Part { + + /** + * Returns the bindings supported by this entry point. + * A single entry point may be bound to multiple transports. + * + * @return a list of bindings supported by this entry point + */ + List<Binding> getBindings(); + + /** + * Returns the configured service exposed by this entry point. + * + * @return the configured service exposed by this entry point + */ + ConfiguredService getConfiguredService(); + + /** + * Sets the configured service exposed by this entry point. + * + * @param configuredService the configured service exposed by this entry point + */ + void setConfiguredService(ConfiguredService configuredService); + + /** + * Returns the configured reference that wires this entry point to the published service + * inside the composite. + * + * @return the reference that wires this entry point to the published service + */ + ConfiguredReference getConfiguredReference(); + + /** + * Sets the configured reference that wires this entry point to the published service + * inside the composite. + * + * @param configuredReference the configured reference that wires this entry point to + * the published service inside the composite + */ + void setConfiguredReference(ConfiguredReference configuredReference); + +} diff --git a/tags/java-M1-20060518/java/sca/model/src/main/java/org/apache/tuscany/model/assembly/Extensible.java b/tags/java-M1-20060518/java/sca/model/src/main/java/org/apache/tuscany/model/assembly/Extensible.java new file mode 100644 index 0000000000..b4651a6186 --- /dev/null +++ b/tags/java-M1-20060518/java/sca/model/src/main/java/org/apache/tuscany/model/assembly/Extensible.java @@ -0,0 +1,37 @@ +/** + * + * Copyright 2005 The Apache Software Foundation or its licensors, as applicable. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.tuscany.model.assembly; + +import java.util.List; + +/** + * An extensible model object. We actually need this even though we have the ability to load specializations + * of individual model objects + */ +public interface Extensible extends AssemblyObject { + + /** + * Returns the extensibility elements. + */ + List<Object> getExtensibilityElements(); + + /** + * Returns the extensibility attributes. + */ + List<Object> getExtensibilityAttributes(); + +} diff --git a/tags/java-M1-20060518/java/sca/model/src/main/java/org/apache/tuscany/model/assembly/ExternalService.java b/tags/java-M1-20060518/java/sca/model/src/main/java/org/apache/tuscany/model/assembly/ExternalService.java new file mode 100644 index 0000000000..f2b72ec928 --- /dev/null +++ b/tags/java-M1-20060518/java/sca/model/src/main/java/org/apache/tuscany/model/assembly/ExternalService.java @@ -0,0 +1,59 @@ +/** + * + * Copyright 2005 The Apache Software Foundation or its licensors, as applicable. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.tuscany.model.assembly; + +import java.util.List; + + +/** + * An external service consumed by its containing {@link Composite}. + * All references used by the composite are specified as external services. + */ +public interface ExternalService extends Part { + + /** + * Returns the bindings that can be used by operations on this external service. + * A single external service may be bound to multiple transports. + */ + List<Binding> getBindings(); + + /** + * Returns the override option that determines if any wiring for this external service + * that is contained in this composite can be overridden by wired supplied from outside. + */ + OverrideOption getOverrideOption(); + + /** + * Set the override option that determines if any wiring for this external service + * that is contained in this composite can be overridden by wired supplied from outside. + * + * @param value the option that determines how wires can be overriden + */ + void setOverrideOption(OverrideOption value); + + /** + * Returns the configured service that this external service provides to other parts of the containing composite. + * @return the configured service that this external service provides to other parts of the containing composite + */ + ConfiguredService getConfiguredService(); + + /** + * Sets the configured service that this external service provides to other parts of the containing composite + * @param configuredService the configured service that this external service provides to other parts of the containing composite + */ + void setConfiguredService(ConfiguredService configuredService); +} diff --git a/tags/java-M1-20060518/java/sca/model/src/main/java/org/apache/tuscany/model/assembly/Implementation.java b/tags/java-M1-20060518/java/sca/model/src/main/java/org/apache/tuscany/model/assembly/Implementation.java new file mode 100644 index 0000000000..2777d985f8 --- /dev/null +++ b/tags/java-M1-20060518/java/sca/model/src/main/java/org/apache/tuscany/model/assembly/Implementation.java @@ -0,0 +1,40 @@ +/** + * + * Copyright 2005 The Apache Software Foundation or its licensors, as applicable. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.tuscany.model.assembly; + + +/** + * The implementation for a specific component instance. + * This interface will typically be extended by component type implementations to indicate the + * specific implementation to be used by a runtime and to allow for additional runtime configuration + * properties. + */ +public interface Implementation extends Extensible { + + /** + * Returns the generic component type corresponding to this implementation. + * @return the generic component type corresponding to this implementation + */ + ComponentType getComponentType(); + + /** + * Sets the generic component type corresponding to this implementation. + * @param componentType the generic component type corresponding to this implementation + */ + void setComponentType(ComponentType componentType); + +} diff --git a/tags/java-M1-20060518/java/sca/model/src/main/java/org/apache/tuscany/model/assembly/ImportWSDL.java b/tags/java-M1-20060518/java/sca/model/src/main/java/org/apache/tuscany/model/assembly/ImportWSDL.java new file mode 100644 index 0000000000..7c858a1b76 --- /dev/null +++ b/tags/java-M1-20060518/java/sca/model/src/main/java/org/apache/tuscany/model/assembly/ImportWSDL.java @@ -0,0 +1,62 @@ +/** + * + * Copyright 2006 The Apache Software Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.tuscany.model.assembly; + +import javax.wsdl.Definition; + +/** + * Model object that represents the import of an external WSDL definition. + * + * @version $Rev$ $Date$ + */ +public interface ImportWSDL extends AssemblyObject { + /** + * Returns the location where the WSDL definition can be found. + * @return the location where the WSDL definition can be found + */ + String getLocation(); + + /** + * Set the location where the WSDL definition can be found. + * @param uri the location where the WSDL definition can be found + */ + void setLocation(String uri); + + /** + * Returns the namespace URI for this import. + * @return the namespace URI for this import + */ + String getNamespace(); + + /** + * Sets the namespace URI for this import. + * @param uri the namespace URI for this import + */ + void setNamespace(String uri); + + /** + * Returns the WSDL Definition. + * @return the WSDL Definition + */ + Definition getDefinition(); + + /** + * Sets the WSDL Definition. + * @param definition the WSDL Definition + */ + void setDefinition(Definition definition); +} diff --git a/tags/java-M1-20060518/java/sca/model/src/main/java/org/apache/tuscany/model/assembly/Module.java b/tags/java-M1-20060518/java/sca/model/src/main/java/org/apache/tuscany/model/assembly/Module.java new file mode 100644 index 0000000000..40d1d1534b --- /dev/null +++ b/tags/java-M1-20060518/java/sca/model/src/main/java/org/apache/tuscany/model/assembly/Module.java @@ -0,0 +1,40 @@ +/** + * + * Copyright 2005 The Apache Software Foundation or its licensors, as applicable. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.tuscany.model.assembly; + +import java.util.List; + +/** + * A specialized {@link Implementation} that defines a modular unit of assembly. + * A Module denotes the extent of assembly in which pass-by-reference semantics are supported. + */ +public interface Module extends Composite { + + /** + * Returns a list of assembly fragments that combine to form a single module. + * @return a list of assembly fragments that combine to form a single module + */ + List<ModuleFragment> getModuleFragments(); + + /** + * Returns the specified assembly fragment. + * @param name the name of the fragment + * @return the fragment with the specified name, or null if there is no fragment with that name + */ + ModuleFragment getModuleFragment(String name); + +} diff --git a/tags/java-M1-20060518/java/sca/model/src/main/java/org/apache/tuscany/model/assembly/ModuleComponent.java b/tags/java-M1-20060518/java/sca/model/src/main/java/org/apache/tuscany/model/assembly/ModuleComponent.java new file mode 100644 index 0000000000..00f6079096 --- /dev/null +++ b/tags/java-M1-20060518/java/sca/model/src/main/java/org/apache/tuscany/model/assembly/ModuleComponent.java @@ -0,0 +1,24 @@ +/** + * + * Copyright 2005 The Apache Software Foundation or its licensors, as applicable. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.tuscany.model.assembly; + +/** + * Specialization of Component that represents a configured {@link Module}. + */ +public interface ModuleComponent extends CompositeComponent<Module> { + +} diff --git a/tags/java-M1-20060518/java/sca/model/src/main/java/org/apache/tuscany/model/assembly/ModuleFragment.java b/tags/java-M1-20060518/java/sca/model/src/main/java/org/apache/tuscany/model/assembly/ModuleFragment.java new file mode 100644 index 0000000000..dec1e8bfd3 --- /dev/null +++ b/tags/java-M1-20060518/java/sca/model/src/main/java/org/apache/tuscany/model/assembly/ModuleFragment.java @@ -0,0 +1,25 @@ +/** + * + * Copyright 2005 The Apache Software Foundation or its licensors, as applicable. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.tuscany.model.assembly; + +/** + * A fragment of assembly configuration within a module. + * To support flexibility and reuse, modules can be defined in multiple fragments that are + * then combined by the runtime to form the complete module definition. + */ +public interface ModuleFragment extends Composite { +} diff --git a/tags/java-M1-20060518/java/sca/model/src/main/java/org/apache/tuscany/model/assembly/Multiplicity.java b/tags/java-M1-20060518/java/sca/model/src/main/java/org/apache/tuscany/model/assembly/Multiplicity.java new file mode 100644 index 0000000000..c51ab7b8ea --- /dev/null +++ b/tags/java-M1-20060518/java/sca/model/src/main/java/org/apache/tuscany/model/assembly/Multiplicity.java @@ -0,0 +1,46 @@ +/** + * + * Copyright 2005 The Apache Software Foundation or its licensors, as applicable. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.tuscany.model.assembly; + +/** + * Enumeration for multiplicity. + */ +public enum Multiplicity { + /** + * Indicates a relationship that is optionally connected to the requestor and which, if supplied, + * must be connected to exactly one provider. + */ + ZERO_ONE, + + /** + * Indicates a relationship that must be connected between exactly one requestor and + * exactly one provider. + */ + ONE_ONE, + + /** + * Indicates a relationship that is optionally connects the requestor to zero to unbounded providers. + */ + ZERO_N, + + /** + * Indicates a relationship that must be connected at the requestor and which connects it to + * zero to unbounded providers. + */ + ONE_N + +} diff --git a/tags/java-M1-20060518/java/sca/model/src/main/java/org/apache/tuscany/model/assembly/OverrideOption.java b/tags/java-M1-20060518/java/sca/model/src/main/java/org/apache/tuscany/model/assembly/OverrideOption.java new file mode 100644 index 0000000000..68489d0200 --- /dev/null +++ b/tags/java-M1-20060518/java/sca/model/src/main/java/org/apache/tuscany/model/assembly/OverrideOption.java @@ -0,0 +1,39 @@ +/** + * + * Copyright 2005 The Apache Software Foundation or its licensors, as applicable. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.tuscany.model.assembly; + +/** + * Enumeration for override options that are used to control whether configuration information + * can be overridden by larger grained definitions. + */ +public enum OverrideOption { + /** + * Indicates that the supplied configuration cannot be overridden. + */ + NO, + + /** + * Indicates that the supplied configuration may be overriden. + */ + MAY, + + /** + * Indicates that the supplied configuration must be overriden. + */ + MUST + +} diff --git a/tags/java-M1-20060518/java/sca/model/src/main/java/org/apache/tuscany/model/assembly/Part.java b/tags/java-M1-20060518/java/sca/model/src/main/java/org/apache/tuscany/model/assembly/Part.java new file mode 100644 index 0000000000..9645ad6d35 --- /dev/null +++ b/tags/java-M1-20060518/java/sca/model/src/main/java/org/apache/tuscany/model/assembly/Part.java @@ -0,0 +1,49 @@ +/** + * + * Copyright 2005 The Apache Software Foundation or its licensors, as applicable. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.tuscany.model.assembly; + + + +/** + * A configured object that is contained inside a {@link Composite}. + */ +public interface Part extends Extensible, ContextFactoryHolder { + /** + * Returns the name that uniquely identifies this component within its containing composite. + * @return the name that uniquely identifies this component within its containing composite + */ + String getName(); + + /** + * Sets the name that uniquely identifies this component within its containing composite. + * @param value the name that uniquely identifies this component within its containing composite + */ + void setName(String value); + + /** + * Returns the composite that contains this component. + * @return the composite that contains this component + */ + Composite getComposite(); + + /** + * Sets the composite that contains this component. + * @param the composite that contains this component + */ + void setComposite(Composite composite); + +} diff --git a/tags/java-M1-20060518/java/sca/model/src/main/java/org/apache/tuscany/model/assembly/Port.java b/tags/java-M1-20060518/java/sca/model/src/main/java/org/apache/tuscany/model/assembly/Port.java new file mode 100644 index 0000000000..13b9d0a1db --- /dev/null +++ b/tags/java-M1-20060518/java/sca/model/src/main/java/org/apache/tuscany/model/assembly/Port.java @@ -0,0 +1,47 @@ +/** + * + * Copyright 2005 The Apache Software Foundation or its licensors, as applicable. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.tuscany.model.assembly; + +/** + * Abstraction for the association of a service contract with a requestor or provider. + */ +public interface Port extends AssemblyObject { + /** + * Returns the contract for invocations of a service using this port. + * @return the oontract for invocations of a service using this port + */ + ServiceContract getServiceContract(); + + /** + * Set the contract for invocations of a service using this port. + * @param contract the contract for invocations of a service using this port + */ + void setServiceContract(ServiceContract contract); + + /** + * Returns the name of the port where it is associated with a requestor or provider. + * @return the name of the port + */ + String getName(); + + /** + * Sets the name of the port where it is associated with a requestor or provider. + * @param name the name of the port where it is associated with a requestor or provider + */ + void setName(String name); + +} diff --git a/tags/java-M1-20060518/java/sca/model/src/main/java/org/apache/tuscany/model/assembly/Property.java b/tags/java-M1-20060518/java/sca/model/src/main/java/org/apache/tuscany/model/assembly/Property.java new file mode 100644 index 0000000000..1f238efce6 --- /dev/null +++ b/tags/java-M1-20060518/java/sca/model/src/main/java/org/apache/tuscany/model/assembly/Property.java @@ -0,0 +1,91 @@ +/** + * + * Copyright 2005 The Apache Software Foundation or its licensors, as applicable. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.tuscany.model.assembly; + + + +/** + * A description of a property that can be used to configure a component. + */ +public interface Property extends Extensible { + // todo should we decalre this as Property<T> where T would be the type of this Property? + + /** + * Returns the property name. + * @return the property name + */ + String getName(); + + /** + * Sets the property name. + * @param name the property name + */ + void setName(String name); + + /** + * Returns the default value of the property. + * @return the default value of ths property + */ + Object getDefaultValue(); + + /** + * Sets the default value of the property. + * @param value the default value of ths property + */ + void setDefaultValue(Object value); + + /** + * Returns true if the property allows multiple values. + * @return true if the property allows multiple values + */ + boolean isMany(); + + /** + * Sets whether or not the property allows multiple values. + * @param value true if the property should allow multiple values + */ + void setMany(boolean value); + + /** + * Returns true if a value must be supplied for the property. + * @return true is a value must be supplied for the property + */ + boolean isRequired(); + + /** + * Sets whether a value must be supplied for the property. + * For ease of use, it is recommended that a meaningful default value should + * be supplied for all properties; users should only be required to specify + * a value if there is no reasonable default. + * + * @param value set to true to require that a value be supplied for uses of this property + */ + void setRequired(boolean value); + + /** + * Returns the type of this property as used by the runtime. + * @return the type of this property as used by the runtime + */ + Class<?> getType(); + + /** + * Sets the type of this property as used by the runtime + * @param value the type of this property as used by the runtime + */ + void setType(Class<?> value); + +} diff --git a/tags/java-M1-20060518/java/sca/model/src/main/java/org/apache/tuscany/model/assembly/ProxyFactoryHolder.java b/tags/java-M1-20060518/java/sca/model/src/main/java/org/apache/tuscany/model/assembly/ProxyFactoryHolder.java new file mode 100644 index 0000000000..055448b2f5 --- /dev/null +++ b/tags/java-M1-20060518/java/sca/model/src/main/java/org/apache/tuscany/model/assembly/ProxyFactoryHolder.java @@ -0,0 +1,34 @@ +/** + * + * Copyright 2005 The Apache Software Foundation or its licensors, as applicable. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.tuscany.model.assembly; + +/** + * A model object that can hold a runtime proxy factory object. + */ +public interface ProxyFactoryHolder { + + /** + * Sets the proxy factory + */ + void setProxyFactory(Object proxyFactory); + + /** + * Returns the proxy factory + */ + Object getProxyFactory(); + +} diff --git a/tags/java-M1-20060518/java/sca/model/src/main/java/org/apache/tuscany/model/assembly/Reference.java b/tags/java-M1-20060518/java/sca/model/src/main/java/org/apache/tuscany/model/assembly/Reference.java new file mode 100644 index 0000000000..8cc13e98ec --- /dev/null +++ b/tags/java-M1-20060518/java/sca/model/src/main/java/org/apache/tuscany/model/assembly/Reference.java @@ -0,0 +1,36 @@ +/** + * + * Copyright 2005 The Apache Software Foundation or its licensors, as applicable. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.tuscany.model.assembly; + + +/** + * The association of a port with a requestor. + */ +public interface Reference extends Port { + /** + * Returns the multiplicity allowed for wires connected to this reference. + * @return the multiplicity allowed for wires connected to this reference + */ + Multiplicity getMultiplicity(); + + /** + * Sets the multiplicity allowed for wires connected to this reference. + * @param multiplicity the multiplicity allowed for wires connected to this reference + */ + void setMultiplicity(Multiplicity multiplicity); + +} diff --git a/tags/java-M1-20060518/java/sca/model/src/main/java/org/apache/tuscany/model/assembly/Scope.java b/tags/java-M1-20060518/java/sca/model/src/main/java/org/apache/tuscany/model/assembly/Scope.java new file mode 100644 index 0000000000..c7194292f0 --- /dev/null +++ b/tags/java-M1-20060518/java/sca/model/src/main/java/org/apache/tuscany/model/assembly/Scope.java @@ -0,0 +1,31 @@ +/** + * + * Copyright 2005 The Apache Software Foundation or its licensors, as applicable. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.tuscany.model.assembly; + +/** + * The types of scope supported by assemblies. + */ +public enum Scope { + // todo define what these are + INSTANCE, + REQUEST, + SESSION, + MODULE, + AGGREGATE, + UNDEFINED + +} diff --git a/tags/java-M1-20060518/java/sca/model/src/main/java/org/apache/tuscany/model/assembly/Service.java b/tags/java-M1-20060518/java/sca/model/src/main/java/org/apache/tuscany/model/assembly/Service.java new file mode 100644 index 0000000000..c73002efba --- /dev/null +++ b/tags/java-M1-20060518/java/sca/model/src/main/java/org/apache/tuscany/model/assembly/Service.java @@ -0,0 +1,24 @@ +/** + * + * Copyright 2005 The Apache Software Foundation or its licensors, as applicable. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.tuscany.model.assembly; + + +/** + * The association of a port with a provider. + */ +public interface Service extends Port { +} diff --git a/tags/java-M1-20060518/java/sca/model/src/main/java/org/apache/tuscany/model/assembly/ServiceContract.java b/tags/java-M1-20060518/java/sca/model/src/main/java/org/apache/tuscany/model/assembly/ServiceContract.java new file mode 100644 index 0000000000..1600e11663 --- /dev/null +++ b/tags/java-M1-20060518/java/sca/model/src/main/java/org/apache/tuscany/model/assembly/ServiceContract.java @@ -0,0 +1,60 @@ +/** + * + * Copyright 2005 The Apache Software Foundation or its licensors, as applicable. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.tuscany.model.assembly; + +/** + * The contract specified by a requestor or provider for invocations across a port. + */ +public interface ServiceContract extends Extensible { + + /** + * Returns the interface for invocations from the requestor to the provider. + * @return the interface for invocations from the requestor to the provider + */ + Class getInterface(); + + /** + * Sets the interface for invocations from the requestor to the provider. + * @param value the interface for invocations from the requestor to the provider + */ + void setInterface(Class value); + + /** + * Returns the callback interface for wire from the provider back to its requestor. + * @return the callback interface for wire from the provider back to its requestor + */ + Class getCallbackInterface(); + + /** + * Sets the callback interface for wire from the provider back to its requestor. + * @param value the callback interface for wire from the provider back to its requestor + */ + void setCallbackInterface(Class value); + + /** + * Returns the scope of this service contract. + * @return + */ + Scope getScope(); + + /** + * Sets the scope. + * @param scope of this service contract. + */ + void setScope(Scope scope); + +} diff --git a/tags/java-M1-20060518/java/sca/model/src/main/java/org/apache/tuscany/model/assembly/ServiceURI.java b/tags/java-M1-20060518/java/sca/model/src/main/java/org/apache/tuscany/model/assembly/ServiceURI.java new file mode 100644 index 0000000000..740febc360 --- /dev/null +++ b/tags/java-M1-20060518/java/sca/model/src/main/java/org/apache/tuscany/model/assembly/ServiceURI.java @@ -0,0 +1,58 @@ +/** + * + * Copyright 2005 The Apache Software Foundation or its licensors, as applicable. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.tuscany.model.assembly; + +/** + * Represents a service URI. + */ +public interface ServiceURI { + + /** + * Returns true if the address scheme is sca + * @return + */ + public boolean isSCAScheme(); + + /** + * @return Returns the address. + */ + public String getAddress(); + + /** + * @return Returns the path. + */ + public String getPath(); + + /** + * Returns the module component name + * @return + */ + public String getModuleComponentName(); + + /** + * Returns the part name + * @return + */ + public String getPartName(); + + /** + * Returns the service name + * @return + */ + public String getServiceName(); + +} diff --git a/tags/java-M1-20060518/java/sca/model/src/main/java/org/apache/tuscany/model/assembly/Subsystem.java b/tags/java-M1-20060518/java/sca/model/src/main/java/org/apache/tuscany/model/assembly/Subsystem.java new file mode 100644 index 0000000000..709ba4da35 --- /dev/null +++ b/tags/java-M1-20060518/java/sca/model/src/main/java/org/apache/tuscany/model/assembly/Subsystem.java @@ -0,0 +1,38 @@ +/** + * + * Copyright 2005 The Apache Software Foundation or its licensors, as applicable. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.tuscany.model.assembly; + + + +/** + * Represents a subsystem. + */ +public interface Subsystem extends Composite { + + /** + * Returns the subsystem uri. + * @return + */ + String getURI(); + + /** + * Sets the subsystem uri. + * @param value + */ + void setURI(String value); + +} diff --git a/tags/java-M1-20060518/java/sca/model/src/main/java/org/apache/tuscany/model/assembly/Wire.java b/tags/java-M1-20060518/java/sca/model/src/main/java/org/apache/tuscany/model/assembly/Wire.java new file mode 100644 index 0000000000..dfe553210a --- /dev/null +++ b/tags/java-M1-20060518/java/sca/model/src/main/java/org/apache/tuscany/model/assembly/Wire.java @@ -0,0 +1,48 @@ +/** + * + * Copyright 2005 The Apache Software Foundation or its licensors, as applicable. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.tuscany.model.assembly; + + +/** + * A connection between a requestor (source) and a provider (target). + */ +public interface Wire extends Extensible { + /** + * Returns the URI for the source of the request. + * @return the URI for the source of the request + */ + ServiceURI getSource(); + + /** + * Sets the URI for the source of the request. + * @param uri the URI for the source of the request + */ + void setSource(ServiceURI uri); + + /** + * Returns the URI for the target of the request. + * @return the URI for the target of the request + */ + ServiceURI getTarget(); + + /** + * Sets the URI for the target of the request. + * @param uri the URI for the target of the request + */ + void setTarget(ServiceURI uri); + +} diff --git a/tags/java-M1-20060518/java/sca/model/src/main/java/org/apache/tuscany/model/assembly/impl/AssemblyContextImpl.java b/tags/java-M1-20060518/java/sca/model/src/main/java/org/apache/tuscany/model/assembly/impl/AssemblyContextImpl.java new file mode 100644 index 0000000000..a7f9012db7 --- /dev/null +++ b/tags/java-M1-20060518/java/sca/model/src/main/java/org/apache/tuscany/model/assembly/impl/AssemblyContextImpl.java @@ -0,0 +1,88 @@ +/** + * + * Copyright 2005 The Apache Software Foundation or its licensors, as applicable. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.tuscany.model.assembly.impl; + +import org.apache.tuscany.common.resource.ResourceLoader; +import org.apache.tuscany.model.assembly.AssemblyFactory; +import org.apache.tuscany.model.assembly.AssemblyContext; +import org.apache.tuscany.model.assembly.loader.AssemblyModelLoader; +import org.apache.tuscany.sdo.util.SDOUtil; + +import commonj.sdo.helper.TypeHelper; + +/** + */ +public class AssemblyContextImpl implements AssemblyContext { + + private final AssemblyFactory assemblyFactory; + private final AssemblyModelLoader assemblyLoader; + private final ResourceLoader applicationResourceLoader; + private final TypeHelper typeHelper; + private String webAppName; + + public AssemblyContextImpl(AssemblyModelLoader assemblyLoader, ResourceLoader resourceLoader) { + this(new AssemblyFactoryImpl(), assemblyLoader, resourceLoader); + } + + public AssemblyContextImpl(AssemblyFactory assemblyFactory, AssemblyModelLoader assemblyLoader, ResourceLoader artifactLoader) { + this(assemblyFactory, assemblyLoader, artifactLoader, SDOUtil.createTypeHelper()); + } + + public AssemblyContextImpl(AssemblyFactory assemblyFactory, AssemblyModelLoader assemblyLoader, ResourceLoader artifactLoader, String webAppName) { + this(assemblyFactory, assemblyLoader, artifactLoader, SDOUtil.createTypeHelper(), webAppName); + } + public AssemblyContextImpl(AssemblyFactory assemblyFactory, AssemblyModelLoader assemblyLoader, ResourceLoader artifactLoader, TypeHelper typeHelper) { + this(assemblyFactory, assemblyLoader, artifactLoader, SDOUtil.createTypeHelper(), null); + } + + public AssemblyContextImpl(AssemblyFactory assemblyFactory, AssemblyModelLoader assemblyLoader, ResourceLoader artifactLoader, TypeHelper typeHelper, String webAppName) { + this.assemblyFactory = assemblyFactory; + this.assemblyLoader = assemblyLoader; + this.applicationResourceLoader = artifactLoader; + this.typeHelper=typeHelper; + this.webAppName=webAppName; + } + + /** + * @see org.apache.tuscany.model.assembly.AssemblyContext#getAssemblyFactory() + */ + public AssemblyFactory getAssemblyFactory() { + return assemblyFactory; + } + + public ResourceLoader getApplicationResourceLoader() { + return applicationResourceLoader; + } + + /** + * @see org.apache.tuscany.model.assembly.AssemblyContext#getAssemblyLoader() + */ + public AssemblyModelLoader getAssemblyLoader() { + return assemblyLoader; + } + + /** + * @see org.apache.tuscany.model.assembly.AssemblyContext#getTypeHelper() + */ + public TypeHelper getTypeHelper() { + return typeHelper; + } + + public String getWebAppName() { + return webAppName; + } +} diff --git a/tags/java-M1-20060518/java/sca/model/src/main/java/org/apache/tuscany/model/assembly/impl/AssemblyFactoryImpl.java b/tags/java-M1-20060518/java/sca/model/src/main/java/org/apache/tuscany/model/assembly/impl/AssemblyFactoryImpl.java new file mode 100644 index 0000000000..c88ea4448f --- /dev/null +++ b/tags/java-M1-20060518/java/sca/model/src/main/java/org/apache/tuscany/model/assembly/impl/AssemblyFactoryImpl.java @@ -0,0 +1,217 @@ +/** + * + * Copyright 2005 The Apache Software Foundation or its licensors, as applicable. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.tuscany.model.assembly.impl; + +import javax.xml.namespace.QName; + +import org.apache.tuscany.model.assembly.Part; +import org.apache.tuscany.model.assembly.AssemblyFactory; +import org.apache.tuscany.model.assembly.ComponentType; +import org.apache.tuscany.model.assembly.ConfiguredPort; +import org.apache.tuscany.model.assembly.ConfiguredProperty; +import org.apache.tuscany.model.assembly.ConfiguredReference; +import org.apache.tuscany.model.assembly.ConfiguredService; +import org.apache.tuscany.model.assembly.EntryPoint; +import org.apache.tuscany.model.assembly.ExternalService; +import org.apache.tuscany.model.assembly.Module; +import org.apache.tuscany.model.assembly.ModuleComponent; +import org.apache.tuscany.model.assembly.ModuleFragment; +import org.apache.tuscany.model.assembly.Multiplicity; +import org.apache.tuscany.model.assembly.Property; +import org.apache.tuscany.model.assembly.Reference; +import org.apache.tuscany.model.assembly.Service; +import org.apache.tuscany.model.assembly.ServiceURI; +import org.apache.tuscany.model.assembly.AtomicComponent; +import org.apache.tuscany.model.assembly.Subsystem; +import org.apache.tuscany.model.assembly.Wire; +import org.apache.tuscany.model.assembly.Binding; +import org.apache.tuscany.model.assembly.ServiceContract; +import org.apache.tuscany.model.assembly.ImportWSDL; +import org.apache.tuscany.model.types.java.JavaServiceContract; +import org.apache.tuscany.model.types.java.impl.JavaServiceContractImpl; +import org.apache.tuscany.model.types.wsdl.WSDLServiceContract; +import org.apache.tuscany.model.types.wsdl.impl.WSDLServiceContractImpl; + +/** + * Default implementation of AssemblyFactory + */ +public class AssemblyFactoryImpl implements AssemblyFactory { + + /** + * Constructor + */ + public AssemblyFactoryImpl() { + super(); + } + + public AtomicComponent createSimpleComponent() { + return new AtomicComponentImpl(); + } + + public ComponentType createComponentType() { + return new ComponentTypeImpl(); + } + + public EntryPoint createEntryPoint() { + return new EntryPointImpl(); + } + + public ExternalService createExternalService() { + return new ExternalServiceImpl(); + } + + public JavaServiceContract createJavaServiceContract() { + return new JavaServiceContractImpl(); + } + + public Module createModule() { + return new ModuleImpl(); + } + + public ModuleFragment createModuleFragment() { + return new ModuleFragmentImpl(); + } + + public ModuleComponent createModuleComponent() { + return new ModuleComponentImpl(); + } + + public Property createProperty() { + return new PropertyImpl(); + } + + public ConfiguredProperty createConfiguredProperty() { + return new ConfiguredPropertyImpl(); + } + + public Reference createReference() { + return new ReferenceImpl(); + } + + public ConfiguredReference createConfiguredReference() { + return new ConfiguredReferenceImpl(); + } + + public Service createService() { + return new ServiceImpl(); + } + + public ConfiguredService createConfiguredService() { + return new ConfiguredServiceImpl(); + } + + public Subsystem createSubsystem() { + return new SubsystemImpl(); + } + + public WSDLServiceContract createWSDLServiceContract() { + return new WSDLServiceContractImpl(); + } + + public ServiceURI createServiceURI(String uri) { + return new ServiceURIImpl(uri); + } + + public ServiceURI createServiceURI(ModuleComponent moduleComponent, String serviceName) { + return new ServiceURIImpl(moduleComponent, serviceName); + } + + public ServiceURI createServiceURI(ModuleComponent moduleComponent, Part part, ConfiguredPort configuredPort) { + return new ServiceURIImpl(moduleComponent, part, configuredPort); + } + + public ServiceURI createServiceURI(ModuleComponent moduleComponent, String partName, String serviceName) { + return new ServiceURIImpl(moduleComponent,partName,serviceName); + } + + public QName createQName(String uri) { + int h = uri.indexOf('#'); + return new QName(uri.substring(0, h), uri.substring(h + 1)); + } + + public Wire createWire() { + return new WireImpl(); + } + + public Reference createReference(String name, Class<?> service) { + return createReference(name,service,Multiplicity.ZERO_ONE); + } + + public Reference createReference(String name, Class<?> service, Multiplicity multiplicity){ + JavaServiceContract refContract = createJavaServiceContract(); + refContract.setInterface(service); + Reference reference = createReference(); + reference.setName(name); + reference.setServiceContract(refContract); + reference.setMultiplicity(multiplicity); + return reference; + } + + public ConfiguredReference createConfiguredReference(String name, String... targets) { + ConfiguredReference ref = createConfiguredReference(); + ref.setName(name); + for (String target : targets) { + ref.getTargets().add(target); + } + return ref; + } + + public EntryPoint createEntryPoint(String entryPointName, ServiceContract serviceContract, Binding binding, String targetName) { + // create and configure the exposed service + Service service = createService(); + service.setName(entryPointName); + service.setServiceContract(serviceContract); + ConfiguredService configuredService = createConfiguredService(); + configuredService.setPort(service); + + // create and configure a reference to target + Reference reference = createReference(); + reference.setMultiplicity(Multiplicity.ONE_ONE); + reference.setServiceContract(serviceContract); + ConfiguredReference configuredReference = createConfiguredReference(null, targetName); + configuredReference.setPort(reference); + + return createEntryPoint(entryPointName, configuredService, binding, configuredReference); + } + + public EntryPoint createEntryPoint(String entryPointName, ConfiguredService configuredService, Binding binding, ConfiguredReference configuredReference) { + EntryPoint entryPoint = createEntryPoint(); + entryPoint.setName(entryPointName); + entryPoint.setConfiguredService(configuredService); + entryPoint.setConfiguredReference(configuredReference); + entryPoint.getBindings().add((Binding)binding); + return entryPoint; + } + + public Property createProperty(String name, Class<?> type) { + Property property = createProperty(); + property.setName(name); + property.setType(type); + return property; + } + + public ImportWSDL createImportWSDL() { + return new ImportWSDLImpl(); + } + + public ImportWSDL createImportWSDL(String location, String namespace) { + ImportWSDL importWSDL = createImportWSDL(); + importWSDL.setLocation(location); + importWSDL.setNamespace(namespace); + return importWSDL; + } +} diff --git a/tags/java-M1-20060518/java/sca/model/src/main/java/org/apache/tuscany/model/assembly/impl/AssemblyObjectImpl.java b/tags/java-M1-20060518/java/sca/model/src/main/java/org/apache/tuscany/model/assembly/impl/AssemblyObjectImpl.java new file mode 100644 index 0000000000..38056e1e1c --- /dev/null +++ b/tags/java-M1-20060518/java/sca/model/src/main/java/org/apache/tuscany/model/assembly/impl/AssemblyObjectImpl.java @@ -0,0 +1,123 @@ +/** + * + * Copyright 2005 The Apache Software Foundation or its licensors, as applicable. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.tuscany.model.assembly.impl; + +import java.util.Collection; +import java.util.Collections; +import java.util.List; + +import org.apache.tuscany.model.assembly.AssemblyContext; +import org.apache.tuscany.model.assembly.AssemblyObject; +import org.apache.tuscany.model.assembly.AssemblyVisitor; + +/** + * A base class for assembly model objects. + */ +public abstract class AssemblyObjectImpl implements AssemblyObject { + + private boolean frozen; + private boolean initialized; + + protected AssemblyObjectImpl() { + } + + public boolean accept(AssemblyVisitor visitor) { + return visitor.visit(this); + } + + /** + * Walk a visitor through a collection of model objects. + * @param collection + * @param visitor + */ + protected boolean accept(Collection collection, AssemblyVisitor visitor) { + for (Object member : collection) { + if (member instanceof AssemblyObject) { + if (!((AssemblyObject)member).accept(visitor)) + return false; + } + } + return true; + } + + public void freeze() { + if (!frozen) + frozen=true; + } + + /** + * Returns true if the object is frozen + */ + protected boolean isFrozen() { + return frozen; + } + + /** + * Freeze a list and its members + */ + protected <T> List<T> freeze(List<T> list) { + list=Collections.unmodifiableList(list); + for (Object member : list) { + if (member instanceof AssemblyObject) { + ((AssemblyObject)member).freeze(); + } + } + return list; + } + + /** + * Check that the current model object can be modified. + * @throws IllegalStateException + */ + protected void checkNotFrozen() { + if (frozen) + throw new IllegalStateException("Attempt to modify a frozen assembly model"); + } + + public void initialize(AssemblyContext modelContext) { + if (!initialized) + initialized=true; + } + + /** + * Returns true if the object is initialized + */ + protected boolean isInitialized() { + return initialized; + } + + /** + * Initialize members of a collection + */ + protected void initialize(Collection collection, AssemblyContext modelContext) { + for (Object member : collection) { + if (member instanceof AssemblyObject) { + ((AssemblyObject)member).initialize(modelContext); + } + } + } + + /** + * Check that the current model object is initialized. + * @throws IllegalStateException + */ + protected void checkInitialized() { + if (!initialized) + throw new IllegalStateException("Attempt to use an uninitialized assembly model"); + } + +} diff --git a/tags/java-M1-20060518/java/sca/model/src/main/java/org/apache/tuscany/model/assembly/impl/AtomicComponentImpl.java b/tags/java-M1-20060518/java/sca/model/src/main/java/org/apache/tuscany/model/assembly/impl/AtomicComponentImpl.java new file mode 100644 index 0000000000..186d685d12 --- /dev/null +++ b/tags/java-M1-20060518/java/sca/model/src/main/java/org/apache/tuscany/model/assembly/impl/AtomicComponentImpl.java @@ -0,0 +1,30 @@ +/** + * + * Copyright 2005 The Apache Software Foundation or its licensors, as applicable. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.tuscany.model.assembly.impl; + +import org.apache.tuscany.model.assembly.AtomicComponent; +import org.apache.tuscany.model.assembly.AtomicImplementation; + +/** + * An implementation of AtomicComponent. + */ +public class AtomicComponentImpl extends ComponentImpl<AtomicImplementation> implements AtomicComponent { + + protected AtomicComponentImpl() { + } + +} diff --git a/tags/java-M1-20060518/java/sca/model/src/main/java/org/apache/tuscany/model/assembly/impl/AtomicImplementationImpl.java b/tags/java-M1-20060518/java/sca/model/src/main/java/org/apache/tuscany/model/assembly/impl/AtomicImplementationImpl.java new file mode 100644 index 0000000000..1f85afa2cc --- /dev/null +++ b/tags/java-M1-20060518/java/sca/model/src/main/java/org/apache/tuscany/model/assembly/impl/AtomicImplementationImpl.java @@ -0,0 +1,29 @@ +/** + * + * Copyright 2005 The Apache Software Foundation or its licensors, as applicable. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.tuscany.model.assembly.impl; + +import org.apache.tuscany.model.assembly.AtomicImplementation; + +/** + * An implementation of AtomicImplementation. + */ +public abstract class AtomicImplementationImpl extends ImplementationImpl implements AtomicImplementation { + + protected AtomicImplementationImpl() { + } + +} diff --git a/tags/java-M1-20060518/java/sca/model/src/main/java/org/apache/tuscany/model/assembly/impl/BindingImpl.java b/tags/java-M1-20060518/java/sca/model/src/main/java/org/apache/tuscany/model/assembly/impl/BindingImpl.java new file mode 100644 index 0000000000..c13dabb17e --- /dev/null +++ b/tags/java-M1-20060518/java/sca/model/src/main/java/org/apache/tuscany/model/assembly/impl/BindingImpl.java @@ -0,0 +1,62 @@ +/** + * + * Copyright 2005 The Apache Software Foundation or its licensors, as applicable. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.tuscany.model.assembly.impl; + +import org.apache.tuscany.model.assembly.AssemblyContext; +import org.apache.tuscany.model.assembly.AssemblyVisitor; +import org.apache.tuscany.model.assembly.Binding; + +/** + * An implementation of Binding. + */ +public class BindingImpl extends ExtensibleImpl implements Binding { + + private String uri; + + protected BindingImpl() { + } + + public String getURI() { + return uri; + } + + public void setURI(String value) { + checkNotFrozen(); + uri=value; + } + + public void initialize(AssemblyContext modelContext) { + if (isInitialized()) + return; + super.initialize(modelContext); + } + + public void freeze() { + if (isFrozen()) + return; + super.freeze(); + + } + + public boolean accept(AssemblyVisitor visitor) { + if (!super.accept(visitor)) + return false; + + return true; + } + +} diff --git a/tags/java-M1-20060518/java/sca/model/src/main/java/org/apache/tuscany/model/assembly/impl/ComponentImpl.java b/tags/java-M1-20060518/java/sca/model/src/main/java/org/apache/tuscany/model/assembly/impl/ComponentImpl.java new file mode 100644 index 0000000000..a952ebe34d --- /dev/null +++ b/tags/java-M1-20060518/java/sca/model/src/main/java/org/apache/tuscany/model/assembly/impl/ComponentImpl.java @@ -0,0 +1,213 @@ +/** + * + * Copyright 2005 The Apache Software Foundation or its licensors, as applicable. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.tuscany.model.assembly.impl; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import org.apache.tuscany.model.assembly.AssemblyContext; +import org.apache.tuscany.model.assembly.AssemblyFactory; +import org.apache.tuscany.model.assembly.AssemblyInitializationException; +import org.apache.tuscany.model.assembly.AssemblyVisitor; +import org.apache.tuscany.model.assembly.Component; +import org.apache.tuscany.model.assembly.ComponentType; +import org.apache.tuscany.model.assembly.ConfiguredPort; +import org.apache.tuscany.model.assembly.ConfiguredProperty; +import org.apache.tuscany.model.assembly.ConfiguredReference; +import org.apache.tuscany.model.assembly.ConfiguredService; +import org.apache.tuscany.model.assembly.Implementation; +import org.apache.tuscany.model.assembly.Property; +import org.apache.tuscany.model.assembly.Reference; +import org.apache.tuscany.model.assembly.Service; +import org.apache.tuscany.model.util.NotifyingList; + +/** + * An implementation of Component. + */ +public abstract class ComponentImpl<I extends Implementation> extends PartImpl implements Component<I> { + + /** + * A list of configured ports synchronized with a map + */ + private class ConfiguredPortList<E extends ConfiguredPort> extends NotifyingList<E>{ + + Map<String, E> map; + + private ConfiguredPortList(Map<String, E> map) { + this.map=map; + } + + protected void added(E element) { + String name=element.getPort()!=null? element.getPort().getName():element.getName(); + map.put(name, element); + element.setPart(ComponentImpl.this); + } + protected void removed(E element) { + String name=element.getPort()!=null? element.getPort().getName():element.getName(); + map.remove(name); + element.setPart(null); + } + } + + private Map<String, ConfiguredReference> configuredReferencesMap = new HashMap<String, ConfiguredReference>(); + private List<ConfiguredReference> configuredReferences = new ConfiguredPortList<ConfiguredReference>(configuredReferencesMap); + + private Map<String, ConfiguredService> configuredServicesMap = new HashMap<String, ConfiguredService>(); + private List<ConfiguredService> configuredServices = new ConfiguredPortList<ConfiguredService>(configuredServicesMap); + + /** + * A list of properties synchronized with a map + */ + private class ConfiguredPropertyList<E extends ConfiguredProperty> extends NotifyingList<E>{ + + protected void added(E element) { + String name=element.getProperty()!=null? element.getProperty().getName():element.getName(); + configuredPropertiesMap.put(name, element); + } + protected void removed(E element) { + String name=element.getProperty()!=null? element.getProperty().getName():element.getName(); + configuredPropertiesMap.remove(name); + } + } + + private List<ConfiguredProperty> configuredProperties = new ConfiguredPropertyList<ConfiguredProperty>(); + private Map<String, ConfiguredProperty> configuredPropertiesMap=new HashMap<String, ConfiguredProperty>(); + + private I implementation; + + public I getImplementation() { + return implementation; + } + + public void setImplementation(I value) { + checkNotFrozen(); + implementation = value; + } + + public List<ConfiguredService> getConfiguredServices() { + return configuredServices; + } + + public ConfiguredService getConfiguredService(String name) { + return configuredServicesMap.get(name); + } + + public List<ConfiguredReference> getConfiguredReferences() { + return configuredReferences; + } + + public ConfiguredReference getConfiguredReference(String name) { + return configuredReferencesMap.get(name); + } + + public List<ConfiguredProperty> getConfiguredProperties() { + return configuredProperties; + } + + public ConfiguredProperty getConfiguredProperty(String name) { + return configuredPropertiesMap.get(name); + } + + public void initialize(AssemblyContext modelContext) { + if (isInitialized()) + return; + super.initialize(modelContext); + + // Initialize the implementation + if (implementation == null) { + throw new AssemblyInitializationException("No implementation for component [" + getName() + ']'); + } + implementation.initialize(modelContext); + + // Derive the configured services from the component implementation + ComponentType componentType=implementation.getComponentType(); + AssemblyFactory factory = modelContext.getAssemblyFactory(); + for (Service service : componentType.getServices()) { + ConfiguredService configuredService = factory.createConfiguredService(); + configuredService.setPort(service); + configuredServices.add(configuredService); + configuredService.initialize(modelContext); + } + + // Derive the configured references from the references on the component info + for (Reference reference : componentType.getReferences()) { + ConfiguredReference configuredReference = configuredReferencesMap.get(reference.getName()); + if (configuredReference==null) { + configuredReference=factory.createConfiguredReference(); + configuredReference.setPort(reference); + configuredReferences.add(configuredReference); + configuredReference.initialize(modelContext); + } else { + configuredReference.setPort(reference); + configuredReference.initialize(modelContext); + } + } + for (ConfiguredReference configuredReference : configuredReferences) { + if (configuredReference.getPort()==null) { + throw new AssemblyInitializationException("Undefined reference ["+configuredReference.getName()+"]"); + } + } + + // Derive the configured properties from the properties on the component info + for (Property property : componentType.getProperties()) { + ConfiguredProperty configuredProperty = configuredPropertiesMap.get(property.getName()); + if (configuredProperty != null) { + configuredProperty.setProperty(property); + configuredProperty.initialize(modelContext); + } + } + for (ConfiguredProperty configuredProperty : configuredProperties) { + if (configuredProperty.getProperty()==null) { + throw new AssemblyInitializationException("Undefined property ["+configuredProperty.getName()+"]"); + } + } + + } + + public void freeze() { + if (isFrozen()) + return; + super.freeze(); + + // Freeze configured services, references and properties + configuredServices = freeze(configuredServices); + configuredReferences = freeze(configuredReferences); + configuredProperties = freeze(configuredProperties); + if (implementation != null) + implementation.freeze(); + } + + public boolean accept(AssemblyVisitor visitor) { + if (!super.accept(visitor)) + return false; + + if (!accept(configuredServices, visitor)) + return false; + if (!accept(configuredReferences, visitor)) + return false; + if (!accept(configuredProperties, visitor)) + return false; + if (implementation != null) { + if (!implementation.accept(visitor)) + return false; + } + + return true; + } + +} diff --git a/tags/java-M1-20060518/java/sca/model/src/main/java/org/apache/tuscany/model/assembly/impl/ComponentTypeImpl.java b/tags/java-M1-20060518/java/sca/model/src/main/java/org/apache/tuscany/model/assembly/impl/ComponentTypeImpl.java new file mode 100644 index 0000000000..617206b6af --- /dev/null +++ b/tags/java-M1-20060518/java/sca/model/src/main/java/org/apache/tuscany/model/assembly/impl/ComponentTypeImpl.java @@ -0,0 +1,147 @@ +/** + * + * Copyright 2005 The Apache Software Foundation or its licensors, as applicable. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.tuscany.model.assembly.impl; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import org.apache.tuscany.model.assembly.AssemblyContext; +import org.apache.tuscany.model.assembly.AssemblyVisitor; +import org.apache.tuscany.model.assembly.ComponentType; +import org.apache.tuscany.model.assembly.Port; +import org.apache.tuscany.model.assembly.Property; +import org.apache.tuscany.model.assembly.Reference; +import org.apache.tuscany.model.assembly.Service; +import org.apache.tuscany.model.util.NotifyingList; + +/** + * An implementation of ComponentType. + */ +public class ComponentTypeImpl extends ExtensibleImpl implements ComponentType { + + /** + * A list of ports synchronized with a map + */ + private class PortList<E extends Port> extends NotifyingList<E>{ + + Map<String, E> map; + + private PortList(Map<String, E> map) { + this.map=map; + } + + protected void added(E element) { + map.put(element.getName(), element); + } + protected void removed(E element) { + map.remove(element.getName()); + } + } + + private Map<String, Reference> referencesMap=new HashMap<String, Reference>(); + private List<Reference> references=new PortList<Reference>(referencesMap); + + private Map<String, Service> servicesMap=new HashMap<String, Service>(); + private List<Service> services=new PortList<Service>(servicesMap); + + /** + * A list of properties synchronized with a map + */ + private class PropertyList<E extends Property> extends NotifyingList<E>{ + + protected void added(E element) { + propertiesMap.put(element.getName(), element); + } + protected void removed(E element) { + propertiesMap.remove(element.getName()); + } + } + + private Map<String, Property> propertiesMap=new HashMap<String, Property>(); + private List<Property> properties=new PropertyList<Property>(); + + protected ComponentTypeImpl() { + } + + public List<Reference> getReferences() { + return references; + } + + public Reference getReference(String name) { + return referencesMap.get(name); + } + + public List<Service> getServices() { + return services; + } + + public Service getService(String name) { + return servicesMap.get(name); + } + + public List<Property> getProperties() { + return properties; + } + + public Property getProperty(String name) { + return propertiesMap.get(name); + } + + public void initialize(AssemblyContext modelContext) { + if (isInitialized()) + return; + super.initialize(modelContext); + + // Initialize references, properties and services + for (Reference reference : references) { + reference.initialize(modelContext); + } + for (Property property : properties) { + property.initialize(modelContext); + } + for (Service service : services) { + service.initialize(modelContext); + } + } + + public void freeze() { + if (isFrozen()) + return; + super.freeze(); + + // Freeze lists of services, references and properties + services=freeze(services); + references=freeze(references); + properties=freeze(properties); + } + + public boolean accept(AssemblyVisitor visitor) { + if (!super.accept(visitor)) + return false; + + if (!accept(services, visitor)) + return false; + if (!accept(references, visitor)) + return false; + if (!accept(properties, visitor)) + return false; + + return true; + } + +} diff --git a/tags/java-M1-20060518/java/sca/model/src/main/java/org/apache/tuscany/model/assembly/impl/CompositeImpl.java b/tags/java-M1-20060518/java/sca/model/src/main/java/org/apache/tuscany/model/assembly/impl/CompositeImpl.java new file mode 100644 index 0000000000..fff32e3398 --- /dev/null +++ b/tags/java-M1-20060518/java/sca/model/src/main/java/org/apache/tuscany/model/assembly/impl/CompositeImpl.java @@ -0,0 +1,357 @@ +/** + * + * Copyright 2005 The Apache Software Foundation or its licensors, as applicable. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.tuscany.model.assembly.impl; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import org.apache.tuscany.model.assembly.AssemblyContext; +import org.apache.tuscany.model.assembly.AssemblyFactory; +import org.apache.tuscany.model.assembly.AssemblyVisitor; +import org.apache.tuscany.model.assembly.Component; +import org.apache.tuscany.model.assembly.ComponentType; +import org.apache.tuscany.model.assembly.Composite; +import org.apache.tuscany.model.assembly.ConfiguredProperty; +import org.apache.tuscany.model.assembly.ConfiguredReference; +import org.apache.tuscany.model.assembly.ConfiguredService; +import org.apache.tuscany.model.assembly.EntryPoint; +import org.apache.tuscany.model.assembly.ExternalService; +import org.apache.tuscany.model.assembly.Implementation; +import org.apache.tuscany.model.assembly.ImportWSDL; +import org.apache.tuscany.model.assembly.Multiplicity; +import org.apache.tuscany.model.assembly.OverrideOption; +import org.apache.tuscany.model.assembly.Part; +import org.apache.tuscany.model.assembly.Reference; +import org.apache.tuscany.model.assembly.Service; +import org.apache.tuscany.model.assembly.ServiceContract; +import org.apache.tuscany.model.assembly.ServiceURI; +import org.apache.tuscany.model.assembly.Wire; +import org.apache.tuscany.model.util.NotifyingList; + +/** + * An implementation of Composite. + */ +public abstract class CompositeImpl extends ExtensibleImpl implements Composite { + + private String name; + private ComponentType componentType; + private Class<?> implementationClass; + + /** + * A list of parts synchronized with a map + */ + private class PartList<E extends Part> extends NotifyingList<E> { + protected void added(E element) { + partsMap.put(element.getName(), element); + element.setComposite(CompositeImpl.this); + } + + protected void removed(E element) { + partsMap.remove(element.getName()); + element.setComposite(null); + } + } + + private Map<String, Part> partsMap = new HashMap<String, Part>(); + + private List<Component> components = new PartList<Component>(); + private List<EntryPoint> entryPoints = new PartList<EntryPoint>(); + private List<ExternalService> externalServices = new PartList<ExternalService>(); + + private List<Wire> wires = new ArrayList<Wire>(); + + /** + * A list of WSDL imports synchronized with a map + */ + private class ImportWSDLList extends NotifyingList<ImportWSDL> { + protected void added(ImportWSDL element) { + List<ImportWSDL> importList = wsdlImportsMap.get(element.getNamespace()); + if (importList == null) { + importList = new ArrayList<ImportWSDL>(); + wsdlImportsMap.put(element.getNamespace(), importList); + } + importList.add(element); + } + + protected void removed(ImportWSDL element) { + List<ImportWSDL> importList = wsdlImportsMap.get(element.getNamespace()); + if (importList != null) { + importList.remove(element); + if (importList.isEmpty()) + wsdlImportsMap.remove(element.getNamespace()); + } + } + } + + private Map<String, List<ImportWSDL>> wsdlImportsMap = new HashMap<String, List<ImportWSDL>>(); + + private List<ImportWSDL> wsdlImports = new ImportWSDLList(); + + protected CompositeImpl() { + } + + public String getName() { + return name; + } + + public void setName(String newName) { + checkNotFrozen(); + name = newName; + } + + public List<Component> getComponents() { + return components; + } + + public List<EntryPoint> getEntryPoints() { + return entryPoints; + } + + public List<ExternalService> getExternalServices() { + return externalServices; + } + + public Part getPart(String name) { + return partsMap.get(name); + } + + public List<Wire> getWires() { + return wires; + } + + public List<ImportWSDL> getWSDLImports() { + return wsdlImports; + } + + public List<ImportWSDL> getWSDLImports(String namespace) { + return wsdlImportsMap.get(namespace); + } + + public ComponentType getComponentType() { + return componentType; + } + + public void setComponentType(ComponentType componentType) { + checkNotFrozen(); + this.componentType = componentType; + } + + public ConfiguredService getConfiguredService(ServiceURI address) { + String partName = address.getPartName(); + String serviceName = address.getServiceName(); + Part part = getPart(partName); + if (part instanceof Component) { + Component<?> component = (Component<?>) part; + if (serviceName != null) { + return component.getConfiguredService(serviceName); + } else { + if (!component.getConfiguredServices().isEmpty()) { + return component.getConfiguredServices().get(0); + } else { + return null; + } + } + + } + if (part instanceof ExternalService) { + ExternalService externalService = (ExternalService) part; + return externalService.getConfiguredService(); + } else + return null; + } + + public void initialize(AssemblyContext modelContext) { + if (isInitialized()) + return; + super.initialize(modelContext); + + // Initialize WSDL imports + for (ImportWSDL importWSDL : wsdlImports) { + importWSDL.initialize(modelContext); + } + + // Initialize parts + for (Part part : externalServices) { + part.initialize(modelContext); + } + for (Part part : components) { + part.initialize(modelContext); + } + for (Part part : entryPoints) { + part.initialize(modelContext); + } + + // Derive the component type from the entry points and external services in the composite + // Also derive properties from the overridable properties of the components in the composite + if (componentType == null) { + AssemblyFactory factory = modelContext.getAssemblyFactory(); + componentType = factory.createComponentType(); + for (EntryPoint entryPoint : getEntryPoints()) { + Service service = factory.createService(); + service.setName(entryPoint.getName()); + ServiceContract serviceContract = entryPoint.getConfiguredService().getPort().getServiceContract(); + if (serviceContract != null) + service.setServiceContract(serviceContract); + componentType.getServices().add(service); + + ConfiguredReference configuredReference = entryPoint.getConfiguredReference(); + ServiceURI sourceURI = factory.createServiceURI(null, entryPoint, configuredReference); + for (String target : configuredReference.getTargets()) { + ServiceURI targetURI = factory.createServiceURI(null, target); + Wire wire = factory.createWire(); + wire.setSource(sourceURI); + wire.setTarget(targetURI); + getWires().add(wire); + } + } + for (ExternalService externalService : getExternalServices()) { + if (externalService.getOverrideOption() == null || externalService.getOverrideOption() == OverrideOption.NO) + continue; + Reference reference = factory.createReference(); + reference.setName(externalService.getName()); + ServiceContract serviceContract = externalService.getConfiguredService().getPort().getServiceContract(); + if (serviceContract != null) + reference.setServiceContract(serviceContract); + componentType.getReferences().add(reference); + } + for (Component<Implementation> component : getComponents()) { + for (ConfiguredProperty configuredProperty : component.getConfiguredProperties()) { + if (configuredProperty.getOverrideOption() == null || configuredProperty.getOverrideOption() == OverrideOption.NO) + continue; + componentType.getProperties().add(configuredProperty.getProperty()); + } + + for (ConfiguredReference configuredReference : component.getConfiguredReferences()) { + // Create a wire + ServiceURI sourceURI = factory.createServiceURI(null, component, configuredReference); + for (String target : configuredReference.getTargets()) { + ServiceURI targetURI = factory.createServiceURI(null, target); + Wire wire = factory.createWire(); + wire.setSource(sourceURI); + wire.setTarget(targetURI); + getWires().add(wire); + } + } + } + } + componentType.initialize(modelContext); + + // Wire the parts in this composite + wire(modelContext); + } + + /** + * Wire the parts in this composite. + * @param modelContext + */ + protected void wire(AssemblyContext modelContext) { + for (Wire wire : getWires()) { + + // Get the source reference + ServiceURI sourceURI = wire.getSource(); + ConfiguredReference configuredReference = null; + String partName = sourceURI.getPartName(); + String referenceName = sourceURI.getServiceName(); + if (referenceName != null) { + //Component<?> component = (Component<?>)getPart(partName); +// if (component != null) { + Part part = getPart(partName); + if (part instanceof Component) { + configuredReference = ((Component) part).getConfiguredReference(referenceName); + } else if (part instanceof EntryPoint) { + configuredReference = ((EntryPoint) part).getConfiguredReference(); + } + } else { + EntryPoint entryPoint = (EntryPoint) getPart(partName); + if (entryPoint != null) { + configuredReference = entryPoint.getConfiguredReference(); + } + } + if (configuredReference == null) { + throw new IllegalArgumentException("Cannot find wire source " + sourceURI.getPath()); + } else { + + // Resolve the target service endpoint + ServiceURI targetURI = wire.getTarget(); + ConfiguredService configuredService = getConfiguredService(targetURI); + if (configuredService != null) { + + // Wire the reference to the target + Multiplicity multiplicity = configuredReference.getPort().getMultiplicity(); + if (multiplicity == Multiplicity.ZERO_N || multiplicity == Multiplicity.ONE_N) { + configuredReference.getTargetConfiguredServices().add(configuredService); + } else { + configuredReference.getTargetConfiguredServices().clear(); + configuredReference.getTargetConfiguredServices().add(configuredService); + } + } else { + throw new IllegalArgumentException("Cannot find service '" + targetURI.getPath() +"'."); + } + } + } + } + + public Class<?> getImplementationClass() { + return implementationClass; + } + + public void setImplementationClass(Class<?> clazz) { + checkNotFrozen(); + this.implementationClass = clazz; + } + + public void freeze() { + if (isFrozen()) + return; + super.freeze(); + + // Freeze component type + if (componentType != null) + componentType.freeze(); + + // Freeze lists + wsdlImports = freeze(wsdlImports); + components = freeze(components); + entryPoints = freeze(entryPoints); + externalServices = freeze(externalServices); + wires = freeze(wires); + } + + public boolean accept(AssemblyVisitor visitor) { + if (!super.accept(visitor)) + return false; + + if (!accept(wsdlImports, visitor)) + return false; + + if (!accept(partsMap.values(), visitor)) + return false; + + if (!accept(wires, visitor)) + return false; + + if (componentType != null) { + if (!componentType.accept(visitor)) + return false; + } + + return true; + } + +} diff --git a/tags/java-M1-20060518/java/sca/model/src/main/java/org/apache/tuscany/model/assembly/impl/ConfiguredPortImpl.java b/tags/java-M1-20060518/java/sca/model/src/main/java/org/apache/tuscany/model/assembly/impl/ConfiguredPortImpl.java new file mode 100644 index 0000000000..f1007e8c07 --- /dev/null +++ b/tags/java-M1-20060518/java/sca/model/src/main/java/org/apache/tuscany/model/assembly/impl/ConfiguredPortImpl.java @@ -0,0 +1,106 @@ +/** + * + * Copyright 2005 The Apache Software Foundation or its licensors, as applicable. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.tuscany.model.assembly.impl; + +import org.apache.tuscany.model.assembly.Part; +import org.apache.tuscany.model.assembly.AssemblyContext; +import org.apache.tuscany.model.assembly.AssemblyVisitor; +import org.apache.tuscany.model.assembly.ConfiguredPort; +import org.apache.tuscany.model.assembly.Port; + +/** + * Implementation of ConfiguredPort. + */ +public abstract class ConfiguredPortImpl<P extends Port> extends AssemblyObjectImpl implements ConfiguredPort<P> { + private String name; + private Part part; + private P port; + + private Object proxyFactory; + + protected ConfiguredPortImpl() { + } + + public String getName() { + return name; + } + + public void setName(String name) { + checkNotFrozen(); + this.name=name; + } + + public P getPort() { + return port; + } + + public void setPort(P port) { + checkNotFrozen(); + this.port = port; + } + + public Part getPart() { + return part; + } + + public void setPart(Part part) { + checkNotFrozen(); + this.part=part; + } + + public Object getProxyFactory() { + return proxyFactory; + } + + public void setProxyFactory(Object proxyFactory) { + checkNotFrozen(); + this.proxyFactory = proxyFactory; + } + + public void initialize(AssemblyContext modelContext) { + if (isInitialized()) + return; + super.initialize(modelContext); + + if (port!=null) { + name=port.getName(); + port.initialize(modelContext); + } + } + + public void freeze() { + if (isFrozen()) + return; + super.freeze(); + + if (port!=null) + port.freeze(); + } + + public boolean accept(AssemblyVisitor visitor) { + if (!super.accept(visitor)) + return false; + + if (port!=null) { + if (!port.accept(visitor)) + return false; + } + + return true; + } + +} diff --git a/tags/java-M1-20060518/java/sca/model/src/main/java/org/apache/tuscany/model/assembly/impl/ConfiguredPropertyImpl.java b/tags/java-M1-20060518/java/sca/model/src/main/java/org/apache/tuscany/model/assembly/impl/ConfiguredPropertyImpl.java new file mode 100644 index 0000000000..4c64676451 --- /dev/null +++ b/tags/java-M1-20060518/java/sca/model/src/main/java/org/apache/tuscany/model/assembly/impl/ConfiguredPropertyImpl.java @@ -0,0 +1,102 @@ +/** + * + * Copyright 2005 The Apache Software Foundation or its licensors, as applicable. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.tuscany.model.assembly.impl; + +import org.apache.tuscany.model.assembly.AssemblyContext; +import org.apache.tuscany.model.assembly.AssemblyVisitor; +import org.apache.tuscany.model.assembly.ConfiguredProperty; +import org.apache.tuscany.model.assembly.OverrideOption; +import org.apache.tuscany.model.assembly.Property; + +/** + * Implementation of ConfiguredProperty + */ +public class ConfiguredPropertyImpl extends AssemblyObjectImpl implements ConfiguredProperty { + private String name; + private OverrideOption overrideOption; + private Object value; + private Property property; + + protected ConfiguredPropertyImpl() { + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public Property getProperty() { + return property; + } + + public void setProperty(Property property) { + checkNotFrozen(); + this.property = property; + } + + public Object getValue() { + return value; + } + + public void setValue(Object value) { + checkNotFrozen(); + this.value = value; + } + + public OverrideOption getOverrideOption() { + return overrideOption; + } + + public void setOverrideOption(OverrideOption value) { + checkNotFrozen(); + this.overrideOption=value; + } + + public void initialize(AssemblyContext modelContext) { + if (isInitialized()) + return; + super.initialize(modelContext); + + if (property!=null) + property.initialize(modelContext); + } + + public void freeze() { + if (isFrozen()) + return; + super.freeze(); + + if (property!=null) + property.freeze(); + } + + public boolean accept(AssemblyVisitor visitor) { + if (!super.accept(visitor)) + return false; + + if (property!=null) { + if (!property.accept(visitor)) + return false; + } + + return true; + } + +} diff --git a/tags/java-M1-20060518/java/sca/model/src/main/java/org/apache/tuscany/model/assembly/impl/ConfiguredReferenceImpl.java b/tags/java-M1-20060518/java/sca/model/src/main/java/org/apache/tuscany/model/assembly/impl/ConfiguredReferenceImpl.java new file mode 100644 index 0000000000..f21a5be52e --- /dev/null +++ b/tags/java-M1-20060518/java/sca/model/src/main/java/org/apache/tuscany/model/assembly/impl/ConfiguredReferenceImpl.java @@ -0,0 +1,53 @@ +/** + * + * Copyright 2005 The Apache Software Foundation or its licensors, as applicable. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.tuscany.model.assembly.impl; + +import java.util.ArrayList; +import java.util.List; + +import org.apache.tuscany.model.assembly.ConfiguredReference; +import org.apache.tuscany.model.assembly.ConfiguredService; +import org.apache.tuscany.model.assembly.Reference; + +/** + * An implementation of ConfiguredReference. + */ +public class ConfiguredReferenceImpl extends ConfiguredPortImpl<Reference> implements ConfiguredReference { + + private List<String> targets = new ArrayList<String>(); + + private List<ConfiguredService> targetConfiguredServices = new ArrayList<ConfiguredService>(); + + protected ConfiguredReferenceImpl() { + } + + public List<String> getTargets() { + return targets; + } + + public List<ConfiguredService> getTargetConfiguredServices() { + return targetConfiguredServices; + } + + public void freeze() { + super.freeze(); + + targetConfiguredServices = freeze(targetConfiguredServices); + targets = freeze(targets); + } + +} diff --git a/tags/java-M1-20060518/java/sca/model/src/main/java/org/apache/tuscany/model/assembly/impl/ConfiguredServiceImpl.java b/tags/java-M1-20060518/java/sca/model/src/main/java/org/apache/tuscany/model/assembly/impl/ConfiguredServiceImpl.java new file mode 100644 index 0000000000..923af1882c --- /dev/null +++ b/tags/java-M1-20060518/java/sca/model/src/main/java/org/apache/tuscany/model/assembly/impl/ConfiguredServiceImpl.java @@ -0,0 +1,30 @@ +/** + * + * Copyright 2005 The Apache Software Foundation or its licensors, as applicable. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.tuscany.model.assembly.impl; + +import org.apache.tuscany.model.assembly.ConfiguredService; +import org.apache.tuscany.model.assembly.Service; + +/** + * An implementation of ConfiguredService. + */ +public class ConfiguredServiceImpl extends ConfiguredPortImpl<Service> implements ConfiguredService { + + protected ConfiguredServiceImpl() { + } + +} diff --git a/tags/java-M1-20060518/java/sca/model/src/main/java/org/apache/tuscany/model/assembly/impl/EntryPointImpl.java b/tags/java-M1-20060518/java/sca/model/src/main/java/org/apache/tuscany/model/assembly/impl/EntryPointImpl.java new file mode 100644 index 0000000000..a894a7c48f --- /dev/null +++ b/tags/java-M1-20060518/java/sca/model/src/main/java/org/apache/tuscany/model/assembly/impl/EntryPointImpl.java @@ -0,0 +1,116 @@ +/** + * + * Copyright 2005 The Apache Software Foundation or its licensors, as applicable. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.tuscany.model.assembly.impl; + +import java.util.ArrayList; +import java.util.List; + +import org.apache.tuscany.model.assembly.AssemblyContext; +import org.apache.tuscany.model.assembly.AssemblyVisitor; +import org.apache.tuscany.model.assembly.Binding; +import org.apache.tuscany.model.assembly.ConfiguredReference; +import org.apache.tuscany.model.assembly.ConfiguredService; +import org.apache.tuscany.model.assembly.EntryPoint; + +/** + * An implementation of EntryPoint. + */ +public class EntryPointImpl extends PartImpl implements EntryPoint { + + private ConfiguredService configuredService; + private ConfiguredReference configuredReference; + private List<Binding> bindings=new ArrayList<Binding>(); + + protected EntryPointImpl() { + } + + public ConfiguredReference getConfiguredReference() { + return configuredReference; + } + + public void setConfiguredReference(ConfiguredReference configuredReference) { + checkNotFrozen(); + configuredReference.setPart(this); + this.configuredReference=configuredReference; + } + + public ConfiguredService getConfiguredService() { + return configuredService; + } + + public void setConfiguredService(ConfiguredService configuredService) { + checkNotFrozen(); + configuredService.setPart(this); + this.configuredService=configuredService; + } + + public List<Binding> getBindings() { + return bindings; + } + + public void initialize(AssemblyContext modelContext) { + if (isInitialized()) + return; + super.initialize(modelContext); + + // Initialize the service contract and reference to the published service + if (configuredReference != null) { + configuredReference.initialize(modelContext); + } + if (configuredService != null) { + configuredService.initialize(modelContext); + } + + // Initialize the bindings + initialize(bindings, modelContext); + } + + public void freeze() { + if (isFrozen()) + return; + super.freeze(); + + // Freeze the service contract and configured reference + if (configuredReference != null) + configuredReference.freeze(); + if (configuredService != null) + configuredService.freeze(); + + // Freeze the bindings + bindings=freeze(bindings); + } + + public boolean accept(AssemblyVisitor visitor) { + if (!super.accept(visitor)) + return false; + + if (configuredReference!=null) { + if (!configuredReference.accept(visitor)) + return false; + } + + if (configuredService!=null) { + if (!configuredService.accept(visitor)) + return false; + } + + if (!accept(bindings, visitor)) + return false; + + return true; + } +} diff --git a/tags/java-M1-20060518/java/sca/model/src/main/java/org/apache/tuscany/model/assembly/impl/ExtensibleImpl.java b/tags/java-M1-20060518/java/sca/model/src/main/java/org/apache/tuscany/model/assembly/impl/ExtensibleImpl.java new file mode 100644 index 0000000000..6adf66dc9e --- /dev/null +++ b/tags/java-M1-20060518/java/sca/model/src/main/java/org/apache/tuscany/model/assembly/impl/ExtensibleImpl.java @@ -0,0 +1,75 @@ +/** + * + * Copyright 2005 The Apache Software Foundation or its licensors, as applicable. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.tuscany.model.assembly.impl; + +import java.util.ArrayList; +import java.util.List; + +import org.apache.tuscany.model.assembly.AssemblyContext; +import org.apache.tuscany.model.assembly.AssemblyVisitor; +import org.apache.tuscany.model.assembly.Extensible; + +/** + * An implementation of Extensible. + */ +public abstract class ExtensibleImpl extends AssemblyObjectImpl implements Extensible { + + private List<Object> extensibilityElements = new ArrayList<Object>(); + private List<Object> extensibilityAttributes = new ArrayList<Object>(); + + protected ExtensibleImpl() { + } + + public List<Object> getExtensibilityElements() { + return extensibilityElements; + } + + public List<Object> getExtensibilityAttributes() { + return extensibilityAttributes; + } + + public void initialize(AssemblyContext modelContext) { + if (isInitialized()) + return; + super.initialize(modelContext); + + // Initialize extensibility elements and attributes + initialize(extensibilityElements, modelContext); + initialize(extensibilityAttributes, modelContext); + } + + public void freeze() { + if (isFrozen()) + return; + super.freeze(); + + // Freeze extensibility elements and attributes + freeze(extensibilityElements); + freeze(extensibilityAttributes); + } + + public boolean accept(AssemblyVisitor visitor) { + if (!super.accept(visitor)) + return false; + + if (!accept(extensibilityElements, visitor)) + return false; + return accept(extensibilityAttributes, visitor); + + } + +} diff --git a/tags/java-M1-20060518/java/sca/model/src/main/java/org/apache/tuscany/model/assembly/impl/ExternalServiceImpl.java b/tags/java-M1-20060518/java/sca/model/src/main/java/org/apache/tuscany/model/assembly/impl/ExternalServiceImpl.java new file mode 100644 index 0000000000..9110731c34 --- /dev/null +++ b/tags/java-M1-20060518/java/sca/model/src/main/java/org/apache/tuscany/model/assembly/impl/ExternalServiceImpl.java @@ -0,0 +1,116 @@ +/** + * + * Copyright 2005 The Apache Software Foundation or its licensors, as applicable. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.tuscany.model.assembly.impl; + +import java.util.ArrayList; +import java.util.List; + +import org.apache.tuscany.model.assembly.AssemblyContext; +import org.apache.tuscany.model.assembly.AssemblyVisitor; +import org.apache.tuscany.model.assembly.Binding; +import org.apache.tuscany.model.assembly.ConfiguredService; +import org.apache.tuscany.model.assembly.ExternalService; +import org.apache.tuscany.model.assembly.OverrideOption; + +/** + * An implementation ExternalService. + */ +public class ExternalServiceImpl extends PartImpl implements ExternalService { + + private ConfiguredService configuredService; + private OverrideOption overrideOption; + private List<Binding> bindings=new ArrayList<Binding>(); + + private Object contextFactory; + + protected ExternalServiceImpl() { + } + + public OverrideOption getOverrideOption() { + return overrideOption; + } + + public void setOverrideOption(OverrideOption newOverridable) { + checkNotFrozen(); + overrideOption=newOverridable; + } + + public List<Binding> getBindings() { + return bindings; + } + + public ConfiguredService getConfiguredService() { + return configuredService; + } + + public void setConfiguredService(ConfiguredService configuredService) { + checkNotFrozen(); + configuredService.setPart(this); + this.configuredService=configuredService; + } + + public Object getContextFactory() { + return contextFactory; + } + + public void setContextFactory(Object contextFactory) { + this.contextFactory=contextFactory; + } + + public void initialize(AssemblyContext modelContext) { + if (isInitialized()) + return; + super.initialize(modelContext); + + // Initialize the configured service + if (configuredService != null) { + configuredService.initialize(modelContext); + } + + // Initialize the bindings + initialize(bindings, modelContext); + } + + public void freeze() { + if (isFrozen()) + return; + super.freeze(); + + // Freeze the configured service + if (configuredService!= null) + configuredService.freeze(); + + // Freeze the bindings + bindings=freeze(bindings); + } + + public boolean accept(AssemblyVisitor visitor) { + if (!super.accept(visitor)) + return false; + + if (configuredService!=null) { + if (!configuredService.accept(visitor)) + return false; + } + + if (!accept(bindings, visitor)) + return false; + + return true; + } + +} diff --git a/tags/java-M1-20060518/java/sca/model/src/main/java/org/apache/tuscany/model/assembly/impl/ImplementationImpl.java b/tags/java-M1-20060518/java/sca/model/src/main/java/org/apache/tuscany/model/assembly/impl/ImplementationImpl.java new file mode 100644 index 0000000000..a44d80cc66 --- /dev/null +++ b/tags/java-M1-20060518/java/sca/model/src/main/java/org/apache/tuscany/model/assembly/impl/ImplementationImpl.java @@ -0,0 +1,72 @@ +/** + * + * Copyright 2005 The Apache Software Foundation or its licensors, as applicable. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.tuscany.model.assembly.impl; + +import org.apache.tuscany.model.assembly.AssemblyContext; +import org.apache.tuscany.model.assembly.AssemblyVisitor; +import org.apache.tuscany.model.assembly.ComponentType; +import org.apache.tuscany.model.assembly.Implementation; + +/** + * An implementation of Implementation. + */ +public abstract class ImplementationImpl extends ExtensibleImpl implements Implementation { + + private ComponentType componentType; + + public ComponentType getComponentType() { + return componentType; + } + + public void setComponentType(ComponentType componentType) { + checkNotFrozen(); + this.componentType=componentType; + } + + public void initialize(AssemblyContext modelContext) { + if (isInitialized()) + return; + super.initialize(modelContext); + + // Initialize the component type + if (componentType!=null) { + componentType.initialize(modelContext); + } + + } + + public void freeze() { + if (isFrozen()) + return; + super.freeze(); + + if (componentType!=null) + componentType.freeze(); + } + + public boolean accept(AssemblyVisitor visitor) { + if (!super.accept(visitor)) + return false; + + if (componentType!=null) { + if (!componentType.accept(visitor)) + return false; + } + return true; + } + +} diff --git a/tags/java-M1-20060518/java/sca/model/src/main/java/org/apache/tuscany/model/assembly/impl/ImportWSDLImpl.java b/tags/java-M1-20060518/java/sca/model/src/main/java/org/apache/tuscany/model/assembly/impl/ImportWSDLImpl.java new file mode 100644 index 0000000000..56aedd18f5 --- /dev/null +++ b/tags/java-M1-20060518/java/sca/model/src/main/java/org/apache/tuscany/model/assembly/impl/ImportWSDLImpl.java @@ -0,0 +1,82 @@ +/** + * + * Copyright 2006 The Apache Software Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.tuscany.model.assembly.impl; + +import java.net.URL; + +import javax.wsdl.Definition; + +import org.apache.tuscany.common.resource.ResourceLoader; +import org.apache.tuscany.model.assembly.AssemblyContext; +import org.apache.tuscany.model.assembly.ImportWSDL; + +/** + * Implementation of ImportWSDL. + * + * @version $Rev$ $Date$ + */ +public class ImportWSDLImpl extends AssemblyObjectImpl implements ImportWSDL { + private String location; + private String namespace; + private Definition definition; + + protected ImportWSDLImpl() { + } + + public String getLocation() { + return location; + } + + public void setLocation(String uri) { + checkNotFrozen(); + this.location = uri; + } + + public String getNamespace() { + return namespace; + } + + public void setNamespace(String uri) { + checkNotFrozen(); + this.namespace = uri; + } + + public Definition getDefinition() { + return definition; + } + + public void setDefinition(Definition definition) { + checkNotFrozen(); + this.definition = definition; + } + + public void initialize(AssemblyContext modelContext) { + if (isInitialized()) + return; + super.initialize(modelContext); + + // Load the WSDL definition if necessary + ResourceLoader resourceLoader = modelContext.getApplicationResourceLoader(); + if (definition == null) { + URL url = resourceLoader.getResource(location); + if (url == null) + throw new IllegalArgumentException("Cannot find " + location); + definition = modelContext.getAssemblyLoader().loadDefinition(url.toString()); + } + } + +} diff --git a/tags/java-M1-20060518/java/sca/model/src/main/java/org/apache/tuscany/model/assembly/impl/ModuleComponentImpl.java b/tags/java-M1-20060518/java/sca/model/src/main/java/org/apache/tuscany/model/assembly/impl/ModuleComponentImpl.java new file mode 100644 index 0000000000..60cb42a981 --- /dev/null +++ b/tags/java-M1-20060518/java/sca/model/src/main/java/org/apache/tuscany/model/assembly/impl/ModuleComponentImpl.java @@ -0,0 +1,41 @@ +/** + * + * Copyright 2005 The Apache Software Foundation or its licensors, as applicable. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.tuscany.model.assembly.impl; + +import org.apache.tuscany.model.assembly.Module; +import org.apache.tuscany.model.assembly.ModuleComponent; + +/** + * An implementation of ModuleComponent. + */ +public class ModuleComponentImpl extends ComponentImpl<Module> implements ModuleComponent { + + private String uri; + + protected ModuleComponentImpl() { + } + + public String getURI() { + return uri; + } + + public void setURI(String value) { + checkNotFrozen(); + uri=value; + } + +} diff --git a/tags/java-M1-20060518/java/sca/model/src/main/java/org/apache/tuscany/model/assembly/impl/ModuleFragmentImpl.java b/tags/java-M1-20060518/java/sca/model/src/main/java/org/apache/tuscany/model/assembly/impl/ModuleFragmentImpl.java new file mode 100644 index 0000000000..08536d23b8 --- /dev/null +++ b/tags/java-M1-20060518/java/sca/model/src/main/java/org/apache/tuscany/model/assembly/impl/ModuleFragmentImpl.java @@ -0,0 +1,35 @@ +/** + * + * Copyright 2005 The Apache Software Foundation or its licensors, as applicable. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.tuscany.model.assembly.impl; + +import org.apache.tuscany.model.assembly.AssemblyContext; +import org.apache.tuscany.model.assembly.ModuleFragment; + +/** + * An implementation of ModuleFragment. + */ +public class ModuleFragmentImpl extends CompositeImpl implements ModuleFragment { + + protected ModuleFragmentImpl() { + } + + protected void wire(AssemblyContext modelContext) { + // No wiring inside a module fragment + // Wires are handled at the module level + } + +} diff --git a/tags/java-M1-20060518/java/sca/model/src/main/java/org/apache/tuscany/model/assembly/impl/ModuleImpl.java b/tags/java-M1-20060518/java/sca/model/src/main/java/org/apache/tuscany/model/assembly/impl/ModuleImpl.java new file mode 100644 index 0000000000..f64317ac86 --- /dev/null +++ b/tags/java-M1-20060518/java/sca/model/src/main/java/org/apache/tuscany/model/assembly/impl/ModuleImpl.java @@ -0,0 +1,104 @@ +/** + * + * Copyright 2005 The Apache Software Foundation or its licensors, as applicable. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.tuscany.model.assembly.impl; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import org.apache.tuscany.model.assembly.AssemblyContext; +import org.apache.tuscany.model.assembly.AssemblyVisitor; +import org.apache.tuscany.model.assembly.Module; +import org.apache.tuscany.model.assembly.ModuleFragment; +import org.apache.tuscany.model.util.NotifyingList; + +/** + * An implementation of Module. + */ +public class ModuleImpl extends CompositeImpl implements Module { + + /** + * A list of module fragments synchronized with a map + */ + private class ModuleFragmentList<E extends ModuleFragment> extends NotifyingList<E> { + protected void added(E element) { + moduleFragmentsMap.put(element.getName(), element); + } + + protected void removed(E element) { + moduleFragmentsMap.remove(element.getName()); + } + } + + private List<ModuleFragment> moduleFragments = new ModuleFragmentList<ModuleFragment>(); + private Map<String, ModuleFragment> moduleFragmentsMap = new HashMap<String, ModuleFragment>(); + + /** + * Constructor + */ + protected ModuleImpl() { + } + + public List<ModuleFragment> getModuleFragments() { + return moduleFragments; + } + + public ModuleFragment getModuleFragment(String name) { + checkInitialized(); + return moduleFragmentsMap.get(name); + } + + public void initialize(AssemblyContext modelContext) { + if (isInitialized()) + return; + + // Initialize module fragments + for (ModuleFragment moduleFragment : moduleFragments) { + + // Add all WSDL imports, components, entry points and external services from the module fragments + getWSDLImports().addAll(moduleFragment.getWSDLImports()); + getComponents().addAll(moduleFragment.getComponents()); + getEntryPoints().addAll(moduleFragment.getEntryPoints()); + getExternalServices().addAll(moduleFragment.getExternalServices()); + + // Add all the wires from the module fragments + getWires().addAll(moduleFragment.getWires()); + + moduleFragment.initialize(modelContext); + } + + // Initialize the composite + super.initialize(modelContext); + } + + public void freeze() { + if (isFrozen()) + return; + super.freeze(); + + moduleFragments = freeze(moduleFragments); + } + + public boolean accept(AssemblyVisitor visitor) { + if (!super.accept(visitor)) + return false; + + return accept(moduleFragments, visitor); + + } + +} diff --git a/tags/java-M1-20060518/java/sca/model/src/main/java/org/apache/tuscany/model/assembly/impl/PartImpl.java b/tags/java-M1-20060518/java/sca/model/src/main/java/org/apache/tuscany/model/assembly/impl/PartImpl.java new file mode 100644 index 0000000000..3743c7505b --- /dev/null +++ b/tags/java-M1-20060518/java/sca/model/src/main/java/org/apache/tuscany/model/assembly/impl/PartImpl.java @@ -0,0 +1,61 @@ +/** + * + * Copyright 2005 The Apache Software Foundation or its licensors, as applicable. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.tuscany.model.assembly.impl; + +import org.apache.tuscany.model.assembly.Composite; +import org.apache.tuscany.model.assembly.Part; + +/** + * Implementation of Part. + */ +public abstract class PartImpl extends ExtensibleImpl implements Part { + private Composite composite; + private String name; + + private Object contextFactory; + + protected PartImpl() { + } + + public String getName() { + return name; + } + + public void setName(String value) { + checkNotFrozen(); + name=value; + } + + public Composite getComposite() { + return composite; + } + + public void setComposite(Composite composite) { + checkNotFrozen(); + this.composite=composite; + } + + public Object getContextFactory() { + return contextFactory; + } + + public void setContextFactory(Object contextFactory) { + checkNotFrozen(); + this.contextFactory=contextFactory; + } + +} diff --git a/tags/java-M1-20060518/java/sca/model/src/main/java/org/apache/tuscany/model/assembly/impl/PortImpl.java b/tags/java-M1-20060518/java/sca/model/src/main/java/org/apache/tuscany/model/assembly/impl/PortImpl.java new file mode 100644 index 0000000000..c11cee590a --- /dev/null +++ b/tags/java-M1-20060518/java/sca/model/src/main/java/org/apache/tuscany/model/assembly/impl/PortImpl.java @@ -0,0 +1,82 @@ +/** + * + * Copyright 2005 The Apache Software Foundation or its licensors, as applicable. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.tuscany.model.assembly.impl; + +import org.apache.tuscany.model.assembly.AssemblyContext; +import org.apache.tuscany.model.assembly.AssemblyVisitor; +import org.apache.tuscany.model.assembly.Port; +import org.apache.tuscany.model.assembly.ServiceContract; + +/** + * An implementation of Port. + */ +public abstract class PortImpl extends AssemblyObjectImpl implements Port { + + private ServiceContract serviceContract; + private String name; + + protected PortImpl() { + } + + public String getName() { + return name; + } + + public void setName(String value) { + checkNotFrozen(); + name=value; + } + + public ServiceContract getServiceContract() { + return serviceContract; + } + + public void setServiceContract(ServiceContract value) { + checkNotFrozen(); + serviceContract=value; + } + + public void initialize(AssemblyContext modelContext) { + if (isInitialized()) + return; + super.initialize(modelContext); + + if (serviceContract!=null) + serviceContract.initialize(modelContext); + } + + public void freeze() { + if (isFrozen()) + return; + super.freeze(); + + if (serviceContract!=null) + serviceContract.freeze(); + } + + public boolean accept(AssemblyVisitor visitor) { + if (!super.accept(visitor)) + return false; + + if (serviceContract!=null) { + if (!serviceContract.accept(visitor)) + return false; + } + + return true; + } +} diff --git a/tags/java-M1-20060518/java/sca/model/src/main/java/org/apache/tuscany/model/assembly/impl/PropertyImpl.java b/tags/java-M1-20060518/java/sca/model/src/main/java/org/apache/tuscany/model/assembly/impl/PropertyImpl.java new file mode 100644 index 0000000000..e91245504b --- /dev/null +++ b/tags/java-M1-20060518/java/sca/model/src/main/java/org/apache/tuscany/model/assembly/impl/PropertyImpl.java @@ -0,0 +1,80 @@ +/** + * + * Copyright 2005 The Apache Software Foundation or its licensors, as applicable. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.tuscany.model.assembly.impl; + +import org.apache.tuscany.model.assembly.Property; + +/** + * An implementation of Property. + */ +public class PropertyImpl extends ExtensibleImpl implements Property { + + private Object defaultValue; + private String name; + private boolean many; + private boolean required; + private Class<?> type; + + protected PropertyImpl() { + } + + public Object getDefaultValue() { + return defaultValue; + } + + public String getName() { + return name; + } + + public Class<?> getType() { + return type; + } + + public boolean isMany() { + return many; + } + + public boolean isRequired() { + return required; + } + + public void setDefaultValue(Object value) { + checkNotFrozen(); + defaultValue = value; + } + + public void setMany(boolean value) { + checkNotFrozen(); + many = value; + } + + public void setName(String value) { + checkNotFrozen(); + name = value; + } + + public void setRequired(boolean value) { + checkNotFrozen(); + required = value; + } + + public void setType(Class<?> value) { + checkNotFrozen(); + type = value; + } + +} diff --git a/tags/java-M1-20060518/java/sca/model/src/main/java/org/apache/tuscany/model/assembly/impl/ReferenceImpl.java b/tags/java-M1-20060518/java/sca/model/src/main/java/org/apache/tuscany/model/assembly/impl/ReferenceImpl.java new file mode 100644 index 0000000000..1a064e5092 --- /dev/null +++ b/tags/java-M1-20060518/java/sca/model/src/main/java/org/apache/tuscany/model/assembly/impl/ReferenceImpl.java @@ -0,0 +1,41 @@ +/** + * + * Copyright 2005 The Apache Software Foundation or its licensors, as applicable. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.tuscany.model.assembly.impl; + +import org.apache.tuscany.model.assembly.Multiplicity; +import org.apache.tuscany.model.assembly.Reference; + +/** + * An implementation of Reference. + */ +public class ReferenceImpl extends PortImpl implements Reference { + + private Multiplicity multiplicity; + + protected ReferenceImpl() { + } + + public Multiplicity getMultiplicity() { + return multiplicity; + } + + public void setMultiplicity(Multiplicity multiplicity) { + checkNotFrozen(); + this.multiplicity=multiplicity; + } + +} diff --git a/tags/java-M1-20060518/java/sca/model/src/main/java/org/apache/tuscany/model/assembly/impl/ServiceContractImpl.java b/tags/java-M1-20060518/java/sca/model/src/main/java/org/apache/tuscany/model/assembly/impl/ServiceContractImpl.java new file mode 100644 index 0000000000..f71702792b --- /dev/null +++ b/tags/java-M1-20060518/java/sca/model/src/main/java/org/apache/tuscany/model/assembly/impl/ServiceContractImpl.java @@ -0,0 +1,60 @@ +/** + * + * Copyright 2005 The Apache Software Foundation or its licensors, as applicable. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.tuscany.model.assembly.impl; + +import org.apache.tuscany.model.assembly.Scope; +import org.apache.tuscany.model.assembly.ServiceContract; + +/** + * An implementation of ServiceContract. + */ +public class ServiceContractImpl extends ExtensibleImpl implements ServiceContract { + + private Class interface_; + private Class callbackInterface; + private Scope scope; + + protected ServiceContractImpl() { + } + + public Class getCallbackInterface() { + return callbackInterface; + } + + public Class getInterface() { + return interface_; + } + + public Scope getScope() { + return scope; + } + + public void setCallbackInterface(Class value) { + checkNotFrozen(); + callbackInterface=value; + } + + public void setInterface(Class value) { + checkNotFrozen(); + interface_=value; + } + + public void setScope(Scope scope) { + checkNotFrozen(); + this.scope=scope; + } +} diff --git a/tags/java-M1-20060518/java/sca/model/src/main/java/org/apache/tuscany/model/assembly/impl/ServiceImpl.java b/tags/java-M1-20060518/java/sca/model/src/main/java/org/apache/tuscany/model/assembly/impl/ServiceImpl.java new file mode 100644 index 0000000000..d1432d0149 --- /dev/null +++ b/tags/java-M1-20060518/java/sca/model/src/main/java/org/apache/tuscany/model/assembly/impl/ServiceImpl.java @@ -0,0 +1,29 @@ +/** + * + * Copyright 2005 The Apache Software Foundation or its licensors, as applicable. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.tuscany.model.assembly.impl; + +import org.apache.tuscany.model.assembly.Service; + +/** + * An implementation of Service. + */ +public class ServiceImpl extends PortImpl implements Service { + + protected ServiceImpl() { + } + +} diff --git a/tags/java-M1-20060518/java/sca/model/src/main/java/org/apache/tuscany/model/assembly/impl/ServiceURIImpl.java b/tags/java-M1-20060518/java/sca/model/src/main/java/org/apache/tuscany/model/assembly/impl/ServiceURIImpl.java new file mode 100644 index 0000000000..ef180814ff --- /dev/null +++ b/tags/java-M1-20060518/java/sca/model/src/main/java/org/apache/tuscany/model/assembly/impl/ServiceURIImpl.java @@ -0,0 +1,210 @@ +/** + * + * Copyright 2005 The Apache Software Foundation or its licensors, as applicable. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.tuscany.model.assembly.impl; + +import org.apache.tuscany.model.assembly.ConfiguredPort; +import org.apache.tuscany.model.assembly.ConfiguredReference; +import org.apache.tuscany.model.assembly.ConfiguredService; +import org.apache.tuscany.model.assembly.ModuleComponent; +import org.apache.tuscany.model.assembly.Part; +import org.apache.tuscany.model.assembly.Service; +import org.apache.tuscany.model.assembly.ServiceURI; + +/** + * An implementation of ServiceURI. + */ +public class ServiceURIImpl implements ServiceURI { + + private String address; + private Boolean isSCAScheme; + private boolean isParsed; + private String moduleComponentName; + private String partName; + private String serviceName; + + /** + * Constructs a new ServiceURIImpl. + * @param address + */ + protected ServiceURIImpl(String address) { + this.address = address; + } + + /** + * Constructs a new ServiceURIImpl. + * @param moduleComponent + * @param partName + * @param portName + */ + protected ServiceURIImpl(ModuleComponent moduleComponent, String partName, String portName) { + if (moduleComponent != null) + moduleComponentName = moduleComponent.getName(); + else + moduleComponentName = ""; + this.partName = partName; + this.serviceName = portName; + } + + /** + * Constructs a new ServiceURIImpl. + * @param moduleComponent + * @param configuredPort + */ + protected ServiceURIImpl(ModuleComponent moduleComponent, Part part, ConfiguredPort configuredPort) { + if (moduleComponent != null) + moduleComponentName = moduleComponent.getName(); + else + moduleComponentName = ""; + if (configuredPort instanceof ConfiguredService) { + partName = part.getName(); + ConfiguredService configuredService = (ConfiguredService) configuredPort; + Service service = configuredService.getPort(); + if (service != null) { + serviceName = configuredService.getPort().getName(); + address = "sca:///" + moduleComponentName + '/' + partName + '/' + serviceName; + } else { + address = "sca:///" + moduleComponentName + '/' + partName; + } + + } else if (configuredPort instanceof ConfiguredReference) { + ConfiguredReference configuredReference = (ConfiguredReference) configuredPort; + partName = part.getName(); + serviceName = configuredReference.getPort().getName(); + if (serviceName!=null) + address = "sca:///" + moduleComponentName + '/' + partName + '/' + serviceName; + else + address = "sca:///" + moduleComponentName + '/' + partName; + } + + isSCAScheme = Boolean.TRUE; + isParsed = true; + } + + /** + * Constructor + * + * @param moduleComponent + * @param targetServiceName + */ + protected ServiceURIImpl(ModuleComponent moduleComponent, String targetServiceName) { + if (moduleComponent != null) + moduleComponentName = moduleComponent.getName(); + else + moduleComponentName = ""; + int s = targetServiceName.indexOf('/'); + if (s == -1) { + partName = targetServiceName; + address = "sca:///" + moduleComponentName + '/' + partName; + } else { + partName = targetServiceName.substring(0, s); + this.serviceName = targetServiceName.substring(s + 1); + address = "sca:///" + moduleComponentName + '/' + partName + '/' + this.serviceName; + } + isSCAScheme = Boolean.TRUE; + isParsed = true; + } + + public boolean isSCAScheme() { + if (isSCAScheme == null) { + if (address != null && address.startsWith("sca://")) { + isSCAScheme = Boolean.TRUE; + } else { + isSCAScheme = Boolean.FALSE; + } + } + return isSCAScheme.booleanValue(); + } + + public String getAddress() { + return address; + } + + public String getPath() { + StringBuffer path = new StringBuffer(); + String mc = getModuleComponentName(); + if (mc != null) { + path.append(mc); + } + String p = getPartName(); + if (p !=null) { + if (path.length()!=0) + path.append('/'); + path.append(p); + } + String s = getServiceName(); + if (s !=null) { + if (path.length()!=0) + path.append('/'); + path.append(s); + } + return path.toString(); + } + + /** + * Parse the address. + */ + private void parse() { + isParsed = true; + if (isSCAScheme()) { + int s1 = address.indexOf('/', 6); + if (s1 == -1) + return; + s1++; + int s2 = address.indexOf('/', s1); + if (s2 == -1) + return; + moduleComponentName = address.substring(s1, s2); + s2++; + int s3 = address.indexOf('/', s2); + if (s3 == -1) { + partName = address.substring(s2); + return; + } + partName = address.substring(s2, s3); + s3++; + serviceName = address.substring(s3); + } + } + + /** + * Returns the module component name + */ + public String getModuleComponentName() { + if (!isParsed) + parse(); + return moduleComponentName; + } + + /** + * Returns the part name + */ + public String getPartName() { + if (!isParsed) + parse(); + return partName; + } + + /** + * Returns the service name + */ + public String getServiceName() { + if (!isParsed) + parse(); + return serviceName; + } + +} diff --git a/tags/java-M1-20060518/java/sca/model/src/main/java/org/apache/tuscany/model/assembly/impl/SubsystemImpl.java b/tags/java-M1-20060518/java/sca/model/src/main/java/org/apache/tuscany/model/assembly/impl/SubsystemImpl.java new file mode 100644 index 0000000000..334e34ba5b --- /dev/null +++ b/tags/java-M1-20060518/java/sca/model/src/main/java/org/apache/tuscany/model/assembly/impl/SubsystemImpl.java @@ -0,0 +1,51 @@ +/** + * + * Copyright 2005 The Apache Software Foundation or its licensors, as applicable. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.tuscany.model.assembly.impl; + +import org.apache.tuscany.model.assembly.ComponentType; +import org.apache.tuscany.model.assembly.Subsystem; + +/** + * An implementation of Subsystem. + */ +public class SubsystemImpl extends CompositeImpl implements Subsystem { + + private String uri; + + protected SubsystemImpl() { + } + + public String getURI() { + return uri; + } + + public void setURI(String value) { + checkNotFrozen(); + uri=value; + } + + public ComponentType getComponentType() { + //TODO implement + return null; + } + + public void setComponentType(ComponentType componentType) { + } + + + +} diff --git a/tags/java-M1-20060518/java/sca/model/src/main/java/org/apache/tuscany/model/assembly/impl/WireImpl.java b/tags/java-M1-20060518/java/sca/model/src/main/java/org/apache/tuscany/model/assembly/impl/WireImpl.java new file mode 100644 index 0000000000..c7c4bda7a1 --- /dev/null +++ b/tags/java-M1-20060518/java/sca/model/src/main/java/org/apache/tuscany/model/assembly/impl/WireImpl.java @@ -0,0 +1,51 @@ +/** + * + * Copyright 2005 The Apache Software Foundation or its licensors, as applicable. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.tuscany.model.assembly.impl; + +import org.apache.tuscany.model.assembly.ServiceURI; +import org.apache.tuscany.model.assembly.Wire; + +/** + * An implementation of Wire. + */ +public class WireImpl extends ExtensibleImpl implements Wire { + + private ServiceURI source; + private ServiceURI target; + + protected WireImpl() { + } + + public ServiceURI getSource() { + return source; + } + + public void setSource(ServiceURI uri) { + checkNotFrozen(); + source=uri; + } + + public ServiceURI getTarget() { + return target; + } + + public void setTarget(ServiceURI uri) { + checkNotFrozen(); + target=uri; + } + +} diff --git a/tags/java-M1-20060518/java/sca/model/src/main/java/org/apache/tuscany/model/assembly/loader/AssemblyModelLoader.java b/tags/java-M1-20060518/java/sca/model/src/main/java/org/apache/tuscany/model/assembly/loader/AssemblyModelLoader.java new file mode 100644 index 0000000000..95793cc439 --- /dev/null +++ b/tags/java-M1-20060518/java/sca/model/src/main/java/org/apache/tuscany/model/assembly/loader/AssemblyModelLoader.java @@ -0,0 +1,38 @@ +/** + * + * Copyright 2005 The Apache Software Foundation or its licensors, as applicable. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.tuscany.model.assembly.loader; + +import java.util.List; + +import javax.wsdl.Definition; + +/** + * An assembly model loader. + */ +public interface AssemblyModelLoader { + + /** + * Load a WSDL definition + */ + Definition loadDefinition(String uri); + + /** + * Load definitions by namespace + */ + List<Definition> loadDefinitions(String namespace); + +} diff --git a/tags/java-M1-20060518/java/sca/model/src/main/java/org/apache/tuscany/model/scdl/loader/impl/AssemblyModelLoadException.java b/tags/java-M1-20060518/java/sca/model/src/main/java/org/apache/tuscany/model/scdl/loader/impl/AssemblyModelLoadException.java new file mode 100644 index 0000000000..6c5e0ef75d --- /dev/null +++ b/tags/java-M1-20060518/java/sca/model/src/main/java/org/apache/tuscany/model/scdl/loader/impl/AssemblyModelLoadException.java @@ -0,0 +1,42 @@ +/** + * + * Copyright 2005 The Apache Software Foundation or its licensors, as applicable. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package org.apache.tuscany.model.scdl.loader.impl; + +import org.apache.tuscany.common.TuscanyRuntimeException; + +/** + * The root runtime exception for the model loader. + * + * @version $Rev$ $Date$ + */ +public class AssemblyModelLoadException extends TuscanyRuntimeException { + private static final long serialVersionUID = -5891723952359470362L; + + public AssemblyModelLoadException() { + super(); + } + + public AssemblyModelLoadException(String message) { + super(message); + } + + public AssemblyModelLoadException(String message, Throwable cause) { + super(message, cause); + } + + public AssemblyModelLoadException(Throwable cause) { + super(cause); + } + +} diff --git a/tags/java-M1-20060518/java/sca/model/src/main/java/org/apache/tuscany/model/scdl/loader/impl/SCDLAssemblyModelLoaderImpl.java b/tags/java-M1-20060518/java/sca/model/src/main/java/org/apache/tuscany/model/scdl/loader/impl/SCDLAssemblyModelLoaderImpl.java new file mode 100644 index 0000000000..8413350e50 --- /dev/null +++ b/tags/java-M1-20060518/java/sca/model/src/main/java/org/apache/tuscany/model/scdl/loader/impl/SCDLAssemblyModelLoaderImpl.java @@ -0,0 +1,71 @@ +/** + * + * Copyright 2005 The Apache Software Foundation or its licensors, as applicable. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.tuscany.model.scdl.loader.impl; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import javax.wsdl.Definition; +import javax.wsdl.WSDLException; +import javax.wsdl.factory.WSDLFactory; +import javax.wsdl.xml.WSDLReader; + +import org.apache.tuscany.model.assembly.loader.AssemblyModelLoader; + +/** + */ +public class SCDLAssemblyModelLoaderImpl implements AssemblyModelLoader { + private WSDLReader wsdlReader; + private Map<String, Definition> definitions=new HashMap<String, Definition>(); + private Map<String, List<Definition>> definitionsByNamespace=new HashMap<String, List<Definition>>(); + + public Definition loadDefinition(String uri) { + Definition definition=definitions.get(uri); + if (definition!=null) + return definition; + + try { + if (wsdlReader==null) { + wsdlReader=WSDLFactory.newInstance().newWSDLReader(); + wsdlReader.setFeature("javax.wsdl.verbose", false); + } + definition = wsdlReader.readWSDL(uri); + } catch (WSDLException e) { + throw new IllegalArgumentException(e); + } + if (definition==null) + throw new IllegalArgumentException("Could not load WSDL definition at "+uri); + + definitions.put(uri, definition); + + String namespace=definition.getTargetNamespace(); + List<Definition> list=definitionsByNamespace.get(namespace); + if (list==null) { + list=new ArrayList<Definition>(); + definitionsByNamespace.put(namespace, list); + } + list.add(definition); + + return definition; + } + + public List<Definition> loadDefinitions(String namespace) { + return definitionsByNamespace.get(namespace); + } + +} diff --git a/tags/java-M1-20060518/java/sca/model/src/main/java/org/apache/tuscany/model/types/java/JavaServiceContract.java b/tags/java-M1-20060518/java/sca/model/src/main/java/org/apache/tuscany/model/types/java/JavaServiceContract.java new file mode 100644 index 0000000000..68f9dfa6f8 --- /dev/null +++ b/tags/java-M1-20060518/java/sca/model/src/main/java/org/apache/tuscany/model/types/java/JavaServiceContract.java @@ -0,0 +1,34 @@ +/** + * + * Copyright 2005 The Apache Software Foundation or its licensors, as applicable. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.tuscany.model.types.java; + +import org.apache.tuscany.model.assembly.ServiceContract; + + +/** + * Represents a Java service contract. + */ +public interface JavaServiceContract extends ServiceContract { + + String getInterfaceName(); + + void setInterfaceName(String interfaceName); + + String getCallbackInterfaceName(); + + void setCallbackInterfaceName(String callbackInterfaceName); +} diff --git a/tags/java-M1-20060518/java/sca/model/src/main/java/org/apache/tuscany/model/types/java/impl/JavaServiceContractImpl.java b/tags/java-M1-20060518/java/sca/model/src/main/java/org/apache/tuscany/model/types/java/impl/JavaServiceContractImpl.java new file mode 100644 index 0000000000..d384bcd670 --- /dev/null +++ b/tags/java-M1-20060518/java/sca/model/src/main/java/org/apache/tuscany/model/types/java/impl/JavaServiceContractImpl.java @@ -0,0 +1,89 @@ +/** + * + * Copyright 2005 The Apache Software Foundation or its licensors, as applicable. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.tuscany.model.types.java.impl; + +import org.apache.tuscany.model.assembly.AssemblyContext; +import org.apache.tuscany.model.assembly.impl.ServiceContractImpl; +import org.apache.tuscany.model.types.java.JavaServiceContract; + +/** + * An implementation of JavaServiceContract. + */ +public class JavaServiceContractImpl extends ServiceContractImpl implements JavaServiceContract { + + private String interfaceName; + private String callbackInterfaceName; + + /** + * Constructor + */ + public JavaServiceContractImpl() { + } + + /** + * @param interfaceName The interfaceName to set. + */ + public void setInterfaceName(String interfaceName) { + this.interfaceName = interfaceName; + } + + /** + * @param callbackInterfaceName The callbackInterfaceName to set. + */ + public void setCallbackInterfaceName(String callbackInterfaceName) { + this.callbackInterfaceName = callbackInterfaceName; + } + + public String getInterfaceName() { + return interfaceName; + } + + public String getCallbackInterfaceName() { + return callbackInterfaceName; + } + + /** + * @see org.apache.tuscany.model.assembly.impl.ExtensibleImpl#initialize(org.apache.tuscany.model.assembly.AssemblyContext) + */ + public void initialize(AssemblyContext modelContext) { + if (isInitialized()) + return; + + // Load the interface + if (getInterface()==null && interfaceName!=null) { + try { + Class<?> interfaceClass=modelContext.getApplicationResourceLoader().loadClass(interfaceName); + setInterface(interfaceClass); + } catch (ClassNotFoundException e) { + throw new IllegalArgumentException(e); + } + } + + // Load the callback interface + if (getCallbackInterface()==null && callbackInterfaceName!=null) { + try { + Class<?> callbackInterfaceClass=modelContext.getApplicationResourceLoader().loadClass(callbackInterfaceName); + setInterface(callbackInterfaceClass); + } catch (ClassNotFoundException e) { + throw new IllegalArgumentException(e); + } + } + + super.initialize(modelContext); + } + +} diff --git a/tags/java-M1-20060518/java/sca/model/src/main/java/org/apache/tuscany/model/types/wsdl/WSDLServiceContract.java b/tags/java-M1-20060518/java/sca/model/src/main/java/org/apache/tuscany/model/types/wsdl/WSDLServiceContract.java new file mode 100644 index 0000000000..999242a4c2 --- /dev/null +++ b/tags/java-M1-20060518/java/sca/model/src/main/java/org/apache/tuscany/model/types/wsdl/WSDLServiceContract.java @@ -0,0 +1,51 @@ +/** + * + * Copyright 2005 The Apache Software Foundation or its licensors, as applicable. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.tuscany.model.types.wsdl; + +import javax.wsdl.PortType; + +import org.apache.tuscany.model.assembly.ServiceContract; + +/** + * A WSDL service contract. + */ +public interface WSDLServiceContract extends ServiceContract { + + /** + * Returns the WSDL portType. + * @return the WSDL portType + */ + PortType getPortType(); + + /** + * Sets the WSDL portType. + * @param portType + */ + void setPortType(PortType portType); + + /** + * Returns the callback WSDL portType. + * @return the callback WSDL portType + */ + PortType getCallbackPortType(); + + /** + * Sets the callback WSDL portType. + * @param portType + */ + void setCallbackPortType(PortType portType); +} diff --git a/tags/java-M1-20060518/java/sca/model/src/main/java/org/apache/tuscany/model/types/wsdl/impl/WSDLServiceContractImpl.java b/tags/java-M1-20060518/java/sca/model/src/main/java/org/apache/tuscany/model/types/wsdl/impl/WSDLServiceContractImpl.java new file mode 100644 index 0000000000..a596eb539f --- /dev/null +++ b/tags/java-M1-20060518/java/sca/model/src/main/java/org/apache/tuscany/model/types/wsdl/impl/WSDLServiceContractImpl.java @@ -0,0 +1,234 @@ +/** + * + * Copyright 2005 The Apache Software Foundation or its licensors, as applicable. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.tuscany.model.types.wsdl.impl; + +import static org.objectweb.asm.Opcodes.ACC_ABSTRACT; +import static org.objectweb.asm.Opcodes.ACC_INTERFACE; +import static org.objectweb.asm.Opcodes.ACC_PUBLIC; +import static org.objectweb.asm.Opcodes.V1_5; + +import java.util.ArrayList; +import java.util.List; + +import javax.wsdl.Operation; +import javax.wsdl.Part; +import javax.wsdl.PortType; +import javax.xml.namespace.QName; + +import org.apache.tuscany.common.resource.ResourceLoader; +import org.apache.tuscany.model.assembly.AssemblyContext; +import org.apache.tuscany.model.assembly.impl.ServiceContractImpl; +import org.apache.tuscany.model.types.wsdl.WSDLServiceContract; +import org.apache.tuscany.model.util.XMLNameUtil; +import org.apache.tuscany.sdo.util.SDOUtil; +import org.objectweb.asm.ClassWriter; +import org.objectweb.asm.Type; + +import commonj.sdo.Property; +import commonj.sdo.helper.TypeHelper; +import commonj.sdo.helper.XSDHelper; + +/** + * An implementation of WSDLServiceContract. + */ +public class WSDLServiceContractImpl extends ServiceContractImpl implements WSDLServiceContract { + + private PortType portType; + + private PortType callbackPortType; + + private static final String[] EMPTY_STRINGS = new String[0]; + + /** + * Constructor + */ + public WSDLServiceContractImpl() { + } + + public PortType getPortType() { + return portType; + } + + public void setPortType(PortType portType) { + checkNotFrozen(); + this.portType = portType; + } + + public PortType getCallbackPortType() { + return callbackPortType; + } + + public void setCallbackPortType(PortType portType) { + checkNotFrozen(); + callbackPortType = portType; + } + + /** + * @see org.apache.tuscany.model.assembly.impl.ExtensibleImpl#initialize(org.apache.tuscany.model.assembly.AssemblyContext) + */ + public void initialize(AssemblyContext modelContext) { + if (isInitialized()) + return; + super.initialize(modelContext); + + // Load the Java interface for the portType + if (portType != null && getInterface() == null) { + QName qname = portType.getQName(); + String interfaceName = XMLNameUtil.getFullyQualifiedClassNameFromQName(qname.getNamespaceURI(), qname.getLocalPart()); + Class<?> interfaceClass; + try { + // Load the interface + interfaceClass = modelContext.getApplicationResourceLoader().loadClass(interfaceName); + } catch (ClassNotFoundException e) { + // Generate the interface on the fly + interfaceClass = generateJavaInterface(modelContext.getTypeHelper(), modelContext.getApplicationResourceLoader(), portType, interfaceName); + } + super.setInterface(interfaceClass); + } + + // Load the Java interface for the callback portType + if (callbackPortType != null && getCallbackInterface() == null) { + QName qname = callbackPortType.getQName(); + String interfaceName = XMLNameUtil.getFullyQualifiedClassNameFromQName(qname.getNamespaceURI(), qname.getLocalPart()); + Class<?> interfaceClass; + try { + // Load the interface + interfaceClass = modelContext.getApplicationResourceLoader().loadClass(interfaceName); + } catch (ClassNotFoundException e) { + // Generate the interface on the fly + interfaceClass = generateJavaInterface(modelContext.getTypeHelper(), modelContext.getApplicationResourceLoader(), portType, interfaceName); + } + super.setCallbackInterface(interfaceClass); + } + } + + /** + * Generate a Java interface from a WSDL portType. + * + * @param portType + * @param interfaceName + * @return a Java interface that provides the same service contract as the WSDL portType + */ + @SuppressWarnings("unchecked") + private static Class<?> generateJavaInterface(TypeHelper typeHelper, ResourceLoader resourceLoader, PortType portType, String interfaceName) { + + ClassLoader cl=Thread.currentThread().getContextClassLoader(); + try { + Thread.currentThread().setContextClassLoader(resourceLoader.getClassLoader()); + + // Create an XSD helper + XSDHelper xsdHelper = SDOUtil.createXSDHelper(typeHelper); + + ClassWriter cw = new ClassWriter(false); + + // Generate the interface + interfaceName = interfaceName.replace('.', '/'); + cw.visit(V1_5, ACC_PUBLIC + ACC_ABSTRACT + ACC_INTERFACE, interfaceName, null, "java/lang/Object", EMPTY_STRINGS); + + // Generate methods from the WSDL operations + for (Operation operation : (List<Operation>) portType.getOperations()) { + + //FIXME Workaround for TUSCANY-170, we will need to make this consistent with the algorithm used by Axis2 WSDL2Java + // to generate method names from operations names + //String methodName = XMLNameUtil.getJavaNameFromXMLName(operation.getName(), false); + String methodName = operation.getName(); + + // FIXME later we may want to wwitch to use the Axis2 WSDL2Java (not to generate the Java source, + // just to figure the WSDL to Java mapping) + + // Derive the method signature from the input message part (and check if it's a doc-wrapped or doc-bare operation) + List<Class> inputTypes=new ArrayList<Class>(); + boolean wrapped = false; + if (operation.getInput() != null && operation.getInput().getMessage()!=null && !operation.getInput().getMessage().getParts().isEmpty()) { + QName qname=((Part)operation.getInput().getMessage().getParts().values().iterator().next()).getElementName(); + if (qname!=null) { + Property property = xsdHelper.getGlobalProperty(qname.getNamespaceURI(), qname.getLocalPart(), true); + commonj.sdo.Type type = property.getType(); + if (property.getName().equals(operation.getName())) { + String localName = xsdHelper.getLocalName(type); + if (localName.indexOf("_._")!=-1) { + for (Property param : (List<Property>)type.getProperties()) { + Class inputType = param.getType().getInstanceClass(); + if (inputType == null) + inputType = Object.class; + inputTypes.add(inputType); + } + wrapped=true; + } + } + + // Bare doc style + if (!wrapped) { + Class inputType = type.getInstanceClass(); + if (inputType == null) + inputType = Object.class; + inputTypes.add(inputType); + } + + } else { + // FIXME only support elements for now + } + } + + // Derive the return type from the output message part (also support doc-wrapped and doc-bare here) + Class outputType=Void.class; + if (operation.getOutput() != null && operation.getOutput().getMessage()!=null && !operation.getOutput().getMessage().getParts().isEmpty()) { + QName qname=((Part)operation.getOutput().getMessage().getParts().values().iterator().next()).getElementName(); + if (qname!=null) { + Property property = xsdHelper.getGlobalProperty(qname.getNamespaceURI(), qname.getLocalPart(), true); + commonj.sdo.Type type = property.getType(); + if (wrapped) { + if (!type.getProperties().isEmpty()) { + outputType=((Property)type.getProperties().get(0)).getType().getInstanceClass(); + if (outputType==null) + outputType=Object.class; + } + } else { + outputType = type.getInstanceClass(); + if (outputType==null) + outputType=Object.class; + } + } else { + // FIXME only support elements for now + } + } + + // FIXME integrate XSD to Java type mapping here + StringBuffer inputSignature=new StringBuffer(); + for (Class inputType : inputTypes) { + inputSignature.append(Type.getDescriptor(inputType)); + } + String outputSignature = Type.getDescriptor(outputType); + + cw.visitMethod(ACC_PUBLIC + ACC_ABSTRACT, methodName, '(' + inputSignature.toString() + ')' + outputSignature, null, null).visitEnd(); + } + + // Generate the bytecodes + cw.visitEnd(); + byte[] bytes = cw.toByteArray(); + + // Add the class to the resource loader + + return resourceLoader.addClass(bytes); + + } finally { + Thread.currentThread().setContextClassLoader(cl); + } + + } + +} diff --git a/tags/java-M1-20060518/java/sca/model/src/main/java/org/apache/tuscany/model/util/NotifyingList.java b/tags/java-M1-20060518/java/sca/model/src/main/java/org/apache/tuscany/model/util/NotifyingList.java new file mode 100644 index 0000000000..1f064e0977 --- /dev/null +++ b/tags/java-M1-20060518/java/sca/model/src/main/java/org/apache/tuscany/model/util/NotifyingList.java @@ -0,0 +1,108 @@ +/** + * + * Copyright 2005 The Apache Software Foundation or its licensors, as applicable. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.tuscany.model.util; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.List; + +/** + * A list that invokes added or removed methods when elements are added or removed. + * + */ +public abstract class NotifyingList<E> extends ArrayList<E> { + + private boolean frozen; + + public NotifyingList() { + } + + public void freeze() { + frozen=true; + } + + protected void checkNotFrozen() { + if (frozen) + throw new IllegalStateException("Attempt to modify a frozen list"); + } + + public boolean add(E element) { + checkNotFrozen(); + boolean result=super.add(element); + added(element); + return result; + } + + public void add(int index, E element) { + checkNotFrozen(); + super.add(index, element); + added(element); + } + + public boolean addAll(Collection<? extends E> c) { + checkNotFrozen(); + boolean result=super.addAll(c); + for (E element : c) + added(element); + return result; + } + + public boolean addAll(int index, Collection<? extends E> c) { + checkNotFrozen(); + boolean result=super.addAll(index, c); + for (E element : c) + added(element); + return result; + } + + public void clear() { + checkNotFrozen(); + List<E> l=new ArrayList<E>(this); + super.clear(); + for (E element : l) + removed(element); + } + + public E remove(int index) { + checkNotFrozen(); + E element=super.remove(index); + removed(element); + return element; + } + + @SuppressWarnings("unchecked") + public boolean remove(Object element) { + checkNotFrozen(); + boolean result=super.remove(element); + removed((E)element); + return result; + } + + @SuppressWarnings("unchecked") + public boolean removeAll(Collection<?> c) { + checkNotFrozen(); + boolean result=super.removeAll(c); + for (E element : (Collection<? extends E>)c) + removed(element); + return result; + } + + protected abstract void added(E element); + + protected abstract void removed(E element); + +} diff --git a/tags/java-M1-20060518/java/sca/model/src/main/java/org/apache/tuscany/model/util/XMLNameUtil.java b/tags/java-M1-20060518/java/sca/model/src/main/java/org/apache/tuscany/model/util/XMLNameUtil.java new file mode 100644 index 0000000000..f493356594 --- /dev/null +++ b/tags/java-M1-20060518/java/sca/model/src/main/java/org/apache/tuscany/model/util/XMLNameUtil.java @@ -0,0 +1,212 @@ +/** + * + * Copyright 2005 The Apache Software Foundation or its licensors, as applicable. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.tuscany.model.util; + +import java.net.URI; +import java.net.URISyntaxException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collections; +import java.util.List; +import org.apache.tuscany.sdo.helper.SDOXSDEcoreBuilder; + + + +/** + * A utility class that converts between XML names and Java names. + */ +public final class XMLNameUtil { + + private static final List<String> DOMAINS = Arrays.asList(new String[]{"COM", "com", "ORG", "org"}); + + /** + * Constructor + */ + private XMLNameUtil() { + super(); + } + + /** + * Return an EPackage name for the given namespace. + * + * @param namespace + * @return an EPackage name for the given namespace + */ + public static String getPackageNameFromNamespace(String namespace) { + return org.apache.tuscany.sdo.helper.SDOXSDEcoreBuilder.getDefaultPackageName(namespace); + } + + /** + * Trim the file extension from a path. + * @param path + * @return + */ + private static String trimFileExtension(String path) { + int s=path.lastIndexOf('/'); + int d=path.lastIndexOf('.'); + if (d>s) { + return path.substring(0,d); + } else { + return path; + } + } + + /** + * Returns a namespace prefix for the given package Name. + * + * @param packageName + * @return a namespace prefix for the given package Name + */ + public static String getNSPrefixFromPackageName(String packageName) { + int index = packageName.lastIndexOf('.'); + return index == -1 ? packageName : packageName.substring(index + 1); + } + + /** + * Parse the given name. + * + * @param sourceName + * @param separator + * @return some stuff parsed from the name + */ + private static List<String> parseName(String sourceName, char separator) { + List<String> result = new ArrayList<String>(); + if (sourceName != null) { + StringBuilder currentWord = new StringBuilder(64); + boolean lastIsLower = false; + int index; + int length; + for (index = 0, length = sourceName.length(); index < length; ++index) { + char curChar = sourceName.charAt(index); + if (!Character.isJavaIdentifierPart(curChar)) { + curChar = separator; + } + if (Character.isUpperCase(curChar) + || (!lastIsLower && Character.isDigit(curChar)) + || curChar == separator) { + + if (lastIsLower && currentWord.length() > 1 + || curChar == separator && currentWord.length() > 0) { + result.add(currentWord.toString()); + currentWord = new StringBuilder(64); + } + lastIsLower = false; + } else { + if (!lastIsLower) { + int currentWordLength = currentWord.length(); + if (currentWordLength > 1) { + char lastChar = currentWord.charAt(--currentWordLength); + currentWord.setLength(currentWordLength); + result.add(currentWord.toString()); + currentWord = new StringBuilder(64); + currentWord.append(lastChar); + } + } + lastIsLower = true; + } + + if (curChar != separator) { + currentWord.append(curChar); + } + } + + result.add(currentWord.toString()); + } + return result; + } + + /** + * Returns a valid Java name from an XML Name. + * + * @param name + * @param isUpperCase + * @return a valid Java name from an XML Name + */ + public static String getJavaNameFromXMLName(String name, boolean isUpperCase) { + List<String> parsedName = parseName(name, '_'); + StringBuilder result = new StringBuilder(64 * parsedName.size()); + for (String nameComponent: parsedName) { + if (nameComponent.length() > 0) { + if (result.length() > 0 || isUpperCase) { + result.append(Character.toUpperCase(nameComponent.charAt(0))); + result.append(nameComponent.substring(1)); + } else { + result.append(nameComponent); + } + } + } + + if (result.length() == 0) { + return "_"; + } + if (Character.isJavaIdentifierStart(result.charAt(0))) { + return isUpperCase ? result.toString() : decapitalizeName(result.toString()); + } + return "_" + result; + } + + /** + * Returns a valid fully qualified class name from a QName. + * @param namespace + * @param name + * @return a valid fully qualified class name from a QName + */ + public static String getFullyQualifiedClassNameFromQName(String namespace, String name) { + return XMLNameUtil.getPackageNameFromNamespace(namespace) + '.' + + XMLNameUtil.getJavaNameFromXMLName(name, true); + } + + /** + * Decapitalize a name. + * @param name + * @return a decapitalized name + */ + public static String decapitalizeName(String name) { + if (name.length() == 0) { + return name; + } else { + String lowerName = name.toLowerCase(); + int i; + for (i = 0; i < name.length(); i++) { + if (name.charAt(i) == lowerName.charAt(i)) { + break; + } + } + if (i > 1 && i < name.length()) { + --i; + } + return name.substring(0, i).toLowerCase() + name.substring(i); + } + } + + /** + * Capitalize a name. + * @param name + * @return a capitalized name + */ + public static String capitalizeName(String name) { + int l = name.length(); + if (l == 0) { + return name; + } else if (l == 1) { + return name.toUpperCase(); + } else { + return name.substring(0, 1).toUpperCase() + name.substring(1); + } + } + +} diff --git a/tags/java-M1-20060518/java/sca/model/src/main/resources/model/sca-binding-sca.xsd b/tags/java-M1-20060518/java/sca/model/src/main/resources/model/sca-binding-sca.xsd new file mode 100644 index 0000000000..3b003ce77a --- /dev/null +++ b/tags/java-M1-20060518/java/sca/model/src/main/resources/model/sca-binding-sca.xsd @@ -0,0 +1,36 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + Copyright (c) 2005 The Apache Software Foundation or its licensors, as applicable. + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + --> +<schema xmlns="http://www.w3.org/2001/XMLSchema" + targetNamespace="http://www.osoa.org/xmlns/sca/0.9" + xmlns:sca="http://www.osoa.org/xmlns/sca/0.9" + xmlns:sdo="commonj.sdo/xml" + elementFormDefault="qualified"> + + <include schemaLocation="sca-core.xsd"/> + + <element name="binding.sca" type="sca:SCABinding" substitutionGroup="sca:binding" sdo:name="bindingSca"/> + <complexType name="SCABinding"> + <complexContent> + <extension base="sca:Binding"> + <sequence> + <any namespace="##other" processContents="lax" minOccurs="0" maxOccurs="unbounded"/> + </sequence> + <anyAttribute namespace="##any" processContents="lax"/> + </extension> + </complexContent> + </complexType> +</schema> diff --git a/tags/java-M1-20060518/java/sca/model/src/main/resources/model/sca-binding-webservice.xsd b/tags/java-M1-20060518/java/sca/model/src/main/resources/model/sca-binding-webservice.xsd new file mode 100644 index 0000000000..79131506c4 --- /dev/null +++ b/tags/java-M1-20060518/java/sca/model/src/main/resources/model/sca-binding-webservice.xsd @@ -0,0 +1,37 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + Copyright (c) 2005 The Apache Software Foundation or its licensors, as applicable. + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + --> +<schema xmlns="http://www.w3.org/2001/XMLSchema" + targetNamespace="http://www.osoa.org/xmlns/sca/0.9" + xmlns:sca="http://www.osoa.org/xmlns/sca/0.9" + xmlns:sdo="commonj.sdo/xml" + elementFormDefault="qualified"> + + <include schemaLocation="sca-core.xsd"/> + + <element name="binding.ws" type="sca:WebServiceBinding" substitutionGroup="sca:binding" sdo:name="bindingWs"/> + <complexType name="WebServiceBinding"> + <complexContent> + <extension base="sca:Binding"> + <sequence> + <any namespace="##other" processContents="lax" minOccurs="0" maxOccurs="unbounded"/> + </sequence> + <attribute name="port" type="anyURI" use="required"/> + <anyAttribute namespace="##any" processContents="lax"/> + </extension> + </complexContent> + </complexType> +</schema> diff --git a/tags/java-M1-20060518/java/sca/model/src/main/resources/model/sca-core.xsd b/tags/java-M1-20060518/java/sca/model/src/main/resources/model/sca-core.xsd new file mode 100644 index 0000000000..7d3ca73676 --- /dev/null +++ b/tags/java-M1-20060518/java/sca/model/src/main/resources/model/sca-core.xsd @@ -0,0 +1,239 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + Copyright (c) 2005 The Apache Software Foundation or its licensors, as applicable. + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + --> +<schema xmlns="http://www.w3.org/2001/XMLSchema" + targetNamespace="http://www.osoa.org/xmlns/sca/0.9" + xmlns:sca="http://www.osoa.org/xmlns/sca/0.9" + xmlns:sdo="commonj.sdo/xml" + xmlns:sdojava="commonj.sdo/java" + sdojava:package="org.apache.tuscany.model.scdl" + elementFormDefault="qualified"> + + <element name="componentType" type="sca:ComponentType"/> + <complexType name="ComponentType"> + <sequence> + <element minOccurs="0" maxOccurs="unbounded" name="service" type="sca:Service"/> + <element minOccurs="0" maxOccurs="unbounded" name="reference" type="sca:Reference"/> + <element minOccurs="0" maxOccurs="unbounded" name="property" type="sca:Property"/> + <any namespace="##other" processContents="lax" minOccurs="0" maxOccurs="unbounded"/> + </sequence> + <anyAttribute namespace="##any" processContents="lax"/> + </complexType> + + <complexType name="Service"> + <sequence> + <element minOccurs="1" maxOccurs="1" ref="sca:interface"/> + <any namespace="##other" processContents="lax" minOccurs="0" maxOccurs="unbounded"/> + </sequence> + <attribute name="name" type="NCName" use="required"/> + <anyAttribute namespace="##any" processContents="lax"/> + </complexType> + + <element name="interface" type="sca:Interface"/> + <complexType name="Interface"/> + + <complexType name="Reference"> + <sequence> + <element minOccurs="1" maxOccurs="1" ref="sca:interface"/> + <any namespace="##other" processContents="lax" minOccurs="0" maxOccurs="unbounded"/> + </sequence> + <attribute name="name" type="NCName" use="required"/> + <attribute name="multiplicity" type="sca:Multiplicity" use="optional" default="1..1"/> + <anyAttribute namespace="##any" processContents="lax"/> + </complexType> + + <complexType name="Property"> + <sequence> + <any namespace="##other" processContents="lax" minOccurs="0" maxOccurs="unbounded"/> + </sequence> + <attribute name="name" type="NCName" use="required"/> + <attribute name="type" type="QName" use="required" sdo:name="dataType"/> + <attribute name="many" type="boolean" default="false" use="optional"/> + <attribute name="required" type="boolean" default="false" use="optional"/> + <attribute name="default" type="string" use="optional"/> + <anyAttribute namespace="##any" processContents="lax"/> + </complexType> + + + <element name="moduleFragment" type="sca:ModuleFragment"/> + <complexType name="ModuleFragment"> + <sequence> + <!-- This is a Tuscany extension --> + <element minOccurs="0" maxOccurs="unbounded" name="import" type="sca:Import"/> + <element minOccurs="0" maxOccurs="unbounded" name="entryPoint" type="sca:EntryPoint"/> + <element minOccurs="0" maxOccurs="unbounded" name="component" type="sca:Component"/> + <element minOccurs="0" maxOccurs="unbounded" name="externalService" type="sca:ExternalService"/> + <element minOccurs="0" maxOccurs="unbounded" name="wire" type="sca:ModuleWire"/> + <any namespace="##other" processContents="lax" minOccurs="0" maxOccurs="unbounded"/> + </sequence> + <attribute name="name" type="NCName" use="required"/> + <anyAttribute namespace="##any" processContents="lax"/> + </complexType> + + <element name="module" type="sca:Module"/> + <complexType name="Module"> + <complexContent> + <extension base="sca:ModuleFragment"/> + </complexContent> + </complexType> + + <complexType name="EntryPoint"> + <sequence> + <element minOccurs="0" maxOccurs="1" ref="sca:interface"/> + <element minOccurs="1" maxOccurs="unbounded" ref="sca:binding"/> + <element minOccurs="1" maxOccurs="unbounded" name="reference" type="anyURI"/> + <any namespace="##other" processContents="lax" minOccurs="0" maxOccurs="unbounded"/> + </sequence> + <attribute name="name" type="NCName" use="required"/> + <attribute name="multiplicity" type="sca:Multiplicity" use="optional" default="1..1"/> + <anyAttribute namespace="##any" processContents="lax"/> + </complexType> + <!-- a multiplicity 1..1 or 0..n sample + <reference>StockQuoteComponent</reference> - type must be URI + a multiplicity 1..n or 0..n sample + <reference>StockQuoteComponent1</reference> - type must be URI + <reference>StockQuoteComponent2</reference> + --> + + <element name="binding" type="sca:Binding"/> + <complexType name="Binding"> + <attribute name="uri" type="anyURI" use="optional"/> + </complexType> + + <complexType name="Component"> + <sequence> + <element minOccurs="1" maxOccurs="1" ref="sca:implementation"/> + <element minOccurs="0" maxOccurs="1" name="properties" type="sca:PropertyValues"/> + <element minOccurs="0" maxOccurs="1" name="references" type="sca:ReferenceValues"/> + <any namespace="##other" processContents="lax" minOccurs="0" maxOccurs="unbounded"/> + </sequence> + <attribute name="name" type="NCName" use="required"/> + <anyAttribute namespace="##any" processContents="lax"/> + </complexType> + <!-- a multiplicity 1..1 or 0..1 sample + <references> + <v:stockQuote>StockQuoteComponent</v:stockquote> - type must be URI + </references> + a multiplicity 1..n or 0..n sample + <references> + <v:stockQuote>StockQuoteComponent1</v:stockQuote> - type must be URI + <v:stockQuote>StockQuoteComponent2</v:stockQuote> + </references> + --> + + <element name="implementation" type="sca:Implementation"/> + <complexType name="Implementation"/> + + <complexType name="PropertyValues"> + <sequence> + <any namespace="##other" processContents="lax" minOccurs="0" maxOccurs="unbounded"/> + </sequence> + <anyAttribute namespace="##any" processContents="lax"/> + </complexType> + + <complexType name="ReferenceValues"> + <sequence> + <any namespace="##other" processContents="lax" minOccurs="0" maxOccurs="unbounded"/> + </sequence> + <anyAttribute namespace="##any" processContents="lax"/> + </complexType> + + + <complexType name="ExternalService"> + <sequence> + <element minOccurs="1" maxOccurs="1" ref="sca:interface"/> + <element minOccurs="0" maxOccurs="unbounded" ref="sca:binding"/> + </sequence> + <attribute name="name" type="NCName" use="required"/> + <attribute name="overridable" type="sca:OverrideOptions" default="may" use="optional"/> + <anyAttribute namespace="##any" processContents="lax"/> + </complexType> + + + <complexType name="ModuleWire"> + <sequence> + <element minOccurs="1" maxOccurs="1" ref="sca:source.uri"/> + <element minOccurs="1" maxOccurs="1" ref="sca:target.uri"/> + <any namespace="##other" processContents="lax" minOccurs="0" maxOccurs="unbounded"/> + </sequence> + <anyAttribute namespace="##any" processContents="lax"/> + </complexType> + + <element name="source" type="anyType"/> + <element name="target" type="anyType"/> + + <element name="source.uri" type="anyURI" substitutionGroup="sca:source" sdo:name="sourceUri"/> + <element name="target.uri" type="anyURI" substitutionGroup="sca:target" sdo:name="targetUri"/> + + <element name="subsystem" type="sca:Subsystem"/> + <complexType name="Subsystem"> + <sequence> + <element minOccurs="0" maxOccurs="unbounded" name="entryPoint" type="sca:EntryPoint"/> + <element minOccurs="0" maxOccurs="unbounded" name="moduleComponent" type="sca:ModuleComponent"/> + <element minOccurs="0" maxOccurs="unbounded" name="externalService" type="sca:ExternalService"/> + <element minOccurs="0" maxOccurs="unbounded" name="wire" type="sca:SystemWire"/> + <any namespace="##other" processContents="lax" minOccurs="0" maxOccurs="unbounded"/> + </sequence> + <attribute name="name" type="NCName" use="required"/> + <attribute name="uri" type="anyURI" use="optional"/> + <anyAttribute namespace="##any" processContents="lax"/> + </complexType> + + <complexType name="ModuleComponent"> + <sequence> + <element minOccurs="0" maxOccurs="1" name="properties" type="sca:PropertyValues"/> + <element minOccurs="0" maxOccurs="1" name="references" type="sca:ReferenceValues"/> + <any namespace="##other" processContents="lax" minOccurs="0" maxOccurs="unbounded"/> + </sequence> + <attribute name="name" type="NCName" use="required"/> + <attribute name="module" type="NCName" use="required"/> + <attribute name="uri" type="anyURI" use="optional"/> + <anyAttribute namespace="##any" processContents="lax"/> + </complexType> + + <complexType name="SystemWire"> + <sequence> + <element minOccurs="1" maxOccurs="1" ref="sca:source"/> + <element minOccurs="1" maxOccurs="1" ref="sca:target"/> + <any namespace="##other" processContents="lax" minOccurs="0" maxOccurs="unbounded"/> + </sequence> + </complexType> + + <element name="source.epr" type="anyType" substitutionGroup="sca:source" sdo:name="sourceEpr"/> + <element name="target.epr" type="anyType" substitutionGroup="sca:target" sdo:name="targetEpr"/> + + <simpleType name="Multiplicity"> + <restriction base="string"> + <enumeration value="0..1" sdo:name="_01"/> + <enumeration value="1..1" sdo:name="_11"/> + <enumeration value="0..n" sdo:name="_0n"/> + <enumeration value="1..n" sdo:name="_1n"/> + </restriction> + </simpleType> + + <simpleType name="OverrideOptions"> + <restriction base="string"> + <enumeration value="no"/> + <enumeration value="may"/> + <enumeration value="must"/> + </restriction> + </simpleType> + + <!-- This is a Tuscany extension --> + <element name="import" type="sca:Import"/> + <complexType name="Import"/> + +</schema> diff --git a/tags/java-M1-20060518/java/sca/model/src/main/resources/model/sca-implementation-java.xsd b/tags/java-M1-20060518/java/sca/model/src/main/resources/model/sca-implementation-java.xsd new file mode 100644 index 0000000000..d7998a355c --- /dev/null +++ b/tags/java-M1-20060518/java/sca/model/src/main/resources/model/sca-implementation-java.xsd @@ -0,0 +1,37 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + Copyright (c) 2005 The Apache Software Foundation or its licensors, as applicable. + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + --> +<schema xmlns="http://www.w3.org/2001/XMLSchema" + targetNamespace="http://www.osoa.org/xmlns/sca/0.9" + xmlns:sca="http://www.osoa.org/xmlns/sca/0.9" + xmlns:sdo="commonj.sdo/xml" + elementFormDefault="qualified"> + + <include schemaLocation="sca-core.xsd"/> + + <element name="implementation.java" type="sca:JavaImplementation" substitutionGroup="sca:implementation" sdo:name="implementationJava"/> + <complexType name="JavaImplementation"> + <complexContent> + <extension base="sca:Implementation"> + <sequence> + <any namespace="##other" processContents="lax" minOccurs="0" maxOccurs="unbounded"/> + </sequence> + <attribute name="class" type="NCName" use="required"/> + <anyAttribute namespace="##any" processContents="lax"/> + </extension> + </complexContent> + </complexType> +</schema> diff --git a/tags/java-M1-20060518/java/sca/model/src/main/resources/model/sca-interface-java.xsd b/tags/java-M1-20060518/java/sca/model/src/main/resources/model/sca-interface-java.xsd new file mode 100644 index 0000000000..2b3f263b52 --- /dev/null +++ b/tags/java-M1-20060518/java/sca/model/src/main/resources/model/sca-interface-java.xsd @@ -0,0 +1,38 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + Copyright (c) 2005 The Apache Software Foundation or its licensors, as applicable. + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + --> +<schema xmlns="http://www.w3.org/2001/XMLSchema" + targetNamespace="http://www.osoa.org/xmlns/sca/0.9" + xmlns:sca="http://www.osoa.org/xmlns/sca/0.9" + xmlns:sdo="commonj.sdo/xml" + elementFormDefault="qualified"> + + <include schemaLocation="sca-core.xsd"/> + + <element name="interface.java" type="sca:JavaInterface" substitutionGroup="sca:interface" sdo:name="interfaceJava"/> + <complexType name="JavaInterface"> + <complexContent> + <extension base="sca:Interface"> + <sequence> + <any namespace="##other" processContents="lax" minOccurs="0" maxOccurs="unbounded"/> + </sequence> + <attribute name="interface" type="NCName" use="required"/> + <attribute name="callbackInterface" type="NCName" use="optional"/> + <anyAttribute namespace="##any" processContents="lax"/> + </extension> + </complexContent> + </complexType> +</schema> diff --git a/tags/java-M1-20060518/java/sca/model/src/main/resources/model/sca-interface-wsdl.xsd b/tags/java-M1-20060518/java/sca/model/src/main/resources/model/sca-interface-wsdl.xsd new file mode 100644 index 0000000000..3649f4d898 --- /dev/null +++ b/tags/java-M1-20060518/java/sca/model/src/main/resources/model/sca-interface-wsdl.xsd @@ -0,0 +1,69 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + Copyright (c) 2005 The Apache Software Foundation or its licensors, as applicable. + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + --> +<schema xmlns="http://www.w3.org/2001/XMLSchema" + targetNamespace="http://www.osoa.org/xmlns/sca/0.9" + xmlns:sca="http://www.osoa.org/xmlns/sca/0.9" + xmlns:sdo="commonj.sdo/xml" + elementFormDefault="qualified"> + + <include schemaLocation="sca-core.xsd"/> + + <element name="interface.wsdl" type="sca:WSDLPortType" substitutionGroup="sca:interface" sdo:name="interfaceWsdl"/> + <complexType name="WSDLPortType"> + <complexContent> + <extension base="sca:Interface"> + <sequence> + <any namespace="##other" processContents="lax" minOccurs="0" maxOccurs="unbounded"/> + </sequence> + <attribute name="interface" type="anyURI" use="required"/> + <attribute name="callbackInterface" type="anyURI" use="optional"/> + <anyAttribute namespace="##any" processContents="lax"/> + </extension> + </complexContent> + </complexType> + + <!-- This is a Tuscany extension --> + <element name="import.wsdl" type="sca:WSDLImport" substitutionGroup="sca:import" sdo:name="importWsdl"/> + <complexType name="WSDLImport"> + <complexContent> + <extension base="sca:Import"> + <sequence> + <any namespace="##other" processContents="lax" minOccurs="0" maxOccurs="unbounded"/> + </sequence> + <attribute name="namespace" type="anyURI" use="optional"/> + <attribute name="location" type="anyURI" use="required"/> + <anyAttribute namespace="##any" processContents="lax"/> + </extension> + </complexContent> + </complexType> + + <!-- This is a Tuscany extension --> + <element name="import.sdo" type="sca:SDOImport" substitutionGroup="sca:import" sdo:name="importSdo"/> + <complexType name="SDOImport"> + <complexContent> + <extension base="sca:Import"> + <sequence> + <any namespace="##other" processContents="lax" minOccurs="0" maxOccurs="unbounded"/> + </sequence> + <attribute name="location" type="anyURI" use="optional"/> + <attribute name="factory" type="NCName" use="optional"/> + <anyAttribute namespace="##any" processContents="lax"/> + </extension> + </complexContent> + </complexType> + +</schema> diff --git a/tags/java-M1-20060518/java/sca/model/src/main/resources/model/sca.xsd b/tags/java-M1-20060518/java/sca/model/src/main/resources/model/sca.xsd new file mode 100644 index 0000000000..d49dfeff79 --- /dev/null +++ b/tags/java-M1-20060518/java/sca/model/src/main/resources/model/sca.xsd @@ -0,0 +1,33 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + Copyright (c) 2005 The Apache Software Foundation or its licensors, as applicable. + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + --> +<schema xmlns="http://www.w3.org/2001/XMLSchema" + targetNamespace="http://www.osoa.org/xmlns/sca/0.9" + xmlns:sdojava="commonj.sdo/java" + xmlns:sca="http://www.osoa.org/xmlns/sca/0.9" + sdojava:package="org.apache.tuscany.model.scdl"> + + <include schemaLocation="sca-core.xsd"/> + + <include schemaLocation="sca-interface-java.xsd"/> + <include schemaLocation="sca-interface-wsdl.xsd"/> + + <include schemaLocation="sca-implementation-java.xsd"/> + + <include schemaLocation="sca-binding-webservice.xsd"/> + <include schemaLocation="sca-binding-sca.xsd"/> + +</schema> diff --git a/tags/java-M1-20060518/java/sca/model/src/main/resources/org/apache/tuscany/model/Messages.properties b/tags/java-M1-20060518/java/sca/model/src/main/resources/org/apache/tuscany/model/Messages.properties new file mode 100644 index 0000000000..4581e44bff --- /dev/null +++ b/tags/java-M1-20060518/java/sca/model/src/main/resources/org/apache/tuscany/model/Messages.properties @@ -0,0 +1,25 @@ +# Copyright (c) 2005 The Apache Software Foundation or its licensors, as applicable. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# ==================================================================== +# To code developer: +# Do NOT change the properties between this line and the +# "%%% END OF TRANSLATED PROPERTIES %%%" line. +# Make a new property name, append to the end of the file and change +# the code to use the new property. +# ==================================================================== + +# ===================================================================== +# %%% END OF TRANSLATED PROPERTIES %%% +# ===================================================================== +# NLS_MESSAGEFORMAT_ALL diff --git a/tags/java-M1-20060518/java/sca/model/src/test/java/org/apache/tuscany/model/assembly/tests/bigbank/account/services/account/AccountReport.java b/tags/java-M1-20060518/java/sca/model/src/test/java/org/apache/tuscany/model/assembly/tests/bigbank/account/services/account/AccountReport.java new file mode 100644 index 0000000000..b1b5913adc --- /dev/null +++ b/tags/java-M1-20060518/java/sca/model/src/test/java/org/apache/tuscany/model/assembly/tests/bigbank/account/services/account/AccountReport.java @@ -0,0 +1,32 @@ +/** + * + * Copyright 2005 The Apache Software Foundation or its licensors, as applicable. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.tuscany.model.assembly.tests.bigbank.account.services.account; + +import java.util.List; + +/** + * @model + */ + +public interface AccountReport { + + /** + * @model type="services.account.AccountSummary" + */ + + List getAccountSummaries(); +} diff --git a/tags/java-M1-20060518/java/sca/model/src/test/java/org/apache/tuscany/model/assembly/tests/bigbank/account/services/account/AccountService.java b/tags/java-M1-20060518/java/sca/model/src/test/java/org/apache/tuscany/model/assembly/tests/bigbank/account/services/account/AccountService.java new file mode 100644 index 0000000000..83df13439a --- /dev/null +++ b/tags/java-M1-20060518/java/sca/model/src/test/java/org/apache/tuscany/model/assembly/tests/bigbank/account/services/account/AccountService.java @@ -0,0 +1,25 @@ +/** + * + * Copyright 2005 The Apache Software Foundation or its licensors, as applicable. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.tuscany.model.assembly.tests.bigbank.account.services.account; + +import org.osoa.sca.annotations.Remotable; + +@Remotable +public interface AccountService { + + public AccountReport getAccountReport(String customerID); +} diff --git a/tags/java-M1-20060518/java/sca/model/src/test/java/org/apache/tuscany/model/assembly/tests/bigbank/account/services/account/AccountService.wsdl b/tags/java-M1-20060518/java/sca/model/src/test/java/org/apache/tuscany/model/assembly/tests/bigbank/account/services/account/AccountService.wsdl new file mode 100644 index 0000000000..baf9ecd81d --- /dev/null +++ b/tags/java-M1-20060518/java/sca/model/src/test/java/org/apache/tuscany/model/assembly/tests/bigbank/account/services/account/AccountService.wsdl @@ -0,0 +1,78 @@ +<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Copyright (c) 2005 The Apache Software Foundation or its licensors, as applicable.
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+ -->
+<wsdl:definitions xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
+ xmlns:tns="http://www.bigbank.com/AccountService/"
+ xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
+ xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+ targetNamespace="http://www.bigbank.com/AccountService/"
+
+ name="AccountService">
+
+ <wsdl:types>
+ <xsd:schema targetNamespace="http://www.bigbank.com/AccountService/" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
+
+ <xsd:element name="customerID" type="xsd:string"/>
+ <xsd:element name="getAccountReportResponse" type="tns:AccountReport"/>
+
+ <xsd:complexType name="AccountReport">
+ <xsd:sequence>
+ <xsd:element name="accountSummary" type="tns:AccountSummary" maxOccurs="unbounded"/>
+ </xsd:sequence>
+ </xsd:complexType>
+ <xsd:complexType name="AccountSummary">
+ <xsd:sequence>
+ <xsd:element name="accountNumber" type="xsd:string"/>
+ <xsd:element name="accountType" type="xsd:string"/>
+ <xsd:element name="balance" type="xsd:float"/>
+ </xsd:sequence>
+ </xsd:complexType>
+
+ </xsd:schema>
+ </wsdl:types>
+ <wsdl:message name="getAccountReportRequest">
+ <wsdl:part element="tns:customerID" name="getAccountReportRequest"/>
+ </wsdl:message>
+ <wsdl:message name="getAccountReportResponse">
+ <wsdl:part element="tns:getAccountReportResponse" name="getAccountReportResponse"/>
+ </wsdl:message>
+ <wsdl:portType name="AccountService">
+ <wsdl:operation name="getAccountReport">
+ <wsdl:input message="tns:getAccountReportRequest"/>
+ <wsdl:output message="tns:getAccountReportResponse"/>
+ </wsdl:operation>
+ </wsdl:portType>
+ <wsdl:binding name="AccountServiceSOAP" type="tns:AccountService">
+ <soap:binding style="document"
+ transport="http://schemas.xmlsoap.org/soap/http"/>
+ <wsdl:operation name="getAccountReport">
+ <soap:operation
+ soapAction="http://www.bigbank.com/AccountService/getAccountReport"/>
+ <wsdl:input>
+ <soap:body use="literal"/>
+ </wsdl:input>
+ <wsdl:output>
+ <soap:body use="literal"/>
+ </wsdl:output>
+ </wsdl:operation>
+ </wsdl:binding>
+ <wsdl:service name="AccountService">
+ <wsdl:port binding="tns:AccountServiceSOAP"
+ name="AccountServiceSOAP">
+ <soap:address location="http://localhost:8080/tuscany-model/services/AccountService"/>
+ </wsdl:port>
+ </wsdl:service>
+</wsdl:definitions>
diff --git a/tags/java-M1-20060518/java/sca/model/src/test/java/org/apache/tuscany/model/assembly/tests/bigbank/account/services/account/AccountServiceImpl.java b/tags/java-M1-20060518/java/sca/model/src/test/java/org/apache/tuscany/model/assembly/tests/bigbank/account/services/account/AccountServiceImpl.java new file mode 100644 index 0000000000..a5619bb41e --- /dev/null +++ b/tags/java-M1-20060518/java/sca/model/src/test/java/org/apache/tuscany/model/assembly/tests/bigbank/account/services/account/AccountServiceImpl.java @@ -0,0 +1,42 @@ +/** + * + * Copyright 2005 The Apache Software Foundation or its licensors, as applicable. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.tuscany.model.assembly.tests.bigbank.account.services.account; + +import org.osoa.sca.annotations.Property; +import org.osoa.sca.annotations.Reference; + +import org.apache.tuscany.model.assembly.tests.bigbank.account.services.accountdata.AccountDataService; +import org.apache.tuscany.model.assembly.tests.bigbank.account.services.stockquote.StockQuoteService; + +public class AccountServiceImpl implements AccountService { + + @Property + public String currency = "USD"; + + @Reference + public AccountDataService accountDataService; + @Reference + public StockQuoteService stockQuoteService; + + public AccountServiceImpl() { + } + + public AccountReport getAccountReport(String customerID) { + return null; + } + +} diff --git a/tags/java-M1-20060518/java/sca/model/src/test/java/org/apache/tuscany/model/assembly/tests/bigbank/account/services/account/AccountSummary.java b/tags/java-M1-20060518/java/sca/model/src/test/java/org/apache/tuscany/model/assembly/tests/bigbank/account/services/account/AccountSummary.java new file mode 100644 index 0000000000..c1650c79fa --- /dev/null +++ b/tags/java-M1-20060518/java/sca/model/src/test/java/org/apache/tuscany/model/assembly/tests/bigbank/account/services/account/AccountSummary.java @@ -0,0 +1,46 @@ +/** + * + * Copyright 2005 The Apache Software Foundation or its licensors, as applicable. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.tuscany.model.assembly.tests.bigbank.account.services.account; + +/** + * @model + */ + +public interface AccountSummary { + + /** + * @model + */ + String getAccountNumber(); + + void setAccountNumber(String accountNumber); + + /** + * @model + */ + String getAccountType(); + + void setAccountType(String accountType); + + /** + * @model + */ + float getBalance(); + + void setBalance(float balance); +} + diff --git a/tags/java-M1-20060518/java/sca/model/src/test/java/org/apache/tuscany/model/assembly/tests/bigbank/account/services/accountdata/AccountDataService.java b/tags/java-M1-20060518/java/sca/model/src/test/java/org/apache/tuscany/model/assembly/tests/bigbank/account/services/accountdata/AccountDataService.java new file mode 100644 index 0000000000..04ae8e5bd5 --- /dev/null +++ b/tags/java-M1-20060518/java/sca/model/src/test/java/org/apache/tuscany/model/assembly/tests/bigbank/account/services/accountdata/AccountDataService.java @@ -0,0 +1,26 @@ +/** + * + * Copyright 2005 The Apache Software Foundation or its licensors, as applicable. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.tuscany.model.assembly.tests.bigbank.account.services.accountdata; + +public interface AccountDataService { + + CheckingAccount getCheckingAccount(String customerID); + + SavingsAccount getSavingsAccount(String customerID); + + StockAccount getStockAccount(String customerID); +} diff --git a/tags/java-M1-20060518/java/sca/model/src/test/java/org/apache/tuscany/model/assembly/tests/bigbank/account/services/accountdata/AccountDataServiceImpl.java b/tags/java-M1-20060518/java/sca/model/src/test/java/org/apache/tuscany/model/assembly/tests/bigbank/account/services/accountdata/AccountDataServiceImpl.java new file mode 100644 index 0000000000..4d5eee1f01 --- /dev/null +++ b/tags/java-M1-20060518/java/sca/model/src/test/java/org/apache/tuscany/model/assembly/tests/bigbank/account/services/accountdata/AccountDataServiceImpl.java @@ -0,0 +1,48 @@ +/** + * + * Copyright 2005 The Apache Software Foundation or its licensors, as applicable. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.tuscany.model.assembly.tests.bigbank.account.services.accountdata; + +public class AccountDataServiceImpl implements AccountDataService { + + public CheckingAccount getCheckingAccount(String customerID) { + + CheckingAccount checkingAccount = new CheckingAccount(); + checkingAccount.setAccountNumber(customerID + "_CHA12345"); + checkingAccount.setBalance(1500.0f); + + return checkingAccount; + } + + public SavingsAccount getSavingsAccount(String customerID) { + + SavingsAccount savingsAccount = new SavingsAccount(); + savingsAccount.setAccountNumber(customerID + "_SAA12345"); + savingsAccount.setBalance(1500.0f); + + return savingsAccount; + } + + public StockAccount getStockAccount(String customerID) { + + StockAccount stockAccount = new StockAccount(); + stockAccount.setAccountNumber(customerID + "_STA12345"); + stockAccount.setSymbol("IBM"); + stockAccount.setQuantity(100); + + return stockAccount; + } +} diff --git a/tags/java-M1-20060518/java/sca/model/src/test/java/org/apache/tuscany/model/assembly/tests/bigbank/account/services/accountdata/CheckingAccount.java b/tags/java-M1-20060518/java/sca/model/src/test/java/org/apache/tuscany/model/assembly/tests/bigbank/account/services/accountdata/CheckingAccount.java new file mode 100644 index 0000000000..d4f2f8be6c --- /dev/null +++ b/tags/java-M1-20060518/java/sca/model/src/test/java/org/apache/tuscany/model/assembly/tests/bigbank/account/services/accountdata/CheckingAccount.java @@ -0,0 +1,39 @@ +/** + * + * Copyright 2005 The Apache Software Foundation or its licensors, as applicable. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.tuscany.model.assembly.tests.bigbank.account.services.accountdata; + +public class CheckingAccount { + + private String accountNumber; + private float balance; + + public String getAccountNumber() { + return accountNumber; + } + + public void setAccountNumber(String accountNumber) { + this.accountNumber = accountNumber; + } + + public float getBalance() { + return balance; + } + + public void setBalance(float balance) { + this.balance = balance; + } +} diff --git a/tags/java-M1-20060518/java/sca/model/src/test/java/org/apache/tuscany/model/assembly/tests/bigbank/account/services/accountdata/SavingsAccount.java b/tags/java-M1-20060518/java/sca/model/src/test/java/org/apache/tuscany/model/assembly/tests/bigbank/account/services/accountdata/SavingsAccount.java new file mode 100644 index 0000000000..73474585da --- /dev/null +++ b/tags/java-M1-20060518/java/sca/model/src/test/java/org/apache/tuscany/model/assembly/tests/bigbank/account/services/accountdata/SavingsAccount.java @@ -0,0 +1,39 @@ +/** + * + * Copyright 2005 The Apache Software Foundation or its licensors, as applicable. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.tuscany.model.assembly.tests.bigbank.account.services.accountdata; + +public class SavingsAccount { + + private String accountNumber; + private float balance; + + public String getAccountNumber() { + return accountNumber; + } + + public void setAccountNumber(String accountNumber) { + this.accountNumber = accountNumber; + } + + public float getBalance() { + return balance; + } + + public void setBalance(float balance) { + this.balance = balance; + } +} diff --git a/tags/java-M1-20060518/java/sca/model/src/test/java/org/apache/tuscany/model/assembly/tests/bigbank/account/services/accountdata/StockAccount.java b/tags/java-M1-20060518/java/sca/model/src/test/java/org/apache/tuscany/model/assembly/tests/bigbank/account/services/accountdata/StockAccount.java new file mode 100644 index 0000000000..eeb7238abc --- /dev/null +++ b/tags/java-M1-20060518/java/sca/model/src/test/java/org/apache/tuscany/model/assembly/tests/bigbank/account/services/accountdata/StockAccount.java @@ -0,0 +1,48 @@ +/** + * + * Copyright 2005 The Apache Software Foundation or its licensors, as applicable. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.tuscany.model.assembly.tests.bigbank.account.services.accountdata; + +public class StockAccount { + + private String accountNumber; + private String symbol; + private int quantity; + + public String getAccountNumber() { + return accountNumber; + } + + public void setAccountNumber(String accountNumber) { + this.accountNumber = accountNumber; + } + + public int getQuantity() { + return quantity; + } + + public void setQuantity(int quantity) { + this.quantity = quantity; + } + + public String getSymbol() { + return symbol; + } + + public void setSymbol(String symbol) { + this.symbol = symbol; + } +} diff --git a/tags/java-M1-20060518/java/sca/model/src/test/java/org/apache/tuscany/model/assembly/tests/bigbank/account/services/stockquote/StockQuoteService.java b/tags/java-M1-20060518/java/sca/model/src/test/java/org/apache/tuscany/model/assembly/tests/bigbank/account/services/stockquote/StockQuoteService.java new file mode 100644 index 0000000000..7545e9fbbb --- /dev/null +++ b/tags/java-M1-20060518/java/sca/model/src/test/java/org/apache/tuscany/model/assembly/tests/bigbank/account/services/stockquote/StockQuoteService.java @@ -0,0 +1,24 @@ +/** + * + * Copyright 2005 The Apache Software Foundation or its licensors, as applicable. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.tuscany.model.assembly.tests.bigbank.account.services.stockquote; + +public interface StockQuoteService { + + public float getQuote(String symbol); +} + +
\ No newline at end of file diff --git a/tags/java-M1-20060518/java/sca/model/src/test/java/org/apache/tuscany/model/assembly/tests/bigbank/account/services/stockquote/StockQuoteServiceImpl.java b/tags/java-M1-20060518/java/sca/model/src/test/java/org/apache/tuscany/model/assembly/tests/bigbank/account/services/stockquote/StockQuoteServiceImpl.java new file mode 100644 index 0000000000..85f85340ec --- /dev/null +++ b/tags/java-M1-20060518/java/sca/model/src/test/java/org/apache/tuscany/model/assembly/tests/bigbank/account/services/stockquote/StockQuoteServiceImpl.java @@ -0,0 +1,28 @@ +/** + * + * Copyright 2005 The Apache Software Foundation or its licensors, as applicable. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.tuscany.model.assembly.tests.bigbank.account.services.stockquote; + +/* Dummy'd up StockQuoteService, override webservice for now */ + +public class StockQuoteServiceImpl implements StockQuoteService { + + public float getQuote(String symbol) { + // Just hardcode for now + return 83.00f; + } + +}
\ No newline at end of file diff --git a/tags/java-M1-20060518/java/sca/model/src/test/java/org/apache/tuscany/model/assembly/tests/bigbank/account/services/stockquote/StockQuoteWebService.wsdl b/tags/java-M1-20060518/java/sca/model/src/test/java/org/apache/tuscany/model/assembly/tests/bigbank/account/services/stockquote/StockQuoteWebService.wsdl new file mode 100644 index 0000000000..6af61ef80e --- /dev/null +++ b/tags/java-M1-20060518/java/sca/model/src/test/java/org/apache/tuscany/model/assembly/tests/bigbank/account/services/stockquote/StockQuoteWebService.wsdl @@ -0,0 +1,98 @@ +<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Copyright (c) 2005 The Apache Software Foundation or its licensors, as applicable.
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+ -->
+<wsdl:definitions targetNamespace="http://webservice.stockquote" xmlns:apachesoap="http://xml.apache.org/xml-soap" xmlns:impl="http://webservice.stockquote" xmlns:intf="http://webservice.stockquote" xmlns:tns1="http://stockquote" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:wsdlsoap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" name="stockquote">
+ <!--WSDL created by Apache Axis version: 1.2.1
+Built on Jun 14, 2005 (09:15:57 EDT)-->
+ <wsdl:types>
+ <schema elementFormDefault="qualified" targetNamespace="http://stockquote" xmlns="http://www.w3.org/2001/XMLSchema">
+ <complexType name="GetQuoteRequest">
+ <sequence>
+ <element name="symbol" nillable="true" type="xsd:string"/>
+ </sequence>
+ </complexType>
+ <complexType name="GetQuoteResponse">
+ <sequence>
+ <element name="price" type="xsd:float"/>
+ </sequence>
+ </complexType>
+ </schema>
+ <schema elementFormDefault="qualified" targetNamespace="http://webservice.stockquote" xmlns="http://www.w3.org/2001/XMLSchema">
+ <import namespace="http://stockquote"/>
+ <element name="request" type="tns1:GetQuoteRequest"/>
+ <element name="getQuoteReturn" type="tns1:GetQuoteResponse"/>
+ </schema>
+ </wsdl:types>
+
+ <wsdl:message name="getQuoteResponse">
+
+ <wsdl:part element="impl:getQuoteReturn" name="getQuoteReturn"/>
+
+ </wsdl:message>
+
+ <wsdl:message name="getQuoteRequest">
+
+ <wsdl:part element="impl:request" name="request"/>
+
+ </wsdl:message>
+
+ <wsdl:portType name="StockQuoteWebService">
+
+ <wsdl:operation name="getQuote" parameterOrder="request">
+
+ <wsdl:input message="impl:getQuoteRequest" name="getQuoteRequest"/>
+
+ <wsdl:output message="impl:getQuoteResponse" name="getQuoteResponse"/>
+
+ </wsdl:operation>
+
+ </wsdl:portType>
+
+ <wsdl:binding name="StockQuoteWebServiceSoapBinding" type="impl:StockQuoteWebService">
+
+ <wsdlsoap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
+
+ <wsdl:operation name="getQuote">
+
+ <wsdlsoap:operation soapAction=""/>
+
+ <wsdl:input name="getQuoteRequest">
+
+ <wsdlsoap:body use="literal"/>
+
+ </wsdl:input>
+
+ <wsdl:output name="getQuoteResponse">
+
+ <wsdlsoap:body use="literal"/>
+
+ </wsdl:output>
+
+ </wsdl:operation>
+
+ </wsdl:binding>
+
+ <wsdl:service name="StockQuoteWebServiceService">
+
+ <wsdl:port binding="impl:StockQuoteWebServiceSoapBinding" name="StockQuoteWebService">
+
+ <wsdlsoap:address location="http://localhost:8123/StockQuoteWebService/services/StockQuoteWebService"/>
+
+ </wsdl:port>
+
+ </wsdl:service>
+
+</wsdl:definitions>
diff --git a/tags/java-M1-20060518/java/sca/model/src/test/resources/org/apache/tuscany/model/assembly/tests/sca.module b/tags/java-M1-20060518/java/sca/model/src/test/resources/org/apache/tuscany/model/assembly/tests/sca.module new file mode 100644 index 0000000000..7290f9c0c3 --- /dev/null +++ b/tags/java-M1-20060518/java/sca/model/src/test/resources/org/apache/tuscany/model/assembly/tests/sca.module @@ -0,0 +1,58 @@ +<?xml version="1.0" encoding="ASCII"?>
+<!--
+ Copyright (c) 2005 The Apache Software Foundation or its licensors, as applicable.
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+ -->
+<module xmlns="http://www.osoa.org/xmlns/sca/0.9" xmlns:v="http://www.osoa.org/xmlns/sca/values/0.9"
+
+ name="tuscany.model.assembly.tests.bigbank.account">
+
+ <entryPoint name="AccountService">
+ <interface.java interface="org.apache.tuscany.model.assembly.tests.bigbank.account.services.account.AccountService"/>
+ <binding.ws port="http://www.bigbank.com/AccountService#wsdl.endpoint(AccountService/AccountServiceSOAP)"/> + <!--
+ <reference>AccountServiceComponent</reference> + -->
+ </entryPoint>
+
+ <component name="AccountServiceComponent">
+ <implementation.java class="org.apache.tuscany.model.assembly.tests.bigbank.account.services.account.AccountServiceImpl"/> + <!--
+ <properties>
+ <v:currency>EURO</v:currency>
+ </properties>
+ <references>
+ <v:accountDataService>AccountDataServiceComponent</v:accountDataService>
+ <v:stockQuoteService>StockQuoteService</v:stockQuoteService>
+ </references> + -->
+ </component>
+
+ <component name="AccountDataServiceComponent">
+ <implementation.java class="org.apache.tuscany.model.assembly.tests.bigbank.account.services.accountdata.AccountDataServiceImpl"/>
+ </component>
+
+ <component name="StockQuoteService">
+ <implementation.java class="org.apache.tuscany.model.assembly.tests.bigbank.account.services.stockquote.StockQuoteServiceImpl"/>
+ </component>
+
+ <!--
+ <externalService name="StockQuoteService">
+ <interface.java interface="org.apache.tuscany.model.assembly.tests.bigbank.account.services.stockquote"/>
+ <binding.ws port="http://www.quickstockquote.com/StockQuoteService#wsdl.endpoint(StockQuote/StockQuoteServiceSOAP)"/>
+ </externalService>
+ -->
+
+</module>
+
diff --git a/tags/java-M1-20060518/java/sca/model/src/test/resources/org/apache/tuscany/model/assembly/tests/sca.subsystem b/tags/java-M1-20060518/java/sca/model/src/test/resources/org/apache/tuscany/model/assembly/tests/sca.subsystem new file mode 100644 index 0000000000..bff90f010d --- /dev/null +++ b/tags/java-M1-20060518/java/sca/model/src/test/resources/org/apache/tuscany/model/assembly/tests/sca.subsystem @@ -0,0 +1,24 @@ +<?xml version="1.0" encoding="ASCII"?>
+<!--
+ Copyright (c) 2005 The Apache Software Foundation or its licensors, as applicable.
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+ -->
+<subsystem xmlns="http://www.osoa.org/xmlns/sca/0.9"
+
+ name="tuscany.runtime.bigbank.account">
+
+ <moduleComponent name="AccountModuleComponent" module="tuscany.runtime.bigbank.account"/>
+
+</subsystem>
+
|