tuscany-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jmar...@apache.org
Subject svn commit: r376070 [1/2] - in /incubator/tuscany/java/sca: container.java/src/main/java/org/apache/tuscany/container/java/assembly/pojo/ container.java/src/main/java/org/apache/tuscany/container/java/builder/ container.java/src/main/java/org/apache/tu...
Date Wed, 08 Feb 2006 21:23:22 GMT
Author: jmarino
Date: Wed Feb  8 13:23:16 2006
New Revision: 376070

URL: http://svn.apache.org/viewcvs?rev=376070&view=rev
Log:
early work on revised proxy creation for new aggregate context restructure

Added:
    incubator/tuscany/java/sca/container.java/src/main/java/org/apache/tuscany/container/java/assembly/pojo/PojoJavaOperationType.java
    incubator/tuscany/java/sca/container.java/src/main/java/org/apache/tuscany/container/java/builder/JavaComponentContextBuilder2.java
    incubator/tuscany/java/sca/container.java/src/test/java/org/apache/tuscany/container/java/mock/MockConfigContext.java
    incubator/tuscany/java/sca/core/src/main/java/org/apache/tuscany/core/builder/ProxyObjectFactory.java
    incubator/tuscany/java/sca/core/src/main/java/org/apache/tuscany/core/builder/ReferenceBuilder.java
    incubator/tuscany/java/sca/core/src/main/java/org/apache/tuscany/core/invocation/jdk/JDKProxyFactoryFactory.java
    incubator/tuscany/java/sca/core/src/main/java/org/apache/tuscany/core/invocation/spi/ProxyFactoryFactory.java
    incubator/tuscany/java/sca/core/src/main/java/org/apache/tuscany/core/message/impl/PojoMessageFactory.java
Modified:
    incubator/tuscany/java/sca/container.java/src/main/java/org/apache/tuscany/container/java/config/JavaComponentRuntimeConfiguration.java
    incubator/tuscany/java/sca/container.java/src/main/java/org/apache/tuscany/container/java/handler/AbstractJavaComponentInvoker.java
    incubator/tuscany/java/sca/container.java/src/test/java/org/apache/tuscany/container/java/invocation/jdk/JDKInvocationHandlerTestCase.java
    incubator/tuscany/java/sca/container.java/src/test/java/org/apache/tuscany/container/java/invocation/mock/MockHandler.java
    incubator/tuscany/java/sca/container.java/src/test/java/org/apache/tuscany/container/java/invocation/mock/MockScopeContext.java
    incubator/tuscany/java/sca/container.java/src/test/java/org/apache/tuscany/container/java/invocation/mock/MockSyncInterceptor.java
    incubator/tuscany/java/sca/core/src/main/java/org/apache/tuscany/core/builder/RuntimeConfiguration.java
    incubator/tuscany/java/sca/core/src/main/java/org/apache/tuscany/core/builder/impl/PortRuntimeConfigurationBuilderImpl.java
    incubator/tuscany/java/sca/core/src/main/java/org/apache/tuscany/core/context/impl/AbstractAggregateContext.java
    incubator/tuscany/java/sca/core/src/main/java/org/apache/tuscany/core/invocation/InvocationConfiguration.java
    incubator/tuscany/java/sca/core/src/main/java/org/apache/tuscany/core/invocation/ProxyConfiguration.java
    incubator/tuscany/java/sca/core/src/main/java/org/apache/tuscany/core/invocation/TargetInvoker.java
    incubator/tuscany/java/sca/core/src/main/java/org/apache/tuscany/core/invocation/impl/RequestResponseInterceptor.java
    incubator/tuscany/java/sca/core/src/main/java/org/apache/tuscany/core/invocation/jdk/JDKInvocationHandler.java
    incubator/tuscany/java/sca/core/src/main/java/org/apache/tuscany/core/invocation/jdk/JDKProxyFactory.java
    incubator/tuscany/java/sca/core/src/main/java/org/apache/tuscany/core/invocation/jdk/NullProxyFactory.java
    incubator/tuscany/java/sca/core/src/main/java/org/apache/tuscany/core/invocation/spi/ProxyFactory.java
    incubator/tuscany/java/sca/core/src/main/java/org/apache/tuscany/core/system/builder/ProxyFactoryBuilder.java
    incubator/tuscany/java/sca/core/src/main/java/org/apache/tuscany/core/system/config/SystemComponentRuntimeConfiguration.java
    incubator/tuscany/java/sca/core/src/main/java/org/apache/tuscany/core/system/config/SystemEntryPointRuntimeConfiguration.java
    incubator/tuscany/java/sca/core/src/main/java/org/apache/tuscany/core/system/config/SystemExternalServiceRuntimeConfiguration.java

Added: incubator/tuscany/java/sca/container.java/src/main/java/org/apache/tuscany/container/java/assembly/pojo/PojoJavaOperationType.java
URL: http://svn.apache.org/viewcvs/incubator/tuscany/java/sca/container.java/src/main/java/org/apache/tuscany/container/java/assembly/pojo/PojoJavaOperationType.java?rev=376070&view=auto
==============================================================================
--- incubator/tuscany/java/sca/container.java/src/main/java/org/apache/tuscany/container/java/assembly/pojo/PojoJavaOperationType.java (added)
+++ incubator/tuscany/java/sca/container.java/src/main/java/org/apache/tuscany/container/java/assembly/pojo/PojoJavaOperationType.java Wed Feb  8 13:23:16 2006
@@ -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.container.java.assembly.pojo;
+
+import java.lang.reflect.Method;
+
+import org.apache.tuscany.model.assembly.pojo.PojoOperationType;
+import org.apache.tuscany.model.types.java.JavaOperationType;
+
+/**
+ * 
+ * 
+ * @version $Rev$ $Date$
+ */
+public class PojoJavaOperationType extends PojoOperationType implements JavaOperationType {
+
+    public PojoJavaOperationType() {
+    }
+
+    private Method m;
+
+    public Method getJavaMethod() {
+        return m;
+    }
+
+    public void setJavaMethod(Method m) {
+        this.m = m;
+    }
+
+}

Added: incubator/tuscany/java/sca/container.java/src/main/java/org/apache/tuscany/container/java/builder/JavaComponentContextBuilder2.java
URL: http://svn.apache.org/viewcvs/incubator/tuscany/java/sca/container.java/src/main/java/org/apache/tuscany/container/java/builder/JavaComponentContextBuilder2.java?rev=376070&view=auto
==============================================================================
--- incubator/tuscany/java/sca/container.java/src/main/java/org/apache/tuscany/container/java/builder/JavaComponentContextBuilder2.java (added)
+++ incubator/tuscany/java/sca/container.java/src/main/java/org/apache/tuscany/container/java/builder/JavaComponentContextBuilder2.java Wed Feb  8 13:23:16 2006
@@ -0,0 +1,331 @@
+package org.apache.tuscany.container.java.builder;
+
+import java.lang.reflect.Constructor;
+import java.lang.reflect.Field;
+import java.lang.reflect.Method;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import org.apache.tuscany.container.java.assembly.JavaImplementation;
+import org.apache.tuscany.container.java.config.JavaComponentRuntimeConfiguration;
+import org.apache.tuscany.core.builder.BuilderConfigException;
+import org.apache.tuscany.core.builder.BuilderException;
+import org.apache.tuscany.core.builder.NoAccessorException;
+import org.apache.tuscany.core.builder.ProxyObjectFactory;
+import org.apache.tuscany.core.builder.RuntimeConfigurationBuilder;
+import org.apache.tuscany.core.config.JavaIntrospectionHelper;
+import org.apache.tuscany.core.context.AggregateContext;
+import org.apache.tuscany.core.context.QualifiedName;
+import org.apache.tuscany.core.injection.EventInvoker;
+import org.apache.tuscany.core.injection.FactoryInitException;
+import org.apache.tuscany.core.injection.FieldInjector;
+import org.apache.tuscany.core.injection.Injector;
+import org.apache.tuscany.core.injection.MethodEventInvoker;
+import org.apache.tuscany.core.injection.MethodInjector;
+import org.apache.tuscany.core.injection.SDOObjectFactory;
+import org.apache.tuscany.core.injection.SingletonObjectFactory;
+import org.apache.tuscany.core.invocation.InvocationConfiguration;
+import org.apache.tuscany.core.invocation.ProxyConfiguration;
+import org.apache.tuscany.core.invocation.spi.ProxyFactory;
+import org.apache.tuscany.core.invocation.spi.ProxyFactoryFactory;
+import org.apache.tuscany.core.message.MessageFactory;
+import org.apache.tuscany.core.system.annotation.Autowire;
+import org.apache.tuscany.model.assembly.AssemblyModelObject;
+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.Interface;
+import org.apache.tuscany.model.assembly.ScopeEnum;
+import org.apache.tuscany.model.assembly.Service;
+import org.apache.tuscany.model.assembly.SimpleComponent;
+import org.apache.tuscany.model.types.OperationType;
+import org.osoa.sca.annotations.ComponentName;
+import org.osoa.sca.annotations.Context;
+import org.osoa.sca.annotations.Destroy;
+import org.osoa.sca.annotations.Init;
+
+import commonj.sdo.DataObject;
+
+/**
+ * Decorates components whose implementation type is a
+ * {@link org.apache.tuscany.container.java.assembly.JavaImplementation} with the appropriate runtime configuration
+ * 
+ * @version $Rev: 368822 $ $Date: 2006-01-13 10:54:38 -0800 (Fri, 13 Jan 2006) $
+ */
+public class JavaComponentContextBuilder2 implements RuntimeConfigurationBuilder<AggregateContext> {
+
+    private String name;
+
+    private final List<Injector> setters = new ArrayList();
+
+    private AggregateContext parentContext;
+
+    private AssemblyModelObject modelObject;
+
+    private ProxyFactoryFactory factory;
+
+    @Autowire
+    public void setProxyFactoryFactory(ProxyFactoryFactory factory) {
+        this.factory = factory;
+    }
+
+    private MessageFactory msgFactory;
+
+    @Autowire
+    public void setMessageFactory(MessageFactory msgFactory) {
+        this.msgFactory = msgFactory;
+    }
+
+    private RuntimeConfigurationBuilder referenceBuilder;
+
+    @Autowire
+    public void setReferenceBuilder(RuntimeConfigurationBuilder builder) {
+        this.referenceBuilder = builder;
+    }
+
+    // ----------------------------------
+    // Constructors
+    // ----------------------------------
+
+    public JavaComponentContextBuilder2() {
+    }
+
+    // ----------------------------------
+    // Methods
+    // ----------------------------------
+
+    public void setModelObject(AssemblyModelObject modelObject) {
+        this.modelObject = modelObject;
+    }
+
+    public void setParentContext(AggregateContext context) {
+        parentContext = context;
+    }
+
+    public void build() throws BuilderException {
+        if (!(modelObject instanceof SimpleComponent)) {
+            return;
+        }
+        SimpleComponent component = (SimpleComponent) modelObject;
+        if (component.getComponentImplementation() instanceof JavaImplementation) {
+            JavaImplementation javaImpl = (JavaImplementation) component.getComponentImplementation();
+            // FIXME scope
+            ScopeEnum scope = component.getComponentImplementation().getServices().get(0).getInterfaceContract().getScope();
+            Class implClass = null;
+            Set<Field> fields;
+            Set<Method> methods;
+            try {
+                implClass = JavaIntrospectionHelper.loadClass(javaImpl.getClass_());
+                fields = JavaIntrospectionHelper.getAllFields(implClass);
+                methods = JavaIntrospectionHelper.getAllUniqueMethods(implClass);
+                name = component.getName();
+                Constructor ctr = implClass.getConstructor((Class[]) null);
+
+                List<Injector> injectors = new ArrayList();
+
+                EventInvoker initInvoker = null;
+                boolean eagerInit = false;
+                EventInvoker destroyInvoker = null;
+                // FIXME this should be run as part of the LCM load
+                for (Field field : fields) {
+                    ComponentName compName = field.getAnnotation(ComponentName.class);
+                    if (compName != null) {
+                        Injector injector = new FieldInjector(field, new SingletonObjectFactory(name));
+                        injectors.add(injector);
+                    }
+                    Context context = field.getAnnotation(Context.class);
+                    if (context != null) {
+                        Injector injector = new FieldInjector(field, new SingletonObjectFactory(parentContext));
+                        injectors.add(injector);
+                    }
+                }
+                for (Method method : methods) {
+                    // FIXME Java5
+                    Init init = method.getAnnotation(Init.class);
+                    if (init != null && initInvoker == null) {
+                        initInvoker = new MethodEventInvoker(method);
+                        eagerInit = init.eager();
+                        continue;
+                    }
+                    // @spec - should we allow the same method to have @init and
+                    // @destroy?
+                    Destroy destroy = method.getAnnotation(Destroy.class);
+                    if (destroy != null && destroyInvoker == null) {
+                        destroyInvoker = new MethodEventInvoker(method);
+                        continue;
+                    }
+                    ComponentName compName = method.getAnnotation(ComponentName.class);
+                    if (compName != null) {
+                        Injector injector = new MethodInjector(method, new SingletonObjectFactory(name));
+                        injectors.add(injector);
+                    }
+                    Context context = method.getAnnotation(Context.class);
+                    if (context != null) {
+                        Injector injector = new MethodInjector(method, new SingletonObjectFactory(parentContext));
+                        injectors.add(injector);
+                    }
+                }
+                // handle properties
+                List<ConfiguredProperty> configuredProperties = component.getConfiguredProperties();
+                // FIXME should return empty properties - does it?
+                if (configuredProperties != null) {
+                    for (ConfiguredProperty property : configuredProperties) {
+                        Injector injector = createPropertyInjector(property, fields, methods);
+                        injectors.add(injector);
+                    }
+                }
+                JavaComponentRuntimeConfiguration config = new JavaComponentRuntimeConfiguration(name, JavaIntrospectionHelper
+                        .getDefaultConstructor(implClass), eagerInit, initInvoker, destroyInvoker, scope.getValue());
+                component.getComponentImplementation().setRuntimeConfiguration(config);
+
+                // create chains for handling incoming requests
+                for (ConfiguredService configuredService : component.getConfiguredServices()) {
+                    Service service = configuredService.getService();
+                    Interface interfaze = service.getInterfaceContract();
+                    Map<OperationType, InvocationConfiguration> iConfigMap = new HashMap();
+                    ProxyFactory proxyFactory = factory.createProxyFactory();
+                    // FIXME we pass null for scopes since ProxyConfiguration requires scopes - this should be removed
+                    for (OperationType type : interfaze.getInterfaceType().getOperationTypes()) {
+                        InvocationConfiguration iConfig = new InvocationConfiguration(type);
+                        iConfigMap.put(type, iConfig);
+                    }
+                    //@FIXME hardcode separator
+                    QualifiedName qName = new QualifiedName(configuredService.getPart().getName()+"/"+configuredService.getPort().getName());
+                    ProxyConfiguration pConfiguration = new ProxyConfiguration(qName,iConfigMap, null, null, msgFactory);
+                    proxyFactory.setBusinessInterface(interfaze.getInterfaceType().getInstanceClass());
+                    proxyFactory.setProxyConfiguration(pConfiguration);
+                    config.addTargetProxyFactory(service.getName(), proxyFactory);
+                    configuredService.setProxyFactory(proxyFactory);
+                    // invoke another builder to add interceptors, etc.
+                    referenceBuilder.setParentContext(parentContext);
+                    referenceBuilder.setModelObject(configuredService);
+                    referenceBuilder.build();
+                }
+
+                // handle references
+                List<ConfiguredReference> configuredReferences = component.getConfiguredReferences();
+                if (configuredReferences != null) {
+                    for (ConfiguredReference reference : configuredReferences) {
+                        ProxyFactory proxyFactory = factory.createProxyFactory();
+                        Interface interfaze = reference.getReference().getInterfaceContract();
+                        Map<OperationType, InvocationConfiguration> iConfigMap = new HashMap();
+                        for (OperationType type : interfaze.getInterfaceType().getOperationTypes()) {
+                            InvocationConfiguration iConfig = new InvocationConfiguration(type);
+                            iConfigMap.put(type, iConfig);
+                        }
+
+                        /*
+                         * FIXME we pass null for scopes since ProxyConfiguration requires scopes - this should be
+                         * removed from the constructor
+                         */
+                        QualifiedName qName = new QualifiedName(reference.getPart().getName() +"/"+reference.getPort().getName());
+                        ProxyConfiguration pConfiguration = new ProxyConfiguration(qName,iConfigMap, null, null, msgFactory);
+                        proxyFactory.setBusinessInterface(interfaze.getInterfaceType().getInstanceClass());
+                        proxyFactory.setProxyConfiguration(pConfiguration);
+                        config.addSourceProxyFactory(reference.getReference().getName(), proxyFactory);
+                        reference.setProxyFactory(proxyFactory);
+                        // invoke another builder to add interceptors, etc.
+                        referenceBuilder.setParentContext(parentContext);
+                        referenceBuilder.setModelObject(reference);
+                        referenceBuilder.build();
+                        Injector injector = createReferenceInjector(reference.getReference().getName(), proxyFactory, fields,
+                                methods);
+                        injectors.add(injector);
+                    }
+                }
+                config.setSetters(injectors);
+            } catch (BuilderException e) {
+                e.addContextName(component.getName());
+                e.addContextName(parentContext.getName());
+                throw e;
+            } catch (ClassNotFoundException e) {
+                BuilderException be = new BuilderConfigException(e);
+                be.addContextName(component.getName());
+                be.addContextName(parentContext.getName());
+                throw be;
+            } catch (NoSuchMethodException e) {
+                BuilderConfigException ce = new BuilderConfigException("Class does not have a no-arg constructor", e);
+                ce.setIdentifier(implClass.getName());
+                ce.addContextName(component.getName());
+                ce.addContextName(parentContext.getName());
+                throw ce;
+            }
+        }
+    }
+
+    // ----------------------------------
+    // Private methods
+    // ----------------------------------
+
+    /**
+     * Creates an <code>Injector</code> for component properties
+     */
+    private Injector createPropertyInjector(ConfiguredProperty property, Set<Field> fields, Set<Method> methods)
+            throws NoAccessorException {
+        Object value = property.getValue();
+        String propName = property.getProperty().getName();
+        // @FIXME is this how to get property type of object
+        Class type = value.getClass();
+
+        // There is no efficient way to do this
+        Method method = null;
+        Field field = JavaIntrospectionHelper.findClosestMatchingField(propName, type, fields);
+        if (field == null) {
+            method = JavaIntrospectionHelper.findClosestMatchingMethod(propName, new Class[] { type }, methods);
+            if (method == null) {
+                throw new NoAccessorException(propName);
+            }
+        }
+        Injector injector = null;
+        // FIXME support types other than String
+        if (value instanceof DataObject) {
+            if (field != null) {
+                injector = new FieldInjector(field, new SDOObjectFactory((DataObject) value));
+            } else {
+                injector = new MethodInjector(method, new SDOObjectFactory((DataObject) value));
+            }
+        } else if (JavaIntrospectionHelper.isImmutable(type)) {
+            if (field != null) {
+                injector = new FieldInjector(field, new SingletonObjectFactory(value));
+            } else {
+                injector = new MethodInjector(method, new SingletonObjectFactory(value));
+            }
+        }
+        return injector;
+
+    }
+
+    /**
+     * Creates an <code>Injector</code> for service references
+     */
+    private Injector createReferenceInjector(String refName, ProxyFactory proxyFactory, Set<Field> fields, Set<Method> methods)
+            throws NoAccessorException, BuilderConfigException {
+        Method method = null;
+        Field field = JavaIntrospectionHelper.findClosestMatchingField(refName, proxyFactory.getBusinessInterface(), fields);
+        if (field == null) {
+            method = JavaIntrospectionHelper.findClosestMatchingMethod(refName,
+                    new Class[] { proxyFactory.getBusinessInterface() }, methods);
+            if (method == null) {
+                throw new NoAccessorException(refName);
+            }
+        }
+        Injector injector;
+        try {
+            if (field != null) {
+                injector = new FieldInjector(field, new ProxyObjectFactory(proxyFactory));
+            } else {
+                injector = new MethodInjector(method, new ProxyObjectFactory(proxyFactory));
+            }
+        } catch (FactoryInitException e) {
+            BuilderConfigException ce = new BuilderConfigException("Error configuring reference", e);
+            ce.setIdentifier(refName);
+            throw ce;
+        }
+        return injector;
+
+    }
+
+}

Modified: incubator/tuscany/java/sca/container.java/src/main/java/org/apache/tuscany/container/java/config/JavaComponentRuntimeConfiguration.java
URL: http://svn.apache.org/viewcvs/incubator/tuscany/java/sca/container.java/src/main/java/org/apache/tuscany/container/java/config/JavaComponentRuntimeConfiguration.java?rev=376070&r1=376069&r2=376070&view=diff
==============================================================================
--- incubator/tuscany/java/sca/container.java/src/main/java/org/apache/tuscany/container/java/config/JavaComponentRuntimeConfiguration.java (original)
+++ incubator/tuscany/java/sca/container.java/src/main/java/org/apache/tuscany/container/java/config/JavaComponentRuntimeConfiguration.java Wed Feb  8 13:23:16 2006
@@ -14,15 +14,30 @@
 package org.apache.tuscany.container.java.config;
 
 import java.lang.reflect.Constructor;
+import java.lang.reflect.Field;
+import java.lang.reflect.Method;
+import java.util.HashMap;
 import java.util.List;
+import java.util.Map;
+import java.util.Set;
 
 import org.apache.tuscany.container.java.context.JavaComponentContext;
+import org.apache.tuscany.container.java.injection.ReferenceProxyTargetFactory;
+import org.apache.tuscany.core.builder.BuilderConfigException;
 import org.apache.tuscany.core.builder.ContextCreationException;
+import org.apache.tuscany.core.builder.NoAccessorException;
 import org.apache.tuscany.core.builder.RuntimeConfiguration;
+import org.apache.tuscany.core.config.JavaIntrospectionHelper;
 import org.apache.tuscany.core.context.SimpleComponentContext;
 import org.apache.tuscany.core.injection.EventInvoker;
+import org.apache.tuscany.core.injection.FactoryInitException;
+import org.apache.tuscany.core.injection.FieldInjector;
 import org.apache.tuscany.core.injection.Injector;
+import org.apache.tuscany.core.injection.MethodInjector;
 import org.apache.tuscany.core.injection.PojoObjectFactory;
+import org.apache.tuscany.core.invocation.spi.ProxyFactory;
+import org.apache.tuscany.model.assembly.ConfiguredReference;
+import org.apache.tuscany.model.assembly.ConfiguredService;
 import org.apache.tuscany.model.assembly.ScopeEnum;
 
 /**
@@ -53,7 +68,7 @@
 
     // the scope of the implementation instance
     private int scope;
-    
+
     private boolean stateless;
 
     // ----------------------------------
@@ -65,10 +80,11 @@
      * 
      * @param name the SCDL name of the component the context refers to
      * @param ctr the implementation type constructor
-     * @param setters a collection of <code>Injectors</code> used to configure properties, references and other meta data values
-     *        on implementation instances
+     * @param setters a collection of <code>Injectors</code> used to configure properties, references and other meta
+     *        data values on implementation instances
      * @param eagerInit whether the component should be eagerly initialized
-     * @param init an <code>Invoker</code> pointing to a method on the implementation type decorated with <code>@Init</code>
+     * @param init an <code>Invoker</code> pointing to a method on the implementation type decorated with
+     *        <code>@Init</code>
      * @param destroy an <code>Invoker</code> pointing to a method on the implementation type decorated with
      *        <code>@Destroy</code>
      * @param scope the scope of the component implementation type
@@ -77,8 +93,6 @@
             EventInvoker init, EventInvoker destroy, int scope) {
         assert (name != null) : "Name was null";
         assert (ctr != null) : "Constructor was null";
-        assert (setters != null) : "Setters were null";
-        //assert (scope != null) : "Scope was null";
         this.name = name;
         this.ctr = ctr;
         this.setters = setters;
@@ -89,21 +103,104 @@
         stateless = (scope == ScopeEnum.INSTANCE);
     }
 
+    public JavaComponentRuntimeConfiguration(String name, Constructor ctr, boolean eagerInit, EventInvoker init,
+            EventInvoker destroy, int scope) {
+        this(name, ctr, null, eagerInit, init, destroy, scope);
+    }
+
     // ----------------------------------
     // Methods
     // ----------------------------------
-    
-    public String getName(){
+
+    public String getName() {
         return name;
     }
-    
-    public int getScope(){
+
+    public int getScope() {
         return scope;
     }
-    
+
     public SimpleComponentContext createInstanceContext() throws ContextCreationException {
         PojoObjectFactory objectFactory = new PojoObjectFactory(ctr, null, setters);
         return new JavaComponentContext(name, objectFactory, eagerInit, init, destroy, stateless);
     }
 
+    // //
+
+    private Map<String, ProxyFactory> targetProxyFactories = new HashMap();
+
+    public void addTargetProxyFactory(String serviceName, ProxyFactory factory) {
+        targetProxyFactories.put(serviceName, factory);
+    }
+
+    public ProxyFactory getTargetProxyFactory(String serviceName) {
+        return targetProxyFactories.get(serviceName);
+    }
+
+    public Map<String, ProxyFactory> getTargetProxyFactories() {
+        return targetProxyFactories;
+    }
+
+    private Map<String, ProxyFactory> sourceProxyFactories = new HashMap();
+
+    public void addSourceProxyFactory(String referenceName, ProxyFactory factory) {
+        sourceProxyFactories.put(referenceName, factory);
+    }
+
+    public ProxyFactory getSourceProxyFactory(String referenceName) {
+        return sourceProxyFactories.get(referenceName);
+    }
+
+    public Map<String, ProxyFactory> getSourceProxyFactories() {
+        return sourceProxyFactories;
+    }
+
+    public void setSetters(List<Injector> setters) {
+        this.setters = setters;
+    }
+
+    public void prepare(){
+        
+    }
+    
+    
+//    
+//    private Injector createReferenceInjector(ProxyFactory factory,
+//            Set<Field> fields, Set<Method> methods) throws NoAccessorException, BuilderConfigException {
+//        String refName = reference.getReference().getName();
+//        List<ConfiguredService> services = reference.getConfiguredServices();
+//        Class type;
+//        // FIXME added the size check - do we need to do this?
+//        if (services.size() == 1) {
+//            // get the interface
+//            type = reference.getReference().getInterfaceContract().getInterfaceType().getInstanceClass();
+//        } else {
+//            // FIXME do we support arrays?
+//            type = List.class;
+//        }
+//
+//        Method method = null;
+//
+//        Field field = JavaIntrospectionHelper.findClosestMatchingField(refName, type, fields);
+//        if (field == null) {
+//            method = JavaIntrospectionHelper.findClosestMatchingMethod(refName, new Class[] { type }, methods);
+//            if (method == null) {
+//                throw new NoAccessorException(refName);
+//            }
+//        }
+//        Injector injector;
+//        try {
+//            if (field != null) {
+//                injector = new FieldInjector(field, new ReferenceProxyTargetFactory(reference));
+//            } else {
+//                injector = new MethodInjector(method, new ReferenceProxyTargetFactory(reference));
+//            }
+//        } catch (FactoryInitException e) {
+//            BuilderConfigException ce = new BuilderConfigException("Error configuring reference", e);
+//            ce.setIdentifier(refName);
+//            throw ce;
+//        }
+//        return injector;
+//    }
+    
 }

Modified: incubator/tuscany/java/sca/container.java/src/main/java/org/apache/tuscany/container/java/handler/AbstractJavaComponentInvoker.java
URL: http://svn.apache.org/viewcvs/incubator/tuscany/java/sca/container.java/src/main/java/org/apache/tuscany/container/java/handler/AbstractJavaComponentInvoker.java?rev=376070&r1=376069&r2=376070&view=diff
==============================================================================
--- incubator/tuscany/java/sca/container.java/src/main/java/org/apache/tuscany/container/java/handler/AbstractJavaComponentInvoker.java (original)
+++ incubator/tuscany/java/sca/container.java/src/main/java/org/apache/tuscany/container/java/handler/AbstractJavaComponentInvoker.java Wed Feb  8 13:23:16 2006
@@ -31,7 +31,7 @@
  * 
  * @version $Rev$ $Date$
  */
-public abstract class AbstractJavaComponentInvoker implements TargetInvoker, Interceptor {
+public abstract class AbstractJavaComponentInvoker implements TargetInvoker {
 
     protected Method operation;
 

Modified: incubator/tuscany/java/sca/container.java/src/test/java/org/apache/tuscany/container/java/invocation/jdk/JDKInvocationHandlerTestCase.java
URL: http://svn.apache.org/viewcvs/incubator/tuscany/java/sca/container.java/src/test/java/org/apache/tuscany/container/java/invocation/jdk/JDKInvocationHandlerTestCase.java?rev=376070&r1=376069&r2=376070&view=diff
==============================================================================
--- incubator/tuscany/java/sca/container.java/src/test/java/org/apache/tuscany/container/java/invocation/jdk/JDKInvocationHandlerTestCase.java (original)
+++ incubator/tuscany/java/sca/container.java/src/test/java/org/apache/tuscany/container/java/invocation/jdk/JDKInvocationHandlerTestCase.java Wed Feb  8 13:23:16 2006
@@ -61,6 +61,72 @@
         Assert.assertEquals("hello", proxy.hello("hello"));
     }
 
+    public void testInterceptorsOnly() throws Exception {
+        Map<Method, InvocationConfiguration> config = new HashMap();
+        OperationType operation = new MockJavaOperationType(hello);
+        StaticJavaComponentTargetInvoker invoker = new StaticJavaComponentTargetInvoker(hello, new SimpleTargetImpl());
+        InvocationConfiguration invocationConfiguration = new InvocationConfiguration(operation);
+        invocationConfiguration.addSourceInterceptor(new MockSyncInterceptor());
+        invocationConfiguration.addTargetInterceptor(new MockSyncInterceptor());
+        invocationConfiguration.setTargetInvoker(invoker);
+        invocationConfiguration.build();
+        InvocationConfiguration helloConfig = invocationConfiguration;
+        config.put(hello, helloConfig);
+        InvocationHandler handler = new JDKInvocationHandler(new MessageFactoryImpl(), config);
+        SimpleTarget proxy = (SimpleTarget) Proxy.newProxyInstance(Thread.currentThread().getContextClassLoader(),
+                new Class[]{SimpleTarget.class}, handler);
+        Assert.assertEquals("hello", proxy.hello("hello"));
+    }
+
+    public void testSourceInterceptoOnly() throws Exception {
+        Map<Method, InvocationConfiguration> config = new HashMap();
+        OperationType operation = new MockJavaOperationType(hello);
+        StaticJavaComponentTargetInvoker invoker = new StaticJavaComponentTargetInvoker(hello, new SimpleTargetImpl());
+        InvocationConfiguration invocationConfiguration = new InvocationConfiguration(operation);
+        invocationConfiguration.addSourceInterceptor(new MockSyncInterceptor());
+        invocationConfiguration.setTargetInvoker(invoker);
+        invocationConfiguration.build();
+        InvocationConfiguration helloConfig = invocationConfiguration;
+        config.put(hello, helloConfig);
+        InvocationHandler handler = new JDKInvocationHandler(new MessageFactoryImpl(), config);
+        SimpleTarget proxy = (SimpleTarget) Proxy.newProxyInstance(Thread.currentThread().getContextClassLoader(),
+                new Class[]{SimpleTarget.class}, handler);
+        Assert.assertEquals("hello", proxy.hello("hello"));
+    }
+
+    public void testTargetInterceptorOnly() throws Exception {
+        Map<Method, InvocationConfiguration> config = new HashMap();
+        OperationType operation = new MockJavaOperationType(hello);
+        StaticJavaComponentTargetInvoker invoker = new StaticJavaComponentTargetInvoker(hello, new SimpleTargetImpl());
+        InvocationConfiguration invocationConfiguration = new InvocationConfiguration(operation);
+        invocationConfiguration.addTargetInterceptor(new MockSyncInterceptor());
+        invocationConfiguration.setTargetInvoker(invoker);
+        invocationConfiguration.build();
+        InvocationConfiguration helloConfig = invocationConfiguration;
+        config.put(hello, helloConfig);
+        InvocationHandler handler = new JDKInvocationHandler(new MessageFactoryImpl(), config);
+        SimpleTarget proxy = (SimpleTarget) Proxy.newProxyInstance(Thread.currentThread().getContextClassLoader(),
+                new Class[]{SimpleTarget.class}, handler);
+        Assert.assertEquals("hello", proxy.hello("hello"));
+    }
+
+    public void testHandlerAndTargetInterceptor() throws Exception {
+        Map<Method, InvocationConfiguration> config = new HashMap();
+        OperationType operation = new MockJavaOperationType(hello);
+        StaticJavaComponentTargetInvoker invoker = new StaticJavaComponentTargetInvoker(hello, new SimpleTargetImpl());
+        InvocationConfiguration invocationConfiguration = new InvocationConfiguration(operation);
+        invocationConfiguration.addRequestHandler(new MockHandler());
+        invocationConfiguration.addTargetInterceptor(new MockSyncInterceptor());
+        invocationConfiguration.setTargetInvoker(invoker);
+        invocationConfiguration.build();
+        InvocationConfiguration helloConfig = invocationConfiguration;
+        config.put(hello, helloConfig);
+        InvocationHandler handler = new JDKInvocationHandler(new MessageFactoryImpl(), config);
+        SimpleTarget proxy = (SimpleTarget) Proxy.newProxyInstance(Thread.currentThread().getContextClassLoader(),
+                new Class[]{SimpleTarget.class}, handler);
+        Assert.assertEquals("hello", proxy.hello("hello"));
+    }
+
     private InvocationConfiguration getConfiguration(Method m) {
         OperationType operation = new MockJavaOperationType(m);
         StaticJavaComponentTargetInvoker invoker = new StaticJavaComponentTargetInvoker(m, new SimpleTargetImpl());

Modified: incubator/tuscany/java/sca/container.java/src/test/java/org/apache/tuscany/container/java/invocation/mock/MockHandler.java
URL: http://svn.apache.org/viewcvs/incubator/tuscany/java/sca/container.java/src/test/java/org/apache/tuscany/container/java/invocation/mock/MockHandler.java?rev=376070&r1=376069&r2=376070&view=diff
==============================================================================
--- incubator/tuscany/java/sca/container.java/src/test/java/org/apache/tuscany/container/java/invocation/mock/MockHandler.java (original)
+++ incubator/tuscany/java/sca/container.java/src/test/java/org/apache/tuscany/container/java/invocation/mock/MockHandler.java Wed Feb  8 13:23:16 2006
@@ -12,7 +12,7 @@
 public class MockHandler implements MessageHandler {
 
     public boolean processMessage(Message message) {
-        System.out.println("Invoking handler");
+        //System.out.println("Invoking handler");
         return true;
     }
 }

Modified: incubator/tuscany/java/sca/container.java/src/test/java/org/apache/tuscany/container/java/invocation/mock/MockScopeContext.java
URL: http://svn.apache.org/viewcvs/incubator/tuscany/java/sca/container.java/src/test/java/org/apache/tuscany/container/java/invocation/mock/MockScopeContext.java?rev=376070&r1=376069&r2=376070&view=diff
==============================================================================
--- incubator/tuscany/java/sca/container.java/src/test/java/org/apache/tuscany/container/java/invocation/mock/MockScopeContext.java (original)
+++ incubator/tuscany/java/sca/container.java/src/test/java/org/apache/tuscany/container/java/invocation/mock/MockScopeContext.java Wed Feb  8 13:23:16 2006
@@ -41,6 +41,10 @@
         components.put("bar", new SimpleTargetImpl());
     }
 
+    public MockScopeContext(Map<String,Object> instances) {
+        components = instances;
+    }
+
     
     public void start() {
     }

Modified: incubator/tuscany/java/sca/container.java/src/test/java/org/apache/tuscany/container/java/invocation/mock/MockSyncInterceptor.java
URL: http://svn.apache.org/viewcvs/incubator/tuscany/java/sca/container.java/src/test/java/org/apache/tuscany/container/java/invocation/mock/MockSyncInterceptor.java?rev=376070&r1=376069&r2=376070&view=diff
==============================================================================
--- incubator/tuscany/java/sca/container.java/src/test/java/org/apache/tuscany/container/java/invocation/mock/MockSyncInterceptor.java (original)
+++ incubator/tuscany/java/sca/container.java/src/test/java/org/apache/tuscany/container/java/invocation/mock/MockSyncInterceptor.java Wed Feb  8 13:23:16 2006
@@ -30,7 +30,7 @@
 
     public Message invoke(Message msg) {
         ++count;
-        System.out.println("Invoking interceptor");
+        //System.out.println("Invoking interceptor");
         return next.invoke(msg);
     }
 

Added: incubator/tuscany/java/sca/container.java/src/test/java/org/apache/tuscany/container/java/mock/MockConfigContext.java
URL: http://svn.apache.org/viewcvs/incubator/tuscany/java/sca/container.java/src/test/java/org/apache/tuscany/container/java/mock/MockConfigContext.java?rev=376070&view=auto
==============================================================================
--- incubator/tuscany/java/sca/container.java/src/test/java/org/apache/tuscany/container/java/mock/MockConfigContext.java (added)
+++ incubator/tuscany/java/sca/container.java/src/test/java/org/apache/tuscany/container/java/mock/MockConfigContext.java Wed Feb  8 13:23:16 2006
@@ -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.container.java.mock;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.tuscany.core.builder.BuilderConfigException;
+import org.apache.tuscany.core.builder.RuntimeConfigurationBuilder;
+import org.apache.tuscany.core.builder.impl.AssemblyVisitor;
+import org.apache.tuscany.core.config.ConfigurationException;
+import org.apache.tuscany.core.context.AggregateContext;
+import org.apache.tuscany.core.context.ConfigurationContext;
+import org.apache.tuscany.model.assembly.ExtensibleModelObject;
+
+/**
+ *  A mock configuration context
+ * 
+ * @version $Rev: 368822 $ $Date: 2006-01-13 10:54:38 -0800 (Fri, 13 Jan 2006) $
+ */
+public class MockConfigContext implements ConfigurationContext {
+
+    private List<RuntimeConfigurationBuilder> builders = new ArrayList();
+
+    public MockConfigContext(List<RuntimeConfigurationBuilder> builders) {
+        this.builders=builders;
+    }
+
+    public void configure(ExtensibleModelObject model) throws ConfigurationException {
+    }
+
+    public void build(AggregateContext parent, ExtensibleModelObject model) throws BuilderConfigException {
+        AssemblyVisitor visitor = new AssemblyVisitor(parent, builders);
+        visitor.start(model);
+    }
+
+}

Added: incubator/tuscany/java/sca/core/src/main/java/org/apache/tuscany/core/builder/ProxyObjectFactory.java
URL: http://svn.apache.org/viewcvs/incubator/tuscany/java/sca/core/src/main/java/org/apache/tuscany/core/builder/ProxyObjectFactory.java?rev=376070&view=auto
==============================================================================
--- incubator/tuscany/java/sca/core/src/main/java/org/apache/tuscany/core/builder/ProxyObjectFactory.java (added)
+++ incubator/tuscany/java/sca/core/src/main/java/org/apache/tuscany/core/builder/ProxyObjectFactory.java Wed Feb  8 13:23:16 2006
@@ -0,0 +1,24 @@
+package org.apache.tuscany.core.builder;
+
+import org.apache.tuscany.core.injection.ObjectCreationException;
+import org.apache.tuscany.core.injection.ObjectFactory;
+import org.apache.tuscany.core.invocation.spi.ProxyCreationException;
+import org.apache.tuscany.core.invocation.spi.ProxyFactory;
+
+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);
+        }
+    }
+
+}

Added: incubator/tuscany/java/sca/core/src/main/java/org/apache/tuscany/core/builder/ReferenceBuilder.java
URL: http://svn.apache.org/viewcvs/incubator/tuscany/java/sca/core/src/main/java/org/apache/tuscany/core/builder/ReferenceBuilder.java?rev=376070&view=auto
==============================================================================
--- incubator/tuscany/java/sca/core/src/main/java/org/apache/tuscany/core/builder/ReferenceBuilder.java (added)
+++ incubator/tuscany/java/sca/core/src/main/java/org/apache/tuscany/core/builder/ReferenceBuilder.java Wed Feb  8 13:23:16 2006
@@ -0,0 +1,89 @@
+/**
+ * 
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * 
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
+ * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations under the License.
+ */
+package org.apache.tuscany.core.builder;
+
+import org.apache.tuscany.core.context.AggregateContext;
+import org.apache.tuscany.core.invocation.spi.ProxyFactory;
+import org.apache.tuscany.core.invocation.spi.ProxyFactoryFactory;
+import org.apache.tuscany.core.message.MessageFactory;
+import org.apache.tuscany.core.system.annotation.Autowire;
+import org.apache.tuscany.core.system.context.RuntimeContext;
+import org.apache.tuscany.model.assembly.AssemblyModelObject;
+import org.apache.tuscany.model.assembly.ConfiguredReference;
+import org.apache.tuscany.model.assembly.ConfiguredService;
+import org.osoa.sca.annotations.Init;
+import org.osoa.sca.annotations.Scope;
+
+/**
+ * Builds the source and target sides of wires for a component
+ * 
+ * @version $Rev$ $Date$
+ */
+@Scope("MODULE")
+public class ReferenceBuilder implements RuntimeConfigurationBuilder<AggregateContext> {
+
+    private ProxyFactoryFactory factory;
+
+    private RuntimeContext runtimeContext;
+
+    private AggregateContext parentContext;
+
+    private AssemblyModelObject modelObject;
+
+    private MessageFactory msgFactory;
+
+    // ----------------------------------
+    // Constructors
+    // ----------------------------------
+
+    public ReferenceBuilder() {
+    }
+
+    // ----------------------------------
+    // Methods
+    // ----------------------------------
+
+    @Autowire
+    public void setRuntimeContext(RuntimeContext ctx) {
+        runtimeContext = ctx;
+    }
+
+    @Init(eager = true)
+    public void init() {
+        runtimeContext.addBuilder(this);
+    }
+
+    public void setModelObject(AssemblyModelObject modelObject) {
+        this.modelObject = modelObject;
+    }
+
+    public void setParentContext(AggregateContext context) {
+        parentContext = context;
+    }
+
+    public void build() throws BuilderException {
+        if (!(modelObject instanceof ConfiguredReference) && (!(modelObject instanceof ConfiguredService))) {
+            return; // FIXME support external service
+        }
+        if (modelObject instanceof ConfiguredReference) {
+            ConfiguredReference configuredReference = (ConfiguredReference) modelObject;
+            ProxyFactory proxyFactory = (ProxyFactory) configuredReference.getProxyFactory();
+            // Do some magic here
+        } else {
+            ConfiguredService configuredService = (ConfiguredService) modelObject;
+            ProxyFactory proxyFactory = (ProxyFactory) configuredService.getProxyFactory();
+            // Do some magic here
+        }
+    }
+}

Modified: incubator/tuscany/java/sca/core/src/main/java/org/apache/tuscany/core/builder/RuntimeConfiguration.java
URL: http://svn.apache.org/viewcvs/incubator/tuscany/java/sca/core/src/main/java/org/apache/tuscany/core/builder/RuntimeConfiguration.java?rev=376070&r1=376069&r2=376070&view=diff
==============================================================================
--- incubator/tuscany/java/sca/core/src/main/java/org/apache/tuscany/core/builder/RuntimeConfiguration.java (original)
+++ incubator/tuscany/java/sca/core/src/main/java/org/apache/tuscany/core/builder/RuntimeConfiguration.java Wed Feb  8 13:23:16 2006
@@ -1,6 +1,9 @@
 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;
 
 /**
  * Implementations create instance contexts based on a compiled runtime
@@ -17,9 +20,31 @@
      * @return a new instance context
      * @throws ContextCreationException if an error occurs creating the context
      */
-    T createInstanceContext() throws ContextCreationException;
+    public T createInstanceContext() throws ContextCreationException;
+    
+    public int getScope();
+    
+    public String getName();
+    
+    /////////////
+    public void prepare();
     
-    int getScope();
+    /**
+     * Adds a poxy factory for the given service name
+     */
+    public void addTargetProxyFactory(String serviceName, ProxyFactory factory);
+
+    public ProxyFactory getTargetProxyFactory(String serviceName);
     
-    String getName();
+    public Map<String, ProxyFactory> getTargetProxyFactories();
+
+    /**
+     * Adds a poxy factory for the given reference
+     */
+    public void addSourceProxyFactory(String referenceName, ProxyFactory factory);
+
+    public ProxyFactory getSourceProxyFactory(String referenceName);
+    
+    public Map<String,ProxyFactory> getSourceProxyFactories();
+
 }

Modified: incubator/tuscany/java/sca/core/src/main/java/org/apache/tuscany/core/builder/impl/PortRuntimeConfigurationBuilderImpl.java
URL: http://svn.apache.org/viewcvs/incubator/tuscany/java/sca/core/src/main/java/org/apache/tuscany/core/builder/impl/PortRuntimeConfigurationBuilderImpl.java?rev=376070&r1=376069&r2=376070&view=diff
==============================================================================
--- incubator/tuscany/java/sca/core/src/main/java/org/apache/tuscany/core/builder/impl/PortRuntimeConfigurationBuilderImpl.java (original)
+++ incubator/tuscany/java/sca/core/src/main/java/org/apache/tuscany/core/builder/impl/PortRuntimeConfigurationBuilderImpl.java Wed Feb  8 13:23:16 2006
@@ -24,6 +24,7 @@
 
 import org.apache.tuscany.core.addressing.AddressingFactory;
 import org.apache.tuscany.core.addressing.EndpointReference;
+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.ProxyConfiguration;
@@ -106,7 +107,8 @@
         // Create Proxy configuration
         Map<OperationType, InvocationConfiguration> invocationConfigurations = new HashMap<OperationType, InvocationConfiguration>();
         Class javaInterface=interfaceType.getInstanceClass();
-        ProxyConfiguration proxyConfiguration = new ProxyConfiguration(invocationConfigurations, javaInterface.getClassLoader(), scopeContainers, messageFactory);
+        //@FIXME Proxy this will break
+        ProxyConfiguration proxyConfiguration = new ProxyConfiguration(null,invocationConfigurations, javaInterface.getClassLoader(), scopeContainers, messageFactory);
         
         // Create invocation configurations for all the operations on the business interface
         for (OperationType operationType : interfaceType.getOperationTypes()) {
@@ -125,7 +127,9 @@
         // Create a proxy factory
         ProxyFactory proxyFactory = new JDKProxyFactory();
         try {
-            proxyFactory.initialize(javaInterface, proxyConfiguration);
+            proxyFactory.initialize();
+            proxyFactory.setBusinessInterface(javaInterface);
+            proxyFactory.setProxyConfiguration(proxyConfiguration);
         } catch (ProxyInitializationException e) {
             throw new ServiceRuntimeException(e);
         }
@@ -140,7 +144,8 @@
         // Create Proxy configuration
         Map<OperationType, InvocationConfiguration> invocationConfigurations = new HashMap<OperationType, InvocationConfiguration>();
         Class javaInterface=interfaceType.getInstanceClass();
-        ProxyConfiguration proxyConfiguration = new ProxyConfiguration(invocationConfigurations, javaInterface.getClassLoader(), scopeContainers, messageFactory);
+        QualifiedName qName = new QualifiedName(configuredService.getPart().getName() +"/"+configuredService.getPort().getName());
+        ProxyConfiguration proxyConfiguration = new ProxyConfiguration(qName, invocationConfigurations, javaInterface.getClassLoader(), scopeContainers, messageFactory);
         
         // Create invocation configurations for all the operations on the business interface
         for (OperationType operationType : interfaceType.getOperationTypes()) {
@@ -168,7 +173,9 @@
         // Create a proxy factory
         ProxyFactory proxyFactory = new JDKProxyFactory();
         try {
-            proxyFactory.initialize(javaInterface, proxyConfiguration);
+            proxyFactory.initialize();
+            proxyFactory.setBusinessInterface(javaInterface);
+            proxyFactory.setProxyConfiguration(proxyConfiguration);
         } catch (ProxyInitializationException e) {
             throw new ServiceRuntimeException(e);
         }

Modified: incubator/tuscany/java/sca/core/src/main/java/org/apache/tuscany/core/context/impl/AbstractAggregateContext.java
URL: http://svn.apache.org/viewcvs/incubator/tuscany/java/sca/core/src/main/java/org/apache/tuscany/core/context/impl/AbstractAggregateContext.java?rev=376070&r1=376069&r2=376070&view=diff
==============================================================================
--- incubator/tuscany/java/sca/core/src/main/java/org/apache/tuscany/core/context/impl/AbstractAggregateContext.java (original)
+++ incubator/tuscany/java/sca/core/src/main/java/org/apache/tuscany/core/context/impl/AbstractAggregateContext.java Wed Feb  8 13:23:16 2006
@@ -38,6 +38,8 @@
 import org.apache.tuscany.core.context.SimpleComponentContext;
 import org.apache.tuscany.core.context.TargetException;
 import org.apache.tuscany.core.context.scope.DefaultScopeStrategy;
+import org.apache.tuscany.core.invocation.InvocationConfiguration;
+import org.apache.tuscany.core.invocation.spi.ProxyFactory;
 import org.apache.tuscany.core.system.annotation.Autowire;
 import org.apache.tuscany.core.system.annotation.ParentContext;
 import org.apache.tuscany.model.assembly.Component;
@@ -47,6 +49,7 @@
 import org.apache.tuscany.model.assembly.Module;
 import org.apache.tuscany.model.assembly.Part;
 import org.apache.tuscany.model.assembly.pojo.PojoModule;
+import org.apache.tuscany.model.types.OperationType;
 
 /**
  * The base implementation of an aggregate context
@@ -77,7 +80,7 @@
     // protected ModuleComponent moduleComponent;
     protected Module module;
 
-    protected List<RuntimeConfiguration<InstanceContext>> configurations = new ArrayList();
+    protected Map<String, RuntimeConfiguration<InstanceContext>> configurations = new HashMap();
 
     // Factory for scope contexts
     @Autowire(required = false)
@@ -89,8 +92,8 @@
     // The scopes for this context
     protected Map<Integer, ScopeContext> scopeContexts;
 
-    protected  Map<Integer, ScopeContext> immutableScopeContexts;
-    
+    protected Map<Integer, ScopeContext> immutableScopeContexts;
+
     // A component context name to scope context index
     protected Map<String, ScopeContext> scopeIndex;
 
@@ -131,7 +134,7 @@
     public void start() {
         synchronized (initializeLatch) {
             try {
-                if(lifecycleState != UNINITIALIZED){
+                if (lifecycleState != UNINITIALIZED) {
                     throw new IllegalStateException("Context not in UNINITIALIZED state");
                 }
                 lifecycleState = INITIALIZING;
@@ -139,13 +142,47 @@
 
                 Map<Integer, List<RuntimeConfiguration<SimpleComponentContext>>> configurationsByScope = new HashMap();
                 if (configurations != null) {
-                    for (RuntimeConfiguration config : configurations) {
+                    for (RuntimeConfiguration config : configurations.values()) {
                         // FIXME scopes are defined at the interface level
                         int scope = config.getScope();
                         // ensure duplicate names were not added before the context was started
-                        if (scopeIndex.get(config.getName()) != null) {
-                            throw new DuplicateNameException(config.getName());
+                        // if (scopeIndex.get(config.getName()) != null) {
+                        // throw new DuplicateNameException(config.getName());
+                        // }
+                        // /----------------
+                        if (config.getSourceProxyFactories() != null) {
+                            for (ProxyFactory sourceFactory : ((Map<String, ProxyFactory>) config.getSourceProxyFactories())
+                                    .values()) {
+                                QualifiedName targetName = sourceFactory.getProxyConfiguration().getTargetName();
+                                RuntimeConfiguration target = configurations.get(targetName.getPartName());
+                                if (target == null) {
+                                    ContextInitException e = new ContextInitException("Target not found");
+                                    e.setIdentifier(targetName.getPartName());
+                                    e.addContextName(name);
+                                    throw e;
+                                }
+                                // get the proxy chain for the target
+                                ProxyFactory targetFactory = target.getTargetProxyFactory(sourceFactory.getProxyConfiguration()
+                                        .getTargetName().getPortName());
+                                Map<OperationType, InvocationConfiguration> targetInvocationConfigs = targetFactory
+                                        .getProxyConfiguration().getInvocationConfigurations();
+                                for (InvocationConfiguration sourceInvocationConfig : sourceFactory.getProxyConfiguration()
+                                        .getInvocationConfigurations().values()) {
+                                    // match invocation chains
+                                    InvocationConfiguration targetInvocationConfig = targetInvocationConfigs
+                                            .get(sourceInvocationConfig.getOperationType());
+                                    // if handler is configured, add that
+                                    if (targetInvocationConfig.getHeadHandler() != null) {
+                                        sourceInvocationConfig.addRequestHandler(targetInvocationConfig.getHeadHandler());
+                                    } else {
+                                        // no handlers, just conntect interceptors
+                                        sourceInvocationConfig.addTargetInterceptor(targetInvocationConfig.getInterceptor());
+                                    }
+                                }
+                            }
                         }
+                        config.prepare();
+                        // /---------------
                         scopeIndex.put(config.getName(), scopeContexts.get(scope));
                         List<RuntimeConfiguration<SimpleComponentContext>> list = configurationsByScope.get(scope);
                         if (list == null) {
@@ -356,7 +393,10 @@
             scope.registerConfiguration(configuration);
             scopeIndex.put(configuration.getName(), scope);
         } else {
-            configurations.add(configuration);
+            if (configurations.get(configuration.getName()) != null) {
+                throw new DuplicateNameException(configuration.getName());
+            }
+            configurations.put(configuration.getName(), configuration);
         }
 
     }
@@ -430,8 +470,8 @@
             throw e;
         }
     }
-    
-    public Map<Integer,ScopeContext> getScopeContexts(){
+
+    public Map<Integer, ScopeContext> getScopeContexts() {
         initializeScopes();
         return immutableScopeContexts;
     }
@@ -470,7 +510,7 @@
 
     protected void initializeScopes() {
         if (scopeContexts == null) {
-            if(scopeStrategy == null){
+            if (scopeStrategy == null) {
                 scopeStrategy = new DefaultScopeStrategy();
             }
             scopeContexts = scopeStrategy.createScopes(eventContext);

Modified: incubator/tuscany/java/sca/core/src/main/java/org/apache/tuscany/core/invocation/InvocationConfiguration.java
URL: http://svn.apache.org/viewcvs/incubator/tuscany/java/sca/core/src/main/java/org/apache/tuscany/core/invocation/InvocationConfiguration.java?rev=376070&r1=376069&r2=376070&view=diff
==============================================================================
--- incubator/tuscany/java/sca/core/src/main/java/org/apache/tuscany/core/invocation/InvocationConfiguration.java (original)
+++ incubator/tuscany/java/sca/core/src/main/java/org/apache/tuscany/core/invocation/InvocationConfiguration.java Wed Feb  8 13:23:16 2006
@@ -59,30 +59,34 @@
     }
 
     public void addSourceInterceptor(Interceptor interceptor) {
-        if (sourceInterceptorChainHead == null)
+        if (sourceInterceptorChainHead == null) {
             sourceInterceptorChainHead = interceptor;
-        else
+        } else {
             sourceInterceptorChainTail.setNext(interceptor);
+        }
         sourceInterceptorChainTail = interceptor;
     }
 
     public void addTargetInterceptor(Interceptor interceptor) {
-        if (targetInterceptorChainHead == null)
+        if (targetInterceptorChainHead == null){
             targetInterceptorChainHead = interceptor;
-        else
+        }else{
             targetInterceptorChainTail.setNext(interceptor);
+        }
         targetInterceptorChainTail = interceptor;
     }
 
     public void addRequestHandler(MessageHandler handler) {
-        if (requestHandlers == null)
+        if (requestHandlers == null){
             requestHandlers = new ArrayList<MessageHandler>();
+        }
         requestHandlers.add(handler);
     }
 
     public void addResponseHandler(MessageHandler handler) {
-        if (responseHandlers == null)
+        if (responseHandlers == null){
             responseHandlers = new ArrayList<MessageHandler>();
+        }
         responseHandlers.add(handler);
     }
 
@@ -98,6 +102,14 @@
         return sourceInterceptorChainHead;
     }
 
+    public MessageHandler getHeadHandler() {
+        if (responseHandlers != null && responseHandlers.size() > 0) {
+            return responseHandlers.get(0);
+        } else {
+            return null;
+        }
+    }
+
     /**
      * Build the configuration, link the interceptors and handlers together
      */
@@ -106,9 +118,9 @@
         // Build target interceptor chain
         if (targetInvoker != null) {
             if (targetInterceptorChainHead != null) {
-                targetInterceptorChainTail.setNext((Interceptor) targetInvoker);
+                targetInterceptorChainTail.setNext(targetInvoker);
             } else {
-                targetInterceptorChainHead = (Interceptor) targetInvoker;
+                targetInterceptorChainHead = targetInvoker;
             }
         }
 

Modified: incubator/tuscany/java/sca/core/src/main/java/org/apache/tuscany/core/invocation/ProxyConfiguration.java
URL: http://svn.apache.org/viewcvs/incubator/tuscany/java/sca/core/src/main/java/org/apache/tuscany/core/invocation/ProxyConfiguration.java?rev=376070&r1=376069&r2=376070&view=diff
==============================================================================
--- incubator/tuscany/java/sca/core/src/main/java/org/apache/tuscany/core/invocation/ProxyConfiguration.java (original)
+++ incubator/tuscany/java/sca/core/src/main/java/org/apache/tuscany/core/invocation/ProxyConfiguration.java Wed Feb  8 13:23:16 2006
@@ -18,32 +18,41 @@
 
 import java.util.Map;
 
+import org.apache.tuscany.core.context.QualifiedName;
 import org.apache.tuscany.core.context.ScopeContext;
 import org.apache.tuscany.core.message.MessageFactory;
 import org.apache.tuscany.model.types.OperationType;
 
 /**
  * Represents configuration information for creating a service reference proxy
- *
+ * 
  * @version $Rev$ $Date$
  */
 public class ProxyConfiguration {
 
     private Map<OperationType, InvocationConfiguration> configurations;
+
     private ClassLoader proxyClassLoader;
+
     private MessageFactory messageFactory;
-    private Map<Integer,ScopeContext> scopeContainers;
+
+    private Map<Integer, ScopeContext> scopeContainers;
+
+    private QualifiedName targetName;
 
     // ----------------------------------
     // Constructors
     // ----------------------------------
 
-    //TODO add "from"
-    public ProxyConfiguration(Map<OperationType, InvocationConfiguration> invocationConfigs, ClassLoader proxyClassLoader, Map<Integer,ScopeContext> scopeContainers, MessageFactory messageFactory) {
+    // TODO add "from"
+    public ProxyConfiguration(QualifiedName targetName, Map<OperationType, InvocationConfiguration> invocationConfigs,
+            ClassLoader proxyClassLoader, Map<Integer, ScopeContext> scopeContainers, MessageFactory messageFactory) {
         assert (invocationConfigs != null) : "No invocation configuration map specified";
+        assert (targetName != null) : "No target name specified";
+        this.targetName = targetName;
         configurations = invocationConfigs;
-        this.scopeContainers=scopeContainers;
-        this.messageFactory=messageFactory;
+        this.scopeContainers = scopeContainers;
+        this.messageFactory = messageFactory;
         if (proxyClassLoader == null) {
             this.proxyClassLoader = Thread.currentThread().getContextClassLoader();
         } else {
@@ -55,10 +64,13 @@
     // Methods
     // ----------------------------------
 
+    public QualifiedName getTargetName() {
+        return targetName;
+    }
+
     /**
-     * Returns a collection of operation types to {@link InvocationConfiguration}
-     * mappings that represent the specific proxy configuration information for
-     * particular operations
+     * Returns a collection of operation types to {@link InvocationConfiguration} mappings that represent the specific
+     * proxy configuration information for particular operations
      */
     public Map<OperationType, InvocationConfiguration> getInvocationConfigurations() {
         return configurations;
@@ -78,8 +90,8 @@
     /**
      * @return Returns the scopeContainers.
      */
-    public Map<Integer,ScopeContext> getScopeContainers() {
+    public Map<Integer, ScopeContext> getScopeContainers() {
         return scopeContainers;
     }
-    
+
 }

Modified: incubator/tuscany/java/sca/core/src/main/java/org/apache/tuscany/core/invocation/TargetInvoker.java
URL: http://svn.apache.org/viewcvs/incubator/tuscany/java/sca/core/src/main/java/org/apache/tuscany/core/invocation/TargetInvoker.java?rev=376070&r1=376069&r2=376070&view=diff
==============================================================================
--- incubator/tuscany/java/sca/core/src/main/java/org/apache/tuscany/core/invocation/TargetInvoker.java (original)
+++ incubator/tuscany/java/sca/core/src/main/java/org/apache/tuscany/core/invocation/TargetInvoker.java Wed Feb  8 13:23:16 2006
@@ -24,7 +24,7 @@
  * 
  * @version $Rev$ $Date$
  */
-public interface TargetInvoker {
+public interface TargetInvoker extends Interceptor{
 
     /**
      * Responsible for invoking an operation on a target with the given payload

Modified: incubator/tuscany/java/sca/core/src/main/java/org/apache/tuscany/core/invocation/impl/RequestResponseInterceptor.java
URL: http://svn.apache.org/viewcvs/incubator/tuscany/java/sca/core/src/main/java/org/apache/tuscany/core/invocation/impl/RequestResponseInterceptor.java?rev=376070&r1=376069&r2=376070&view=diff
==============================================================================
--- incubator/tuscany/java/sca/core/src/main/java/org/apache/tuscany/core/invocation/impl/RequestResponseInterceptor.java (original)
+++ incubator/tuscany/java/sca/core/src/main/java/org/apache/tuscany/core/invocation/impl/RequestResponseInterceptor.java Wed Feb  8 13:23:16 2006
@@ -22,7 +22,7 @@
 
 /**
  * An interceptor that first sends the invocation Message down its request channel then extracts the response from the message and
- * sends it down the response channel before returning it the up the interceptor stack.
+ * sends it down the response channel before returning it up the interceptor stack.
  * 
  * @version $Rev$ $Date$
  */

Modified: incubator/tuscany/java/sca/core/src/main/java/org/apache/tuscany/core/invocation/jdk/JDKInvocationHandler.java
URL: http://svn.apache.org/viewcvs/incubator/tuscany/java/sca/core/src/main/java/org/apache/tuscany/core/invocation/jdk/JDKInvocationHandler.java?rev=376070&r1=376069&r2=376070&view=diff
==============================================================================
--- incubator/tuscany/java/sca/core/src/main/java/org/apache/tuscany/core/invocation/jdk/JDKInvocationHandler.java (original)
+++ incubator/tuscany/java/sca/core/src/main/java/org/apache/tuscany/core/invocation/jdk/JDKInvocationHandler.java Wed Feb  8 13:23:16 2006
@@ -55,8 +55,8 @@
      * Dispatches a client request made on a proxy
      */
     public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
-        InvocationConfiguration config = configuration.get(method);
         Interceptor headInterceptor = null;
+        InvocationConfiguration config = configuration.get(method);
         if (config != null) {
             headInterceptor = config.getInterceptor();
         }

Modified: incubator/tuscany/java/sca/core/src/main/java/org/apache/tuscany/core/invocation/jdk/JDKProxyFactory.java
URL: http://svn.apache.org/viewcvs/incubator/tuscany/java/sca/core/src/main/java/org/apache/tuscany/core/invocation/jdk/JDKProxyFactory.java?rev=376070&r1=376069&r2=376070&view=diff
==============================================================================
--- incubator/tuscany/java/sca/core/src/main/java/org/apache/tuscany/core/invocation/jdk/JDKProxyFactory.java (original)
+++ incubator/tuscany/java/sca/core/src/main/java/org/apache/tuscany/core/invocation/jdk/JDKProxyFactory.java Wed Feb  8 13:23:16 2006
@@ -32,7 +32,7 @@
 
 /**
  * Creates proxies for handling invocations using JDK dynamic proxies
- *
+ * 
  * @version $Rev$ $Date$
  */
 public class JDKProxyFactory implements ProxyFactory {
@@ -40,14 +40,11 @@
     private Class[] businessInterfaceArray;
 
     private Map<Method, InvocationConfiguration> methodToInvocationConfig;
+
     private ProxyConfiguration configuration;
 
-    public void initialize(Class businessInterface, ProxyConfiguration config) throws ProxyInitializationException {
-        assert (businessInterface != null) : "No business interface specified";
-        assert (config != null) : "No proxy configuration specified";
-        configuration = config;
-        businessInterfaceArray = new Class[]{businessInterface};
-        Map<OperationType, InvocationConfiguration> invocationConfigs = config.getInvocationConfigurations();
+    public void initialize() throws ProxyInitializationException {
+        Map<OperationType, InvocationConfiguration> invocationConfigs = configuration.getInvocationConfigurations();
         methodToInvocationConfig = new HashMap(invocationConfigs.size());
         for (Map.Entry entry : invocationConfigs.entrySet()) {
             OperationType operation = (OperationType) entry.getKey();
@@ -55,11 +52,9 @@
                 JavaOperationType javaOperation = (JavaOperationType) operation;
                 Method method = javaOperation.getJavaMethod();
                 methodToInvocationConfig.put(method, (InvocationConfiguration) entry.getValue());
-//				throw new ProxyInitializationException("Operation [" + operation.getName()
-//						+ "] not a Java type on interface [" + businessInterface.getName() + "]");
             } else {
                 WSDLOperationType wsdlOperation = (WSDLOperationType) operation;
-                Method[] methods = businessInterface.getMethods();
+                Method[] methods = businessInterfaceArray[0].getMethods();
                 for (int i = 0; i < methods.length; i++) {
                     if (methods[i].getName().equals(wsdlOperation.getName())) {
                         methodToInvocationConfig.put(methods[i], (InvocationConfiguration) entry.getValue());
@@ -72,9 +67,32 @@
     }
 
     public Object createProxy() {
-        // TODO pass from part of proxyconfig
         InvocationHandler handler = new JDKInvocationHandler(configuration.getMessageFactory(), methodToInvocationConfig);
         return Proxy.newProxyInstance(configuration.getProxyClassLoader(), businessInterfaceArray, handler);
+    }
+
+    public ProxyConfiguration getProxyConfiguration() {
+        return configuration;
+    }
+
+    public void setProxyConfiguration(ProxyConfiguration config) {
+        configuration = config;
+    }
+
+    public void setBusinessInterface(Class interfaze) {
+        businessInterfaceArray = new Class[] { interfaze };
+    }
+
+    public Class getBusinessInterface() {
+        return businessInterfaceArray[0];
+    }
+
+    public void addInterface(Class claz) {
+        throw new UnsupportedOperationException("Additional proxy interfaces not yet supported");
+    }
+
+    public Class[] getImplementatedInterfaces() {
+        return businessInterfaceArray;
     }
 
 }

Added: incubator/tuscany/java/sca/core/src/main/java/org/apache/tuscany/core/invocation/jdk/JDKProxyFactoryFactory.java
URL: http://svn.apache.org/viewcvs/incubator/tuscany/java/sca/core/src/main/java/org/apache/tuscany/core/invocation/jdk/JDKProxyFactoryFactory.java?rev=376070&view=auto
==============================================================================
--- incubator/tuscany/java/sca/core/src/main/java/org/apache/tuscany/core/invocation/jdk/JDKProxyFactoryFactory.java (added)
+++ incubator/tuscany/java/sca/core/src/main/java/org/apache/tuscany/core/invocation/jdk/JDKProxyFactoryFactory.java Wed Feb  8 13:23:16 2006
@@ -0,0 +1,34 @@
+/**
+ * 
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * 
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
+ * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations under the License.
+ */
+package org.apache.tuscany.core.invocation.jdk;
+
+import org.apache.tuscany.core.invocation.spi.ProxyFactory;
+import org.apache.tuscany.core.invocation.spi.ProxyFactoryFactory;
+
+/**
+ * 
+ * 
+ * @version $Rev$ $Date$
+ */
+public class JDKProxyFactoryFactory implements ProxyFactoryFactory {
+
+    public JDKProxyFactoryFactory() {
+    }
+
+    public ProxyFactory createProxyFactory() {
+        return new JDKProxyFactory();
+    }
+
+}
+

Modified: incubator/tuscany/java/sca/core/src/main/java/org/apache/tuscany/core/invocation/jdk/NullProxyFactory.java
URL: http://svn.apache.org/viewcvs/incubator/tuscany/java/sca/core/src/main/java/org/apache/tuscany/core/invocation/jdk/NullProxyFactory.java?rev=376070&r1=376069&r2=376070&view=diff
==============================================================================
--- incubator/tuscany/java/sca/core/src/main/java/org/apache/tuscany/core/invocation/jdk/NullProxyFactory.java (original)
+++ incubator/tuscany/java/sca/core/src/main/java/org/apache/tuscany/core/invocation/jdk/NullProxyFactory.java Wed Feb  8 13:23:16 2006
@@ -32,4 +32,28 @@
         return ctx.locateService(serviceName);
     }
 
+    public void initialize() throws ProxyInitializationException {
+    }
+
+    public ProxyConfiguration getProxyConfiguration() {
+        return null;
+    }
+
+    public void setProxyConfiguration(ProxyConfiguration config) {
+    }
+
+    public void setBusinessInterface(Class interfaze) {
+    }
+
+    public Class getBusinessInterface() {
+        return null;
+    }
+
+    public void addInterface(Class claz) {
+    }
+
+    public Class[] getImplementatedInterfaces() {
+        return null;
+    }
+
 }

Modified: incubator/tuscany/java/sca/core/src/main/java/org/apache/tuscany/core/invocation/spi/ProxyFactory.java
URL: http://svn.apache.org/viewcvs/incubator/tuscany/java/sca/core/src/main/java/org/apache/tuscany/core/invocation/spi/ProxyFactory.java?rev=376070&r1=376069&r2=376070&view=diff
==============================================================================
--- incubator/tuscany/java/sca/core/src/main/java/org/apache/tuscany/core/invocation/spi/ProxyFactory.java (original)
+++ incubator/tuscany/java/sca/core/src/main/java/org/apache/tuscany/core/invocation/spi/ProxyFactory.java Wed Feb  8 13:23:16 2006
@@ -36,11 +36,23 @@
      * @throws ProxyInitializationException if an error generating a proxy is
      *                                      encountered
      */
-    public void initialize(Class businessInterface, ProxyConfiguration config) throws ProxyInitializationException;
+    public void initialize() throws ProxyInitializationException;
 
     /**
      * Returns a proxy for a service reference
      */
     public T createProxy() throws ProxyCreationException;
 
+    public ProxyConfiguration getProxyConfiguration();
+    
+    public void setProxyConfiguration(ProxyConfiguration config);
+
+    public void setBusinessInterface(Class interfaze);
+    
+    public Class getBusinessInterface();
+    
+    public void addInterface(Class claz);
+    
+    public Class[] getImplementatedInterfaces();
+    
 }

Added: incubator/tuscany/java/sca/core/src/main/java/org/apache/tuscany/core/invocation/spi/ProxyFactoryFactory.java
URL: http://svn.apache.org/viewcvs/incubator/tuscany/java/sca/core/src/main/java/org/apache/tuscany/core/invocation/spi/ProxyFactoryFactory.java?rev=376070&view=auto
==============================================================================
--- incubator/tuscany/java/sca/core/src/main/java/org/apache/tuscany/core/invocation/spi/ProxyFactoryFactory.java (added)
+++ incubator/tuscany/java/sca/core/src/main/java/org/apache/tuscany/core/invocation/spi/ProxyFactoryFactory.java Wed Feb  8 13:23:16 2006
@@ -0,0 +1,8 @@
+package org.apache.tuscany.core.invocation.spi;
+
+public interface ProxyFactoryFactory {
+
+    public ProxyFactory createProxyFactory();
+    
+}
+

Added: incubator/tuscany/java/sca/core/src/main/java/org/apache/tuscany/core/message/impl/PojoMessageFactory.java
URL: http://svn.apache.org/viewcvs/incubator/tuscany/java/sca/core/src/main/java/org/apache/tuscany/core/message/impl/PojoMessageFactory.java?rev=376070&view=auto
==============================================================================
--- incubator/tuscany/java/sca/core/src/main/java/org/apache/tuscany/core/message/impl/PojoMessageFactory.java (added)
+++ incubator/tuscany/java/sca/core/src/main/java/org/apache/tuscany/core/message/impl/PojoMessageFactory.java Wed Feb  8 13:23:16 2006
@@ -0,0 +1,34 @@
+/**
+ * 
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * 
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
+ * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations under the License.
+ */
+package org.apache.tuscany.core.message.impl;
+
+import org.apache.tuscany.core.message.Message;
+import org.apache.tuscany.core.message.MessageFactory;
+
+/**
+ * 
+ * 
+ * @version $Rev$ $Date$
+ */
+public class PojoMessageFactory implements MessageFactory {
+
+    public PojoMessageFactory() {
+    }
+
+    public Message createMessage() {
+        return new PojoMessageImpl();
+    }
+
+}
+

Modified: incubator/tuscany/java/sca/core/src/main/java/org/apache/tuscany/core/system/builder/ProxyFactoryBuilder.java
URL: http://svn.apache.org/viewcvs/incubator/tuscany/java/sca/core/src/main/java/org/apache/tuscany/core/system/builder/ProxyFactoryBuilder.java?rev=376070&r1=376069&r2=376070&view=diff
==============================================================================
--- incubator/tuscany/java/sca/core/src/main/java/org/apache/tuscany/core/system/builder/ProxyFactoryBuilder.java (original)
+++ incubator/tuscany/java/sca/core/src/main/java/org/apache/tuscany/core/system/builder/ProxyFactoryBuilder.java Wed Feb  8 13:23:16 2006
@@ -30,6 +30,7 @@
 import org.apache.tuscany.core.builder.RuntimeConfigurationBuilder;
 import org.apache.tuscany.core.config.JavaIntrospectionHelper;
 import org.apache.tuscany.core.context.AggregateContext;
+import org.apache.tuscany.core.context.QualifiedName;
 import org.apache.tuscany.core.context.ScopeAwareContext;
 import org.apache.tuscany.core.context.ScopeContext;
 import org.apache.tuscany.core.invocation.InvocationConfiguration;
@@ -59,6 +60,7 @@
  * A system component that configures proxy factories for references
  * <p>
  * FIXME integrate back with {@link org.apache.tuscany.core.builder.impl.PortRuntimeConfigurationBuilderImpl}
+ * @deprecated
  */
 
 @Scope("MODULE")
@@ -178,7 +180,7 @@
         // Create Proxy configuration
         Map<OperationType, InvocationConfiguration> invocationConfigurations = new HashMap<OperationType, InvocationConfiguration>();
         Class javaInterface = interfaceType.getInstanceClass();
-        ProxyConfiguration proxyConfiguration = new ProxyConfiguration(invocationConfigurations, javaInterface.getClassLoader(),
+        ProxyConfiguration proxyConfiguration = new ProxyConfiguration(null,invocationConfigurations, javaInterface.getClassLoader(),
                 scopeContexts, messageFactory);
 
         // Create invocation configurations for all the operations on the business interface
@@ -205,7 +207,8 @@
         // Create Proxy configuration
         Map<OperationType, InvocationConfiguration> invocationConfigurations = new HashMap<OperationType, InvocationConfiguration>();
         Class javaInterface = interfaceType.getInstanceClass();
-        ProxyConfiguration proxyConfiguration = new ProxyConfiguration(invocationConfigurations, javaInterface.getClassLoader(),
+        QualifiedName qName = new QualifiedName(configuredService.getPart().getName()+"/"+configuredService.getPort().getName());
+        ProxyConfiguration proxyConfiguration = new ProxyConfiguration(qName, invocationConfigurations, javaInterface.getClassLoader(),
                 scopeContexts, messageFactory);
 
         // Create invocation configurations for all the operations on the business interface
@@ -243,7 +246,9 @@
         try {
             // Create a proxy factory
             ProxyFactory proxyFactory = (ProxyFactory) proxyFactoryConstructor.newInstance((Object[]) null);
-            proxyFactory.initialize(javaInterface, proxyConfiguration);
+            proxyFactory.setBusinessInterface(javaInterface);
+            proxyFactory.setProxyConfiguration(proxyConfiguration);
+            proxyFactory.initialize();
             return proxyFactory;
         } catch (ProxyInitializationException e) {
             e.addContextName(name);

Modified: incubator/tuscany/java/sca/core/src/main/java/org/apache/tuscany/core/system/config/SystemComponentRuntimeConfiguration.java
URL: http://svn.apache.org/viewcvs/incubator/tuscany/java/sca/core/src/main/java/org/apache/tuscany/core/system/config/SystemComponentRuntimeConfiguration.java?rev=376070&r1=376069&r2=376070&view=diff
==============================================================================
--- incubator/tuscany/java/sca/core/src/main/java/org/apache/tuscany/core/system/config/SystemComponentRuntimeConfiguration.java (original)
+++ incubator/tuscany/java/sca/core/src/main/java/org/apache/tuscany/core/system/config/SystemComponentRuntimeConfiguration.java Wed Feb  8 13:23:16 2006
@@ -2,6 +2,7 @@
 
 import java.lang.reflect.Constructor;
 import java.util.List;
+import java.util.Map;
 
 import org.apache.tuscany.core.builder.ContextCreationException;
 import org.apache.tuscany.core.builder.RuntimeConfiguration;
@@ -10,6 +11,7 @@
 import org.apache.tuscany.core.injection.EventInvoker;
 import org.apache.tuscany.core.injection.Injector;
 import org.apache.tuscany.core.injection.PojoObjectFactory;
+import org.apache.tuscany.core.invocation.spi.ProxyFactory;
 import org.apache.tuscany.core.system.context.SystemComponentContext;
 import org.apache.tuscany.model.assembly.ScopeEnum;
 
@@ -104,6 +106,35 @@
             PojoObjectFactory objectFactory = new PojoObjectFactory(ctr, null, setters);
             return new SystemComponentContext(name, objectFactory, eagerInit, init, destroy, stateless);
         }
+    }
+    
+    // -- Proxy
+
+    public void prepare() {
+    }
+
+    public void addTargetProxyFactory(String serviceName, ProxyFactory factory) {
+        throw new UnsupportedOperationException();
+    }
+
+    public ProxyFactory getTargetProxyFactory(String serviceName) {
+        return null;
+    }
+
+    public Map<String, ProxyFactory> getTargetProxyFactories() {
+        throw new UnsupportedOperationException();
+    }
+
+    public void addSourceProxyFactory(String referenceName, ProxyFactory factory) {
+        throw new UnsupportedOperationException();
+    }
+
+    public ProxyFactory getSourceProxyFactory(String referenceName) {
+        return null;
+    }
+
+    public Map<String, ProxyFactory> getSourceProxyFactories() {
+        return null;
     }
 
 }

Modified: incubator/tuscany/java/sca/core/src/main/java/org/apache/tuscany/core/system/config/SystemEntryPointRuntimeConfiguration.java
URL: http://svn.apache.org/viewcvs/incubator/tuscany/java/sca/core/src/main/java/org/apache/tuscany/core/system/config/SystemEntryPointRuntimeConfiguration.java?rev=376070&r1=376069&r2=376070&view=diff
==============================================================================
--- incubator/tuscany/java/sca/core/src/main/java/org/apache/tuscany/core/system/config/SystemEntryPointRuntimeConfiguration.java (original)
+++ incubator/tuscany/java/sca/core/src/main/java/org/apache/tuscany/core/system/config/SystemEntryPointRuntimeConfiguration.java Wed Feb  8 13:23:16 2006
@@ -13,10 +13,13 @@
  */
 package org.apache.tuscany.core.system.config;
 
+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.injection.ObjectFactory;
+import org.apache.tuscany.core.invocation.spi.ProxyFactory;
 import org.apache.tuscany.core.system.context.SystemEntryPointContext;
 import org.apache.tuscany.model.assembly.ScopeEnum;
 
@@ -56,6 +59,34 @@
 
     public String getName() {
         return name;
+    }
+
+    // -- Proxy
+    public void prepare() {
+    }
+
+    public void addTargetProxyFactory(String serviceName, ProxyFactory pFactory) {
+        throw new UnsupportedOperationException();
+ }
+
+    public ProxyFactory getTargetProxyFactory(String serviceName) {
+        return null;
+    }
+
+    public Map<String, ProxyFactory> getTargetProxyFactories() {
+        return null;
+    }
+
+    public void addSourceProxyFactory(String referenceName, ProxyFactory pFactory) {
+        throw new UnsupportedOperationException();
+    }
+
+    public ProxyFactory getSourceProxyFactory(String referenceName) {
+        return null;
+    }
+
+    public Map<String, ProxyFactory> getSourceProxyFactories() {
+        return null;
     }
 
 }



Mime
View raw message