summaryrefslogtreecommitdiffstats
path: root/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org
diff options
context:
space:
mode:
Diffstat (limited to 'sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org')
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/ModelRuntimeException.java41
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/Aggregate.java117
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/AggregatePart.java40
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/AssemblyFactory.java162
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/AssemblyModelContext.java64
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/AssemblyModelObject.java45
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/AssemblyModelVisitor.java32
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/Binding.java40
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/Component.java80
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/ComponentImplementation.java40
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/ComponentType.java66
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/ConfiguredPort.java57
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/ConfiguredProperty.java62
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/ConfiguredReference.java44
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/ConfiguredService.java36
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/EntryPoint.java64
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/Extensible.java38
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/ExternalService.java59
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/ModelInitException.java43
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/Module.java39
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/ModuleComponent.java47
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/ModuleFragment.java25
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/Multiplicity.java47
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/OverrideOption.java40
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/Port.java47
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/Property.java91
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/Reference.java36
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/RuntimeConfigurationHolder.java36
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/Scope.java32
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/Service.java24
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/ServiceContract.java62
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/ServiceURI.java53
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/SimpleComponent.java25
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/Subsystem.java38
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/Wire.java48
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/impl/AggregateImpl.java305
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/impl/AggregatePartImpl.java67
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/impl/AssemblyFactoryImpl.java204
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/impl/AssemblyModelContextImpl.java92
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/impl/AssemblyModelObjectImpl.java132
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/impl/BindingImpl.java96
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/impl/ComponentImpl.java222
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/impl/ComponentImplementationImpl.java108
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/impl/ComponentTypeImpl.java152
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/impl/ConfiguredPortImpl.java142
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/impl/ConfiguredPropertyImpl.java123
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/impl/ConfiguredReferenceImpl.java72
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/impl/ConfiguredServiceImpl.java48
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/impl/EntryPointImpl.java145
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/impl/ExtensibleImpl.java92
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/impl/ExternalServiceImpl.java135
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/impl/ModuleComponentImpl.java65
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/impl/ModuleFragmentImpl.java32
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/impl/ModuleImpl.java243
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/impl/PortImpl.java106
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/impl/PropertyImpl.java178
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/impl/ReferenceImpl.java50
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/impl/ServiceContractImpl.java81
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/impl/ServiceImpl.java32
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/impl/ServiceURIImpl.java198
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/impl/SimpleComponentImpl.java32
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/impl/SubsystemImpl.java49
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/impl/WireImpl.java66
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/loader/AssemblyModelLoader.java81
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/scdl/loader/SCDLModelLoader.java36
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/scdl/loader/impl/AssemblyModelLoadException.java41
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/scdl/loader/impl/SCDLAssemblyModelLoaderImpl.java198
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/scdl/loader/impl/SCDLModelContentHandlerImpl.java708
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/scdl/loader/impl/SCDLXMLReader.java109
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/types/java/JavaServiceContract.java27
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/types/java/impl/JavaServiceContractImpl.java81
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/types/wsdl/WSDLServiceContract.java52
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/types/wsdl/impl/WSDLServiceContractImpl.java212
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/util/ModelContentHandler.java71
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/util/ModelTransformer.java51
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/util/ModelTransformerImpl.java125
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/util/XMLNameUtil.java227
77 files changed, 7106 insertions, 0 deletions
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/ModelRuntimeException.java b/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/ModelRuntimeException.java
new file mode 100644
index 0000000000..ba361fab89
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/ModelRuntimeException.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;
+
+import org.apache.tuscany.common.TuscanyRuntimeException;
+
+/**
+ * The root runtime exception for the model.
+ *
+ * @version $Rev$ $Date$
+ */
+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/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/Aggregate.java b/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/Aggregate.java
new file mode 100644
index 0000000000..d313a087d0
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/Aggregate.java
@@ -0,0 +1,117 @@
+/**
+ *
+ * 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;
+
+import javax.wsdl.Import;
+
+/**
+ * A model object that describes a container for other module objects, which must be {@link AggregatePart}s.
+ */
+public interface Aggregate extends Extensible {
+
+ /**
+ * Returns the name of the aggregate.
+ * @return the name of the aggregate
+ */
+ String getName();
+
+ /**
+ * Sets the name of the aggregate.
+ * @param name the name of the aggregate
+ */
+ void setName(String name);
+
+ /**
+ * Returns the AggregatePart objects that are contained in this aggregate.
+ * @return the AggregatePart objects that are contained in this aggregate
+ */
+ List<AggregatePart> getAggregateParts();
+
+ /**
+ * Helper method that returns all entry points contained in this aggregate.
+ * @return a list of all EntryPoint model objects driectly contained in this aggregate
+ */
+ List<EntryPoint> getEntryPoints();
+
+ /**
+ * Returns the named entry point.
+ * @param name
+ * @return
+ */
+ EntryPoint getEntryPoint(String name);
+
+ /**
+ * Helper method that returns all entry points contained in this aggregate.
+ * @return
+ */
+ List<Component> getComponents();
+
+ /**
+ * Returns the named component.
+ * @param name
+ * @return
+ */
+ Component getComponent(String name);
+
+ /**
+ * Returns external services contained in this aggregate.
+ * @return
+ */
+ List<ExternalService> getExternalServices();
+
+ /**
+ * Returns the named external service.
+ * @param name
+ * @return
+ */
+ ExternalService getExternalService(String name);
+
+ /**
+ * Returns the configured service at the given address.
+ * @param address
+ * @return
+ */
+ ConfiguredService getConfiguredService(ServiceURI address);
+
+ /**
+ * Returns the wires.
+ * @return
+ */
+ List<Wire> getWires();
+
+ /**
+ * Returns the WSDL imports.
+ * @return
+ */
+ List<Import> getWSDLImports();
+
+ /**
+ * Returns the WSDL imports for the given namespace.
+ * @param namespace
+ * @return
+ */
+ List<Import> getWSDLImports(String namespace);
+
+ /**
+ * Returns the assembly model context used by this aggregate.
+ * @return
+ */
+ AssemblyModelContext getAssemblyModelContext();
+
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/AggregatePart.java b/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/AggregatePart.java
new file mode 100644
index 0000000000..f88458eaa8
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/AggregatePart.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;
+
+/**
+ * A configured object that is contained inside an {@link Aggregate}.
+ */
+public interface AggregatePart extends AssemblyModelObject {
+ /**
+ * Returns the name that uniquely identifies this part within its containing aggregate.
+ * @return the name that uniquely identifies this part within its containing aggregate
+ */
+ String getName();
+
+ /**
+ * Sets the name that uniquely identifies this part within its containing aggregate.
+ * @param value the name that uniquely identifies this part within its containing aggregate
+ */
+ void setName(String value);
+
+ /**
+ * Returns the aggregate that contains this part.
+ * @return the aggregate that contains this part
+ */
+ Aggregate getAggregate();
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/AssemblyFactory.java b/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/AssemblyFactory.java
new file mode 100644
index 0000000000..2f5715bd4e
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/AssemblyFactory.java
@@ -0,0 +1,162 @@
+/**
+ *
+ * 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
+ */
+ SimpleComponent createSimpleComponent();
+
+ /**
+ * Returns a new ComponentType.
+ * @return
+ */
+ ComponentType createComponentType();
+
+ /**
+ * Returns a new EntryPoint.
+ * @return
+ */
+ EntryPoint createEntryPoint();
+
+ /**
+ * Returns a new ExternalService.
+ * @return
+ */
+ ExternalService createExternalService();
+
+ /**
+ * Returns a new JavaServiceContract.
+ * @return
+ */
+ JavaServiceContract createJavaServiceContract();
+
+ /**
+ * Returns a new Module.
+ * @return
+ */
+ Module createModule();
+
+ /**
+ * Returns a new ModuleComponent.
+ * @return
+ */
+ ModuleComponent createModuleComponent();
+
+ /**
+ * Returns a new ModuleFragment.
+ * @return
+ */
+ ModuleFragment createModuleFragment();
+
+ /**
+ * Returns a new Reference.
+ * @return
+ */
+ Reference createReference();
+
+ /**
+ * Returns a new ConfiguredReference.
+ * @return
+ */
+ ConfiguredReference createConfiguredReference();
+
+ /**
+ * Returns a new Service.
+ * @return
+ */
+ Service createService();
+
+ /**
+ * Returns a new ConfiguredService.
+ * @return
+ */
+ ConfiguredService createConfiguredService();
+
+ /**
+ * Returns a new Subsystem.
+ * @return
+ */
+ Subsystem createSubsystem();
+
+ /**
+ * Returns Property.
+ * @return
+ */
+ Property createProperty();
+
+ /**
+ * Returns a new ConfiguredProperty.
+ * @return
+ */
+ ConfiguredProperty createConfiguredProperty();
+
+ /**
+ * Returns a new WSDLServiceContract.
+ * @return
+ */
+ WSDLServiceContract createWSDLServiceContract();
+
+ /**
+ * Create a new ServiceURI from the given uri string.
+ * @param uri
+ * @return
+ */
+ ServiceURI createServiceURI(String uri);
+
+ /**
+ * Creates a new ServiceURI from a module component and a service name.
+ * @param moduleComponent
+ * @param serviceName
+ * @return
+ */
+ ServiceURI createServiceURI(ModuleComponent moduleComponent, String serviceName);
+
+ /**
+ * Creates a new ServiceURI from a module component and configured port.
+ * @param moduleComponent
+ * @param aggregatePart
+ * @param configuredPort
+ * @return
+ */
+ ServiceURI createServiceURI(ModuleComponent moduleComponent, AggregatePart aggregatePart, ConfiguredPort configuredPort);
+
+ /**
+ * Create a qname from a URI
+ * @param uri
+ * @return
+ */
+ QName createQName(String uri);
+
+ /**
+ * Create a wire
+ * @return
+ */
+ Wire createWire();
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/AssemblyModelContext.java b/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/AssemblyModelContext.java
new file mode 100644
index 0000000000..43e6766b8b
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/AssemblyModelContext.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 AssemblyModelContext {
+
+ /**
+ * 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 system environment
+ *
+ * @return a resource loader
+ */
+ ResourceLoader getSystemResourceLoader();
+
+ /**
+ * 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();
+
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/AssemblyModelObject.java b/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/AssemblyModelObject.java
new file mode 100644
index 0000000000..e9a32ed4ce
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/AssemblyModelObject.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 AssemblyModelObject {
+
+ /**
+ * Initialize this model object.
+ *
+ * @param modelContext context providing access to the environment in which this model is being used
+ * @throws ModelInitException if an error ocurrs initializing the artifact
+ */
+ void initialize(AssemblyModelContext modelContext) throws ModelInitException;
+
+ /**
+ * 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(AssemblyModelVisitor visitor);
+
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/AssemblyModelVisitor.java b/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/AssemblyModelVisitor.java
new file mode 100644
index 0000000000..9f3153e953
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/AssemblyModelVisitor.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 AssemblyModelVisitor {
+
+ /**
+ * Visit the given model object.
+ *
+ * @param modelObject the assembly model object to visit
+ * @return true if processing is complete
+ */
+ boolean visit(AssemblyModelObject modelObject);
+
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/Binding.java b/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/Binding.java
new file mode 100644
index 0000000000..61207186e3
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/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 by extended by binding implementations to allow
+ * specification of binding/transport specific information.
+ */
+public interface Binding extends AssemblyModelObject, RuntimeConfigurationHolder {
+ /**
+ * 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/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/Component.java b/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/Component.java
new file mode 100644
index 0000000000..86dd1c5f12
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/Component.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;
+
+import java.util.List;
+
+
+/**
+ * A component is a configured instance of a generic {@link ComponentImplementation}.
+ */
+public interface Component extends Extensible, AggregatePart {
+
+ /**
+ * Returns the ComponentImplementation for this configured instance.
+ * @return the ComponentImplementation for this configured instance
+ */
+ ComponentImplementation getComponentImplementation();
+
+ /**
+ * Sets the ComponentImplementation for this configured instance
+ * @param value the ComponentImplementation for this configured instance
+ */
+ void setComponentImplementation(ComponentImplementation 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 a list of configured reference values for the configured instance.
+ * @return a list of configured reference values 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/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/ComponentImplementation.java b/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/ComponentImplementation.java
new file mode 100644
index 0000000000..9bae24522e
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/ComponentImplementation.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 ComponentImplementation extends Extensible, RuntimeConfigurationHolder {
+
+ /**
+ * 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/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/ComponentType.java b/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/ComponentType.java
new file mode 100644
index 0000000000..58ac9bc9de
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/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/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/ConfiguredPort.java b/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/ConfiguredPort.java
new file mode 100644
index 0000000000..d40e852e88
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/ConfiguredPort.java
@@ -0,0 +1,57 @@
+/**
+ *
+ * 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 extends AssemblyModelObject, RuntimeConfigurationHolder {
+
+ /**
+ * Returns the port that is being configured.
+ * @return the port that is being configured
+ */
+ Port getPort();
+
+ /**
+ * Sets the port that is being configured.
+ * @param port the port that is being configured
+ */
+ void setPort(Port port);
+
+ /**
+ * Returns the aggregate part containing this port.
+ * @return the aggregate part that contains this port
+ */
+ AggregatePart getAggregatePart();
+
+ /**
+ * Returns the port's proxy factory
+ * @return the port's proxy factory
+ * todo should this be here or should it be provided in a sub-interface?
+ */
+ Object getProxyFactory();
+
+ /**
+ * Sets the port's proxy factory
+ * @param proxyFactory the port's proxy factory
+ * todo should this be here or should it be provided in a sub-interface?
+ */
+ void setProxyFactory(Object proxyFactory);
+
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/ConfiguredProperty.java b/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/ConfiguredProperty.java
new file mode 100644
index 0000000000..0a28c0a7bf
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/ConfiguredProperty.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;
+
+/**
+ * The configured value of a {@link Property}.
+ */
+public interface ConfiguredProperty extends AssemblyModelObject {
+
+ /**
+ * 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 aggregate 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 aggregate 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/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/ConfiguredReference.java b/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/ConfiguredReference.java
new file mode 100644
index 0000000000..972c6812d8
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/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.
+ */
+public interface ConfiguredReference extends ConfiguredPort {
+
+ /**
+ * Returns the {@link Reference} that is being configured.
+ * @return the {@link Reference} that is being configured
+ */
+ Reference getReference();
+
+ /**
+ * Sets the {@link Reference} that is being configured.
+ * @param reference the {@link Reference} that is being configured
+ */
+ void setReference(Reference reference);
+
+ /**
+ * 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/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/ConfiguredService.java b/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/ConfiguredService.java
new file mode 100644
index 0000000000..14b1c0abbe
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/ConfiguredService.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;
+
+
+/**
+ * A configured service associated with a particular usage.
+ */
+public interface ConfiguredService extends ConfiguredPort {
+ /**
+ * Returns the {@link Service} that is being configured.
+ * @return the {@link Service} that is being configured
+ */
+ Service getService();
+
+ /**
+ * Sets the {@link Service} that is being configured.
+ * @param service the {@link Service} that is being configured
+ */
+ void setService(Service service);
+
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/EntryPoint.java b/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/EntryPoint.java
new file mode 100644
index 0000000000..718ae996c5
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/EntryPoint.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 java.util.List;
+
+
+/**
+ * An entry point exposed by its containing {@link Aggregate}.
+ * References from outside the Aggregate can only be connected to its entry points.
+ */
+public interface EntryPoint extends AggregatePart, Extensible {
+
+ /**
+ * 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 aggregate.
+ *
+ * @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 aggregate.
+ *
+ * @param configuredReference the configured reference that wires this entry point to the published service inside the aggregate
+ */
+ void setConfiguredReference(ConfiguredReference configuredReference);
+
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/Extensible.java b/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/Extensible.java
new file mode 100644
index 0000000000..2a5b5878f8
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/Extensible.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;
+
+import java.util.List;
+
+/**
+ * An extensible model object.
+ * TODO do we actually need this given we have the ability to load specializations of individual model objects
+ * TODO is this the bext interface for this?
+ */
+public interface Extensible extends AssemblyModelObject {
+
+ /**
+ * Returns the extensibility elements.
+ */
+ List getExtensibilityElements();
+
+ /**
+ * Returns the extensibility attributes.
+ */
+ List getExtensibilityAttributes();
+
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/ExternalService.java b/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/ExternalService.java
new file mode 100644
index 0000000000..a30000f387
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/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 Aggregate}.
+ * All references used by the aggregate are specified as external services.
+ */
+public interface ExternalService extends AggregatePart, Extensible {
+
+ /**
+ * 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 aggregate 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 aggregate 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 aggregate.
+ * @return the configured service that this external service provides to other parts of the containing aggregate
+ */
+ ConfiguredService getConfiguredService();
+
+ /**
+ * Sets the configured service that this external service provides to other parts of the containing aggregate
+ * @param configuredService the configured service that this external service provides to other parts of the containing aggregate
+ */
+ void setConfiguredService(ConfiguredService configuredService);
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/ModelInitException.java b/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/ModelInitException.java
new file mode 100644
index 0000000000..4af3737a5d
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/ModelInitException.java
@@ -0,0 +1,43 @@
+/**
+ *
+ * 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 ModelInitException extends ModelRuntimeException {
+ // todo serialuid
+
+ public ModelInitException() {
+ super();
+ }
+
+ public ModelInitException(String message) {
+ super(message);
+ }
+
+ public ModelInitException(String message, Throwable cause) {
+ super(message, cause);
+ }
+
+ public ModelInitException(Throwable cause) {
+ super(cause);
+ }
+
+}
+
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/Module.java b/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/Module.java
new file mode 100644
index 0000000000..90f9fbf9b2
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/Module.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;
+
+import java.util.List;
+
+/**
+ * A specialized {@link ComponentImplementation} 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 Aggregate, ComponentImplementation {
+ /**
+ * 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/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/ModuleComponent.java b/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/ModuleComponent.java
new file mode 100644
index 0000000000..13125076ea
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/ModuleComponent.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;
+
+/**
+ * Specialization of Component that represents a configured {@link Module}.
+ */
+public interface ModuleComponent extends Component {
+ // todo do we need this or can we just override getComponentImplementation() ?
+ /**
+ * Returns the module implementing this module component.
+ * @return the module implementing this module component
+ */
+ Module getModuleImplementation();
+
+ /**
+ * Set the module implementing this module component.
+ * @param module the module implementing this module component
+ */
+ void setModuleImplementation(Module module);
+
+ /**
+ * 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/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/ModuleFragment.java b/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/ModuleFragment.java
new file mode 100644
index 0000000000..f268524c3f
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/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 Aggregate {
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/Multiplicity.java b/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/Multiplicity.java
new file mode 100644
index 0000000000..78ff6ede2f
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/Multiplicity.java
@@ -0,0 +1,47 @@
+/**
+ *
+ * Copyright 2005 BEA Systems Inc.
+ * Copyright 2005 International Business Machines Corporation
+ *
+ * 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/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/OverrideOption.java b/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/OverrideOption.java
new file mode 100644
index 0000000000..62c7b3fb7a
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/OverrideOption.java
@@ -0,0 +1,40 @@
+/**
+ *
+ * Copyright 2005 BEA Systems Inc.
+ * Copyright 2005 International Business Machines Corporation
+ *
+ * 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/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/Port.java b/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/Port.java
new file mode 100644
index 0000000000..5dadfa0d63
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/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 AssemblyModelObject {
+ /**
+ * 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/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/Property.java b/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/Property.java
new file mode 100644
index 0000000000..cd6a918686
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/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/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/Reference.java b/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/Reference.java
new file mode 100644
index 0000000000..8cc13e98ec
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/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/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/RuntimeConfigurationHolder.java b/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/RuntimeConfigurationHolder.java
new file mode 100644
index 0000000000..7b20f2db21
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/RuntimeConfigurationHolder.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;
+
+/**
+ * A model object that can hold a runtime configuration object.
+ */
+public interface RuntimeConfigurationHolder {
+
+ /**
+ * Sets the runtime configuration object.
+ * @param configuration the runtime configuration object
+ */
+ void setRuntimeConfiguration(Object configuration);
+
+ /**
+ * Returns the runtime configuration object.
+ * @return the runtime configuration object
+ */
+ Object getRuntimeConfiguration();
+
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/Scope.java b/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/Scope.java
new file mode 100644
index 0000000000..e5209d05b5
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/Scope.java
@@ -0,0 +1,32 @@
+/**
+ *
+ * Copyright 2005 BEA Systems Inc.
+ * Copyright 2005 International Business Machines Corporation
+ *
+ * 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/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/Service.java b/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/Service.java
new file mode 100644
index 0000000000..c73002efba
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/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/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/ServiceContract.java b/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/ServiceContract.java
new file mode 100644
index 0000000000..3284755ddb
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/ServiceContract.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;
+
+/**
+ * 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 invocation from the provider back to its requestor.
+ * @return the callback interface for invocation from the provider back to its requestor
+ */
+ Class getCallbackInterface();
+
+ /**
+ * Sets the callback interface for invocation from the provider back to its requestor.
+ * @param value the callback interface for invocation from the provider back to its requestor
+ */
+ void setCallbackInterface(Class value);
+
+ /**
+ * Returns the scope of this service contract.
+ * @return
+ * todo missing javadoc
+ */
+ Scope getScope();
+
+ /**
+ * Sets the scope.
+ * @param scope of this service contract.
+ * todo missing javadoc
+ */
+ void setScope(Scope scope);
+
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/ServiceURI.java b/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/ServiceURI.java
new file mode 100644
index 0000000000..3b9c1ec2a7
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/ServiceURI.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;
+
+/**
+ * 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();
+
+ /**
+ * 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/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/SimpleComponent.java b/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/SimpleComponent.java
new file mode 100644
index 0000000000..059c6dbf2d
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/SimpleComponent.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 simple component, specifically not an {@link Aggregate}.
+ */
+public interface SimpleComponent extends Component {
+}
+ \ No newline at end of file
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/Subsystem.java b/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/Subsystem.java
new file mode 100644
index 0000000000..7a14847353
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/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 Aggregate {
+
+ /**
+ * Returns the subsystem uri.
+ * @return
+ */
+ String getURI();
+
+ /**
+ * Sets the subsystem uri.
+ * @param value
+ */
+ void setURI(String value);
+
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/Wire.java b/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/Wire.java
new file mode 100644
index 0000000000..dfe553210a
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/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/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/impl/AggregateImpl.java b/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/impl/AggregateImpl.java
new file mode 100644
index 0000000000..234fff6600
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/impl/AggregateImpl.java
@@ -0,0 +1,305 @@
+/**
+ *
+ * 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.io.IOException;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import javax.wsdl.Definition;
+import javax.wsdl.Import;
+
+import org.apache.tuscany.common.resource.ResourceLoader;
+import org.apache.tuscany.model.assembly.Aggregate;
+import org.apache.tuscany.model.assembly.AggregatePart;
+import org.apache.tuscany.model.assembly.AssemblyModelContext;
+import org.apache.tuscany.model.assembly.AssemblyModelVisitor;
+import org.apache.tuscany.model.assembly.Component;
+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.ServiceURI;
+import org.apache.tuscany.model.assembly.Wire;
+import org.apache.tuscany.sdo.util.SDOUtil;
+
+import commonj.sdo.helper.XSDHelper;
+
+/**
+ * An implementation of Aggregate.
+ */
+public abstract class AggregateImpl extends ExtensibleImpl implements Aggregate {
+
+ private String name;
+ private List<Component> components=new ArrayList<Component>();
+ private Map<String, Component> componentsMap;
+ private List<EntryPoint> entryPoints=new ArrayList<EntryPoint>();
+ private Map<String, EntryPoint> entryPointsMap;
+ private List<ExternalService> externalServices=new ArrayList<ExternalService>();
+ private Map<String, ExternalService> externalServicesMap;
+ private List<AggregatePart> aggregateParts;
+ private List<Wire> wires=new ArrayList<Wire>();
+ private List<Import> wsdlImports=new ArrayList<Import>();
+ private Map<String, List<Import>> wsdlImportsMap;
+ private AssemblyModelContext modelContext;
+
+ /**
+ * Constructor
+ */
+ protected AggregateImpl() {
+ }
+
+ /**
+ * @see org.apache.tuscany.model.assembly.Aggregate#getName()
+ */
+ public String getName() {
+ return name;
+ }
+
+ /**
+ * @see org.apache.tuscany.model.assembly.Aggregate#setName(java.lang.String)
+ */
+ public void setName(String newName) {
+ checkNotFrozen();
+ name=newName;
+ }
+
+ /**
+ * @see org.apache.tuscany.model.assembly.Aggregate#getComponents()
+ */
+ public List<Component> getComponents() {
+ return components;
+ }
+
+ /**
+ * @see org.apache.tuscany.model.assembly.Aggregate#getComponent(java.lang.String)
+ */
+ public Component getComponent(String name) {
+ checkInitialized();
+ return componentsMap.get(name);
+ }
+
+ /**
+ * @see org.apache.tuscany.model.assembly.Aggregate#getEntryPoints()
+ */
+ public List<EntryPoint> getEntryPoints() {
+ return entryPoints;
+ }
+
+ /**
+ * @see org.apache.tuscany.model.assembly.Aggregate#getEntryPoint(java.lang.String)
+ */
+ public EntryPoint getEntryPoint(String name) {
+ checkInitialized();
+ return entryPointsMap.get(name);
+ }
+
+ /**
+ * @see org.apache.tuscany.model.assembly.Aggregate#getExternalServices()
+ */
+ public List<ExternalService> getExternalServices() {
+ return externalServices;
+ }
+
+ /**
+ * @see org.apache.tuscany.model.assembly.Aggregate#getExternalService(java.lang.String)
+ */
+ public ExternalService getExternalService(String name) {
+ checkInitialized();
+ return externalServicesMap.get(name);
+ }
+
+ /**
+ * @see org.apache.tuscany.model.assembly.Aggregate#getAggregateParts()
+ */
+ public List<AggregatePart> getAggregateParts() {
+ checkInitialized();
+ return aggregateParts;
+ }
+
+ /**
+ * @see org.apache.tuscany.model.assembly.Aggregate#getWires()
+ */
+ public List<Wire> getWires() {
+ return wires;
+ }
+
+ /**
+ * @see org.apache.tuscany.model.assembly.Aggregate#getWSDLImports()
+ */
+ public List<Import> getWSDLImports() {
+ return wsdlImports;
+ }
+
+ /**
+ * @see org.apache.tuscany.model.assembly.Aggregate#getWSDLImports(java.lang.String)
+ */
+ public List<Import> getWSDLImports(String namespace) {
+ checkInitialized();
+ return wsdlImportsMap.get(namespace);
+ }
+
+ /**
+ * @see org.apache.tuscany.model.assembly.Aggregate#getAssemblyModelContext()
+ */
+ public AssemblyModelContext getAssemblyModelContext() {
+ checkInitialized();
+ return modelContext;
+ }
+
+ /**
+ * @see org.apache.tuscany.model.assembly.Aggregate#getConfiguredService(org.apache.tuscany.model.assembly.ServiceURI)
+ */
+ public ConfiguredService getConfiguredService(ServiceURI address) {
+ String partName = address.getPartName();
+ String serviceName = address.getServiceName();
+ Component component = getComponent(partName);
+ if (component != null) {
+ if (serviceName != null) {
+ return component.getConfiguredService(serviceName);
+ } else {
+ if (!component.getConfiguredServices().isEmpty()) {
+ return component.getConfiguredServices().get(0);
+ } else {
+ return null;
+ }
+ }
+
+ } else {
+ ExternalService externalService = getExternalService(partName);
+ if (externalService != null) {
+ return externalService.getConfiguredService();
+ } else {
+ return null;
+ }
+ }
+ }
+
+ /**
+ * @see org.apache.tuscany.model.assembly.AssemblyModelObject#initialize(org.apache.tuscany.model.assembly.AssemblyModelContext)
+ */
+ public void initialize(AssemblyModelContext modelContext) {
+ if (isInitialized())
+ return;
+ super.initialize(modelContext);
+
+ // Save the model context
+ this.modelContext=modelContext;
+
+ // Populate map of WSDL imports
+ ResourceLoader resourceLoader=modelContext.getApplicationResourceLoader();
+ wsdlImportsMap = new HashMap<String, List<Import>>();
+ for (Import wsdlImport : wsdlImports) {
+ String namespace=wsdlImport.getNamespaceURI();
+ List<Import> list=wsdlImportsMap.get(namespace);
+ if (list==null) {
+ list=new ArrayList<Import>();
+ wsdlImportsMap.put(namespace, list);
+ }
+ list.add(wsdlImport);
+
+ // Load the WSDL definition if necessary
+ if (wsdlImport.getDefinition()==null) {
+ String location=wsdlImport.getLocationURI();
+ Definition definition;
+ ClassLoader ccl=Thread.currentThread().getContextClassLoader();
+ try {
+ URL url=resourceLoader.getResource(location);
+ if (url==null)
+ throw new IllegalArgumentException("Cannot find "+location);
+ definition = modelContext.getAssemblyLoader().loadDefinition(url.toString());
+ Thread.currentThread().setContextClassLoader(modelContext.getApplicationResourceLoader().getClassLoader());
+ XSDHelper xsdHelper=SDOUtil.createXSDHelper(modelContext.getTypeHelper());
+ xsdHelper.define (url.openStream(), null);
+ } catch (IOException e) {
+ throw new IllegalArgumentException(e);
+ } finally {
+ Thread.currentThread().setContextClassLoader(ccl);
+ }
+ wsdlImport.setDefinition(definition);
+ }
+ }
+
+ // Populate maps of components, entry points and external services
+ aggregateParts = new ArrayList<AggregatePart>();
+ componentsMap = new HashMap<String, Component>();
+ for (Component component : components) {
+ componentsMap.put(component.getName(), component);
+ aggregateParts.add(component);
+ component.initialize(modelContext);
+ ((AggregatePartImpl)component).setAggregate(this);
+ }
+ entryPointsMap = new HashMap<String, EntryPoint>();
+ for (EntryPoint entryPoint : entryPoints) {
+ entryPointsMap.put(entryPoint.getName(), entryPoint);
+ aggregateParts.add(entryPoint);
+ entryPoint.initialize(modelContext);
+ ((AggregatePartImpl)entryPoint).setAggregate(this);
+ }
+ externalServicesMap = new HashMap<String, ExternalService>();
+ for (ExternalService externalService : externalServices) {
+ externalServicesMap.put(externalService.getName(), externalService);
+ aggregateParts.add(externalService);
+ externalService.initialize(modelContext);
+ ((AggregatePartImpl)externalService).setAggregate(this);
+ }
+ for (Wire wire : wires) {
+ wire.initialize(modelContext);
+ }
+ }
+
+ /**
+ * @see org.apache.tuscany.model.assembly.AssemblyModelObject#freeze()
+ */
+ public void freeze() {
+ if (isFrozen())
+ return;
+ super.freeze();
+
+ // Freeze lists
+ wsdlImports=Collections.unmodifiableList(wsdlImports);
+ freeze(wsdlImports);
+ components=Collections.unmodifiableList(components);
+ freeze(components);
+ entryPoints=Collections.unmodifiableList(entryPoints);
+ freeze(entryPoints);
+ externalServices=Collections.unmodifiableList(externalServices);
+ freeze(externalServices);
+ wires=Collections.unmodifiableList(wires);
+ freeze(wires);
+ }
+
+ /**
+ * @see org.apache.tuscany.model.assembly.AssemblyModelObject#accept(org.apache.tuscany.model.assembly.AssemblyModelVisitor)
+ */
+ public boolean accept(AssemblyModelVisitor visitor) {
+ if (!super.accept(visitor))
+ return false;
+
+ if (!accept(aggregateParts, visitor))
+ return false;
+
+ if (!accept(wires, visitor))
+ return false;
+
+ return true;
+ }
+
+} //ModuleImpl
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/impl/AggregatePartImpl.java b/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/impl/AggregatePartImpl.java
new file mode 100644
index 0000000000..b9a4434c58
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/impl/AggregatePartImpl.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.impl;
+
+import org.apache.tuscany.model.assembly.Aggregate;
+import org.apache.tuscany.model.assembly.AggregatePart;
+
+/**
+ * Implementation of AggregatePart.
+ */
+public abstract class AggregatePartImpl extends ExtensibleImpl implements AggregatePart {
+ private Aggregate aggregate;
+ private String name;
+
+ /**
+ * Constructor
+ */
+ protected AggregatePartImpl() {
+ }
+
+ /**
+ * @see org.apache.tuscany.model.assembly.AggregatePart#getName()
+ */
+ public String getName() {
+ return name;
+ }
+
+ /**
+ * @see org.apache.tuscany.model.assembly.AggregatePart#setName(java.lang.String)
+ */
+ public void setName(String value) {
+ checkNotFrozen();
+ name=value;
+ }
+
+ /**
+ * @see org.apache.tuscany.model.assembly.AggregatePart#getAggregate()
+ */
+ public Aggregate getAggregate() {
+ checkInitialized();
+ return aggregate;
+ }
+
+ /**
+ * Sets the aggregate containing this aggregate part.
+ * @param aggregate
+ */
+ protected void setAggregate(Aggregate aggregate) {
+ checkNotFrozen();
+ this.aggregate=aggregate;
+ }
+
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/impl/AssemblyFactoryImpl.java b/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/impl/AssemblyFactoryImpl.java
new file mode 100644
index 0000000000..0c2550ab10
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/impl/AssemblyFactoryImpl.java
@@ -0,0 +1,204 @@
+/**
+ *
+ * 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.AggregatePart;
+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.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.SimpleComponent;
+import org.apache.tuscany.model.assembly.Subsystem;
+import org.apache.tuscany.model.assembly.Wire;
+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();
+ }
+
+ /**
+ * @see org.apache.tuscany.model.assembly.AssemblyFactory#createSimpleComponent()
+ */
+ public SimpleComponent createSimpleComponent() {
+ return new SimpleComponentImpl();
+ }
+
+ /**
+ * @see org.apache.tuscany.model.assembly.AssemblyFactory#createComponentType()
+ */
+ public ComponentType createComponentType() {
+ return new ComponentTypeImpl();
+ }
+
+ /**
+ * @see org.apache.tuscany.model.assembly.AssemblyFactory#createEntryPoint()
+ */
+ public EntryPoint createEntryPoint() {
+ return new EntryPointImpl();
+ }
+
+ /**
+ * @see org.apache.tuscany.model.assembly.AssemblyFactory#createExternalService()
+ */
+ public ExternalService createExternalService() {
+ return new ExternalServiceImpl();
+ }
+
+ /**
+ * @see org.apache.tuscany.model.assembly.AssemblyFactory#createJavaServiceContract()
+ */
+ public JavaServiceContract createJavaServiceContract() {
+ return new JavaServiceContractImpl();
+ }
+
+ /**
+ * @see org.apache.tuscany.model.assembly.AssemblyFactory#createModule()
+ */
+ public Module createModule() {
+ return new ModuleImpl();
+ }
+
+ /**
+ * @see org.apache.tuscany.model.assembly.AssemblyFactory#createModuleFragment()
+ */
+ public ModuleFragment createModuleFragment() {
+ return new ModuleFragmentImpl();
+ }
+
+ /**
+ * @see org.apache.tuscany.model.assembly.AssemblyFactory#createModuleComponent()
+ */
+ public ModuleComponent createModuleComponent() {
+ return new ModuleComponentImpl();
+ }
+
+ /**
+ * @see org.apache.tuscany.model.assembly.AssemblyFactory#createProperty()
+ */
+ public Property createProperty() {
+ return new PropertyImpl();
+ }
+
+ /**
+ * @see org.apache.tuscany.model.assembly.AssemblyFactory#createConfiguredProperty()
+ */
+ public ConfiguredProperty createConfiguredProperty() {
+ return new ConfiguredPropertyImpl();
+ }
+
+ /**
+ * @see org.apache.tuscany.model.assembly.AssemblyFactory#createReference()
+ */
+ public Reference createReference() {
+ return new ReferenceImpl();
+ }
+
+ /**
+ * @see org.apache.tuscany.model.assembly.AssemblyFactory#createConfiguredReference()
+ */
+ public ConfiguredReference createConfiguredReference() {
+ return new ConfiguredReferenceImpl();
+ }
+
+ /**
+ * @see org.apache.tuscany.model.assembly.AssemblyFactory#createService()
+ */
+ public Service createService() {
+ return new ServiceImpl();
+ }
+
+ /**
+ * @see org.apache.tuscany.model.assembly.AssemblyFactory#createConfiguredService()
+ */
+ public ConfiguredService createConfiguredService() {
+ return new ConfiguredServiceImpl();
+ }
+
+ /**
+ * @see org.apache.tuscany.model.assembly.AssemblyFactory#createSubsystem()
+ */
+ public Subsystem createSubsystem() {
+ return new SubsystemImpl();
+ }
+
+ /**
+ * @see org.apache.tuscany.model.assembly.AssemblyFactory#createWSDLServiceContract()
+ */
+ public WSDLServiceContract createWSDLServiceContract() {
+ return new WSDLServiceContractImpl();
+ }
+
+ /**
+ * @see org.apache.tuscany.model.assembly.AssemblyFactory#createServiceURI(java.lang.String)
+ */
+ public ServiceURI createServiceURI(String uri) {
+ return new ServiceURIImpl(uri);
+ }
+
+ /**
+ * @see org.apache.tuscany.model.assembly.AssemblyFactory#createServiceURI(org.apache.tuscany.model.assembly.ModuleComponent, java.lang.String)
+ */
+ public ServiceURI createServiceURI(ModuleComponent moduleComponent, String serviceName) {
+ return new ServiceURIImpl(moduleComponent, serviceName);
+ }
+
+ /*
+ * @see org.apache.tuscany.model.assembly.AssemblyFactory#createServiceURI(org.apache.tuscany.model.assembly.ModuleComponent, org.apache.tuscany.model.assembly.AggregatePart, org.apache.tuscany.model.assembly.ConfiguredPort)
+ */
+ public ServiceURI createServiceURI(ModuleComponent moduleComponent, AggregatePart aggregatePart, ConfiguredPort configuredPort) {
+ return new ServiceURIImpl(moduleComponent, aggregatePart, configuredPort);
+ }
+
+ /**
+ * @see org.apache.tuscany.model.assembly.AssemblyFactory#createQName(java.lang.String)
+ */
+ public QName createQName(String uri) {
+ int h = uri.indexOf('#');
+ return new QName(uri.substring(0, h), uri.substring(h + 1));
+ }
+
+ /**
+ * @see org.apache.tuscany.model.assembly.AssemblyFactory#createWire()
+ */
+ public Wire createWire() {
+ return new WireImpl();
+ }
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/impl/AssemblyModelContextImpl.java b/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/impl/AssemblyModelContextImpl.java
new file mode 100644
index 0000000000..221b3e0af6
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/impl/AssemblyModelContextImpl.java
@@ -0,0 +1,92 @@
+/**
+ *
+ * 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.AssemblyModelContext;
+import org.apache.tuscany.model.assembly.loader.AssemblyModelLoader;
+import org.apache.tuscany.sdo.util.SDOUtil;
+
+import commonj.sdo.helper.TypeHelper;
+
+/**
+ */
+public class AssemblyModelContextImpl implements AssemblyModelContext {
+
+ private final AssemblyFactory assemblyFactory;
+ private final AssemblyModelLoader assemblyLoader;
+ private final ResourceLoader systemResourceLoader;
+ private final ResourceLoader applicationResourceLoader;
+ private final TypeHelper typeHelper;
+
+ public AssemblyModelContextImpl(AssemblyModelLoader assemblyLoader, ResourceLoader resourceLoader) {
+ this(new AssemblyFactoryImpl(), assemblyLoader, resourceLoader, resourceLoader);
+ }
+
+ public AssemblyModelContextImpl(AssemblyFactory assemblyFactory, AssemblyModelLoader assemblyLoader, ResourceLoader resourceLoader) {
+ this(assemblyFactory, assemblyLoader, resourceLoader, resourceLoader);
+ }
+
+ public AssemblyModelContextImpl(AssemblyFactory assemblyFactory, AssemblyModelLoader assemblyLoader, ResourceLoader resourceLoader, ResourceLoader artifactLoader) {
+ this(assemblyFactory, assemblyLoader, resourceLoader, artifactLoader, SDOUtil.createTypeHelper());
+ }
+
+ public AssemblyModelContextImpl(AssemblyFactory assemblyFactory, AssemblyModelLoader assemblyLoader, ResourceLoader resourceLoader, ResourceLoader artifactLoader, TypeHelper typeHelper) {
+ this.assemblyFactory = assemblyFactory;
+ this.assemblyLoader = assemblyLoader;
+ this.systemResourceLoader = resourceLoader;
+ this.applicationResourceLoader = artifactLoader;
+ this.typeHelper=typeHelper;
+
+ //FIXME the caller should configure the assemblyLoader himself
+ if (assemblyLoader!=null)
+ assemblyLoader.setModelContext(this);
+ }
+
+ /**
+ * @see org.apache.tuscany.model.assembly.AssemblyModelContext#getAssemblyFactory()
+ */
+ public AssemblyFactory getAssemblyFactory() {
+ return assemblyFactory;
+ }
+
+ /**
+ * @see org.apache.tuscany.model.assembly.AssemblyModelContext#getSystemResourceLoader()
+ */
+ public ResourceLoader getSystemResourceLoader() {
+ return systemResourceLoader;
+ }
+
+ public ResourceLoader getApplicationResourceLoader() {
+ return applicationResourceLoader;
+ }
+
+ /**
+ * @see org.apache.tuscany.model.assembly.AssemblyModelContext#getAssemblyLoader()
+ */
+ public AssemblyModelLoader getAssemblyLoader() {
+ return assemblyLoader;
+ }
+
+ /**
+ * @see org.apache.tuscany.model.assembly.AssemblyModelContext#getTypeHelper()
+ */
+ public TypeHelper getTypeHelper() {
+ return typeHelper;
+ }
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/impl/AssemblyModelObjectImpl.java b/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/impl/AssemblyModelObjectImpl.java
new file mode 100644
index 0000000000..356fc4f0a9
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/impl/AssemblyModelObjectImpl.java
@@ -0,0 +1,132 @@
+/**
+ *
+ * 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 org.apache.tuscany.model.assembly.AssemblyModelContext;
+import org.apache.tuscany.model.assembly.AssemblyModelObject;
+import org.apache.tuscany.model.assembly.AssemblyModelVisitor;
+
+/**
+ * A base class for assembly model objects.
+ */
+public abstract class AssemblyModelObjectImpl implements AssemblyModelObject {
+
+ private boolean frozen;
+ private boolean initialized;
+
+ /**
+ * Constructor
+ */
+ protected AssemblyModelObjectImpl() {
+ }
+
+ /**
+ * @see org.apache.tuscany.model.assembly.AssemblyModelObject#accept(org.apache.tuscany.model.assembly.AssemblyModelVisitor)
+ */
+ public boolean accept(AssemblyModelVisitor visitor) {
+ return visitor.visit(this);
+ }
+
+ /**
+ * Walk a visitor through a collection of model objects.
+ * @param collection
+ * @param visitor
+ * @return
+ */
+ protected boolean accept(Collection collection, AssemblyModelVisitor visitor) {
+ for (Object member : collection) {
+ if (member instanceof AssemblyModelObject) {
+ if (!((AssemblyModelObject)member).accept(visitor))
+ return false;
+ }
+ }
+ return true;
+ }
+
+ /**
+ * @see org.apache.tuscany.model.assembly.AssemblyModelObject#freeze()
+ */
+ public void freeze() {
+ if (!frozen)
+ frozen=true;
+ }
+
+ /**
+ * Returns true if the object is frozen
+ */
+ protected boolean isFrozen() {
+ return frozen;
+ }
+
+ /**
+ * Freeze members of a collection
+ */
+ protected void freeze(Collection collection) {
+ for (Object member : collection) {
+ if (member instanceof AssemblyModelObject) {
+ ((AssemblyModelObject)member).freeze();
+ }
+ }
+ }
+
+ /**
+ * 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");
+ }
+
+ /**
+ * @see org.apache.tuscany.model.assembly.AssemblyModelObject#initialize(org.apache.tuscany.model.assembly.AssemblyModelContext)
+ */
+ public void initialize(AssemblyModelContext 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, AssemblyModelContext modelContext) {
+ for (Object member : collection) {
+ if (member instanceof AssemblyModelObject) {
+ ((AssemblyModelObject)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/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/impl/BindingImpl.java b/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/impl/BindingImpl.java
new file mode 100644
index 0000000000..cd1f0e2cb4
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/impl/BindingImpl.java
@@ -0,0 +1,96 @@
+/**
+ *
+ * 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.AssemblyModelContext;
+import org.apache.tuscany.model.assembly.AssemblyModelVisitor;
+import org.apache.tuscany.model.assembly.Binding;
+
+/**
+ * An implementation of Binding.
+ */
+public class BindingImpl extends ExtensibleImpl implements Binding {
+
+ private String uri;
+ private Object runtimeConfiguration;
+
+ /**
+ * Constructor
+ */
+ protected BindingImpl() {
+ }
+
+ /**
+ * @see org.apache.tuscany.model.assembly.Binding#getURI()
+ */
+ public String getURI() {
+ return uri;
+ }
+
+ /**
+ * @see org.apache.tuscany.model.assembly.Binding#setURI(java.lang.String)
+ */
+ public void setURI(String value) {
+ checkNotFrozen();
+ uri=value;
+ }
+
+ /**
+ * @see org.apache.tuscany.model.assembly.AssemblyModelObject#initialize(org.apache.tuscany.model.assembly.AssemblyModelContext)
+ */
+ public void initialize(AssemblyModelContext modelContext) {
+ if (isInitialized())
+ return;
+ super.initialize(modelContext);
+ }
+
+ /**
+ * @see org.apache.tuscany.model.assembly.AssemblyModelObject#freeze()
+ */
+ public void freeze() {
+ if (isFrozen())
+ return;
+ super.freeze();
+
+ }
+
+ /**
+ * @see org.apache.tuscany.model.assembly.RuntimeConfigurationHolder#getRuntimeConfiguration()
+ */
+ public Object getRuntimeConfiguration() {
+ return runtimeConfiguration;
+ }
+
+ /**
+ * @see org.apache.tuscany.model.assembly.RuntimeConfigurationHolder#setRuntimeConfiguration(java.lang.Object)
+ */
+ public void setRuntimeConfiguration(Object configuration) {
+ checkNotFrozen();
+ this.runtimeConfiguration = configuration;
+ }
+
+ /**
+ * @see org.apache.tuscany.model.assembly.impl.AggregateImpl#accept(org.apache.tuscany.model.assembly.AssemblyModelVisitor)
+ */
+ public boolean accept(AssemblyModelVisitor visitor) {
+ if (!super.accept(visitor))
+ return false;
+
+ return true;
+ }
+
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/impl/ComponentImpl.java b/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/impl/ComponentImpl.java
new file mode 100644
index 0000000000..2033ebe7f7
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/impl/ComponentImpl.java
@@ -0,0 +1,222 @@
+/**
+ *
+ * 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.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.tuscany.model.assembly.AssemblyFactory;
+import org.apache.tuscany.model.assembly.AssemblyModelContext;
+import org.apache.tuscany.model.assembly.AssemblyModelVisitor;
+import org.apache.tuscany.model.assembly.Component;
+import org.apache.tuscany.model.assembly.ComponentImplementation;
+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.Property;
+import org.apache.tuscany.model.assembly.Reference;
+import org.apache.tuscany.model.assembly.Service;
+
+/**
+ * An implementation of Component.
+ */
+public abstract class ComponentImpl extends AggregatePartImpl implements Component {
+
+ private List<ConfiguredReference> configuredReferences=new ArrayList<ConfiguredReference>();
+ private Map<String, ConfiguredReference> configuredReferencesMap;
+ private List<ConfiguredService> configuredServices=new ArrayList<ConfiguredService>();
+ private Map<String, ConfiguredService> configuredServicesMap;
+ private List<ConfiguredProperty> configuredProperties=new ArrayList<ConfiguredProperty>();
+ private Map<String, ConfiguredProperty> configuredPropertiesMap;
+ private ComponentImplementation implementation;
+
+ /**
+ * @see org.apache.tuscany.model.assembly.Component#getComponentImplementation()
+ */
+ public ComponentImplementation getComponentImplementation() {
+ return implementation;
+ }
+
+ /**
+ * @see org.apache.tuscany.model.assembly.Component#setComponentImplementation(org.apache.tuscany.model.assembly.ComponentImplementation)
+ */
+ public void setComponentImplementation(ComponentImplementation value) {
+ checkNotFrozen();
+ implementation=value;
+ }
+
+ /**
+ * @see org.apache.tuscany.model.assembly.Component#getConfiguredServices()
+ */
+ public List<ConfiguredService> getConfiguredServices() {
+ return configuredServices;
+ }
+
+ public ConfiguredService getConfiguredService(String name) {
+ checkInitialized();
+ return configuredServicesMap.get(name);
+ }
+
+ /**
+ * @see org.apache.tuscany.model.assembly.Component#getConfiguredReferences()
+ */
+ public List<ConfiguredReference> getConfiguredReferences() {
+ return configuredReferences;
+ }
+
+ /**
+ * @see org.apache.tuscany.model.assembly.Component#getConfiguredReference(java.lang.String)
+ */
+ public ConfiguredReference getConfiguredReference(String name) {
+ checkInitialized();
+ return configuredReferencesMap.get(name);
+ }
+
+ /**
+ * @see org.apache.tuscany.model.assembly.Component#getConfiguredProperties()
+ */
+ public List<ConfiguredProperty> getConfiguredProperties() {
+ return configuredProperties;
+ }
+
+ /**
+ * @see org.apache.tuscany.model.assembly.Component#getConfiguredProperty(java.lang.String)
+ */
+ public ConfiguredProperty getConfiguredProperty(String name) {
+ checkInitialized();
+ return configuredPropertiesMap.get(name);
+ }
+
+ /**
+ * @see org.apache.tuscany.model.assembly.AssemblyModelObject#initialize(org.apache.tuscany.model.assembly.AssemblyModelContext)
+ */
+ public void initialize(AssemblyModelContext modelContext) {
+ if (isInitialized())
+ return;
+ super.initialize(modelContext);
+
+ // Initialize the implementation
+ ComponentImplementation implementation = getComponentImplementation();
+ if (implementation != null) {
+ implementation.initialize(modelContext);
+ }
+
+ // Derive the configured services, references and properties from the component implementation
+ //FIXME we have two options here: either just index the configured services, references and properties
+ // that we find in the corresponding lists, or derive them from the services, references and properties on
+ // the component type, for now just check if the lists are empty or not to determine which option to go with
+ configuredServicesMap = new HashMap<String, ConfiguredService>();
+ configuredReferencesMap = new HashMap<String, ConfiguredReference>();
+ configuredPropertiesMap = new HashMap<String, ConfiguredProperty>();
+ if (configuredServices.isEmpty() && configuredReferences.isEmpty() && configuredProperties.isEmpty()) {
+ if (implementation != null) {
+ AssemblyFactory factory = modelContext.getAssemblyFactory();
+ for (Service service : implementation.getComponentType().getServices()) {
+ ConfiguredService configuredService = factory.createConfiguredService();
+ configuredService.setPort(service);
+ configuredServices.add(configuredService);
+ configuredServicesMap.put(service.getName(), configuredService);
+ ((ConfiguredPortImpl)configuredService).setAggregatePart(this);
+ configuredService.initialize(modelContext);
+ }
+
+ for (Reference reference : implementation.getComponentType().getReferences()) {
+ ConfiguredReference configuredReference = factory.createConfiguredReference();
+ configuredReference.setPort(reference);
+ configuredReferences.add(configuredReference);
+ configuredReferencesMap.put(reference.getName(), configuredReference);
+ ((ConfiguredPortImpl)configuredReference).setAggregatePart(this);
+ configuredReference.initialize(modelContext);
+ }
+
+ // Derive configured properties from the properties on the component type
+ for (Property property : implementation.getComponentType().getProperties()) {
+ ConfiguredProperty configuredProperty = factory.createConfiguredProperty();
+ configuredProperty.setProperty(property);
+ configuredProperties.add(configuredProperty);
+ configuredPropertiesMap.put(property.getName(), configuredProperty);
+ configuredProperty.initialize(modelContext);
+ }
+
+ }
+ } else {
+
+ // Just populate the maps of services, references and properties from the contents of
+ // the corresponding lists
+ for (ConfiguredService configuredService : configuredServices) {
+ configuredServicesMap.put(configuredService.getService().getName(), configuredService);
+ ((ConfiguredPortImpl)configuredService).setAggregatePart(this);
+ configuredService.initialize(modelContext);
+ }
+
+ for (ConfiguredReference configuredReference : configuredReferences) {
+ configuredReferencesMap.put(configuredReference.getReference().getName(), configuredReference);
+ ((ConfiguredPortImpl)configuredReference).setAggregatePart(this);
+ configuredReference.initialize(modelContext);
+ }
+
+ for (ConfiguredProperty configuredProperty : configuredProperties) {
+ configuredPropertiesMap.put(configuredProperty.getProperty().getName(), configuredProperty);
+ configuredProperty.initialize(modelContext);
+ }
+ }
+ }
+
+ /**
+ * @see org.apache.tuscany.model.assembly.AssemblyModelObject#freeze()
+ */
+ public void freeze() {
+ if (isFrozen())
+ return;
+ super.freeze();
+
+ // Freeze configured services, references and properties
+ configuredServices=Collections.unmodifiableList(configuredServices);
+ freeze(configuredServices);
+ configuredReferences=Collections.unmodifiableList(configuredReferences);
+ freeze(configuredReferences);
+ configuredProperties=Collections.unmodifiableList(configuredProperties);
+ freeze(configuredProperties);
+ if (implementation!=null)
+ implementation.freeze();
+ }
+
+ /**
+ * @see org.apache.tuscany.model.assembly.impl.AssemblyModelObjectImpl#accept(org.apache.tuscany.model.assembly.AssemblyModelVisitor)
+ */
+ public boolean accept(AssemblyModelVisitor 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/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/impl/ComponentImplementationImpl.java b/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/impl/ComponentImplementationImpl.java
new file mode 100644
index 0000000000..f14a86c713
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/impl/ComponentImplementationImpl.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.assembly.impl;
+
+import org.apache.tuscany.model.assembly.AssemblyModelContext;
+import org.apache.tuscany.model.assembly.AssemblyModelVisitor;
+import org.apache.tuscany.model.assembly.ComponentImplementation;
+import org.apache.tuscany.model.assembly.ComponentType;
+
+/**
+ * An implementation of ComponentImplementation.
+ */
+public class ComponentImplementationImpl extends ExtensibleImpl implements ComponentImplementation {
+
+ private ComponentType componentType;
+ private Object runtimeConfiguration;
+
+ /**
+ * Constructor
+ */
+ protected ComponentImplementationImpl() {
+ }
+
+ /**
+ * @see org.apache.tuscany.model.assembly.ComponentImplementation#getComponentType()
+ */
+ public ComponentType getComponentType() {
+ return componentType;
+ }
+
+ /**
+ * @see org.apache.tuscany.model.assembly.ComponentImplementation#setComponentType(org.apache.tuscany.model.assembly.ComponentType)
+ */
+ public void setComponentType(ComponentType componentType) {
+ checkNotFrozen();
+ this.componentType=componentType;
+ }
+
+ /**
+ * @see org.apache.tuscany.model.assembly.AssemblyModelObject#initialize(org.apache.tuscany.model.assembly.AssemblyModelContext)
+ */
+ public void initialize(AssemblyModelContext modelContext) {
+ if (isInitialized())
+ return;
+ super.initialize(modelContext);
+
+ if (componentType!=null)
+ componentType.initialize(modelContext);
+ }
+
+ /**
+ * @see org.apache.tuscany.model.assembly.AssemblyModelObject#freeze()
+ */
+ public void freeze() {
+ if (isFrozen())
+ return;
+ super.freeze();
+
+ // Freeze component type
+ if (componentType!=null)
+ componentType.freeze();
+ }
+
+ /**
+ * @see org.apache.tuscany.model.assembly.RuntimeConfigurationHolder#getRuntimeConfiguration()
+ */
+ public Object getRuntimeConfiguration() {
+ return runtimeConfiguration;
+ }
+
+ /**
+ * @see org.apache.tuscany.model.assembly.RuntimeConfigurationHolder#setRuntimeConfiguration(java.lang.Object)
+ */
+ public void setRuntimeConfiguration(Object configuration) {
+ checkNotFrozen();
+ this.runtimeConfiguration = configuration;
+ }
+
+ /**
+ * @see org.apache.tuscany.model.assembly.impl.AggregateImpl#accept(org.apache.tuscany.model.assembly.AssemblyModelVisitor)
+ */
+ public boolean accept(AssemblyModelVisitor visitor) {
+ if (!super.accept(visitor))
+ return false;
+
+ if (componentType!=null) {
+ if (!componentType.accept(visitor))
+ return false;
+ }
+
+ return true;
+ }
+
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/impl/ComponentTypeImpl.java b/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/impl/ComponentTypeImpl.java
new file mode 100644
index 0000000000..baef2e9b2a
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/impl/ComponentTypeImpl.java
@@ -0,0 +1,152 @@
+/**
+ *
+ * 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.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.tuscany.model.assembly.AssemblyModelContext;
+import org.apache.tuscany.model.assembly.AssemblyModelVisitor;
+import org.apache.tuscany.model.assembly.ComponentType;
+import org.apache.tuscany.model.assembly.Property;
+import org.apache.tuscany.model.assembly.Reference;
+import org.apache.tuscany.model.assembly.Service;
+
+/**
+ * An implementation of ComponentType.
+ */
+public class ComponentTypeImpl extends ExtensibleImpl implements ComponentType {
+
+ private List<Reference> references=new ArrayList<Reference>();
+ private Map<String, Reference> referencesMap;
+ private List<Service> services=new ArrayList<Service>();
+ private Map<String, Service> servicesMap;
+ private List<Property> properties=new ArrayList<Property>();
+ private Map<String, Property> propertiesMap;
+
+ /**
+ * Constructor
+ */
+ protected ComponentTypeImpl() {
+ }
+
+ /**
+ * @see org.apache.tuscany.model.assembly.ComponentType#getReferences()
+ */
+ public List<Reference> getReferences() {
+ return references;
+ }
+
+ /**
+ * @see org.apache.tuscany.model.assembly.ComponentType#getReference(java.lang.String)
+ */
+ public Reference getReference(String name) {
+ checkInitialized();
+ return referencesMap.get(name);
+ }
+
+ /**
+ * @see org.apache.tuscany.model.assembly.ComponentType#getServices()
+ */
+ public List<Service> getServices() {
+ return services;
+ }
+
+ /**
+ * @see org.apache.tuscany.model.assembly.ComponentType#getService(java.lang.String)
+ */
+ public Service getService(String name) {
+ checkInitialized();
+ return servicesMap.get(name);
+ }
+
+ /**
+ * @see org.apache.tuscany.model.assembly.ComponentType#getProperties()
+ */
+ public List<Property> getProperties() {
+ return properties;
+ }
+
+ /**
+ * @see org.apache.tuscany.model.assembly.ComponentType#getProperty(java.lang.String)
+ */
+ public Property getProperty(String name) {
+ checkInitialized();
+ return propertiesMap.get(name);
+ }
+
+ /**
+ * @see org.apache.tuscany.model.assembly.AssemblyModelObject#initialize(org.apache.tuscany.model.assembly.AssemblyModelContext)
+ */
+ public void initialize(AssemblyModelContext modelContext) {
+ if (isInitialized())
+ return;
+ super.initialize(modelContext);
+
+ // Populate maps of references, properties and services
+ referencesMap = new HashMap<String, Reference>();
+ for (Reference reference : references) {
+ referencesMap.put(reference.getName(), reference);
+ reference.initialize(modelContext);
+ }
+ propertiesMap = new HashMap<String, Property>();
+ for (Property property : properties) {
+ propertiesMap.put(property.getName(), property);
+ property.initialize(modelContext);
+ }
+ servicesMap = new HashMap<String, Service>();
+ for (Service service : services) {
+ servicesMap.put(service.getName(), service);
+ service.initialize(modelContext);
+ }
+ }
+
+ public void freeze() {
+ if (isFrozen())
+ return;
+ super.freeze();
+
+ // Freeze lists of services, references and properties
+ services=Collections.unmodifiableList(services);
+ freeze(services);
+ references=Collections.unmodifiableList(references);
+ freeze(references);
+ properties=Collections.unmodifiableList(properties);
+ freeze(properties);
+ }
+
+ /**
+ * @see org.apache.tuscany.model.assembly.impl.AssemblyModelObjectImpl#accept(org.apache.tuscany.model.assembly.AssemblyModelVisitor)
+ */
+ public boolean accept(AssemblyModelVisitor 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/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/impl/ConfiguredPortImpl.java b/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/impl/ConfiguredPortImpl.java
new file mode 100644
index 0000000000..9662d13dc7
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/impl/ConfiguredPortImpl.java
@@ -0,0 +1,142 @@
+/**
+ *
+ * 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.AggregatePart;
+import org.apache.tuscany.model.assembly.AssemblyModelContext;
+import org.apache.tuscany.model.assembly.AssemblyModelVisitor;
+import org.apache.tuscany.model.assembly.ConfiguredPort;
+import org.apache.tuscany.model.assembly.Port;
+
+/**
+ * Implementation of ConfiguredPort.
+ */
+public abstract class ConfiguredPortImpl extends AssemblyModelObjectImpl implements ConfiguredPort {
+ private AggregatePart aggregatePart;
+ private Port port;
+
+ private Object runtimeConfiguration;
+ private Object proxyFactory;
+
+ /**
+ * Constructor
+ */
+ protected ConfiguredPortImpl() {
+ }
+
+ /**
+ * @see org.apache.tuscany.model.assembly.ConfiguredPort#getPort()
+ */
+ public Port getPort() {
+ return port;
+ }
+
+ /**
+ * @see org.apache.tuscany.model.assembly.ConfiguredPort#setPort(org.apache.tuscany.model.assembly.Port)
+ */
+ public void setPort(Port port) {
+ checkNotFrozen();
+ this.port = port;
+ }
+
+ /**
+ * @see org.apache.tuscany.model.assembly.ConfiguredPort#getAggregatePart()
+ */
+ public AggregatePart getAggregatePart() {
+ checkInitialized();
+ return aggregatePart;
+ }
+
+ /**
+ * Sets the aggregate part containing this configured port.
+ * @param aggregatePart
+ */
+ protected void setAggregatePart(AggregatePart aggregatePart) {
+ checkNotFrozen();
+ this.aggregatePart=aggregatePart;
+ }
+
+ /**
+ * @see org.apache.tuscany.model.assembly.ConfiguredPort#getProxyFactory()
+ */
+ public Object getProxyFactory() {
+ return proxyFactory;
+ }
+
+ /**
+ * @see org.apache.tuscany.model.assembly.ConfiguredPort#setProxyFactory(java.lang.Object)
+ */
+ public void setProxyFactory(Object proxyFactory) {
+ checkNotFrozen();
+ this.proxyFactory = proxyFactory;
+ }
+
+ /**
+ * @see org.apache.tuscany.model.assembly.RuntimeConfigurationHolder#getRuntimeConfiguration()
+ */
+ public Object getRuntimeConfiguration() {
+ return runtimeConfiguration;
+ }
+
+ /**
+ * @see org.apache.tuscany.model.assembly.RuntimeConfigurationHolder#setRuntimeConfiguration(java.lang.Object)
+ */
+ public void setRuntimeConfiguration(Object configuration) {
+ checkNotFrozen();
+ runtimeConfiguration = configuration;
+ }
+
+ /**
+ * @see org.apache.tuscany.model.assembly.impl.AssemblyModelObjectImpl#initialize(org.apache.tuscany.model.assembly.AssemblyModelContext)
+ */
+ public void initialize(AssemblyModelContext modelContext) {
+ if (isInitialized())
+ return;
+ super.initialize(modelContext);
+
+ if (port!=null)
+ port.initialize(modelContext);
+ }
+
+ /**
+ * @see org.apache.tuscany.model.assembly.impl.AssemblyModelObjectImpl#freeze()
+ */
+ public void freeze() {
+ if (isFrozen())
+ return;
+ super.freeze();
+
+ if (port!=null)
+ port.freeze();
+ }
+
+ /**
+ * @see org.apache.tuscany.model.assembly.impl.AssemblyModelObjectImpl#accept(org.apache.tuscany.model.assembly.AssemblyModelVisitor)
+ */
+ public boolean accept(AssemblyModelVisitor visitor) {
+ if (!super.accept(visitor))
+ return false;
+
+ if (port!=null) {
+ if (!port.accept(visitor))
+ return false;
+ }
+
+ return true;
+ }
+
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/impl/ConfiguredPropertyImpl.java b/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/impl/ConfiguredPropertyImpl.java
new file mode 100644
index 0000000000..477c62ad44
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/impl/ConfiguredPropertyImpl.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 org.apache.tuscany.model.assembly.AssemblyModelContext;
+import org.apache.tuscany.model.assembly.AssemblyModelVisitor;
+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 AssemblyModelObjectImpl implements ConfiguredProperty {
+ private Property property;
+ private OverrideOption overrideOption;
+ private Object value;
+
+ /**
+ * Constructor
+ */
+ protected ConfiguredPropertyImpl() {
+ }
+
+ /**
+ * @see org.apache.tuscany.model.assembly.ConfiguredProperty#getProperty()
+ */
+ public Property getProperty() {
+ return property;
+ }
+
+ /**
+ * @see org.apache.tuscany.model.assembly.ConfiguredProperty#setProperty(org.apache.tuscany.model.assembly.Property)
+ */
+ public void setProperty(Property property) {
+ checkNotFrozen();
+ this.property = property;
+ }
+
+ /**
+ * @see org.apache.tuscany.model.assembly.ConfiguredProperty#getValue()
+ */
+ public Object getValue() {
+ return value;
+ }
+
+ /**
+ * @see org.apache.tuscany.model.assembly.ConfiguredProperty#setValue(java.lang.Object)
+ */
+ public void setValue(Object value) {
+ checkNotFrozen();
+ this.value = value;
+ }
+
+ /*
+ * @see org.apache.tuscany.model.assembly.ConfiguredProperty#getOverrideOption()
+ */
+ public OverrideOption getOverrideOption() {
+ return overrideOption;
+ }
+
+ /*
+ * @see org.apache.tuscany.model.assembly.ConfiguredProperty#setOverrideOption(org.apache.tuscany.model.assembly.OverrideOption)
+ */
+ public void setOverrideOption(OverrideOption value) {
+ checkNotFrozen();
+ this.overrideOption=value;
+ }
+
+ /**
+ * @see org.apache.tuscany.model.assembly.impl.AssemblyModelObjectImpl#initialize(org.apache.tuscany.model.assembly.AssemblyModelContext)
+ */
+ public void initialize(AssemblyModelContext modelContext) {
+ if (isInitialized())
+ return;
+ super.initialize(modelContext);
+
+ if (property!=null)
+ property.initialize(modelContext);
+ }
+
+ /**
+ * @see org.apache.tuscany.model.assembly.impl.AssemblyModelObjectImpl#freeze()
+ */
+ public void freeze() {
+ if (isFrozen())
+ return;
+ super.freeze();
+
+ if (property!=null)
+ property.freeze();
+ }
+
+ /**
+ * @see org.apache.tuscany.model.assembly.impl.AssemblyModelObjectImpl#accept(org.apache.tuscany.model.assembly.AssemblyModelVisitor)
+ */
+ public boolean accept(AssemblyModelVisitor visitor) {
+ if (!super.accept(visitor))
+ return false;
+
+ if (property!=null) {
+ if (!property.accept(visitor))
+ return false;
+ }
+
+ return true;
+ }
+
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/impl/ConfiguredReferenceImpl.java b/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/impl/ConfiguredReferenceImpl.java
new file mode 100644
index 0000000000..c9bc9b332f
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/impl/ConfiguredReferenceImpl.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 java.util.ArrayList;
+import java.util.Collections;
+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 implements ConfiguredReference {
+
+ private List<ConfiguredService> targetConfiguredServices = new ArrayList<ConfiguredService>();
+
+ /**
+ * Constructor
+ */
+ protected ConfiguredReferenceImpl() {
+ }
+
+ /**
+ * @see org.apache.tuscany.model.assembly.ConfiguredReference#getReference()
+ */
+ public Reference getReference() {
+ return (Reference) super.getPort();
+ }
+
+ /**
+ * @see org.apache.tuscany.model.assembly.ConfiguredReference#setReference(org.apache.tuscany.model.assembly.Reference)
+ */
+ public void setReference(Reference reference) {
+ checkNotFrozen();
+ super.setPort(reference);
+ }
+
+ /**
+ * @see org.apache.tuscany.model.assembly.ConfiguredReference#getTargetConfiguredServices()
+ */
+ public List<ConfiguredService> getTargetConfiguredServices() {
+ return targetConfiguredServices;
+ }
+
+ /**
+ * @see org.apache.tuscany.model.assembly.impl.ConfiguredPortImpl#freeze()
+ */
+ public void freeze() {
+ super.freeze();
+
+ // Freeze list of configured services
+ targetConfiguredServices=Collections.unmodifiableList(targetConfiguredServices);
+ }
+
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/impl/ConfiguredServiceImpl.java b/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/impl/ConfiguredServiceImpl.java
new file mode 100644
index 0000000000..3e5d1a9cf5
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/impl/ConfiguredServiceImpl.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.impl;
+
+import org.apache.tuscany.model.assembly.ConfiguredService;
+import org.apache.tuscany.model.assembly.Service;
+
+/**
+ * An implementation of ConfiguredService.
+ */
+public class ConfiguredServiceImpl extends ConfiguredPortImpl implements ConfiguredService {
+
+ /**
+ * Constructor
+ */
+ protected ConfiguredServiceImpl() {
+ }
+
+ /**
+ * @see org.apache.tuscany.model.assembly.ConfiguredService#getService()
+ */
+ public Service getService() {
+ return (Service) super.getPort();
+ }
+
+ /**
+ * @see org.apache.tuscany.model.assembly.ConfiguredService#setService(org.apache.tuscany.model.assembly.Service)
+ */
+ public void setService(Service service) {
+ checkNotFrozen();
+ super.setPort(service);
+ }
+
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/impl/EntryPointImpl.java b/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/impl/EntryPointImpl.java
new file mode 100644
index 0000000000..0d39089be9
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/impl/EntryPointImpl.java
@@ -0,0 +1,145 @@
+/**
+ *
+ * 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.Collections;
+import java.util.List;
+
+import org.apache.tuscany.model.assembly.AssemblyModelContext;
+import org.apache.tuscany.model.assembly.AssemblyModelVisitor;
+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 AggregatePartImpl implements EntryPoint {
+
+ private ConfiguredService configuredService;
+ private ConfiguredReference configuredReference;
+ private List<Binding> bindings=new ArrayList<Binding>();
+
+ /**
+ * Constructor
+ */
+ protected EntryPointImpl() {
+ }
+
+ /**
+ * @see org.apache.tuscany.model.assembly.EntryPoint#getConfiguredReference()
+ */
+ public ConfiguredReference getConfiguredReference() {
+ return configuredReference;
+ }
+
+ /**
+ * @see org.apache.tuscany.model.assembly.EntryPoint#setConfiguredReference(org.apache.tuscany.model.assembly.ConfiguredReference)
+ */
+ public void setConfiguredReference(ConfiguredReference configuredReference) {
+ checkNotFrozen();
+ this.configuredReference=configuredReference;
+ }
+
+ /**
+ * @see org.apache.tuscany.model.assembly.EntryPoint#getConfiguredService()
+ */
+ public ConfiguredService getConfiguredService() {
+ return configuredService;
+ }
+
+ /**
+ * @see org.apache.tuscany.model.assembly.EntryPoint#setConfiguredService(org.apache.tuscany.model.assembly.ConfiguredService)
+ */
+ public void setConfiguredService(ConfiguredService configuredService) {
+ checkNotFrozen();
+ this.configuredService=configuredService;
+ }
+
+ /**
+ * @see org.apache.tuscany.model.assembly.EntryPoint#getBindings()
+ */
+ public List<Binding> getBindings() {
+ return bindings;
+ }
+
+ /**
+ * @see org.apache.tuscany.model.assembly.AssemblyModelObject#initialize(org.apache.tuscany.model.assembly.AssemblyModelContext)
+ */
+ public void initialize(AssemblyModelContext modelContext) {
+ if (isInitialized())
+ return;
+ super.initialize(modelContext);
+
+ // Initialize the service contract and reference to the published service
+ if (configuredReference != null) {
+ ((ConfiguredPortImpl)configuredReference).setAggregatePart(this);
+ configuredReference.initialize(modelContext);
+ }
+ if (configuredService != null) {
+ ((ConfiguredPortImpl)configuredService).setAggregatePart(this);
+ configuredService.initialize(modelContext);
+ }
+
+ // Initialize the bindings
+ initialize(bindings, modelContext);
+ }
+
+ /**
+ * @see org.apache.tuscany.model.assembly.AssemblyModelObject#freeze()
+ */
+ 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=Collections.unmodifiableList(bindings);
+ freeze(bindings);
+ }
+
+ /**
+ * @see org.apache.tuscany.model.assembly.impl.AssemblyModelObjectImpl#accept(org.apache.tuscany.model.assembly.AssemblyModelVisitor)
+ */
+ public boolean accept(AssemblyModelVisitor 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/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/impl/ExtensibleImpl.java b/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/impl/ExtensibleImpl.java
new file mode 100644
index 0000000000..05f2082ced
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/impl/ExtensibleImpl.java
@@ -0,0 +1,92 @@
+/**
+ *
+ * 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.AssemblyModelContext;
+import org.apache.tuscany.model.assembly.AssemblyModelVisitor;
+import org.apache.tuscany.model.assembly.Extensible;
+
+/**
+ * An implementation of Extensible.
+ */
+public abstract class ExtensibleImpl extends AssemblyModelObjectImpl implements Extensible {
+
+ private List<Object> extensibilityElements=new ArrayList<Object>();
+ private List<Object> extensibilityAttributes=new ArrayList<Object>();
+
+ /**
+ * Constructor
+ */
+ protected ExtensibleImpl() {
+ }
+
+ /**
+ * @see org.apache.tuscany.model.assembly.Extensible#getExtensibilityElements()
+ */
+ public List getExtensibilityElements() {
+ return extensibilityElements;
+ }
+
+ /**
+ * @see org.apache.tuscany.model.assembly.Extensible#getExtensibilityAttributes()
+ */
+ public List getExtensibilityAttributes() {
+ return extensibilityAttributes;
+ }
+
+ /**
+ * @see org.apache.tuscany.model.assembly.AssemblyModelObject#initialize(org.apache.tuscany.model.assembly.AssemblyModelContext)
+ */
+ public void initialize(AssemblyModelContext 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);
+ }
+
+ /**
+ * @see org.apache.tuscany.model.assembly.impl.AssemblyModelObjectImpl#accept(org.apache.tuscany.model.assembly.AssemblyModelVisitor)
+ */
+ public boolean accept(AssemblyModelVisitor visitor) {
+ if (!super.accept(visitor))
+ return false;
+
+ if (!accept(extensibilityElements, visitor))
+ return false;
+ if (!accept(extensibilityAttributes, visitor))
+ return false;
+
+ return true;
+ }
+
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/impl/ExternalServiceImpl.java b/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/impl/ExternalServiceImpl.java
new file mode 100644
index 0000000000..33eced7e1f
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/impl/ExternalServiceImpl.java
@@ -0,0 +1,135 @@
+/**
+ *
+ * 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.Collections;
+import java.util.List;
+
+import org.apache.tuscany.model.assembly.AssemblyModelContext;
+import org.apache.tuscany.model.assembly.AssemblyModelVisitor;
+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 AggregatePartImpl implements ExternalService {
+
+ private ConfiguredService configuredService;
+ private OverrideOption overrideOption;
+ private List<Binding> bindings=new ArrayList<Binding>();
+
+ /**
+ * Constructor
+ */
+ protected ExternalServiceImpl() {
+ }
+
+ /**
+ * @see org.apache.tuscany.model.assembly.sdo.impl.ExternalServiceImpl#getOverrideOption()
+ */
+ public OverrideOption getOverrideOption() {
+ return overrideOption;
+ }
+
+ /**
+ * @see org.apache.tuscany.model.assembly.ExternalService#setOverrideOption(org.apache.tuscany.model.assembly.OverrideOption)
+ */
+ public void setOverrideOption(OverrideOption newOverridable) {
+ checkNotFrozen();
+ overrideOption=newOverridable;
+ }
+
+ /**
+ * @see org.apache.tuscany.model.assembly.ExternalService#getBindings()
+ */
+ public List<Binding> getBindings() {
+ return bindings;
+ }
+
+ /**
+ * @see org.apache.tuscany.model.assembly.ExternalService#getConfiguredService()
+ */
+ public ConfiguredService getConfiguredService() {
+ return configuredService;
+ }
+
+ /**
+ * @see org.apache.tuscany.model.assembly.ExternalService#setConfiguredService(org.apache.tuscany.model.assembly.ConfiguredService)
+ */
+ public void setConfiguredService(ConfiguredService configuredService) {
+ checkNotFrozen();
+ this.configuredService=configuredService;
+ }
+
+ /**
+ * @see org.apache.tuscany.model.assembly.AssemblyModelObject#initialize(org.apache.tuscany.model.assembly.AssemblyModelContext)
+ */
+ public void initialize(AssemblyModelContext modelContext) {
+ if (isInitialized())
+ return;
+ super.initialize(modelContext);
+
+ // Initialize the configured service
+ if (configuredService != null) {
+ ((ConfiguredPortImpl)configuredService).setAggregatePart(this);
+ configuredService.initialize(modelContext);
+ }
+
+ // Initialize the bindings
+ initialize(bindings, modelContext);
+ }
+
+ /**
+ * @see org.apache.tuscany.model.assembly.AssemblyModelObject#freeze()
+ */
+ public void freeze() {
+ if (isFrozen())
+ return;
+ super.freeze();
+
+ // Freeze the configured service
+ if (configuredService!= null)
+ configuredService.freeze();
+
+ // Freeze the bindings
+ bindings=Collections.unmodifiableList(bindings);
+ freeze(bindings);
+ }
+
+ /**
+ * @see org.apache.tuscany.model.assembly.impl.ExtensibleImpl#accept(org.apache.tuscany.model.assembly.AssemblyModelVisitor)
+ */
+ public boolean accept(AssemblyModelVisitor 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/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/impl/ModuleComponentImpl.java b/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/impl/ModuleComponentImpl.java
new file mode 100644
index 0000000000..d830c5c8d8
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/impl/ModuleComponentImpl.java
@@ -0,0 +1,65 @@
+/**
+ *
+ * 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 implements ModuleComponent {
+
+ private String uri;
+
+ /**
+ * Constructor
+ */
+ protected ModuleComponentImpl() {
+ }
+
+ /**
+ * @see org.apache.tuscany.model.assembly.ModuleComponent#setModuleImplementation(org.apache.tuscany.model.assembly.Module)
+ */
+ public void setModuleImplementation(Module module) {
+ checkNotFrozen();
+ super.setComponentImplementation(module);
+ }
+
+ /**
+ * @see org.apache.tuscany.model.assembly.ModuleComponent#getModuleImplementation()
+ */
+ public Module getModuleImplementation() {
+ return (Module)super.getComponentImplementation();
+ }
+
+ /**
+ * @see org.apache.tuscany.model.assembly.ModuleComponent#getURI()
+ */
+ public String getURI() {
+ return uri;
+ }
+
+ /**
+ * @see org.apache.tuscany.model.assembly.ModuleComponent#setURI(java.lang.String)
+ */
+ public void setURI(String value) {
+ checkNotFrozen();
+ uri=value;
+ }
+
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/impl/ModuleFragmentImpl.java b/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/impl/ModuleFragmentImpl.java
new file mode 100644
index 0000000000..a36935dbfb
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/impl/ModuleFragmentImpl.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.impl;
+
+import org.apache.tuscany.model.assembly.ModuleFragment;
+
+/**
+ * An implementation of ModuleFragment.
+ */
+public class ModuleFragmentImpl extends AggregateImpl implements ModuleFragment {
+
+ /**
+ * Constructor
+ */
+ protected ModuleFragmentImpl() {
+ }
+
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/impl/ModuleImpl.java b/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/impl/ModuleImpl.java
new file mode 100644
index 0000000000..8d89590225
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/impl/ModuleImpl.java
@@ -0,0 +1,243 @@
+/**
+ *
+ * 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.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.tuscany.model.assembly.AssemblyFactory;
+import org.apache.tuscany.model.assembly.AssemblyModelContext;
+import org.apache.tuscany.model.assembly.AssemblyModelVisitor;
+import org.apache.tuscany.model.assembly.Component;
+import org.apache.tuscany.model.assembly.ComponentType;
+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.ModuleFragment;
+import org.apache.tuscany.model.assembly.Multiplicity;
+import org.apache.tuscany.model.assembly.OverrideOption;
+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;
+
+/**
+ * An implementation of Module.
+ */
+public class ModuleImpl extends AggregateImpl implements Module {
+
+ private List<ModuleFragment> moduleFragments = new ArrayList<ModuleFragment>();
+ private Map<String, ModuleFragment> moduleFragmentsMap;
+ private ComponentType componentType;
+ private Object runtimeConfiguration;
+
+ /**
+ * Constructor
+ */
+ protected ModuleImpl() {
+ }
+
+ /**
+ * @see org.apache.tuscany.model.assembly.ComponentImplementation#getComponentType()
+ */
+ public ComponentType getComponentType() {
+ return componentType;
+ }
+
+ /**
+ * @see org.apache.tuscany.model.assembly.ComponentImplementation#setComponentType(org.apache.tuscany.model.assembly.ComponentType)
+ */
+ public void setComponentType(ComponentType componentType) {
+ checkNotFrozen();
+ this.componentType=componentType;
+ }
+
+ /**
+ * @see org.apache.tuscany.model.assembly.Module#getModuleFragments()
+ */
+ public List<ModuleFragment> getModuleFragments() {
+ return moduleFragments;
+ }
+
+ /**
+ * @see org.apache.tuscany.model.assembly.Module#getModuleFragment(java.lang.String)
+ */
+ public ModuleFragment getModuleFragment(String name) {
+ checkInitialized();
+ return moduleFragmentsMap.get(name);
+ }
+
+ /**
+ * @see org.apache.tuscany.model.assembly.AssemblyModelObject#initialize(org.apache.tuscany.model.assembly.AssemblyModelContext)
+ */
+ public void initialize(AssemblyModelContext modelContext) {
+ if (isInitialized())
+ return;
+
+ // Populate map of module fragments
+ moduleFragmentsMap = new HashMap<String, ModuleFragment>();
+ for (ModuleFragment moduleFragment : moduleFragments) {
+ moduleFragmentsMap.put(moduleFragment.getName(), moduleFragment);
+
+ // 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 aggregate
+ super.initialize(modelContext);
+
+ // Derive the component type from the entry points and external services in the module
+ // Also derive properties from the overridable properties of the components in the module
+ 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().getService().getServiceContract();
+ if (serviceContract != null)
+ service.setServiceContract(serviceContract);
+ componentType.getServices().add(service);
+ }
+ 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().getService().getServiceContract();
+ if (serviceContract != null)
+ reference.setServiceContract(serviceContract);
+ componentType.getReferences().add(reference);
+ }
+ for (Component component : getComponents()) {
+ for (ConfiguredProperty configuredProperty : component.getConfiguredProperties()) {
+ if (configuredProperty.getOverrideOption()==null || configuredProperty.getOverrideOption()==OverrideOption.NO)
+ continue;
+ componentType.getProperties().add(configuredProperty.getProperty());
+ }
+ }
+ }
+ componentType.initialize(modelContext);
+
+
+ // Wire the module parts
+ 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 = getComponent(partName);
+ if (component != null) {
+ configuredReference = component.getConfiguredReference(referenceName);
+ }
+ } else {
+ EntryPoint entryPoint = getEntryPoint(partName);
+ if (entryPoint != null) {
+ configuredReference = entryPoint.getConfiguredReference();
+ }
+ }
+ if (configuredReference == null) {
+ throw new IllegalArgumentException("Cannot find wire source " + sourceURI.getAddress());
+ } 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.getReference().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 for " + targetURI.getAddress());
+ }
+ }
+ }
+ }
+
+ /**
+ * @see org.apache.tuscany.model.assembly.AssemblyModelObject#freeze()
+ */
+ public void freeze() {
+ if (isFrozen())
+ return;
+ super.freeze();
+
+ // Freeze component type and module fragments
+ if (componentType!=null)
+ componentType.freeze();
+ moduleFragments=Collections.unmodifiableList(moduleFragments);
+ freeze(moduleFragments);
+ }
+
+ /**
+ * @see org.apache.tuscany.model.assembly.RuntimeConfigurationHolder#getRuntimeConfiguration()
+ */
+ public Object getRuntimeConfiguration() {
+ return runtimeConfiguration;
+ }
+
+ /**
+ * @see org.apache.tuscany.model.assembly.RuntimeConfigurationHolder#setRuntimeConfiguration(java.lang.Object)
+ */
+ public void setRuntimeConfiguration(Object configuration) {
+ checkNotFrozen();
+ this.runtimeConfiguration = configuration;
+ }
+
+ /**
+ * @see org.apache.tuscany.model.assembly.impl.AggregateImpl#accept(org.apache.tuscany.model.assembly.AssemblyModelVisitor)
+ */
+ public boolean accept(AssemblyModelVisitor visitor) {
+ if (!super.accept(visitor))
+ return false;
+
+ if (componentType!=null) {
+ if (!componentType.accept(visitor))
+ return false;
+ }
+
+ if (!accept(moduleFragments, visitor))
+ return false;
+
+ return true;
+ }
+
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/impl/PortImpl.java b/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/impl/PortImpl.java
new file mode 100644
index 0000000000..ae92300d4e
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/impl/PortImpl.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.AssemblyModelContext;
+import org.apache.tuscany.model.assembly.AssemblyModelVisitor;
+import org.apache.tuscany.model.assembly.Port;
+import org.apache.tuscany.model.assembly.ServiceContract;
+
+/**
+ * An implementation of Port.
+ */
+public abstract class PortImpl extends AssemblyModelObjectImpl implements Port {
+
+ private ServiceContract serviceContract;
+ private String name;
+
+ /**
+ * Constructor
+ */
+ protected PortImpl() {
+ }
+
+ /**
+ * @see org.apache.tuscany.model.assembly.Port#getName()
+ */
+ public String getName() {
+ return name;
+ }
+
+ /**
+ * @see org.apache.tuscany.model.assembly.Port#setName(java.lang.String)
+ */
+ public void setName(String value) {
+ checkNotFrozen();
+ name=value;
+ }
+
+ /**
+ * @see org.apache.tuscany.model.assembly.Port#getServiceContract()
+ */
+ public ServiceContract getServiceContract() {
+ return serviceContract;
+ }
+
+ /**
+ * @see org.apache.tuscany.model.assembly.Port#setServiceContract(org.apache.tuscany.model.assembly.ServiceContract)
+ */
+ public void setServiceContract(ServiceContract value) {
+ checkNotFrozen();
+ serviceContract=value;
+ }
+
+ /**
+ * @see org.apache.tuscany.model.assembly.impl.AssemblyModelObjectImpl#initialize(org.apache.tuscany.model.assembly.AssemblyModelContext)
+ */
+ public void initialize(AssemblyModelContext modelContext) {
+ if (isInitialized())
+ return;
+ super.initialize(modelContext);
+
+ if (serviceContract!=null)
+ serviceContract.initialize(modelContext);
+ }
+
+ /**
+ * @see org.apache.tuscany.model.assembly.impl.AssemblyModelObjectImpl#freeze()
+ */
+ public void freeze() {
+ if (isFrozen())
+ return;
+ super.freeze();
+
+ if (serviceContract!=null)
+ serviceContract.freeze();
+ }
+
+ /**
+ * @see org.apache.tuscany.model.assembly.impl.AssemblyModelObjectImpl#accept(org.apache.tuscany.model.assembly.AssemblyModelVisitor)
+ */
+ public boolean accept(AssemblyModelVisitor visitor) {
+ if (!super.accept(visitor))
+ return false;
+
+ if (serviceContract!=null) {
+ if (!serviceContract.accept(visitor))
+ return false;
+ }
+
+ return true;
+ }
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/impl/PropertyImpl.java b/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/impl/PropertyImpl.java
new file mode 100644
index 0000000000..f79ad2df3b
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/impl/PropertyImpl.java
@@ -0,0 +1,178 @@
+/**
+ *
+ * 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.math.BigDecimal;
+import java.math.BigInteger;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.tuscany.model.assembly.AssemblyModelContext;
+import org.apache.tuscany.model.assembly.Property;
+import org.apache.tuscany.sdo.util.SDOUtil;
+
+import commonj.sdo.Type;
+
+/**
+ * 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;
+
+ private Type sdoType;
+
+ /**
+ * Constructor
+ */
+ protected PropertyImpl() {
+ }
+
+ /**
+ * @see org.apache.tuscany.model.assembly.Property#getDefaultValue()
+ */
+ public Object getDefaultValue() {
+ return defaultValue;
+ }
+
+ /**
+ * @see org.apache.tuscany.model.assembly.Property#getName()
+ */
+ public String getName() {
+ return name;
+ }
+
+ /**
+ * @see org.apache.tuscany.model.assembly.Property#getType()
+ */
+ public Class getType() {
+ return type;
+ }
+
+ /**
+ * @see org.apache.tuscany.model.assembly.Property#isMany()
+ */
+ public boolean isMany() {
+ return many;
+ }
+
+ /**
+ * @see org.apache.tuscany.model.assembly.Property#isRequired()
+ */
+ public boolean isRequired() {
+ return required;
+ }
+
+ /**
+ * @see org.apache.tuscany.model.assembly.Property#setDefaultValue(java.lang.Object)
+ */
+ public void setDefaultValue(Object value) {
+ defaultValue=value;
+ }
+
+ /**
+ * @see org.apache.tuscany.model.assembly.Property#setMany(boolean)
+ */
+ public void setMany(boolean value) {
+ checkNotFrozen();
+ many=value;
+ }
+
+ /**
+ * @see org.apache.tuscany.model.assembly.Property#setName(java.lang.String)
+ */
+ public void setName(String value) {
+ checkNotFrozen();
+ name=value;
+ }
+
+ /**
+ * @see org.apache.tuscany.model.assembly.Property#setRequired(boolean)
+ */
+ public void setRequired(boolean value) {
+ checkNotFrozen();
+ required=value;
+ }
+
+ /**
+ * @see org.apache.tuscany.model.assembly.Property#setType(java.lang.Class)
+ */
+ public void setType(Class value) {
+ checkNotFrozen();
+ type=value;
+ }
+
+ /**
+ * @param sdoType The sdoType to set.
+ */
+ public void setSDOType(Type sdoType) {
+ checkNotFrozen();
+ this.sdoType = sdoType;
+ }
+
+ /**
+ * @return Returns the sdoType.
+ */
+ public Type getSDOType() {
+ return sdoType;
+ }
+
+ private final static Map<Class, Type> typeMapping=new HashMap<Class, Type>();
+
+ static {
+ typeMapping.put(BigDecimal.class, SDOUtil.getXSDSDOType("decimal"));
+ typeMapping.put(BigInteger.class, SDOUtil.getXSDSDOType("integer"));
+ typeMapping.put(boolean.class, SDOUtil.getXSDSDOType("boolean"));
+ typeMapping.put(Boolean.class, SDOUtil.getXSDSDOType("boolean"));
+ typeMapping.put(byte.class, SDOUtil.getXSDSDOType("byte"));
+ typeMapping.put(Byte.class, SDOUtil.getXSDSDOType("Byte"));
+ typeMapping.put(byte[].class, SDOUtil.getXSDSDOType("hexBinary"));
+ typeMapping.put(char.class, SDOUtil.getXSDSDOType("string"));
+ typeMapping.put(Character.class, SDOUtil.getXSDSDOType("string"));
+ typeMapping.put(Date.class, SDOUtil.getXSDSDOType("dateTime"));
+ typeMapping.put(double.class, SDOUtil.getXSDSDOType("double"));
+ typeMapping.put(Double.class, SDOUtil.getXSDSDOType("double"));
+ typeMapping.put(float.class, SDOUtil.getXSDSDOType("float"));
+ typeMapping.put(Float.class, SDOUtil.getXSDSDOType("float"));
+ typeMapping.put(int.class, SDOUtil.getXSDSDOType("int"));
+ typeMapping.put(Integer.class, SDOUtil.getXSDSDOType("int"));
+ typeMapping.put(long.class, SDOUtil.getXSDSDOType("long"));
+ typeMapping.put(Long.class, SDOUtil.getXSDSDOType("long"));
+ typeMapping.put(short.class, SDOUtil.getXSDSDOType("short"));
+ typeMapping.put(Short.class, SDOUtil.getXSDSDOType("short"));
+ typeMapping.put(String.class, SDOUtil.getXSDSDOType("string"));
+ }
+
+ /*
+ * @see org.apache.tuscany.model.assembly.impl.ExtensibleImpl#initialize(org.apache.tuscany.model.assembly.AssemblyModelContext)
+ */
+ public void initialize(AssemblyModelContext modelContext) {
+ if (isInitialized())
+ return;
+ super.initialize(modelContext);
+
+ // Get the SDO type corresponding to the property's Java type
+ if (sdoType==null) {
+ sdoType=typeMapping.get(type);
+ }
+ }
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/impl/ReferenceImpl.java b/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/impl/ReferenceImpl.java
new file mode 100644
index 0000000000..8a2d348edc
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/impl/ReferenceImpl.java
@@ -0,0 +1,50 @@
+/**
+ *
+ * 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;
+
+ /**
+ * Constructor
+ */
+ protected ReferenceImpl() {
+ }
+
+ /**
+ * @see org.apache.tuscany.model.assembly.Reference#getMultiplicity()
+ */
+ public Multiplicity getMultiplicity() {
+ return multiplicity;
+ }
+
+ /**
+ * @see org.apache.tuscany.model.assembly.Reference#setMultiplicity(org.apache.tuscany.model.assembly.Multiplicity)
+ */
+ public void setMultiplicity(Multiplicity multiplicity) {
+ checkNotFrozen();
+ this.multiplicity=multiplicity;
+ }
+
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/impl/ServiceContractImpl.java b/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/impl/ServiceContractImpl.java
new file mode 100644
index 0000000000..c9fe9b269d
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/impl/ServiceContractImpl.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.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;
+
+ /**
+ * Constructor
+ */
+ protected ServiceContractImpl() {
+ }
+
+ /**
+ * @see org.apache.tuscany.model.assembly.ServiceContract#getCallbackInterface()
+ */
+ public Class getCallbackInterface() {
+ return callbackInterface;
+ }
+
+ /**
+ * @see org.apache.tuscany.model.assembly.ServiceContract#getInterface()
+ */
+ public Class getInterface() {
+ return interface_;
+ }
+
+ /**
+ * @see org.apache.tuscany.model.assembly.ServiceContract#getScope()
+ */
+ public Scope getScope() {
+ return scope;
+ }
+
+ /**
+ * @see org.apache.tuscany.model.assembly.ServiceContract#setCallbackInterface(java.lang.Class)
+ */
+ public void setCallbackInterface(Class value) {
+ checkNotFrozen();
+ callbackInterface=value;
+ }
+
+ /**
+ * @see org.apache.tuscany.model.assembly.ServiceContract#setInterface(java.lang.Class)
+ */
+ public void setInterface(Class value) {
+ checkNotFrozen();
+ interface_=value;
+ }
+
+ /**
+ * @see org.apache.tuscany.model.assembly.ServiceContract#setScope(org.apache.tuscany.model.assembly.Scope)
+ */
+ public void setScope(Scope scope) {
+ checkNotFrozen();
+ this.scope=scope;
+ }
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/impl/ServiceImpl.java b/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/impl/ServiceImpl.java
new file mode 100644
index 0000000000..230d89e373
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/impl/ServiceImpl.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.impl;
+
+import org.apache.tuscany.model.assembly.Service;
+
+/**
+ * An implementation of Service.
+ */
+public class ServiceImpl extends PortImpl implements Service {
+
+ /**
+ * Constructor
+ */
+ protected ServiceImpl() {
+ }
+
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/impl/ServiceURIImpl.java b/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/impl/ServiceURIImpl.java
new file mode 100644
index 0000000000..6d2972fb7d
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/impl/ServiceURIImpl.java
@@ -0,0 +1,198 @@
+/**
+ *
+ * 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.eclipse.emf.common.util.URI;
+
+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.AggregatePart;
+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;
+
+ /**
+ * Constructor
+ */
+ protected ServiceURIImpl(String address) {
+ this.address = address;
+ }
+
+ /**
+ * Constructor
+ *
+ * @param moduleComponent
+ * @param configuredPort
+ */
+ protected ServiceURIImpl(ModuleComponent moduleComponent, AggregatePart aggregatePart, ConfiguredPort configuredPort) {
+ if (moduleComponent != null)
+ moduleComponentName = moduleComponent.getName();
+ else
+ moduleComponentName = "";
+ if (configuredPort instanceof ConfiguredService) {
+ partName = aggregatePart.getName();
+ ConfiguredService configuredService = (ConfiguredService) configuredPort;
+ Service service = configuredService.getService();
+ if (service != null) {
+ serviceName = configuredService.getService().getName();
+ address = "sca:///" + moduleComponentName + '/' + partName + '/' + serviceName;
+ } else {
+ address = "sca:///" + moduleComponentName + '/' + partName;
+ }
+
+ } else if (configuredPort instanceof ConfiguredReference) {
+ ConfiguredReference configuredReference = (ConfiguredReference) configuredPort;
+ partName = aggregatePart.getName();
+ serviceName = configuredReference.getReference().getName();
+ if (serviceName!=null)
+ address = "sca:///" + moduleComponentName + '/' + partName + '/' + serviceName;
+ else
+ address = "sca:///" + moduleComponentName + '/' + partName;
+ }
+
+ isSCAScheme = Boolean.TRUE;
+ isParsed = true;
+ }
+
+ /**
+ * Constructor
+ *
+ * @param moduleComponent
+ * @param service
+ */
+ 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;
+ }
+
+ /**
+ * Returns true if the address scheme is sca:
+ *
+ * @return
+ */
+ public boolean isSCAScheme() {
+ if (isSCAScheme == null) {
+ if (address.startsWith("sca://")) {
+ isSCAScheme = Boolean.TRUE;
+ } else {
+ isSCAScheme = Boolean.FALSE;
+ }
+ }
+ return isSCAScheme.booleanValue();
+ }
+
+ /**
+ * Returns a URI for this address
+ *
+ * @return
+ */
+ public URI getURI() {
+ return URI.createURI(address);
+ }
+
+ /**
+ * @return Returns the address.
+ */
+ public String getAddress() {
+ return address;
+ }
+
+ /**
+ * 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
+ *
+ * @return
+ */
+ public String getModuleComponentName() {
+ if (!isParsed)
+ parse();
+ return moduleComponentName;
+ }
+
+ /**
+ * Returns the part name
+ *
+ * @return
+ */
+ public String getPartName() {
+ if (!isParsed)
+ parse();
+ return partName;
+ }
+
+ /**
+ * Returns the service name
+ * @return
+ */
+ public String getServiceName() {
+ if (!isParsed)
+ parse();
+ return serviceName;
+ }
+
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/impl/SimpleComponentImpl.java b/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/impl/SimpleComponentImpl.java
new file mode 100644
index 0000000000..6de56e0806
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/impl/SimpleComponentImpl.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.impl;
+
+import org.apache.tuscany.model.assembly.SimpleComponent;
+
+/**
+ * An implementation of SimpleComponent.
+ */
+public class SimpleComponentImpl extends ComponentImpl implements SimpleComponent {
+
+ /**
+ * Constructor
+ */
+ protected SimpleComponentImpl() {
+ }
+
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/impl/SubsystemImpl.java b/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/impl/SubsystemImpl.java
new file mode 100644
index 0000000000..7dc78ee1e6
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/impl/SubsystemImpl.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.impl;
+
+import org.apache.tuscany.model.assembly.Subsystem;
+
+/**
+ * An implementation of Subsystem.
+ */
+public class SubsystemImpl extends AggregateImpl implements Subsystem {
+
+ private String uri;
+
+ /**
+ * Constructor
+ */
+ protected SubsystemImpl() {
+ }
+
+ /**
+ * @see org.apache.tuscany.model.assembly.Subsystem#getURI()
+ */
+ public String getURI() {
+ return uri;
+ }
+
+ /**
+ * @see org.apache.tuscany.model.assembly.Subsystem#setURI(java.lang.String)
+ */
+ public void setURI(String value) {
+ checkNotFrozen();
+ uri=value;
+ }
+
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/impl/WireImpl.java b/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/impl/WireImpl.java
new file mode 100644
index 0000000000..6cbf34334f
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/impl/WireImpl.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.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;
+
+ /**
+ * Constructor
+ */
+ protected WireImpl() {
+ }
+
+ /**
+ * @see org.apache.tuscany.model.assembly.Wire#getSource()
+ */
+ public ServiceURI getSource() {
+ return source;
+ }
+
+ /**
+ * @see org.apache.tuscany.model.assembly.Wire#setSource(org.apache.tuscany.model.assembly.ServiceURI)
+ */
+ public void setSource(ServiceURI uri) {
+ checkNotFrozen();
+ source=uri;
+ }
+
+ /**
+ * @see org.apache.tuscany.model.assembly.Wire#getTarget()
+ */
+ public ServiceURI getTarget() {
+ return target;
+ }
+
+ /**
+ * @see org.apache.tuscany.model.assembly.Wire#setTarget(org.apache.tuscany.model.assembly.ServiceURI)
+ */
+ public void setTarget(ServiceURI uri) {
+ checkNotFrozen();
+ target=uri;
+ }
+
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/loader/AssemblyModelLoader.java b/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/loader/AssemblyModelLoader.java
new file mode 100644
index 0000000000..6b0895e56f
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/assembly/loader/AssemblyModelLoader.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.loader;
+
+import java.util.List;
+
+import javax.wsdl.Definition;
+import javax.wsdl.PortType;
+
+import org.apache.tuscany.model.assembly.AssemblyModelContext;
+import org.apache.tuscany.model.assembly.ComponentType;
+import org.apache.tuscany.model.assembly.Module;
+import org.apache.tuscany.model.assembly.ModuleFragment;
+import org.apache.tuscany.model.assembly.Subsystem;
+
+/**
+ * An assembly model loader.
+ */
+public interface AssemblyModelLoader {
+
+ /**
+ * Sets the model context to use.
+ * @param modelContext
+ */
+ void setModelContext(AssemblyModelContext modelContext);
+
+ /**
+ * Returns the module at the given uri
+ * @param uri
+ * @return
+ */
+ Module loadModule(String uri);
+
+ /**
+ * Returns the module at the given uri
+ * @param uri
+ * @return
+ */
+ ModuleFragment loadModuleFragment(String uri);
+
+ /**
+ * Returns the component type at the given uri
+ * @param uri
+ * @return
+ */
+ ComponentType loadComponentType(String uri);
+
+ /**
+ * Returns the subsystem at the given uri.
+ * @param uri
+ * @return
+ */
+ Subsystem loadSubsystem(String uri);
+
+ /**
+ * Load a WSDL definition
+ */
+ Definition loadDefinition(String uri);
+
+ /**
+ * Load definitions by namespace
+ * @param uri
+ * @return
+ */
+ List<Definition> loadDefinitions(String namespace);
+
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/scdl/loader/SCDLModelLoader.java b/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/scdl/loader/SCDLModelLoader.java
new file mode 100644
index 0000000000..f8fdab2c6c
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/scdl/loader/SCDLModelLoader.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.scdl.loader;
+
+import org.apache.tuscany.model.assembly.Aggregate;
+import org.apache.tuscany.model.assembly.AssemblyModelContext;
+import org.apache.tuscany.model.assembly.AssemblyModelObject;
+
+/**
+ * An SCDL model loader.
+ */
+public interface SCDLModelLoader {
+
+ /**
+ * Load an SCDL model object into an assembly model.
+ * @param modelContext
+ * @param object
+ * @return
+ */
+ AssemblyModelObject load(AssemblyModelContext modelContext, Object object);
+
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/scdl/loader/impl/AssemblyModelLoadException.java b/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/scdl/loader/impl/AssemblyModelLoadException.java
new file mode 100644
index 0000000000..db2ad2ff86
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/scdl/loader/impl/AssemblyModelLoadException.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.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 {
+
+ 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/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/scdl/loader/impl/SCDLAssemblyModelLoaderImpl.java b/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/scdl/loader/impl/SCDLAssemblyModelLoaderImpl.java
new file mode 100644
index 0000000000..cfe8b260ee
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/scdl/loader/impl/SCDLAssemblyModelLoaderImpl.java
@@ -0,0 +1,198 @@
+/**
+ *
+ * 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.Collections;
+import java.util.HashMap;
+import java.util.Iterator;
+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.common.resource.ResourceLoader;
+import org.apache.tuscany.model.assembly.AssemblyModelContext;
+import org.apache.tuscany.model.assembly.ComponentType;
+import org.apache.tuscany.model.assembly.Module;
+import org.apache.tuscany.model.assembly.ModuleFragment;
+import org.apache.tuscany.model.assembly.Subsystem;
+import org.apache.tuscany.model.assembly.loader.AssemblyModelLoader;
+import org.apache.tuscany.model.scdl.loader.SCDLModelLoader;
+import org.apache.tuscany.model.util.ModelTransformer;
+import org.apache.tuscany.model.util.ModelTransformerImpl;
+import org.eclipse.emf.ecore.util.EcoreUtil;
+
+/**
+ */
+public class SCDLAssemblyModelLoaderImpl implements AssemblyModelLoader {
+
+ private SCDLXMLReader xmlReader=new SCDLXMLReader();
+ private WSDLReader wsdlReader;
+ private AssemblyModelContext modelContext;
+
+ private List<SCDLModelLoader> scdlModelLoaders;
+
+ private Map<String, ComponentType> componentTypes=new HashMap<String, ComponentType>();
+ private Map<String, Module> modules=new HashMap<String, Module>();
+ private Map<String, ModuleFragment> moduleFragments=new HashMap<String, ModuleFragment>();
+ private Map<String, Subsystem> subsystems=new HashMap<String, Subsystem>();
+ private Map<String, Definition> definitions=new HashMap<String, Definition>();
+ private Map<String, List<Definition>> definitionsByNamespace=new HashMap<String, List<Definition>>();
+
+ /**
+ * Constructor
+ */
+ public SCDLAssemblyModelLoaderImpl(List<SCDLModelLoader> loaders) {
+ scdlModelLoaders=loaders!=null? loaders:new ArrayList<SCDLModelLoader>();
+ }
+
+ /**
+ * @param modelContext The modelContext to set.
+ */
+ public void setModelContext(AssemblyModelContext modelContext) {
+ this.modelContext = modelContext;
+ }
+
+ /**
+ * @see org.apache.tuscany.model.assembly.loader.AssemblyModelLoader#loadComponentType(java.lang.String)
+ */
+ public ComponentType loadComponentType(String uri) {
+ ComponentType componentType=componentTypes.get(uri);
+ if (componentType!=null)
+ return componentType;
+
+ // Load the SCDL component type
+ org.apache.tuscany.model.scdl.ComponentType scdlComponentType=xmlReader.getComponentType(uri);
+
+ // Transform it to an assembly component type
+ componentType=transform(scdlComponentType).getComponentType();
+
+ componentTypes.put(uri, componentType);
+ return componentType;
+ }
+
+ /**
+ * @see org.apache.tuscany.model.assembly.loader.AssemblyModelLoader#loadModule(java.lang.String)
+ */
+ public Module loadModule(String uri) {
+ Module module=modules.get(uri);
+ if (module!=null)
+ return module;
+
+ // Load the SCDL module
+ org.apache.tuscany.model.scdl.Module scdlModule=xmlReader.getModule(uri);
+
+ // Transform it to an assembly module
+ module=transform(scdlModule).getModule();
+
+ modules.put(uri, module);
+ return module;
+ }
+
+ /**
+ * @see org.apache.tuscany.model.assembly.loader.AssemblyModelLoader#loadModuleFragment(java.lang.String)
+ */
+ public ModuleFragment loadModuleFragment(String uri) {
+ ModuleFragment moduleFragment=moduleFragments.get(uri);
+ if (moduleFragment!=null)
+ return moduleFragment;
+
+ // Load the SCDL module fragment
+ org.apache.tuscany.model.scdl.ModuleFragment scdlFragment=xmlReader.getModuleFragment(uri);
+
+ // Transform it to an assembly module fragment
+ moduleFragment=transform(scdlFragment).getModuleFragment();
+
+ moduleFragments.put(uri, moduleFragment);
+ return moduleFragment;
+ }
+
+ /**
+ * @see org.apache.tuscany.model.assembly.loader.AssemblyModelLoader#loadSubsystem(java.lang.String)
+ */
+ public Subsystem loadSubsystem(String uri) {
+ Subsystem subsystem=subsystems.get(uri);
+ if (subsystem!=null)
+ return subsystem;
+
+ // Load the SCDL subsystem
+ org.apache.tuscany.model.scdl.Subsystem scdlSubsystem=xmlReader.getSubsystem(uri);
+
+ subsystem=transform(scdlSubsystem).getSubsystem();
+
+ subsystems.put(uri, subsystem);
+ return subsystem;
+ }
+
+ /**
+ * @see org.apache.tuscany.model.assembly.loader.AssemblyModelLoader#loadDefinition(java.lang.String)
+ */
+ public Definition loadDefinition(String uri) {
+ Definition definition=definitions.get(uri);
+ if (definition!=null)
+ return definition;
+
+ try {
+ if (wsdlReader==null)
+ wsdlReader=WSDLFactory.newInstance().newWSDLReader();
+ 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;
+ }
+
+ /**
+ * @see org.apache.tuscany.model.assembly.loader.AssemblyModelLoader#loadDefinitions(java.lang.String)
+ */
+ public List<Definition> loadDefinitions(String namespace) {
+ return definitionsByNamespace.get(namespace);
+ }
+
+ /**
+ * Transform a model and return the handler containing the result of the transformation.
+ * @param object
+ * @return
+ */
+ private SCDLModelContentHandlerImpl transform(Object object) {
+ //FIXME Remove this dependency on EMF
+ Iterator contents=EcoreUtil.getAllContents(Collections.singleton(object), true);
+
+ ModelTransformer transformer=new ModelTransformerImpl();
+ SCDLModelContentHandlerImpl handler=new SCDLModelContentHandlerImpl(modelContext, scdlModelLoaders);
+ transformer.transform(contents, handler);
+ return handler;
+ }
+
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/scdl/loader/impl/SCDLModelContentHandlerImpl.java b/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/scdl/loader/impl/SCDLModelContentHandlerImpl.java
new file mode 100644
index 0000000000..f4f1f857e6
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/scdl/loader/impl/SCDLModelContentHandlerImpl.java
@@ -0,0 +1,708 @@
+/**
+ *
+ * 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.List;
+import java.util.Map;
+
+import javax.wsdl.Definition;
+import javax.wsdl.Import;
+import javax.wsdl.WSDLException;
+import javax.wsdl.factory.WSDLFactory;
+
+import org.apache.tuscany.model.assembly.Aggregate;
+import org.apache.tuscany.model.assembly.AssemblyFactory;
+import org.apache.tuscany.model.assembly.AssemblyModelContext;
+import org.apache.tuscany.model.assembly.ComponentImplementation;
+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.OverrideOption;
+import org.apache.tuscany.model.assembly.Scope;
+import org.apache.tuscany.model.assembly.ServiceContract;
+import org.apache.tuscany.model.assembly.ServiceURI;
+import org.apache.tuscany.model.assembly.SimpleComponent;
+import org.apache.tuscany.model.assembly.Wire;
+import org.apache.tuscany.model.assembly.impl.PropertyImpl;
+import org.apache.tuscany.model.scdl.Binding;
+import org.apache.tuscany.model.scdl.Component;
+import org.apache.tuscany.model.scdl.ComponentType;
+import org.apache.tuscany.model.scdl.EntryPoint;
+import org.apache.tuscany.model.scdl.ExternalService;
+import org.apache.tuscany.model.scdl.Implementation;
+import org.apache.tuscany.model.scdl.JavaInterface;
+import org.apache.tuscany.model.scdl.Module;
+import org.apache.tuscany.model.scdl.ModuleComponent;
+import org.apache.tuscany.model.scdl.ModuleFragment;
+import org.apache.tuscany.model.scdl.ModuleWire;
+import org.apache.tuscany.model.scdl.Multiplicity;
+import org.apache.tuscany.model.scdl.OverrideOptions;
+import org.apache.tuscany.model.scdl.Property;
+import org.apache.tuscany.model.scdl.PropertyValues;
+import org.apache.tuscany.model.scdl.Reference;
+import org.apache.tuscany.model.scdl.Service;
+import org.apache.tuscany.model.scdl.Subsystem;
+import org.apache.tuscany.model.scdl.SystemWire;
+import org.apache.tuscany.model.scdl.WSDLImport;
+import org.apache.tuscany.model.scdl.WSDLPortType;
+import org.apache.tuscany.model.scdl.loader.SCDLModelLoader;
+import org.apache.tuscany.model.scdl.util.ScdlSwitch;
+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;
+import org.apache.tuscany.model.util.ModelContentHandler;
+import org.apache.tuscany.sdo.util.SDOUtil;
+import org.eclipse.emf.ecore.EObject;
+
+import commonj.sdo.DataObject;
+import commonj.sdo.Sequence;
+import commonj.sdo.Type;
+
+/**
+ * A model content handler that transforms an SCDL model into an assembly model.
+ */
+public class SCDLModelContentHandlerImpl extends ScdlSwitch implements ModelContentHandler {
+
+ private List contents;
+ private List linkers;
+ private Map targets;
+
+ private List<SCDLModelLoader> scdlModelLoaders;
+
+ private AssemblyModelContext modelContext;
+ private AssemblyFactory factory;
+ private org.apache.tuscany.model.assembly.ComponentType currentComponentType;
+ private org.apache.tuscany.model.assembly.Service currentService;
+ private org.apache.tuscany.model.assembly.Reference currentReference;
+ private org.apache.tuscany.model.assembly.Module currentModule;
+ private Aggregate currentAggregate;
+ private SimpleComponent currentComponent;
+ private org.apache.tuscany.model.assembly.ExternalService currentExternalService;
+ private org.apache.tuscany.model.assembly.EntryPoint currentEntryPoint;
+ private org.apache.tuscany.model.assembly.ModuleFragment currentModuleFragment;
+ private org.apache.tuscany.model.assembly.Subsystem currentSubsystem;
+ private org.apache.tuscany.model.assembly.ModuleComponent currentModuleComponent;
+ private Definition definition;
+
+ /**
+ * Constructor
+ */
+ public SCDLModelContentHandlerImpl(AssemblyModelContext modelContext, List<SCDLModelLoader> scdlModelLoaders) {
+ this.modelContext=modelContext;
+ this.factory=modelContext.getAssemblyFactory();
+ this.scdlModelLoaders=scdlModelLoaders;
+ }
+
+ /**
+ * @see org.apache.tuscany.model.util.ModelContentHandler#doSwitch(java.lang.Object)
+ */
+ public Object doSwitch(Object object) {
+ return super.doSwitch((EObject)object);
+ }
+
+ /**
+ * @see org.apache.tuscany.model.util.ModelContentHandler#startModel()
+ */
+ public void startModel() {
+ }
+
+ /**
+ * @see org.apache.tuscany.model.util.ModelContentHandler#endModel()
+ */
+ public void endModel() {
+ }
+
+ /**
+ * @see org.apache.tuscany.model.util.ModelContentHandler#setContents(java.util.List)
+ */
+ public void setContents(List contents) {
+ this.contents=contents;
+ }
+
+ /**
+ * @see org.apache.tuscany.model.util.ModelContentHandler#setLinkers(java.util.List)
+ */
+ public void setLinkers(List linkers) {
+ this.linkers=linkers;
+ }
+
+ /**
+ * @see org.apache.tuscany.model.util.ModelContentHandler#setTargets(java.util.Map)
+ */
+ public void setTargets(Map targets) {
+ this.targets=targets;
+ }
+
+ /**
+ * @return Returns the componentType.
+ */
+ public org.apache.tuscany.model.assembly.ComponentType getComponentType() {
+ return currentComponentType;
+ }
+
+ /**
+ * @return Returns the module.
+ */
+ public org.apache.tuscany.model.assembly.Module getModule() {
+ return currentModule;
+ }
+
+ /**
+ * @return Returns the subsystem.
+ */
+ public org.apache.tuscany.model.assembly.Subsystem getSubsystem() {
+ return currentSubsystem;
+ }
+
+ /**
+ * @return Returns the moduleFragment.
+ */
+ public org.apache.tuscany.model.assembly.ModuleFragment getModuleFragment() {
+ return currentModuleFragment;
+ }
+
+ /**
+ * @see org.apache.tuscany.model.scdl.util.ScdlSwitch#caseComponentType(org.apache.tuscany.model.scdl.ComponentType)
+ */
+ public Object caseComponentType(ComponentType object) {
+ org.apache.tuscany.model.assembly.ComponentType componentType=factory.createComponentType();
+ contents.add(componentType);
+ currentComponentType=componentType;
+ return componentType;
+ }
+
+ /**
+ * @see org.apache.tuscany.model.scdl.util.ScdlSwitch#caseService(org.apache.tuscany.model.scdl.Service)
+ */
+ public Object caseService(Service object) {
+ final org.apache.tuscany.model.assembly.Service service=factory.createService();
+ service.setName(object.getName());
+
+ linkers.add(new Runnable() {
+ public void run() {
+ currentComponentType.getServices().add(service);
+ };
+ });
+
+ currentService=service;
+ return service;
+ }
+
+ /**
+ * @see org.apache.tuscany.model.scdl.util.ScdlSwitch#caseReference(org.apache.tuscany.model.scdl.Reference)
+ */
+ public Object caseReference(Reference object) {
+ final org.apache.tuscany.model.assembly.Reference reference=factory.createReference();
+ reference.setName(object.getName());
+ reference.setMultiplicity(transformMultiplicity(object.getMultiplicity()));
+
+ linkers.add(new Runnable() {
+ public void run() {
+ currentComponentType.getReferences().add(reference);
+ };
+ });
+
+ currentReference=reference;
+ return reference;
+ }
+
+ /**
+ * Transforms an SCDL multiplicity into an assembly model multiplicity.
+ * @param multiplicity
+ * @return
+ */
+ private org.apache.tuscany.model.assembly.Multiplicity transformMultiplicity(Multiplicity multiplicity) {
+ if (multiplicity==Multiplicity._01_LITERAL)
+ return org.apache.tuscany.model.assembly.Multiplicity.ZERO_ONE;
+ else if (multiplicity==Multiplicity._0N_LITERAL)
+ return org.apache.tuscany.model.assembly.Multiplicity.ZERO_N;
+ else if (multiplicity==Multiplicity._11_LITERAL)
+ return org.apache.tuscany.model.assembly.Multiplicity.ONE_ONE;
+ else if (multiplicity==Multiplicity._1N_LITERAL)
+ return org.apache.tuscany.model.assembly.Multiplicity.ONE_N;
+ else
+ return org.apache.tuscany.model.assembly.Multiplicity.ONE_ONE;
+ }
+
+ /**
+ * @see org.apache.tuscany.model.scdl.util.ScdlSwitch#caseJavaInterface(org.apache.tuscany.model.scdl.JavaInterface)
+ */
+ public Object caseJavaInterface(JavaInterface object) {
+ final JavaServiceContract serviceContract=factory.createJavaServiceContract();
+ serviceContract.setScope(Scope.INSTANCE);
+
+ ((JavaServiceContractImpl)serviceContract).setInterfaceName(object.getInterface());
+ ((JavaServiceContractImpl)serviceContract).setCallbackInterfaceName(object.getCallbackInterface());
+
+ linkServiceContract(object, serviceContract);
+
+ return serviceContract;
+ }
+
+ /**
+ * @see org.apache.tuscany.model.scdl.util.ScdlSwitch#caseWSDLPortType(org.apache.tuscany.model.scdl.WSDLPortType)
+ */
+ public Object caseWSDLPortType(WSDLPortType object) {
+ final WSDLServiceContract serviceContract=factory.createWSDLServiceContract();
+ serviceContract.setScope(Scope.INSTANCE);
+
+ ((WSDLServiceContractImpl)serviceContract).setPortTypeURI(object.getInterface());
+ ((WSDLServiceContractImpl)serviceContract).setCallbackPortTypeURI(object.getCallbackInterface());
+
+ linkServiceContract(object, serviceContract);
+
+ return serviceContract;
+ }
+
+ /**
+ * @see org.apache.tuscany.model.scdl.util.ScdlSwitch#caseWSDLImport(org.apache.tuscany.model.scdl.WSDLImport)
+ */
+ public Object caseWSDLImport(WSDLImport object) {
+ if (definition==null) {
+ try {
+ WSDLFactory wsdlFactory=WSDLFactory.newInstance();
+ definition=wsdlFactory.newDefinition();
+ } catch (WSDLException e) {
+ throw new IllegalStateException(e);
+ }
+
+ }
+ final Import wsdlImport=definition.createImport();
+ wsdlImport.setNamespaceURI(object.getNamespace());
+ wsdlImport.setLocationURI(object.getLocation());
+
+ linkers.add(new Runnable() {
+ public void run() {
+ currentAggregate.getWSDLImports().add(wsdlImport);
+ };
+ });
+
+ return wsdlImport;
+ }
+
+ /**
+ * Link a service contract with the correct owner.
+ * @param object
+ * @param serviceContract
+ */
+ private void linkServiceContract(Object object, final ServiceContract serviceContract) {
+ Object container=((DataObject)object).getContainer();
+ if (container instanceof Service) {
+
+ // Set a service contract on a service
+ final org.apache.tuscany.model.assembly.Service service=currentService;
+ linkers.add(new Runnable() {
+ public void run() {
+ service.setServiceContract(serviceContract);
+ }
+ });
+ }
+ else if (container instanceof Reference) {
+
+ // Set a service contract on a reference
+ final org.apache.tuscany.model.assembly.Reference reference=currentReference;
+ linkers.add(new Runnable() {
+ public void run() {
+ reference.setServiceContract(serviceContract);
+ }
+ });
+ } else if (container instanceof ExternalService) {
+
+ // Set a service contract on an external service
+ final org.apache.tuscany.model.assembly.ExternalService externalService=currentExternalService;
+ linkers.add(new Runnable() {
+ public void run() {
+ externalService.getConfiguredService().getService().setServiceContract(serviceContract);
+ }
+ });
+ } else if (container instanceof EntryPoint) {
+
+ // Set a service contract on an entry point
+ final org.apache.tuscany.model.assembly.EntryPoint entryPoint=currentEntryPoint;
+ linkers.add(new Runnable() {
+ public void run() {
+ entryPoint.getConfiguredService().getService().setServiceContract(serviceContract);
+ entryPoint.getConfiguredReference().getReference().setServiceContract(serviceContract);
+ }
+ });
+ }
+ }
+
+ /**
+ * @see org.apache.tuscany.model.scdl.util.ScdlSwitch#caseProperty(org.apache.tuscany.model.scdl.Property)
+ */
+ public Object caseProperty(Property object) {
+ final org.apache.tuscany.model.assembly.Property property=factory.createProperty();
+ property.setName(object.getName());
+ property.setDefaultValue(object.getDefault());
+ property.setMany(object.isMany());
+ property.setRequired(object.isRequired());
+
+ Object dataType=object.getDataType();
+ if (dataType!=null) {
+ String typeName=dataType.toString();
+ typeName=typeName.substring(typeName.indexOf(':')+1);
+ Type type=SDOUtil.getXSDSDOType(typeName);
+ ((PropertyImpl)property).setSDOType(type);
+ property.setType(type.getInstanceClass());
+ } else {
+ property.setType(String.class);
+ }
+
+ linkers.add(new Runnable() {
+ public void run() {
+ currentComponentType.getProperties().add(property);
+ };
+ });
+
+ return property;
+ }
+
+ /**
+ * @see org.apache.tuscany.model.scdl.util.ScdlSwitch#caseModule(org.apache.tuscany.model.scdl.Module)
+ */
+ public Object caseModule(Module object) {
+ org.apache.tuscany.model.assembly.Module module=factory.createModule();
+ module.setName(object.getName());
+ contents.add(module);
+ currentModule=module;
+ currentAggregate=module;
+ return module;
+ }
+
+ /**
+ * @see org.apache.tuscany.model.scdl.util.ScdlSwitch#caseModuleFragment(org.apache.tuscany.model.scdl.ModuleFragment)
+ */
+ public Object caseModuleFragment(ModuleFragment object) {
+ org.apache.tuscany.model.assembly.ModuleFragment moduleFragment=factory.createModuleFragment();
+ moduleFragment.setName(object.getName());
+ contents.add(moduleFragment);
+ currentModuleFragment=moduleFragment;
+ currentAggregate=moduleFragment;
+ return moduleFragment;
+ }
+
+ /**
+ * @see org.apache.tuscany.model.scdl.util.ScdlSwitch#caseComponent(org.apache.tuscany.model.scdl.Component)
+ */
+ public Object caseComponent(Component object) {
+ final SimpleComponent component=factory.createSimpleComponent();
+ component.setName(object.getName());
+ linkers.add(new Runnable() {
+ public void run() {
+ currentAggregate.getComponents().add(component);
+ component.initialize(modelContext);
+ };
+ });
+ currentComponent=component;
+ return component;
+ }
+
+ /**
+ * @see org.apache.tuscany.model.scdl.util.ScdlSwitch#casePropertyValues(org.apache.tuscany.model.scdl.PropertyValues)
+ */
+ public Object casePropertyValues(final PropertyValues object) {
+
+ // Grab the current component
+ final SimpleComponent component=currentComponent;
+ linkers.add(new Runnable() {
+ public void run() {
+
+ // Initialize the component's configured properties
+ Sequence sequence = object.getAny();
+ for (int p = 0, n = sequence.size(); p < n; p++) {
+
+ // Get each property value element
+ commonj.sdo.Property propertyElementDef = sequence.getProperty(p);
+ DataObject propertyElement = (DataObject) sequence.getValue(p);
+
+ // Get the corresponding property definition
+ String propertyName = propertyElementDef.getName();
+ ConfiguredProperty configuredProperty=component.getConfiguredProperty(propertyName);
+ if (configuredProperty == null) {
+ throw new IllegalArgumentException("Undefined property " + propertyName);
+ }
+
+ // Check if the property is overridable
+ Sequence attrs=propertyElement.getSequence("anyAttribute");
+ if (attrs!=null && attrs.size()!=0) {
+ commonj.sdo.Property attr=attrs.getProperty(0);
+ if (attr!=null && attr.getName().equals("overridable")) {
+ Object overridable=attrs.getValue(0);
+ if ("may".equals(overridable))
+ configuredProperty.setOverrideOption(OverrideOption.MAY);
+ else if ("must".equals(overridable))
+ configuredProperty.setOverrideOption(OverrideOption.MUST);
+ else if ("no".equals(overridable))
+ configuredProperty.setOverrideOption(OverrideOption.NO);
+ }
+ }
+
+ // Get the property value text and convert to the expected java type
+ Sequence text = propertyElement.getSequence("any");
+ if (text != null && text.size() != 0) {
+ String rawValue = text.getValue(0).toString();
+ Type type=((PropertyImpl)configuredProperty.getProperty()).getSDOType();
+ Object value;
+ if (type!=null) {
+ value=SDOUtil.createFromString(type, rawValue);
+ } else {
+ value=rawValue;
+ }
+ configuredProperty.setValue(value);
+ }
+ }
+ }
+ });
+
+ return object;
+ }
+
+ /**
+ * @see org.apache.tuscany.model.scdl.util.ScdlSwitch#caseReferenceValues(org.apache.tuscany.model.scdl.ReferenceValues)
+ */
+ public Object caseReferenceValues(final org.apache.tuscany.model.scdl.ReferenceValues object) {
+
+ // Grab the current component
+ final SimpleComponent component=this.currentComponent;
+
+ linkers.add(new Runnable() {
+ public void run() {
+
+ // Initialize the component's configured references
+ Sequence sequence = object.getAny();
+ for (int r = 0, n = sequence.size(); r < n; r++) {
+
+ // Get each reference value element
+ commonj.sdo.Property referenceElementDef = sequence.getProperty(r);
+ DataObject referenceElement = (DataObject) sequence.getValue(r);
+
+ // Get the corresponding reference definition
+ String referenceName = referenceElementDef.getName();
+ ConfiguredReference configuredReference=component.getConfiguredReference(referenceName);
+ if (configuredReference == null) {
+ throw new IllegalArgumentException("Undefined reference " + referenceName);
+ }
+ ServiceURI referenceURI=factory.createServiceURI(null, component, configuredReference);
+
+ // Get the reference value text
+ Sequence text = referenceElement.getSequence(0);
+ if (text != null && text.size() != 0) {
+ String uri = text.getValue(0).toString();
+ ServiceURI serviceURI=factory.createServiceURI(null, uri);
+
+ // Create a wire
+ Wire wire=factory.createWire();
+ wire.setSource(referenceURI);
+ wire.setTarget(serviceURI);
+ currentAggregate.getWires().add(wire);
+ }
+ }
+ }
+ });
+
+ return object;
+ }
+
+ /**
+ * @see org.apache.tuscany.model.scdl.util.ScdlSwitch#caseEntryPoint(org.apache.tuscany.model.scdl.EntryPoint)
+ */
+ public Object caseEntryPoint(final EntryPoint object) {
+ final org.apache.tuscany.model.assembly.EntryPoint entryPoint=factory.createEntryPoint();
+ entryPoint.setName(object.getName());
+
+ // Create a configured service and a configured reference for this entry point
+ org.apache.tuscany.model.assembly.Service service=factory.createService();
+ service.setName(entryPoint.getName());
+ ConfiguredService configuredService=factory.createConfiguredService();
+ configuredService.setService(service);
+ entryPoint.setConfiguredService(configuredService);
+ org.apache.tuscany.model.assembly.Reference reference=factory.createReference();
+ reference.setName(null);
+ reference.setMultiplicity(transformMultiplicity(object.getMultiplicity()));
+ final ConfiguredReference configuredReference=factory.createConfiguredReference();
+ configuredReference.setReference(reference);
+ entryPoint.setConfiguredReference(configuredReference);
+
+ linkers.add(new Runnable() {
+ public void run() {
+ currentAggregate.getEntryPoints().add(entryPoint);
+
+ // Create wires to the target service
+ final List<Wire>wires=new ArrayList<Wire>();
+ ServiceURI referenceURI=factory.createServiceURI(null, entryPoint, configuredReference);
+ for (String uri : (List<String>)object.getReference()) {
+ ServiceURI serviceURI=factory.createServiceURI(null, uri);
+ final Wire wire=factory.createWire();
+ wire.setSource(referenceURI);
+ wire.setTarget(serviceURI);
+ wires.add(wire);
+ }
+
+ currentAggregate.getWires().addAll(wires);
+ };
+ });
+
+ currentEntryPoint=entryPoint;
+ return entryPoint;
+ }
+
+ /**
+ * @see org.apache.tuscany.model.scdl.util.ScdlSwitch#caseExternalService(org.apache.tuscany.model.scdl.ExternalService)
+ */
+ public Object caseExternalService(ExternalService object) {
+ final org.apache.tuscany.model.assembly.ExternalService externalService=factory.createExternalService();
+ externalService.setName(object.getName());
+
+ OverrideOptions overrideOptions=object.getOverridable();
+ if (overrideOptions==OverrideOptions.MAY_LITERAL)
+ externalService.setOverrideOption(OverrideOption.MAY);
+ else if (overrideOptions==OverrideOptions.MUST_LITERAL)
+ externalService.setOverrideOption(OverrideOption.MUST);
+ else if (overrideOptions==OverrideOptions.NO_LITERAL)
+ externalService.setOverrideOption(OverrideOption.NO);
+ else
+ externalService.setOverrideOption(OverrideOption.NO);
+
+ // Create a configured service for this external service
+ org.apache.tuscany.model.assembly.Service service=factory.createService();
+ service.setName(externalService.getName());
+ ConfiguredService configuredService=factory.createConfiguredService();
+ configuredService.setService(service);
+ externalService.setConfiguredService(configuredService);
+
+ linkers.add(new Runnable() {
+ public void run() {
+ currentAggregate.getExternalServices().add(externalService);
+ };
+ });
+ currentExternalService=externalService;
+ return externalService;
+ }
+
+ /**
+ * @see org.apache.tuscany.model.scdl.util.ScdlSwitch#caseSubsystem(org.apache.tuscany.model.scdl.Subsystem)
+ */
+ public Object caseSubsystem(Subsystem object) {
+ org.apache.tuscany.model.assembly.Subsystem subsystem=factory.createSubsystem();
+ subsystem.setName(object.getName());
+ subsystem.setURI(object.getUri());
+ currentSubsystem=subsystem;
+ currentAggregate=subsystem;
+ return subsystem;
+ }
+
+ /**
+ * @see org.apache.tuscany.model.scdl.util.ScdlSwitch#caseModuleComponent(org.apache.tuscany.model.scdl.ModuleComponent)
+ */
+ public Object caseModuleComponent(ModuleComponent object) {
+ final org.apache.tuscany.model.assembly.ModuleComponent moduleComponent=factory.createModuleComponent();
+ moduleComponent.setName(object.getName());
+ moduleComponent.setURI(object.getUri());
+
+ linkers.add(new Runnable() {
+ public void run() {
+ currentAggregate.getComponents().add(moduleComponent);
+ };
+ });
+
+ currentModuleComponent=moduleComponent;
+ return moduleComponent;
+ }
+
+ /**
+ * @see org.apache.tuscany.model.scdl.util.ScdlSwitch#caseModuleWire(org.apache.tuscany.model.scdl.ModuleWire)
+ */
+ public Object caseModuleWire(ModuleWire object) {
+ final Wire wire=factory.createWire();
+ wire.setSource(factory.createServiceURI(null, object.getSourceUri()));
+ wire.setTarget(factory.createServiceURI(null, object.getTargetUri()));
+
+ linkers.add(new Runnable() {
+ public void run() {
+ currentAggregate.getWires().add(wire);
+ };
+ });
+
+ return wire;
+ }
+
+ /**
+ * @see org.apache.tuscany.model.scdl.util.ScdlSwitch#caseSystemWire(org.apache.tuscany.model.scdl.SystemWire)
+ */
+ public Object caseSystemWire(SystemWire object) {
+ final Wire wire=factory.createWire();
+ wire.setSource(factory.createServiceURI(object.getSource().toString()));
+ wire.setTarget(factory.createServiceURI(object.getTarget().toString()));
+
+ linkers.add(new Runnable() {
+ public void run() {
+ currentAggregate.getWires().add(wire);
+ };
+ });
+
+ return wire;
+ }
+
+ /**
+ * @see org.apache.tuscany.model.scdl.util.ScdlSwitch#caseImplementation(org.apache.tuscany.model.scdl.Implementation)
+ */
+ public Object caseImplementation(Implementation object) {
+ final SimpleComponent component=currentComponent;
+
+ for (SCDLModelLoader scdlModelLoader : scdlModelLoaders) {
+
+ // Invoke an SCDL loader to handle the specific implementation type
+ final ComponentImplementation implementation=(ComponentImplementation)scdlModelLoader.load(modelContext, object);
+ if (implementation!=null) {
+ component.setComponentImplementation(implementation);
+ return implementation;
+ }
+
+ }
+ return null;
+ }
+
+ /**
+ * @see org.apache.tuscany.model.scdl.util.ScdlSwitch#caseBinding(org.apache.tuscany.model.scdl.Binding)
+ */
+ public Object caseBinding(Binding object) {
+
+ final List<org.apache.tuscany.model.assembly.Binding> bindings;
+ Object container=((DataObject)object).getContainer();
+ if (container instanceof EntryPoint) {
+ bindings=currentEntryPoint.getBindings();
+ } else if (container instanceof ExternalService) {
+ bindings=currentExternalService.getBindings();
+ } else
+ bindings=null;
+
+ for (SCDLModelLoader scdlModelLoader : scdlModelLoaders) {
+
+ // Invoke an SCDL loader to handle the specific binding type
+ final org.apache.tuscany.model.assembly.Binding binding=(org.apache.tuscany.model.assembly.Binding)scdlModelLoader.load(modelContext, object);
+ if (binding!=null) {
+ bindings.add(binding);
+ return binding;
+ }
+
+ }
+ return null;
+ }
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/scdl/loader/impl/SCDLXMLReader.java b/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/scdl/loader/impl/SCDLXMLReader.java
new file mode 100644
index 0000000000..6fa426b2f8
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/scdl/loader/impl/SCDLXMLReader.java
@@ -0,0 +1,109 @@
+/**
+ *
+ * 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.io.IOException;
+import java.net.URL;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.tuscany.model.scdl.ComponentType;
+import org.apache.tuscany.model.scdl.Module;
+import org.apache.tuscany.model.scdl.ModuleFragment;
+import org.apache.tuscany.model.scdl.ScdlFactory;
+import org.apache.tuscany.model.scdl.Subsystem;
+import org.apache.tuscany.model.scdl.impl.ScdlPackageImpl;
+import org.apache.tuscany.sdo.util.DataObjectUtil;
+import org.apache.tuscany.sdo.util.SDOUtil;
+import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl;
+
+import commonj.sdo.helper.XMLDocument;
+import commonj.sdo.helper.XMLHelper;
+
+/**
+ */
+public class SCDLXMLReader extends ResourceSetImpl {
+
+ private Map<String, Object> cache=new HashMap<String, Object>();
+
+ // Initialize the SDO runtime and register the SCDL model
+ static {
+ DataObjectUtil.initRuntime();
+ SDOUtil.registerStaticTypes(ScdlFactory.class);
+ }
+
+ /**
+ * Constructor
+ */
+ public SCDLXMLReader() {
+ }
+
+ /**
+ * Returns an SCDL module.
+ * @param uri
+ * @return
+ */
+ public Module getModule(String uri) {
+ return (Module)getRootObject(uri);
+ }
+
+ /**
+ * Returns an SCDL module fragment.
+ * @param uri
+ * @return
+ */
+ public ModuleFragment getModuleFragment(String uri) {
+ return (ModuleFragment)getRootObject(uri);
+ }
+
+ /**
+ * Returns an SCDL component type.
+ * @param uri
+ * @return
+ */
+ public ComponentType getComponentType(String uri) {
+ return (ComponentType)getRootObject(uri);
+ }
+
+ /**
+ * Returns an SCDL subsystem.
+ * @param uri
+ * @return
+ */
+ public Subsystem getSubsystem(String uri) {
+ return (Subsystem)getRootObject(uri);
+ }
+
+ /**
+ * Returns the root object at the given URI.
+ * @param uri
+ * @return
+ */
+ private Object getRootObject(String uri) {
+ Object object = cache.get(uri);
+ if (object==null) {
+ try {
+ XMLDocument document=XMLHelper.INSTANCE.load(new URL(uri).openStream());
+ return document.getRootObject();
+ } catch (IOException e) {
+ throw new RuntimeException(uri, e);
+ }
+ }
+ return object;
+ }
+
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/types/java/JavaServiceContract.java b/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/types/java/JavaServiceContract.java
new file mode 100644
index 0000000000..0a4ea54947
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/types/java/JavaServiceContract.java
@@ -0,0 +1,27 @@
+/**
+ *
+ * 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 {
+
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/types/java/impl/JavaServiceContractImpl.java b/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/types/java/impl/JavaServiceContractImpl.java
new file mode 100644
index 0000000000..589678acbb
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/types/java/impl/JavaServiceContractImpl.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.types.java.impl;
+
+import org.apache.tuscany.model.assembly.AssemblyModelContext;
+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;
+ }
+
+ /**
+ * @see org.apache.tuscany.model.assembly.impl.ExtensibleImpl#initialize(org.apache.tuscany.model.assembly.AssemblyModelContext)
+ */
+ public void initialize(AssemblyModelContext 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/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/types/wsdl/WSDLServiceContract.java b/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/types/wsdl/WSDLServiceContract.java
new file mode 100644
index 0000000000..6133e4a02b
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/types/wsdl/WSDLServiceContract.java
@@ -0,0 +1,52 @@
+/**
+ *
+ * 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
+ */
+ PortType getPortType();
+
+ /**
+ * Sets the WSDL portType.
+ * @param portType
+ */
+ void setPortType(PortType portType);
+
+ /**
+ * Returns the callback WSDL portType.
+ * @return
+ */
+ PortType getCallbackPortType();
+
+ /**
+ * Sets the callback WSDL portType.
+ * @param portType
+ */
+ void setCallbackPortType(PortType portType);
+
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/types/wsdl/impl/WSDLServiceContractImpl.java b/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/types/wsdl/impl/WSDLServiceContractImpl.java
new file mode 100644
index 0000000000..262503feb0
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/types/wsdl/impl/WSDLServiceContractImpl.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.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.List;
+
+import javax.wsdl.Definition;
+import javax.wsdl.Operation;
+import javax.wsdl.PortType;
+import javax.xml.namespace.QName;
+
+import org.apache.tuscany.common.resource.ResourceLoader;
+import org.apache.tuscany.model.assembly.AssemblyModelContext;
+import org.apache.tuscany.model.assembly.impl.ServiceContractImpl;
+import org.apache.tuscany.model.assembly.loader.AssemblyModelLoader;
+import org.apache.tuscany.model.types.wsdl.WSDLServiceContract;
+import org.apache.tuscany.model.util.XMLNameUtil;
+import org.objectweb.asm.ClassWriter;
+import org.objectweb.asm.Type;
+
+import commonj.sdo.DataObject;
+
+/**
+ * An implementation of WSDLServiceContract.
+ */
+public class WSDLServiceContractImpl extends ServiceContractImpl implements WSDLServiceContract {
+
+ private PortType portType;
+ private PortType callbackPortType;
+ private String portTypeURI;
+ private String callbackPortTypeURI;
+
+ /**
+ * Constructor
+ */
+ public WSDLServiceContractImpl() {
+ }
+
+ /**
+ * @see org.apache.tuscany.model.types.wsdl.WSDLServiceContract#getPortType()
+ */
+ public PortType getPortType() {
+ return portType;
+ }
+
+ /**
+ * @see org.apache.tuscany.model.types.wsdl.WSDLServiceContract#setPortType(javax.wsdl.PortType)
+ */
+ public void setPortType(PortType portType) {
+ checkNotFrozen();
+ this.portType=portType;
+ }
+
+ /**
+ * @see org.apache.tuscany.model.types.wsdl.WSDLServiceContract#getCallbackPortType()
+ */
+ public PortType getCallbackPortType() {
+ return callbackPortType;
+ }
+
+ /**
+ * @see org.apache.tuscany.model.types.wsdl.WSDLServiceContract#setCallbackPortType(javax.wsdl.PortType)
+ */
+ public void setCallbackPortType(PortType portType) {
+ checkNotFrozen();
+ callbackPortType=portType;
+ }
+
+ /**
+ * @param portTypeURI The portTypeURI to set.
+ */
+ public void setPortTypeURI(String portTypeURI) {
+ this.portTypeURI = portTypeURI;
+ }
+
+ /**
+ * @param callbackPortTypeURI The callbackPortTypeURI to set.
+ */
+ public void setCallbackPortTypeURI(String callbackPortTypeURI) {
+ this.callbackPortTypeURI = callbackPortTypeURI;
+ }
+
+ /**
+ * @see org.apache.tuscany.model.assembly.impl.ExtensibleImpl#initialize(org.apache.tuscany.model.assembly.AssemblyModelContext)
+ */
+ public void initialize(AssemblyModelContext modelContext) {
+ if (isInitialized())
+ return;
+ super.initialize(modelContext);
+
+ // Resolve the WSDL portType and callback portType
+ AssemblyModelLoader modelLoader=modelContext.getAssemblyLoader();
+ if (portTypeURI!=null && portType==null) {
+ portType=getPortType(modelLoader, portTypeURI);
+ }
+ if (callbackPortTypeURI!=null && callbackPortType==null) {
+ callbackPortType=getPortType(modelLoader, callbackPortTypeURI);
+ }
+
+ // 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.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.getApplicationResourceLoader(), portType, interfaceName);
+ }
+ super.setCallbackInterface(interfaceClass);
+ }
+ }
+
+ /**
+ * Get a portType from the given uri
+ * @param loader
+ * @param uri
+ * @return
+ */
+ private PortType getPortType(AssemblyModelLoader loader, String uri) {
+
+ // Get the WSDL port namespace and name
+ int h=uri.indexOf('#');
+ String namespace=uri.substring(0,h);
+ String name=uri.substring(h+1);
+ QName qname=new QName(namespace, name);
+
+ // Load the WSDL definitions for the given namespace
+ List<Definition> definitions=loader.loadDefinitions(namespace);
+ if (definitions==null)
+ throw new IllegalArgumentException("Cannot find WSDL definition for "+namespace);
+ for (Definition definition: definitions) {
+
+ // Find the port with the given name
+ PortType portType=definition.getPortType(qname);
+ return portType;
+ }
+ throw new IllegalArgumentException("Cannot find WSDL portType "+uri);
+ }
+
+ /**
+ * Generate a Java interface from a WSDL portType.
+ * @param portType
+ * @param interfaceName
+ * @return
+ */
+ private Class generateJavaInterface(ResourceLoader resourceLoader, PortType portType, String interfaceName) {
+ 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", new String[0]);
+
+
+ // Generate methods from the WSDL operations
+ for (Operation operation : (List<Operation>)portType.getOperations()) {
+ String methodName=XMLNameUtil.getJavaNameFromXMLName(operation.getName(), false);
+
+ //FIXME integrate XSD to Java type mapping here
+ String inputType = Type.getDescriptor(String.class);
+ String outputType = Type.getDescriptor(String.class);
+
+ cw.visitMethod(ACC_PUBLIC + ACC_ABSTRACT, methodName, "("+inputType+")"+outputType, null, null).visitEnd();
+ }
+
+ // Generate the bytecodes
+ cw.visitEnd();
+ byte[] bytes=cw.toByteArray();
+
+ // Add the class to the resource loader
+ Class interfaceClass=(Class)resourceLoader.addClass(bytes);
+
+ return interfaceClass;
+ }
+
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/util/ModelContentHandler.java b/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/util/ModelContentHandler.java
new file mode 100644
index 0000000000..515d2128ec
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/util/ModelContentHandler.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.util;
+
+import java.util.List;
+import java.util.Map;
+
+/**
+ * A model content handler. This mimics a SAX content handler for models and
+ * receives notification of the content of a model. A model content handler is
+ * responsible for handling model content notifications. As part of the handling
+ * the handler can produce new contents.
+ */
+public interface ModelContentHandler {
+
+ /**
+ * Starts handling of a model.
+ */
+ public void startModel();
+
+ /**
+ * Ends handling of a model.
+ */
+ public void endModel();
+
+ /**
+ * Sets the contents list, where the content handler should store
+ * the contents that it produces.
+ * @param contents The contents to set
+ */
+ public void setContents(List contents);
+
+ /**
+ * Sets the linkers list. A content handler can add linker objects to this
+ * list. Linker objects must implement java.lang.Runnable. They are
+ * run as part of the endModel notification processing.
+ * Typically linker objects are used to resolve model forward references
+ * or establish model relationships after the model content has been
+ * handled.
+ * @param linkers The linkers to set
+ */
+ public void setLinkers(List linkers);
+
+ /**
+ * Sets the targets map. This map keeps track of the objects returned by
+ * the content handler for each object passed to its doSwitch method.
+ * @param targets The targets to set
+ */
+ public void setTargets(Map targets);
+
+ /**
+ * This method dispatches handling of the given object (XYZ for example) to a
+ * corresponding "caseXYZ()" method on the content handler.
+ */
+ public Object doSwitch(Object object);
+
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/util/ModelTransformer.java b/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/util/ModelTransformer.java
new file mode 100644
index 0000000000..2a6fbe2f8a
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/util/ModelTransformer.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.util;
+
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * A model transformer. Invokes a model content handler to perform the actual transformation.
+ */
+public interface ModelTransformer {
+
+ /**
+ * Uses a ModelContentHandler to transform a model.
+ */
+ public List transform(Iterator iterator, ModelContentHandler handler);
+
+ /**
+ * Uses a ModelContentHandler to transform a model. Performs the first
+ * transform pass.
+ */
+ public List transformPass1(Iterator iterator, ModelContentHandler handler, List deferredHandlers);
+
+ /**
+ * Uses a ModelContentHandler to transform a model. Performs the first
+ * transform pass.
+ */
+ public List transformPass1(Iterator iterator, final ModelContentHandler handler, List deferredHandlers, Map targets, List contents);
+
+ /**
+ * Uses a ModelContentHandler to transform a model. Performs the second
+ * transform pass.
+ */
+ public void transformPass2(List deferredHandlers);
+
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/util/ModelTransformerImpl.java b/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/util/ModelTransformerImpl.java
new file mode 100644
index 0000000000..85458b03ef
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/util/ModelTransformerImpl.java
@@ -0,0 +1,125 @@
+/**
+ *
+ * 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.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+
+/**
+ * @author jsdelfino
+ *
+ * Base implementation for a model transformer.
+ * Invokes a model content handler to perform the actual transformation.
+ */
+public class ModelTransformerImpl implements ModelTransformer {
+
+ /**
+ * Uses a ModelContentHandler to transform a model.
+ */
+ public List transform(Iterator iterator, ModelContentHandler handler) {
+
+ // Pass 1: visit the source model and create target model objects
+ List linkers=new ArrayList();
+ List contents=transformPass1(iterator, handler, linkers);
+
+ // Pass 2: resolve the links between the target model objects
+ transformPass2(linkers);
+
+ // Return the target model contents
+ return contents;
+ }
+
+ /**
+ * Uses a ModelContentHandler to transform a model.
+ */
+ public List transformPass1(Iterator iterator, final ModelContentHandler handler, List deferredHandlers, Map targets, List contents) {
+
+ // Initialize the handler
+ handler.setTargets(targets);
+ handler.setLinkers(deferredHandlers);
+ handler.setContents(contents);
+
+ // This runnable will invoke endModel and clean up the handler
+ Runnable cleanup=new Runnable() {
+ public void run() {
+
+ // Cleanup
+ handler.endModel();
+
+ handler.setTargets(null);
+ handler.setLinkers(null);
+ handler.setContents(null);
+ }
+ };
+
+ // Run the handler
+ try {
+ handler.startModel();
+
+ // Pass 1: compile, visit the source model and create target model objects
+ for (; iterator.hasNext(); ) {
+ Object source=iterator.next();
+ if (source==null)
+ System.out.println("Ooops");
+ Object target=handler.doSwitch(source);
+
+ // Record source to target associations
+ targets.put(source,target);
+ }
+
+ // Add the cleanup runnable
+ deferredHandlers.add(cleanup);
+
+ } catch (Exception e) {
+
+ // An exception occurred, run the cleanup now
+ cleanup.run();
+ throw new RuntimeException(e);
+ }
+
+ // return the target model contents
+ // note that this list may actually be populated in pass2
+ return contents;
+ }
+
+ /**
+ * Uses a ModelContentHandler to transform a model.
+ */
+ public List transformPass1(Iterator iterator, final ModelContentHandler handler, List deferredHandlers) {
+ Map targets=new HashMap();
+ List contents=new ArrayList();
+ return transformPass1(iterator,handler,deferredHandlers,targets,contents);
+ }
+
+ /**
+ * Uses a ModelContentHandler to transform a model.
+ */
+ public void transformPass2(List deferredHandlers) {
+
+ // Pass 2: link, resolve the links between the target model objects
+ for (Iterator i=deferredHandlers.iterator(); i.hasNext(); ) {
+ Runnable runnable=(Runnable)i.next();
+ runnable.run();
+ }
+
+ }
+
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/util/XMLNameUtil.java b/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/util/XMLNameUtil.java
new file mode 100644
index 0000000000..be707dbb9c
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/model/src/main/java/org/apache/tuscany/model/util/XMLNameUtil.java
@@ -0,0 +1,227 @@
+/**
+ *
+ * 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.Arrays;
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.List;
+
+import org.eclipse.emf.common.util.URI;
+
+/**
+ * A utility class that converts between XML names and Java names.
+ */
+public class XMLNameUtil {
+
+ private static final List domains = Arrays.asList(new String[]{"COM", "com", "ORG", "org"});
+
+ /**
+ * Constructor
+ */
+ private XMLNameUtil() {
+ super();
+ }
+
+ /**
+ * Return an EPackage name for the given namespace.
+ *
+ * @param namespace
+ * @return
+ */
+ public static String getPackageNameFromNamespace(String namespace) {
+
+ URI uri = URI.createURI(namespace);
+ List parsedName;
+ if (uri.isHierarchical()) {
+ String host = uri.host();
+ if (host != null && host.startsWith("www.")) {
+ host = host.substring(4);
+ }
+ parsedName = parseName(host, '.');
+ Collections.reverse(parsedName);
+ if (!parsedName.isEmpty()) {
+ parsedName.set(0, ((String) parsedName.get(0)).toLowerCase());
+ }
+
+ parsedName.addAll(parseName(uri.trimFileExtension().path(), '/'));
+
+ } else {
+ String opaquePart = uri.opaquePart();
+ int index = opaquePart.indexOf(":");
+ if (index != -1 && "urn".equalsIgnoreCase(uri.scheme())) {
+ parsedName = parseName(opaquePart.substring(0, index), '-');
+ if (parsedName.size() > 0 && domains.contains(parsedName.get(parsedName.size() - 1))) {
+ Collections.reverse(parsedName);
+ parsedName.set(0, ((String) parsedName.get(0)).toLowerCase());
+ }
+ parsedName.addAll(parseName(opaquePart.substring(index + 1), '/'));
+
+ } else {
+ parsedName = parseName(opaquePart, '/');
+ }
+ }
+
+ StringBuffer qualifiedPackageName = new StringBuffer();
+ for (Iterator i = parsedName.iterator(); i.hasNext();) {
+ String packageName = (String) i.next();
+ if (packageName.length() > 0) {
+ if (qualifiedPackageName.length() > 0) {
+ qualifiedPackageName.append('.');
+ }
+ qualifiedPackageName.append(getJavaNameFromXMLName(packageName, false));
+ }
+ }
+ return qualifiedPackageName.toString();
+
+ }
+
+ /**
+ * Returns a namespace prefix for the given package Name
+ *
+ * @param packageName
+ * @return
+ */
+ public static String getNSPrefixFromPackageName(String packageName) {
+ String nsPrefix = packageName;
+ int index = nsPrefix.lastIndexOf('.');
+ return index == -1 ? nsPrefix : nsPrefix.substring(index + 1);
+ }
+
+ /**
+ * Parse the given name.
+ *
+ * @param sourceName
+ * @param separator
+ * @return
+ */
+ private static List parseName(String sourceName, char separator) {
+ List result = new ArrayList();
+ if (sourceName != null) {
+ StringBuffer currentWord = new StringBuffer();
+ boolean lastIsLower = false;
+ for (int 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 StringBuffer();
+ }
+ 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 StringBuffer();
+ 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
+ */
+ public static String getJavaNameFromXMLName(String name, boolean isUpperCase) {
+ List parsedName = parseName(name, '_');
+ StringBuffer result = new StringBuffer();
+ for (Iterator i = parsedName.iterator(); i.hasNext();) {
+ String nameComponent = (String) i.next();
+ 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);
+ }
+ }
+ }
+
+ return result.length() == 0 ? "_" : Character.isJavaIdentifierStart(result.charAt(0)) ? isUpperCase ? result.toString() : decapitalizeName(result.toString()) : "_" + result;
+ }
+
+ /**
+ * Returns a valid fully qualified class name from a QName
+ * @param namespace
+ * @param name
+ * @return
+ */
+ public static String getFullyQualifiedClassNameFromQName(String namespace, String name) {
+ return XMLNameUtil.getPackageNameFromNamespace(namespace)+'.'+XMLNameUtil.getJavaNameFromXMLName(name, true);
+ }
+
+ /**
+ * Decapitalize a name.
+ * @param name
+ * @return
+ */
+ 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
+ */
+ 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);
+ }
+ }
+
+} \ No newline at end of file