summaryrefslogtreecommitdiffstats
path: root/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/builder
diff options
context:
space:
mode:
Diffstat (limited to 'sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/builder')
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/builder/BuilderConfigException.java26
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/builder/BuilderException.java41
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/builder/BuilderInitException.java39
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/builder/ConfigurationException.java26
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/builder/ContextCreationException.java41
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/builder/HierarchicalWireBuilder.java29
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/builder/NoAccessorException.java39
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/builder/ObjectFactory.java19
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/builder/RuntimeConfiguration.java69
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/builder/RuntimeConfigurationBuilder.java24
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/builder/UnknownTypeException.java26
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/builder/WireBuilder.java60
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/builder/impl/AssemblyVisitor.java62
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/builder/impl/BaseExternalServiceRuntimeConfiguration.java106
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/builder/impl/DefaultWireBuilder.java110
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/builder/impl/EntryPointRuntimeConfiguration.java104
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/builder/impl/HierarchicalBuilder.java58
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/builder/impl/ProxyObjectFactory.java42
18 files changed, 921 insertions, 0 deletions
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/builder/BuilderConfigException.java b/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/builder/BuilderConfigException.java
new file mode 100644
index 0000000000..04b7b69cf5
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/builder/BuilderConfigException.java
@@ -0,0 +1,26 @@
+package org.apache.tuscany.core.builder;
+
+/**
+ * Represents an error processing a logical configuration model
+ *
+ * @version $Rev$ $Date$
+ */
+public class BuilderConfigException extends BuilderException {
+
+ public BuilderConfigException() {
+ super();
+ }
+
+ public BuilderConfigException(String message) {
+ super(message);
+ }
+
+ public BuilderConfigException(String message, Throwable cause) {
+ super(message, cause);
+ }
+
+ public BuilderConfigException(Throwable cause) {
+ super(cause);
+ }
+
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/builder/BuilderException.java b/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/builder/BuilderException.java
new file mode 100644
index 0000000000..246f188988
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/builder/BuilderException.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.core.builder;
+
+import org.apache.tuscany.core.context.CoreRuntimeException;
+
+/**
+ * The root exception for the builder package. Builder exceptions denote a non-recoverable failure.
+ *
+ * @version $Rev$ $Date$
+ */
+public abstract class BuilderException extends CoreRuntimeException {
+
+ public BuilderException() {
+ super();
+ }
+
+ public BuilderException(String message) {
+ super(message);
+ }
+
+ public BuilderException(String message, Throwable cause) {
+ super(message, cause);
+ }
+
+ public BuilderException(Throwable cause) {
+ super(cause);
+ }
+
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/builder/BuilderInitException.java b/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/builder/BuilderInitException.java
new file mode 100644
index 0000000000..cd57eaf7ab
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/builder/BuilderInitException.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.core.builder;
+
+/**
+ * Denotes an exception initializing a builder
+ *
+ * @version $Rev$ $Date$
+ */
+public class BuilderInitException extends BuilderException {
+
+ public BuilderInitException() {
+ super();
+ }
+
+ public BuilderInitException(String message, Throwable cause) {
+ super(message, cause);
+ }
+
+ public BuilderInitException(String message) {
+ super(message);
+ }
+
+ public BuilderInitException(Throwable cause) {
+ super(cause);
+ }
+
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/builder/ConfigurationException.java b/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/builder/ConfigurationException.java
new file mode 100644
index 0000000000..70a31c34c6
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/builder/ConfigurationException.java
@@ -0,0 +1,26 @@
+package org.apache.tuscany.core.builder;
+
+/**
+ * Represents an error processing a logical configuration model
+ *
+ * @version $Rev$ $Date$
+ */
+public class ConfigurationException extends BuilderException {
+
+ public ConfigurationException() {
+ super();
+ }
+
+ public ConfigurationException(String message) {
+ super(message);
+ }
+
+ public ConfigurationException(String message, Throwable cause) {
+ super(message, cause);
+ }
+
+ public ConfigurationException(Throwable cause) {
+ super(cause);
+ }
+
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/builder/ContextCreationException.java b/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/builder/ContextCreationException.java
new file mode 100644
index 0000000000..24b526371d
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/builder/ContextCreationException.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.core.builder;
+
+
+/**
+ * Denotes an exception creating an instance context
+ *
+ * @version $Rev$ $Date$
+ */
+public class ContextCreationException extends BuilderException {
+
+ public ContextCreationException() {
+ super();
+ }
+
+ public ContextCreationException(String message) {
+ super(message);
+ }
+
+ public ContextCreationException(String message, Throwable cause) {
+ super(message, cause);
+ }
+
+ public ContextCreationException(Throwable cause) {
+ super(cause);
+ }
+
+}
+
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/builder/HierarchicalWireBuilder.java b/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/builder/HierarchicalWireBuilder.java
new file mode 100644
index 0000000000..ace34a1ad5
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/builder/HierarchicalWireBuilder.java
@@ -0,0 +1,29 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
+ * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations under the License.
+ */
+package org.apache.tuscany.core.builder;
+
+/**
+ * A wire builder that delegates to child wire builders
+ *
+ * @version $Rev$ $Date$
+ */
+public interface HierarchicalWireBuilder extends WireBuilder{
+
+ /**
+ * Registers a child wire builder
+ */
+ public void addWireBuilder(WireBuilder builder);
+
+}
+
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/builder/NoAccessorException.java b/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/builder/NoAccessorException.java
new file mode 100644
index 0000000000..34b6294638
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/builder/NoAccessorException.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.core.builder;
+
+/**
+ * Denotes an attempt to access a non-existent field or method
+ *
+ * @version $Rev$ $Date$
+ */
+public class NoAccessorException extends BuilderException {
+
+ public NoAccessorException() {
+ super();
+ }
+
+ public NoAccessorException(String message) {
+ super(message);
+ }
+
+ public NoAccessorException(String message, Throwable cause) {
+ super(message, cause);
+ }
+
+ public NoAccessorException(Throwable cause) {
+ super(cause);
+ }
+
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/builder/ObjectFactory.java b/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/builder/ObjectFactory.java
new file mode 100644
index 0000000000..7d27df4ebd
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/builder/ObjectFactory.java
@@ -0,0 +1,19 @@
+package org.apache.tuscany.core.builder;
+
+import org.apache.tuscany.core.injection.ObjectCreationException;
+
+/**
+ * Implementations create new instances of a particular type
+ *
+ * @version $Rev$ $Date$
+ */
+public interface ObjectFactory<T> {
+
+ /**
+ * Return a instance of the type that this factory creates.
+ *
+ * @return a instance from this factory
+ */
+ T getInstance() throws ObjectCreationException;
+
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/builder/RuntimeConfiguration.java b/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/builder/RuntimeConfiguration.java
new file mode 100644
index 0000000000..79396e6052
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/builder/RuntimeConfiguration.java
@@ -0,0 +1,69 @@
+package org.apache.tuscany.core.builder;
+
+import java.util.Map;
+
+import org.apache.tuscany.core.context.Context;
+import org.apache.tuscany.core.invocation.spi.ProxyFactory;
+import org.apache.tuscany.model.assembly.Scope;
+
+/**
+ * Implementations create instances of {@link org.apache.tuscany.core.context.Context} based on a compiled
+ * configuration, such as a logical assembly model. For example, implementations of
+ * {@link org.apache.tuscany.core.builder.RuntimeConfigurationBuilder} analyze an
+ * {@link org.apache.tuscany.model.assembly.AssemblyModelObject} to create implementations of
+ * <tt>RuntimeConfiguration</tt>.
+ *
+ * @version $Rev$ $Date$
+ */
+public interface RuntimeConfiguration<T extends Context> {
+
+ /**
+ * Creates an instance context based on the current runtime configuration
+ *
+ * @return a new instance context
+ * @throws ContextCreationException if an error occurs creating the context
+ */
+ public T createInstanceContext() throws ContextCreationException;
+
+ /**
+ * Returns the scope identifier associated with the type of contexts produced by the current configuration
+ */
+ public Scope getScope();
+
+ /**
+ * Returns the name of the contexts produced by the current configuration
+ */
+ public String getName();
+
+ public void prepare();
+
+ /**
+ * Adds a target-side proxy factory for the given service name to the configuration. Target-side proxy factories
+ * contain the invocation chains associated with the destination service of a wire and are responsible for
+ * generating proxies
+ */
+ public void addTargetProxyFactory(String serviceName, ProxyFactory factory);
+
+ /**
+ * Returns the target-side proxy factory associated with the given service name
+ */
+ public ProxyFactory getTargetProxyFactory(String serviceName);
+
+ /**
+ * Returns a collection of target-side proxy factories for the configuration keyed by service name
+ */
+ public Map<String, ProxyFactory> getTargetProxyFactories();
+
+ /**
+ * Adds a source-side proxy factory for the given reference. Source-side proxy factories contain the invocation
+ * chains for a reference in the component implementation associated with the instance context created by this
+ * configuration. Source-side proxy factories also produce proxies that are injected on a reference in a component
+ * implementation.
+ */
+ public void addSourceProxyFactory(String referenceName, ProxyFactory factory);
+
+ public ProxyFactory getSourceProxyFactory(String referenceName);
+
+ public Map<String, ProxyFactory> getSourceProxyFactories();
+
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/builder/RuntimeConfigurationBuilder.java b/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/builder/RuntimeConfigurationBuilder.java
new file mode 100644
index 0000000000..d797253520
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/builder/RuntimeConfigurationBuilder.java
@@ -0,0 +1,24 @@
+package org.apache.tuscany.core.builder;
+
+import org.apache.tuscany.core.context.Context;
+import org.apache.tuscany.model.assembly.AssemblyModelObject;
+
+/**
+ * Implementations are responsible for generating a runtime configuration model from a logical configuration model. The
+ * logical configuration model (LCM) is decorated with the runtime configuration model (RCM).
+ *
+ * @version $Rev$ $Date$
+ * @see RuntimeConfiguration
+ */
+public interface RuntimeConfigurationBuilder<Y extends Context> {
+
+ /**
+ * Builds a runtime configuration for the supplied model object for registration under the supplied context.
+ *
+ * @param object the logical configuration model node
+ * @param context the context that will be the parent of the built context
+ * @throws BuilderException
+ */
+ public void build(AssemblyModelObject object, Y context) throws BuilderException;
+
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/builder/UnknownTypeException.java b/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/builder/UnknownTypeException.java
new file mode 100644
index 0000000000..015b0ba342
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/builder/UnknownTypeException.java
@@ -0,0 +1,26 @@
+package org.apache.tuscany.core.builder;
+
+/**
+ * Denotes an unknown configuration parameter type
+ *
+ * @version $Rev$ $Date$
+ */
+public class UnknownTypeException extends BuilderException {
+
+ public UnknownTypeException() {
+ super();
+ }
+
+ public UnknownTypeException(String message) {
+ super(message);
+ }
+
+ public UnknownTypeException(String message, Throwable cause) {
+ super(message, cause);
+ }
+
+ public UnknownTypeException(Throwable cause) {
+ super(cause);
+ }
+
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/builder/WireBuilder.java b/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/builder/WireBuilder.java
new file mode 100644
index 0000000000..6f0cf9ce14
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/builder/WireBuilder.java
@@ -0,0 +1,60 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
+ * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations under the License.
+ */
+package org.apache.tuscany.core.builder;
+
+import org.apache.tuscany.core.context.ScopeContext;
+import org.apache.tuscany.core.invocation.spi.ProxyFactory;
+
+/**
+ * Responsible for finalizing target-side proxy factories and bridging
+ * {@link org.apache.tuscany.core.invocation.InvocationConfiguration}s held by source- and target-side proxy factories.
+ * <p>
+ * Wire builders may optimize the invocation chains based on certain characteristics of th wire, such as source and
+ * target scopes.
+ *
+ * @version $Rev$ $Date$
+ */
+public interface WireBuilder {
+
+ /**
+ * Connects invocation configurations of the source proxy factory to corresponding ones in the target proxy to
+ * factory
+ *
+ * @param sourceFactory the proxy factory used in constructing the source side of the invocation chain
+ * @param targetFactory the proxy factory used in constructing the target side of the invocation chain
+ * @param targetType the context type of the target. Used to determine if a paricular wire builder should construct
+ * the wire
+ * @param downScope true if the component containing the reference (source side) is of a lesser scope than the
+ * target service
+ * @param targetScopeContext the scope context responsible for managing intance contexts of the target component
+ * type
+ * @throws BuilderConfigException if an error occurs during the wire build process
+ */
+ public void connect(ProxyFactory sourceFactory, ProxyFactory targetFactory, Class targetType, boolean downScope,
+ ScopeContext targetScopeContext) throws BuilderConfigException;
+
+ /**
+ * Finishes processing the target side invocation chain. For example, a
+ * {@link org.apache.tuscany.core.invocation.TargetInvoker} used by target-side proxies is usually set during this
+ * phase.
+ *
+ * @param targetFactory the target-side proxy factory
+ * @param targetType the target context type
+ * @param targetScopeContext the target scope
+ * @throws BuilderConfigException if an error occurs during the wire build process
+ */
+ public void completeTargetChain(ProxyFactory targetFactory, Class targetType, ScopeContext targetScopeContext)
+ throws BuilderConfigException;
+
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/builder/impl/AssemblyVisitor.java b/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/builder/impl/AssemblyVisitor.java
new file mode 100644
index 0000000000..20e9143537
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/builder/impl/AssemblyVisitor.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.core.builder.impl;
+
+import java.util.List;
+
+import org.apache.tuscany.core.builder.RuntimeConfigurationBuilder;
+import org.apache.tuscany.core.context.AggregateContext;
+import org.apache.tuscany.model.assembly.AssemblyModelObject;
+import org.apache.tuscany.model.assembly.AssemblyModelVisitor;
+
+/**
+ * Decorates an assembly object graph with runtime configurations using a set of builders
+ *
+ * @version $Rev$ $Date$
+ */
+public class AssemblyVisitor implements AssemblyModelVisitor {
+
+ private AggregateContext parent;
+
+ List<RuntimeConfigurationBuilder> builders;
+
+ /**
+ * Constructs a visitor
+ *
+ * @param parent the parent context for the object graph
+ * @param builders the collection of builders for creating runtime configurations
+ */
+ public AssemblyVisitor(AggregateContext parent, List<RuntimeConfigurationBuilder> builders) {
+ this.parent = parent;
+ this.builders = builders;
+ }
+
+ /**
+ * Initiate walking the object graph
+ */
+ public boolean start(AssemblyModelObject modelObject) {
+ return modelObject.accept(this);
+ }
+
+ /**
+ * Callback when walking the graph
+ */
+ public boolean visit(AssemblyModelObject modelObject) {
+ for (RuntimeConfigurationBuilder builder : builders) {
+ builder.build(modelObject, parent);
+ }
+ return true;
+ }
+
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/builder/impl/BaseExternalServiceRuntimeConfiguration.java b/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/builder/impl/BaseExternalServiceRuntimeConfiguration.java
new file mode 100644
index 0000000000..ce092a7d34
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/builder/impl/BaseExternalServiceRuntimeConfiguration.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.core.builder.impl;
+
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.tuscany.core.builder.ContextCreationException;
+import org.apache.tuscany.core.builder.ObjectFactory;
+import org.apache.tuscany.core.builder.RuntimeConfiguration;
+import org.apache.tuscany.core.context.ExternalServiceContext;
+import org.apache.tuscany.core.context.impl.ExternalServiceContextImpl;
+import org.apache.tuscany.core.invocation.spi.ProxyFactory;
+import org.apache.tuscany.model.assembly.Scope;
+
+/**
+ * A template implementation that creates instances of {@link org.apache.tuscany.core.context.ExternalServiceContext}
+ * configured with the appropriate invocation chains and bindings. This class is intended to be subclassed when
+ * contributing new bindings to the runtime. The subclass serves as a marker so the binding {@link WireBuilder}
+ * responsible for setting the proper {@link org.apache.tuscany.core.invocation.TargetInvoker} on the invocation chains
+ * can be notified.
+ *
+ * @version $Rev$ $Date$
+ */
+public abstract class BaseExternalServiceRuntimeConfiguration implements RuntimeConfiguration<ExternalServiceContext> {
+
+ private String name;
+
+ private ProxyFactory proxyFactory;
+
+ private ObjectFactory objectFactory;
+
+ private String targetServiceName;
+
+ private Map<String,ProxyFactory> targetProxyFactories;
+
+ public BaseExternalServiceRuntimeConfiguration(String name, ObjectFactory objectFactory) {
+ assert (name != null) : "Name was null";
+ assert (objectFactory != null) : "Object factory was null";
+ this.name = name;
+ this.objectFactory = objectFactory;
+ }
+
+ public ExternalServiceContext createInstanceContext() throws ContextCreationException {
+ return new ExternalServiceContextImpl(name, proxyFactory, objectFactory);
+ }
+
+ public Scope getScope() {
+ return Scope.MODULE;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void prepare() {
+ }
+
+ public void addTargetProxyFactory(String serviceName, ProxyFactory factory) {
+ assert (serviceName != null) : "No service name specified";
+ assert (factory != null) : "Proxy factory was null";
+ this.targetServiceName = serviceName; // external services are configured with only one service
+ this.proxyFactory = factory;
+ }
+
+ public ProxyFactory getTargetProxyFactory(String serviceName) {
+ if (this.targetServiceName.equals(serviceName)) {
+ return proxyFactory;
+ } else {
+ return null;
+ }
+ }
+
+ public Map<String,ProxyFactory> getTargetProxyFactories() {
+ if (targetProxyFactories == null) {
+ targetProxyFactories = new HashMap(1);
+ targetProxyFactories.put(targetServiceName, proxyFactory);
+ }
+ return targetProxyFactories;
+ }
+
+ public void addSourceProxyFactory(String referenceName, ProxyFactory factory) {
+ // no wires inside an aggregate from an external service
+ }
+
+ public ProxyFactory getSourceProxyFactory(String referenceName) {
+ return null;
+ }
+
+ public Map getSourceProxyFactories() {
+ return Collections.EMPTY_MAP;
+ }
+
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/builder/impl/DefaultWireBuilder.java b/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/builder/impl/DefaultWireBuilder.java
new file mode 100644
index 0000000000..6ed5472a64
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/builder/impl/DefaultWireBuilder.java
@@ -0,0 +1,110 @@
+/**
+ *
+ * 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.core.builder.impl;
+
+import java.lang.reflect.Method;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.tuscany.core.builder.BuilderConfigException;
+import org.apache.tuscany.core.builder.HierarchicalWireBuilder;
+import org.apache.tuscany.core.builder.WireBuilder;
+import org.apache.tuscany.core.context.QualifiedName;
+import org.apache.tuscany.core.context.ScopeContext;
+import org.apache.tuscany.core.invocation.InvocationConfiguration;
+import org.apache.tuscany.core.invocation.impl.InvokerInterceptor;
+import org.apache.tuscany.core.invocation.impl.MessageChannelImpl;
+import org.apache.tuscany.core.invocation.spi.ProxyFactory;
+
+/**
+ * The top-most wire builder configured in a runtime. Responsible for constructing wires from source and target chains,
+ * this implementation first bridges the chains and then delegates to any other wire builders.
+ *
+ * @version $Rev$ $Date$
+ */
+public class DefaultWireBuilder implements HierarchicalWireBuilder {
+
+ // collection configured wire builders
+ private List<WireBuilder> builders = new ArrayList();
+
+ public DefaultWireBuilder() {
+ }
+
+ /**
+ * Adds a wire builder to delegate to
+ */
+ public void addWireBuilder(WireBuilder builder) {
+ builders.add(builder);
+ }
+
+ public void setWireBuilders(List<WireBuilder> builders) {
+ builders.addAll(builders);
+ }
+
+ public void connect(ProxyFactory sourceFactory, ProxyFactory targetFactory, Class targetType, boolean downScope,
+ ScopeContext targetScopeContext) {
+ QualifiedName targetName = sourceFactory.getProxyConfiguration().getTargetName();
+ // get the proxy chain for the target
+ if (targetFactory != null) {
+ // if null, the target side has no interceptors or handlers
+ Map<Method, InvocationConfiguration> targetInvocationConfigs = targetFactory.getProxyConfiguration()
+ .getInvocationConfigurations();
+ for (InvocationConfiguration sourceInvocationConfig : sourceFactory.getProxyConfiguration()
+ .getInvocationConfigurations().values()) {
+ // match invocation chains
+ InvocationConfiguration targetInvocationConfig = targetInvocationConfigs.get(sourceInvocationConfig.getMethod());
+ // if handler is configured, add that
+ if (targetInvocationConfig.getRequestHandlers() != null) {
+ sourceInvocationConfig.setTargetRequestChannel(new MessageChannelImpl(targetInvocationConfig
+ .getRequestHandlers()));
+ sourceInvocationConfig.setTargetResponseChannel(new MessageChannelImpl(targetInvocationConfig
+ .getResponseHandlers()));
+ } else {
+ // no handlers, just connect interceptors
+ if (targetInvocationConfig.getTargetInterceptor() == null) {
+ BuilderConfigException e = new BuilderConfigException("No target handler or interceptor for operation");
+ e.setIdentifier(targetInvocationConfig.getMethod().getName());
+ throw e;
+ }
+ if (!(sourceInvocationConfig.getLastTargetInterceptor() instanceof InvokerInterceptor && targetInvocationConfig
+ .getTargetInterceptor() instanceof InvokerInterceptor)) {
+ // check that we do not have the case where the only interceptors are invokers since we just need one
+ sourceInvocationConfig.addTargetInterceptor(targetInvocationConfig.getTargetInterceptor());
+ }
+ }
+ }
+ }
+ // delegate to other wire builders
+ for (WireBuilder builder : builders) {
+ builder.connect(sourceFactory, targetFactory, targetType, downScope, targetScopeContext);
+ }
+ // signal that wire build process is complete
+ boolean optimizable = true;
+ for (InvocationConfiguration sourceInvocationConfig : sourceFactory.getProxyConfiguration().getInvocationConfigurations()
+ .values()) {
+ sourceInvocationConfig.build();
+ // TODO optimize if no proxy needed using NullProxyFactory
+ }
+ }
+
+ public void completeTargetChain(ProxyFactory targetFactory, Class targetType, ScopeContext targetScopeContext)
+ throws BuilderConfigException {
+ // delegate to other wire builders
+ for (WireBuilder builder : builders) {
+ builder.completeTargetChain(targetFactory, targetType, targetScopeContext);
+ }
+ }
+
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/builder/impl/EntryPointRuntimeConfiguration.java b/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/builder/impl/EntryPointRuntimeConfiguration.java
new file mode 100644
index 0000000000..108cc2d366
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/builder/impl/EntryPointRuntimeConfiguration.java
@@ -0,0 +1,104 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
+ * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations under the License.
+ */
+package org.apache.tuscany.core.builder.impl;
+
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.tuscany.core.builder.ContextCreationException;
+import org.apache.tuscany.core.builder.RuntimeConfiguration;
+import org.apache.tuscany.core.context.EntryPointContext;
+import org.apache.tuscany.core.context.impl.EntryPointContextImpl;
+import org.apache.tuscany.core.invocation.spi.ProxyFactory;
+import org.apache.tuscany.core.message.MessageFactory;
+import org.apache.tuscany.model.assembly.Scope;
+
+/**
+ * Produces entry point contexts
+ *
+ * @version $Rev$ $Date$
+ */
+public abstract class EntryPointRuntimeConfiguration implements RuntimeConfiguration<EntryPointContext> {
+
+ private String name;
+
+ private ProxyFactory proxyFactory;
+
+ private String referenceName;
+
+ private MessageFactory msgFactory;
+
+ private Map<String, ProxyFactory> sourceProxyFactories;
+
+ public EntryPointRuntimeConfiguration(String name, String referenceName, MessageFactory msgFactory) {
+ assert (name != null) : "Entry point name was null";
+ assert (msgFactory != null) : "Message factory was null";
+ this.name = name;
+ this.referenceName = referenceName;
+ this.msgFactory = msgFactory;
+ }
+
+ public EntryPointContext createInstanceContext() throws ContextCreationException {
+ return new EntryPointContextImpl(name, proxyFactory, msgFactory);
+ }
+
+ public Scope getScope() {
+ return Scope.MODULE;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void prepare() {
+ }
+
+ public void addTargetProxyFactory(String serviceName, ProxyFactory factory) {
+ // no wires to an entry point from with an aggregate
+ }
+
+ public ProxyFactory getTargetProxyFactory(String serviceName) {
+ // no wires to an entry point from with an aggregate
+ return null;
+ }
+
+ public Map<String, ProxyFactory> getTargetProxyFactories() {
+ // no wires to an entry point from with an aggregate
+ return Collections.EMPTY_MAP;
+ }
+
+ public void addSourceProxyFactory(String refName, ProxyFactory factory) {
+ assert (refName != null) : "No reference name specified";
+ assert (factory != null) : "Proxy factory was null";
+ this.referenceName = refName; // entry points are configured with only one reference
+ this.proxyFactory = factory;
+ }
+
+ public ProxyFactory getSourceProxyFactory(String refName) {
+ if (this.referenceName.equals(refName)) {
+ return proxyFactory;
+ } else {
+ return null;
+ }
+ }
+
+ public Map<String, ProxyFactory> getSourceProxyFactories() {
+ if (sourceProxyFactories == null) {
+ sourceProxyFactories = new HashMap(1);
+ sourceProxyFactories.put(referenceName, proxyFactory);
+ }
+ return sourceProxyFactories;
+ }
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/builder/impl/HierarchicalBuilder.java b/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/builder/impl/HierarchicalBuilder.java
new file mode 100644
index 0000000000..41f56c1bf0
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/builder/impl/HierarchicalBuilder.java
@@ -0,0 +1,58 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
+ * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations under the License.
+ */
+package org.apache.tuscany.core.builder.impl;
+
+import java.util.Collections;
+import java.util.List;
+import java.util.concurrent.CopyOnWriteArrayList;
+
+import org.apache.tuscany.core.builder.BuilderException;
+import org.apache.tuscany.core.builder.RuntimeConfigurationBuilder;
+import org.apache.tuscany.core.context.Context;
+import org.apache.tuscany.model.assembly.AssemblyModelObject;
+
+/**
+ * A builder that contains nested builders. Used for synchronizing parts of the build process, such as references.
+ *
+ * @version $Rev$ $Date$
+ */
+public class HierarchicalBuilder implements RuntimeConfigurationBuilder {
+ private List<RuntimeConfigurationBuilder> builders = new CopyOnWriteArrayList();
+
+ private List<RuntimeConfigurationBuilder> readOnlyBuilders = Collections.unmodifiableList(builders);
+
+ public HierarchicalBuilder() {
+ }
+
+ public void addBuilder(RuntimeConfigurationBuilder builder) {
+ builders.add(builder);
+ }
+
+ public void removeBuilder(RuntimeConfigurationBuilder builder){
+ builders.remove(builder);
+ }
+
+ public List getBuilders(){
+ return readOnlyBuilders;
+ }
+
+ public void build(AssemblyModelObject object, Context context) throws BuilderException {
+ for (RuntimeConfigurationBuilder builder : builders) {
+ builder.build(object, context);
+ }
+
+ }
+
+
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/builder/impl/ProxyObjectFactory.java b/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/builder/impl/ProxyObjectFactory.java
new file mode 100644
index 0000000000..c5d3b56034
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/builder/impl/ProxyObjectFactory.java
@@ -0,0 +1,42 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
+ * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations under the License.
+ */
+package org.apache.tuscany.core.builder.impl;
+
+import org.apache.tuscany.core.builder.ObjectFactory;
+import org.apache.tuscany.core.injection.ObjectCreationException;
+import org.apache.tuscany.core.invocation.spi.ProxyCreationException;
+import org.apache.tuscany.core.invocation.spi.ProxyFactory;
+
+/**
+ * Uses a proxy factory to return an object instance
+ *
+ * @version $Rev$ $Date$
+ */
+public class ProxyObjectFactory implements ObjectFactory {
+
+ private ProxyFactory factory;
+
+ public ProxyObjectFactory(ProxyFactory factory) {
+ this.factory = factory;
+ }
+
+ public Object getInstance() throws ObjectCreationException {
+ try {
+ return factory.createProxy();
+ } catch (ProxyCreationException e) {
+ throw new ObjectCreationException(e);
+ }
+ }
+
+}