tuscany-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rf...@apache.org
Subject svn commit: r557408 - in /incubator/tuscany/java/sca/modules: core-spi/src/main/java/org/apache/tuscany/sca/context/ core/src/main/java/org/apache/tuscany/sca/core/component/ host-embedded/src/main/java/org/apache/tuscany/sca/host/embedded/impl/ implem...
Date Wed, 18 Jul 2007 21:58:04 GMT
Author: rfeng
Date: Wed Jul 18 14:58:03 2007
New Revision: 557408

URL: http://svn.apache.org/viewvc?view=rev&rev=557408
Log:
Add ContextFactoryExtensionPoint, ComponentContextFactor and RequestContextFactory for pluggability

Added:
    incubator/tuscany/java/sca/modules/core-spi/src/main/java/org/apache/tuscany/sca/context/
    incubator/tuscany/java/sca/modules/core-spi/src/main/java/org/apache/tuscany/sca/context/ComponentContextFactory.java
  (with props)
    incubator/tuscany/java/sca/modules/core-spi/src/main/java/org/apache/tuscany/sca/context/ContextFactoryExtensionPoint.java
  (with props)
    incubator/tuscany/java/sca/modules/core-spi/src/main/java/org/apache/tuscany/sca/context/DefaultContextFactoryExtensionPoint.java
  (with props)
    incubator/tuscany/java/sca/modules/core-spi/src/main/java/org/apache/tuscany/sca/context/RequestContextFactory.java
  (with props)
Modified:
    incubator/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/component/ComponentContextImpl.java
    incubator/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/component/RequestContextImpl.java
    incubator/tuscany/java/sca/modules/host-embedded/src/main/java/org/apache/tuscany/sca/host/embedded/impl/ReallySmallRuntime.java
    incubator/tuscany/java/sca/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/injection/RequestContextObjectFactory.java
    incubator/tuscany/java/sca/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/invocation/JavaComponentInfo.java
    incubator/tuscany/java/sca/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/invocation/JavaImplementationProvider.java
    incubator/tuscany/java/sca/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/invocation/JavaImplementationProviderFactory.java
    incubator/tuscany/java/sca/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/module/JavaRuntimeModuleActivator.java
    incubator/tuscany/java/sca/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/injection/RequestContextObjectFactoryTestCase.java

Added: incubator/tuscany/java/sca/modules/core-spi/src/main/java/org/apache/tuscany/sca/context/ComponentContextFactory.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/core-spi/src/main/java/org/apache/tuscany/sca/context/ComponentContextFactory.java?view=auto&rev=557408
==============================================================================
--- incubator/tuscany/java/sca/modules/core-spi/src/main/java/org/apache/tuscany/sca/context/ComponentContextFactory.java
(added)
+++ incubator/tuscany/java/sca/modules/core-spi/src/main/java/org/apache/tuscany/sca/context/ComponentContextFactory.java
Wed Jul 18 14:58:03 2007
@@ -0,0 +1,38 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.sca.context;
+
+import org.apache.tuscany.sca.runtime.RuntimeComponent;
+import org.osoa.sca.ComponentContext;
+
+/**
+ * Interface implemented by the provider of the ComponentContext.
+ * 
+ * @version $Rev$ $Date$
+ */
+public interface ComponentContextFactory {
+    /**
+     * Create an instance of ComponentContext
+     * 
+     * @param component The runtime component
+     * @param requestContextFactory The factory to create RequestContext
+     * @return An instance of ComponentContext for the component
+     */
+    ComponentContext createComponentContext(RuntimeComponent component, RequestContextFactory
requestContextFactory);
+}

Propchange: incubator/tuscany/java/sca/modules/core-spi/src/main/java/org/apache/tuscany/sca/context/ComponentContextFactory.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/tuscany/java/sca/modules/core-spi/src/main/java/org/apache/tuscany/sca/context/ComponentContextFactory.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: incubator/tuscany/java/sca/modules/core-spi/src/main/java/org/apache/tuscany/sca/context/ContextFactoryExtensionPoint.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/core-spi/src/main/java/org/apache/tuscany/sca/context/ContextFactoryExtensionPoint.java?view=auto&rev=557408
==============================================================================
--- incubator/tuscany/java/sca/modules/core-spi/src/main/java/org/apache/tuscany/sca/context/ContextFactoryExtensionPoint.java
(added)
+++ incubator/tuscany/java/sca/modules/core-spi/src/main/java/org/apache/tuscany/sca/context/ContextFactoryExtensionPoint.java
Wed Jul 18 14:58:03 2007
@@ -0,0 +1,54 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.sca.context;
+
+/**
+ * An extension point for model factories. Model factories are provided to 
+ * abstract the classes that represent artifacts in the assembly model away
+ * from their creation mechanism. When the runtime needs to extend the model
+ * as it reads in contributed artifacts it looks up the factory for the 
+ * artifact required in this registry
+ *
+ * @version $Rev$ $Date$
+ */
+public interface ContextFactoryExtensionPoint {
+    
+    /**
+     * Add a model factory extension.
+     * 
+     * @param factory The factory to add
+     */
+    void addFactory(Object factory);
+    
+    /**
+     * Remove a model factory extension.
+     *  
+     * @param factory The factory to remove
+     */
+    void removeFactory(Object factory); 
+    
+    /**
+     * Get a factory implementing the given interface.
+     * @param factoryInterface the lookup key (factory interface)
+     * @return The factory
+     */
+    <T> T getFactory(Class<T> factoryInterface);
+
+}

Propchange: incubator/tuscany/java/sca/modules/core-spi/src/main/java/org/apache/tuscany/sca/context/ContextFactoryExtensionPoint.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/tuscany/java/sca/modules/core-spi/src/main/java/org/apache/tuscany/sca/context/ContextFactoryExtensionPoint.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: incubator/tuscany/java/sca/modules/core-spi/src/main/java/org/apache/tuscany/sca/context/DefaultContextFactoryExtensionPoint.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/core-spi/src/main/java/org/apache/tuscany/sca/context/DefaultContextFactoryExtensionPoint.java?view=auto&rev=557408
==============================================================================
--- incubator/tuscany/java/sca/modules/core-spi/src/main/java/org/apache/tuscany/sca/context/DefaultContextFactoryExtensionPoint.java
(added)
+++ incubator/tuscany/java/sca/modules/core-spi/src/main/java/org/apache/tuscany/sca/context/DefaultContextFactoryExtensionPoint.java
Wed Jul 18 14:58:03 2007
@@ -0,0 +1,67 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.sca.context;
+
+import java.util.HashMap;
+
+/**
+ * Default implementation of a model factory extension point.
+ *
+ * @version $Rev$ $Date$
+ */
+public class DefaultContextFactoryExtensionPoint implements ContextFactoryExtensionPoint
{
+    
+    private HashMap<Class<?>, Object> factories = new HashMap<Class<?>,
Object>();
+
+    /**
+     * Add a model factory extension.
+     * 
+     * @param factory The factory to add
+     */
+    public void addFactory(Object factory) {
+        Class[] interfaces = factory.getClass().getInterfaces();
+        for (int i = 0; i<interfaces.length; i++) {
+            factories.put(interfaces[i], factory);
+        }
+    }
+
+    /**
+     * Remove a model factory extension.
+     *  
+     * @param factory The factory to remove
+     */
+    public void removeFactory(Object factory) {
+        Class[] interfaces = factory.getClass().getInterfaces();
+        for (int i = 0; i<interfaces.length; i++) {
+            factories.remove(interfaces[i]);
+        }
+    }
+    
+    /**
+     * Get a factory implementing the given interface.
+     * @param factoryInterface The lookup key (factory interface)
+     * @return The factory
+     */    
+    public <T> T getFactory(Class<T> factoryInterface) {
+        Object factory = factories.get(factoryInterface);
+        return factoryInterface.cast(factory);
+    }
+
+}

Propchange: incubator/tuscany/java/sca/modules/core-spi/src/main/java/org/apache/tuscany/sca/context/DefaultContextFactoryExtensionPoint.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/tuscany/java/sca/modules/core-spi/src/main/java/org/apache/tuscany/sca/context/DefaultContextFactoryExtensionPoint.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: incubator/tuscany/java/sca/modules/core-spi/src/main/java/org/apache/tuscany/sca/context/RequestContextFactory.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/core-spi/src/main/java/org/apache/tuscany/sca/context/RequestContextFactory.java?view=auto&rev=557408
==============================================================================
--- incubator/tuscany/java/sca/modules/core-spi/src/main/java/org/apache/tuscany/sca/context/RequestContextFactory.java
(added)
+++ incubator/tuscany/java/sca/modules/core-spi/src/main/java/org/apache/tuscany/sca/context/RequestContextFactory.java
Wed Jul 18 14:58:03 2007
@@ -0,0 +1,33 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.sca.context;
+
+import org.osoa.sca.RequestContext;
+
+/**
+ * Interface implemented by the provider of the RequestContext.
+ *
+ * @version $Rev$ $Date$
+ */
+public interface RequestContextFactory {
+    /**
+     * @return An instance of RequestContext for the current invocation
+     */
+    RequestContext createRequestContext();
+}

Propchange: incubator/tuscany/java/sca/modules/core-spi/src/main/java/org/apache/tuscany/sca/context/RequestContextFactory.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/tuscany/java/sca/modules/core-spi/src/main/java/org/apache/tuscany/sca/context/RequestContextFactory.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Modified: incubator/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/component/ComponentContextImpl.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/component/ComponentContextImpl.java?view=diff&rev=557408&r1=557407&r2=557408
==============================================================================
--- incubator/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/component/ComponentContextImpl.java
(original)
+++ incubator/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/component/ComponentContextImpl.java
Wed Jul 18 14:58:03 2007
@@ -18,6 +18,7 @@
  */
 package org.apache.tuscany.sca.core.component;
 
+import org.apache.tuscany.sca.context.RequestContextFactory;
 import org.osoa.sca.CallableReference;
 import org.osoa.sca.ComponentContext;
 import org.osoa.sca.RequestContext;
@@ -31,9 +32,11 @@
  */
 public class ComponentContextImpl implements ComponentContext {
     private final ComponentContextProvider component;
+    private final RequestContextFactory requestContextFactory;
 
-    public ComponentContextImpl(ComponentContextProvider component) {
+    public ComponentContextImpl(ComponentContextProvider component, RequestContextFactory
requestContextFactory) {
         this.component = component;
+        this.requestContextFactory = requestContextFactory;
     }
 
     public String getURI() {
@@ -88,6 +91,10 @@
     }
 
     public RequestContext getRequestContext() {
-        return null;
+        if (requestContextFactory != null) {
+            return requestContextFactory.createRequestContext();
+        } else {
+            return new RequestContextImpl();
+        }
     }
 }

Modified: incubator/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/component/RequestContextImpl.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/component/RequestContextImpl.java?view=diff&rev=557408&r1=557407&r2=557408
==============================================================================
--- incubator/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/component/RequestContextImpl.java
(original)
+++ incubator/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/component/RequestContextImpl.java
Wed Jul 18 14:58:03 2007
@@ -20,6 +20,12 @@
 
 import javax.security.auth.Subject;
 
+import org.apache.tuscany.sca.core.invocation.ThreadMessageContext;
+import org.apache.tuscany.sca.interfacedef.java.JavaInterface;
+import org.apache.tuscany.sca.runtime.EndpointReference;
+import org.apache.tuscany.sca.runtime.RuntimeComponent;
+import org.apache.tuscany.sca.runtime.RuntimeComponentReference;
+import org.apache.tuscany.sca.runtime.RuntimeComponentService;
 import org.osoa.sca.CallableReference;
 import org.osoa.sca.RequestContext;
 import org.osoa.sca.ServiceReference;
@@ -37,18 +43,30 @@
     }
 
     public String getServiceName() {
-        throw new UnsupportedOperationException();
+        return ThreadMessageContext.getMessageContext().getTo().getContract().getName();
     }
 
     public <B> ServiceReference<B> getServiceReference() {
-        throw new UnsupportedOperationException();
+        EndpointReference to = ThreadMessageContext.getMessageContext().getTo();
+        RuntimeComponentService service = (RuntimeComponentService) to.getContract();
+        RuntimeComponent component = (RuntimeComponent) to.getComponent();
+        JavaInterface javaInterface = (JavaInterface) service.getInterfaceContract().getInterface();
+        return (ServiceReference<B>) component.createSelfReference(javaInterface.getJavaClass(),
service.getName());
     }
 
     public <CB> CB getCallback() {
-        throw new UnsupportedOperationException();
+        return (CB) getCallbackReference().getService();
     }
 
     public <CB> CallableReference<CB> getCallbackReference() {
-        throw new UnsupportedOperationException();
+        EndpointReference from = ThreadMessageContext.getMessageContext().getFrom();
+        RuntimeComponentReference service = (RuntimeComponentReference) from.getContract();
+        RuntimeComponent component = (RuntimeComponent) from.getComponent();
+        JavaInterface javaInterface = (JavaInterface) service.getInterfaceContract().getCallbackInterface();
+        if(javaInterface==null) {
+            return null;
+        }
+        // FIXME: Creating a self-ref is probably not right
+        return (CallableReference<CB>) component.createSelfReference(javaInterface.getCallbackClass());
     }
 }

Modified: incubator/tuscany/java/sca/modules/host-embedded/src/main/java/org/apache/tuscany/sca/host/embedded/impl/ReallySmallRuntime.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/host-embedded/src/main/java/org/apache/tuscany/sca/host/embedded/impl/ReallySmallRuntime.java?view=diff&rev=557408&r1=557407&r2=557408
==============================================================================
--- incubator/tuscany/java/sca/modules/host-embedded/src/main/java/org/apache/tuscany/sca/host/embedded/impl/ReallySmallRuntime.java
(original)
+++ incubator/tuscany/java/sca/modules/host-embedded/src/main/java/org/apache/tuscany/sca/host/embedded/impl/ReallySmallRuntime.java
Wed Jul 18 14:58:03 2007
@@ -31,6 +31,8 @@
 import org.apache.tuscany.sca.assembly.DefaultSCABindingFactory;
 import org.apache.tuscany.sca.assembly.SCABindingFactory;
 import org.apache.tuscany.sca.assembly.xml.Constants;
+import org.apache.tuscany.sca.context.ContextFactoryExtensionPoint;
+import org.apache.tuscany.sca.context.DefaultContextFactoryExtensionPoint;
 import org.apache.tuscany.sca.contribution.ContributionFactory;
 import org.apache.tuscany.sca.contribution.impl.ContributionFactoryImpl;
 import org.apache.tuscany.sca.contribution.processor.ArtifactProcessor;
@@ -91,6 +93,10 @@
         // Create factory extension point
         ModelFactoryExtensionPoint factories = new DefaultModelFactoryExtensionPoint();
         registry.addExtensionPoint(factories);
+        
+        // Create context factory extension point
+        ContextFactoryExtensionPoint contextFactories = new DefaultContextFactoryExtensionPoint();
+        registry.addExtensionPoint(contextFactories);
         
         // Create Message factory
         MessageFactory messageFactory = new MessageFactoryImpl();

Modified: incubator/tuscany/java/sca/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/injection/RequestContextObjectFactory.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/injection/RequestContextObjectFactory.java?view=diff&rev=557408&r1=557407&r2=557408
==============================================================================
--- incubator/tuscany/java/sca/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/injection/RequestContextObjectFactory.java
(original)
+++ incubator/tuscany/java/sca/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/injection/RequestContextObjectFactory.java
Wed Jul 18 14:58:03 2007
@@ -18,23 +18,31 @@
  */
 package org.apache.tuscany.sca.implementation.java.injection;
 
+import org.apache.tuscany.sca.context.RequestContextFactory;
 import org.apache.tuscany.sca.core.component.RequestContextImpl;
 import org.apache.tuscany.sca.factory.ObjectCreationException;
 import org.apache.tuscany.sca.factory.ObjectFactory;
 import org.osoa.sca.RequestContext;
 
 /**
- * Creates instances of {@link org.apache.tuscany.sca.core.component.RequestContextImpl}
for injection on
- * component implementation instances
- *
+ * Creates instances of
+ * {@link org.apache.tuscany.sca.core.component.RequestContextImpl} for
+ * injection on component implementation instances
+ * 
  * @version $Rev$ $Date$
  */
 public class RequestContextObjectFactory implements ObjectFactory<RequestContext> {
+    private RequestContextFactory factory;
 
-    public RequestContextObjectFactory() {
+    public RequestContextObjectFactory(RequestContextFactory factory) {
+        this.factory = factory;
     }
 
     public RequestContext getInstance() throws ObjectCreationException {
-        return new RequestContextImpl();
+        if (factory != null) {
+            return factory.createRequestContext();
+        } else {
+            return new RequestContextImpl();
+        }
     }
 }

Modified: incubator/tuscany/java/sca/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/invocation/JavaComponentInfo.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/invocation/JavaComponentInfo.java?view=diff&rev=557408&r1=557407&r2=557408
==============================================================================
--- incubator/tuscany/java/sca/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/invocation/JavaComponentInfo.java
(original)
+++ incubator/tuscany/java/sca/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/invocation/JavaComponentInfo.java
Wed Jul 18 14:58:03 2007
@@ -34,6 +34,8 @@
 import org.apache.tuscany.sca.assembly.ComponentService;
 import org.apache.tuscany.sca.assembly.Multiplicity;
 import org.apache.tuscany.sca.assembly.Reference;
+import org.apache.tuscany.sca.context.ComponentContextFactory;
+import org.apache.tuscany.sca.context.RequestContextFactory;
 import org.apache.tuscany.sca.core.component.ComponentContextImpl;
 import org.apache.tuscany.sca.core.component.ComponentContextProvider;
 import org.apache.tuscany.sca.core.component.ServiceReferenceImpl;
@@ -81,7 +83,9 @@
 public class JavaComponentInfo implements ComponentContextProvider {
     private JavaPropertyValueObjectFactory propertyValueFactory;
     private DataBindingExtensionPoint dataBindingRegistry;
-
+    private ComponentContextFactory componentContextFactory;
+    private RequestContextFactory requestContextFactory;
+    
     protected RuntimeComponent component;
     protected PojoConfiguration<?> configuration;
     protected Scope scope;
@@ -90,17 +94,26 @@
 
     private final ComponentContext componentContext;
 
-    public JavaComponentInfo(RuntimeComponent component, PojoConfiguration configuration,

+    public JavaComponentInfo(RuntimeComponent component,
+                             PojoConfiguration configuration,
                              DataBindingExtensionPoint dataBindingExtensionPoint,
-                             JavaPropertyValueObjectFactory propertyValueObjectFactory) {
+                             JavaPropertyValueObjectFactory propertyValueObjectFactory,
+                             ComponentContextFactory componentContextFactory,
+                             RequestContextFactory requestContextFactory) {
         super();
         this.configuration = configuration;
-        componentContext = new ComponentContextImpl(this);
+        if (componentContextFactory != null) {
+            this.componentContext = componentContextFactory.createComponentContext(component,
requestContextFactory);
+        } else {
+            this.componentContext = new ComponentContextImpl(this, requestContextFactory);
+        }
         this.groupId = configuration.getGroupId();
         this.component = component;
         this.proxyService = configuration.getProxyFactory();
         this.dataBindingRegistry = dataBindingExtensionPoint;
         this.propertyValueFactory = propertyValueObjectFactory;
+        this.componentContextFactory = componentContextFactory;
+        this.requestContextFactory = requestContextFactory;
     }
   
     public void destroy(Object instance) throws TargetDestructionException {

Modified: incubator/tuscany/java/sca/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/invocation/JavaImplementationProvider.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/invocation/JavaImplementationProvider.java?view=diff&rev=557408&r1=557407&r2=557408
==============================================================================
--- incubator/tuscany/java/sca/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/invocation/JavaImplementationProvider.java
(original)
+++ incubator/tuscany/java/sca/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/invocation/JavaImplementationProvider.java
Wed Jul 18 14:58:03 2007
@@ -23,12 +23,15 @@
 
 import org.apache.tuscany.sca.assembly.ComponentService;
 import org.apache.tuscany.sca.assembly.Service;
+import org.apache.tuscany.sca.context.ComponentContextFactory;
+import org.apache.tuscany.sca.context.RequestContextFactory;
 import org.apache.tuscany.sca.core.invocation.ProxyFactory;
 import org.apache.tuscany.sca.databinding.DataBindingExtensionPoint;
 import org.apache.tuscany.sca.factory.ObjectFactory;
 import org.apache.tuscany.sca.implementation.java.JavaImplementation;
 import org.apache.tuscany.sca.implementation.java.context.JavaPropertyValueObjectFactory;
 import org.apache.tuscany.sca.implementation.java.impl.JavaResourceImpl;
+import org.apache.tuscany.sca.implementation.java.injection.RequestContextObjectFactory;
 import org.apache.tuscany.sca.implementation.java.injection.ResourceHost;
 import org.apache.tuscany.sca.implementation.java.injection.ResourceObjectFactory;
 import org.apache.tuscany.sca.interfacedef.Operation;
@@ -40,30 +43,36 @@
 import org.apache.tuscany.sca.scope.ScopedImplementationProvider;
 import org.apache.tuscany.sca.scope.TargetInvokerCreationException;
 import org.osoa.sca.ComponentContext;
+import org.osoa.sca.RequestContext;
 
 /**
  * @version $Rev$ $Date$
  */
 public class JavaImplementationProvider implements ScopedImplementationProvider {
     private JavaImplementation implementation;
-    private JavaComponentInfo atomicComponent;
-
-    public JavaImplementationProvider(
-                                      RuntimeComponent component,
+    private JavaComponentInfo componentInfo;
+    private ComponentContextFactory componentContextFactory;
+    private RequestContextFactory requestContextFactory;
+    
+    public JavaImplementationProvider(RuntimeComponent component,
                                       JavaImplementation implementation,
                                       ProxyFactory proxyService,
                                       DataBindingExtensionPoint dataBindingRegistry,
-                                      JavaPropertyValueObjectFactory propertyValueObjectFactory)
{
+                                      JavaPropertyValueObjectFactory propertyValueObjectFactory,
+                                      ComponentContextFactory componentContextFactory,
+                                      RequestContextFactory requestContextFactory) {
         super();
         this.implementation = implementation;
-
+        this.componentContextFactory = componentContextFactory;
+        this.requestContextFactory = requestContextFactory;
         try {
             PojoConfiguration configuration = new PojoConfiguration(implementation);
             configuration.setProxyFactory(proxyService);
             // FIXME: Group id to be removed
             configuration.setGroupId(URI.create("/"));
-            atomicComponent = new JavaComponentInfo(component, configuration, dataBindingRegistry,
-                                                                      propertyValueObjectFactory);
+            componentInfo =
+                new JavaComponentInfo(component, configuration, dataBindingRegistry, propertyValueObjectFactory,
+                                      componentContextFactory, requestContextFactory);
 
             Scope scope = getScope();
 
@@ -87,36 +96,38 @@
             }
 
             if (implementation.getConversationIDMember() != null) {
-                atomicComponent.addConversationIDFactory(implementation.getConversationIDMember());
+                componentInfo.addConversationIDFactory(implementation.getConversationIDMember());
             }
 
-            atomicComponent.configureProperties(component.getProperties());
-            handleResources(implementation, atomicComponent);
+            componentInfo.configureProperties(component.getProperties());
+            handleResources(implementation);
         } catch (Exception e) {
             throw new IllegalStateException(e);
         }
 
     }
 
-    private void handleResources(JavaImplementation componentType, JavaComponentInfo component)
{
+    private void handleResources(JavaImplementation componentType) {
         for (JavaResourceImpl resource : componentType.getResources().values()) {
             String name = resource.getName();
 
-            ObjectFactory<?> objectFactory = (ObjectFactory<?>)component.getConfiguration().getFactories().get(resource
-                .getElement());
+            ObjectFactory<?> objectFactory =
+                (ObjectFactory<?>)componentInfo.getConfiguration().getFactories().get(resource.getElement());
             if (objectFactory == null) {
                 Class<?> type = resource.getElement().getType();
                 if (ComponentContext.class.equals(type)) {
-                    objectFactory = new PojoComponentContextFactory(component);
+                    objectFactory = new PojoComponentContextFactory(componentInfo);
+                } else if (RequestContext.class.equals(type)) {
+                    objectFactory = new RequestContextObjectFactory(requestContextFactory);
                 } else if (String.class.equals(type)) {
-                    objectFactory = new PojoComponentNameFactory(component);
+                    objectFactory = new PojoComponentNameFactory(componentInfo);
                 } else {
                     boolean optional = resource.isOptional();
                     String mappedName = resource.getMappedName();
                     objectFactory = createResourceObjectFactory(type, mappedName, optional,
null);
                 }
             }
-            component.addResourceFactory(name, objectFactory);
+            componentInfo.addResourceFactory(name, objectFactory);
         }
     }
 
@@ -128,12 +139,12 @@
     }
 
     public Object createInstance(RuntimeComponent component, ComponentService service) {
-        return atomicComponent.createInstance();
+        return componentInfo.createInstance();
     }
 
     public Invoker createInvoker(RuntimeComponentService service, Operation operation) {
         try {
-            return new TargetInvokerInvoker(atomicComponent.createTargetInvoker(operation));
+            return new TargetInvokerInvoker(componentInfo.createTargetInvoker(operation));
         } catch (TargetInvokerCreationException e) {
             throw new IllegalArgumentException(e);
         }
@@ -141,7 +152,7 @@
 
     public Invoker createCallbackInvoker(Operation operation) {
         try {
-            return new TargetInvokerInvoker(atomicComponent.createTargetInvoker(operation));
+            return new TargetInvokerInvoker(componentInfo.createTargetInvoker(operation));
         } catch (TargetInvokerCreationException e) {
             throw new IllegalArgumentException(e);
         }
@@ -152,15 +163,15 @@
     }
 
     public void start() {
-        atomicComponent.start();
+        componentInfo.start();
     }
 
     public void stop() {
-        atomicComponent.stop();
+        componentInfo.stop();
     }
 
     public InstanceWrapper createInstanceWrapper() {
-        return atomicComponent.createInstanceWrapper();
+        return componentInfo.createInstanceWrapper();
     }
 
     public boolean isEagerInit() {

Modified: incubator/tuscany/java/sca/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/invocation/JavaImplementationProviderFactory.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/invocation/JavaImplementationProviderFactory.java?view=diff&rev=557408&r1=557407&r2=557408
==============================================================================
--- incubator/tuscany/java/sca/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/invocation/JavaImplementationProviderFactory.java
(original)
+++ incubator/tuscany/java/sca/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/invocation/JavaImplementationProviderFactory.java
Wed Jul 18 14:58:03 2007
@@ -19,6 +19,8 @@
 
 package org.apache.tuscany.sca.implementation.java.invocation;
 
+import org.apache.tuscany.sca.context.ComponentContextFactory;
+import org.apache.tuscany.sca.context.RequestContextFactory;
 import org.apache.tuscany.sca.core.invocation.ProxyFactory;
 import org.apache.tuscany.sca.databinding.DataBindingExtensionPoint;
 import org.apache.tuscany.sca.implementation.java.JavaImplementation;
@@ -34,20 +36,26 @@
     private JavaPropertyValueObjectFactory propertyValueObjectFactory;
     private DataBindingExtensionPoint dataBindingRegistry;
     private ProxyFactory proxyService;
+    private ComponentContextFactory componentContextFactory;
+    private RequestContextFactory requestContextFactory;
 
     public JavaImplementationProviderFactory(ProxyFactory proxyService,
                                              DataBindingExtensionPoint dataBindingRegistry,
-                                             JavaPropertyValueObjectFactory propertyValueObjectFactory)
{
+                                             JavaPropertyValueObjectFactory propertyValueObjectFactory,
+                                             ComponentContextFactory componentContextFactory,
+                                             RequestContextFactory requestContextFactory)
{
         super();
         this.proxyService = proxyService;
         this.dataBindingRegistry = dataBindingRegistry;
         this.propertyValueObjectFactory = propertyValueObjectFactory;
+        this.componentContextFactory = componentContextFactory;
+        this.requestContextFactory = requestContextFactory;
     }
 
     public ImplementationProvider createImplementationProvider(RuntimeComponent component,
                                                                JavaImplementation implementation)
{
         return new JavaImplementationProvider(component, implementation, proxyService, dataBindingRegistry,
-                                              propertyValueObjectFactory);
+                                              propertyValueObjectFactory, componentContextFactory,
requestContextFactory);
     }
 
     public Class<JavaImplementation> getModelType() {

Modified: incubator/tuscany/java/sca/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/module/JavaRuntimeModuleActivator.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/module/JavaRuntimeModuleActivator.java?view=diff&rev=557408&r1=557407&r2=557408
==============================================================================
--- incubator/tuscany/java/sca/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/module/JavaRuntimeModuleActivator.java
(original)
+++ incubator/tuscany/java/sca/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/module/JavaRuntimeModuleActivator.java
Wed Jul 18 14:58:03 2007
@@ -20,6 +20,9 @@
 package org.apache.tuscany.sca.implementation.java.module;
 
 import org.apache.tuscany.sca.assembly.AssemblyFactory;
+import org.apache.tuscany.sca.context.ComponentContextFactory;
+import org.apache.tuscany.sca.context.ContextFactoryExtensionPoint;
+import org.apache.tuscany.sca.context.RequestContextFactory;
 import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessorExtensionPoint;
 import org.apache.tuscany.sca.core.ExtensionPointRegistry;
 import org.apache.tuscany.sca.core.ModelFactoryExtensionPoint;
@@ -127,11 +130,16 @@
             new JavaImplementationProcessor(assemblyFactory, policyFactory, javaImplementationFactory,
classIntrospector);
         processors.addArtifactProcessor(javaImplementationProcessor);
 
+        ContextFactoryExtensionPoint contextFactories = registry.getExtensionPoint(ContextFactoryExtensionPoint.class);
+        ComponentContextFactory componentContextFactory = contextFactories.getFactory(ComponentContextFactory.class);
+        RequestContextFactory requestContextFactory = contextFactories.getFactory(RequestContextFactory.class);
         JavaImplementationProviderFactory javaImplementationProviderFactory =
-            new JavaImplementationProviderFactory(proxyFactory, dataBindings, factory);
+            new JavaImplementationProviderFactory(proxyFactory, dataBindings, factory, componentContextFactory,
+                                                  requestContextFactory);
         
         ProviderFactoryExtensionPoint providerFactories = registry.getExtensionPoint(ProviderFactoryExtensionPoint.class);
         providerFactories.addProviderFactory(javaImplementationProviderFactory);
+        
     }
 
     public void stop(ExtensionPointRegistry registry) {

Modified: incubator/tuscany/java/sca/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/injection/RequestContextObjectFactoryTestCase.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/injection/RequestContextObjectFactoryTestCase.java?view=diff&rev=557408&r1=557407&r2=557408
==============================================================================
--- incubator/tuscany/java/sca/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/injection/RequestContextObjectFactoryTestCase.java
(original)
+++ incubator/tuscany/java/sca/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/injection/RequestContextObjectFactoryTestCase.java
Wed Jul 18 14:58:03 2007
@@ -26,7 +26,7 @@
 public class RequestContextObjectFactoryTestCase extends TestCase {
 
     public void testInstanceCreate() {
-        RequestContextObjectFactory factory = new RequestContextObjectFactory();
+        RequestContextObjectFactory factory = new RequestContextObjectFactory(null);
         assertNotNull(factory.getInstance());
     }
 



---------------------------------------------------------------------
To unsubscribe, e-mail: tuscany-commits-unsubscribe@ws.apache.org
For additional commands, e-mail: tuscany-commits-help@ws.apache.org


Mime
View raw message