You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tuscany.apache.org by rf...@apache.org on 2007/05/02 06:33:40 UTC

svn commit: r534302 [1/3] - in /incubator/tuscany/java/sca: itest/spec-api/src/test/java/org/apache/tuscany/sca/test/spec/ modules/binding-rmi/src/test/java/helloworld/ modules/core-spi/src/main/java/org/apache/tuscany/core/ modules/core-spi/src/main/j...

Author: rfeng
Date: Tue May  1 21:33:36 2007
New Revision: 534302

URL: http://svn.apache.org/viewvc?view=rev&rev=534302
Log:
Bring up the CRUD component with the new extension SPIs and simplified runtime without the builders

Added:
    incubator/tuscany/java/sca/modules/core-spi/src/main/java/org/apache/tuscany/invocation/
    incubator/tuscany/java/sca/modules/core-spi/src/main/java/org/apache/tuscany/invocation/AbstractInvocationHandler.java   (with props)
    incubator/tuscany/java/sca/modules/core-spi/src/main/java/org/apache/tuscany/invocation/ProxyCreationException.java   (with props)
    incubator/tuscany/java/sca/modules/core-spi/src/main/java/org/apache/tuscany/invocation/ProxyFactory.java   (with props)
    incubator/tuscany/java/sca/modules/core-spi/src/main/java/org/apache/tuscany/invocation/TargetInvokerInterceptor.java   (with props)
    incubator/tuscany/java/sca/modules/core-spi/src/main/java/org/apache/tuscany/spi/component/Scopeable.java   (with props)
    incubator/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/core/invocation/
    incubator/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/core/invocation/JDKInvocationHandler.java   (with props)
    incubator/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/core/invocation/JDKProxyService.java   (with props)
    incubator/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/core/invocation/WireObjectFactory.java   (with props)
    incubator/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/core/runtime/ActivationException.java   (with props)
    incubator/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/core/runtime/CompositeActivator.java   (with props)
    incubator/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/core/runtime/DefaultCompositeActivator.java   (with props)
    incubator/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/core/runtime/RuntimeActivator.java   (with props)
    incubator/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/core/runtime/RuntimeActivatorImpl.java   (with props)
    incubator/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/core/runtime/RuntimeAssemblyFactory.java   (with props)
    incubator/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/core/runtime/RuntimeComponentImpl.java   (with props)
    incubator/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/core/runtime/RuntimeComponentReferenceImpl.java   (with props)
    incubator/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/core/runtime/RuntimeSCABindingImpl.java   (with props)
    incubator/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/core/runtime/RuntimeWireImpl.java   (with props)
    incubator/tuscany/java/sca/modules/host-embedded/src/main/java/org/apache/tuscany/host/embedded/SCARuntimeActivator.java   (with props)
    incubator/tuscany/java/sca/modules/host-embedded/src/main/java/org/apache/tuscany/host/embedded/impl/DefaultSCARuntimeActivator.java   (with props)
    incubator/tuscany/java/sca/modules/host-embedded/src/main/java/org/apache/tuscany/host/embedded/impl/MiniRuntimeImpl.java   (with props)
    incubator/tuscany/java/sca/modules/host-embedded/src/test/java/crud/
    incubator/tuscany/java/sca/modules/host-embedded/src/test/java/crud/CRUD.java   (with props)
    incubator/tuscany/java/sca/modules/host-embedded/src/test/java/crud/CRUDAtomicComponent.java   (with props)
    incubator/tuscany/java/sca/modules/host-embedded/src/test/java/crud/CRUDComponentBuilder.java   (with props)
    incubator/tuscany/java/sca/modules/host-embedded/src/test/java/crud/CRUDImplementation.java   (with props)
    incubator/tuscany/java/sca/modules/host-embedded/src/test/java/crud/CRUDImplementationProcessor.java   (with props)
    incubator/tuscany/java/sca/modules/host-embedded/src/test/java/crud/CRUDModuleActivator.java   (with props)
    incubator/tuscany/java/sca/modules/host-embedded/src/test/java/crud/CRUDReferenceImpl.java   (with props)
    incubator/tuscany/java/sca/modules/host-embedded/src/test/java/crud/CRUDTargetInvoker.java   (with props)
    incubator/tuscany/java/sca/modules/host-embedded/src/test/java/crud/ResourceManager.java   (with props)
    incubator/tuscany/java/sca/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/implementation/java/invocation/
    incubator/tuscany/java/sca/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/implementation/java/invocation/JavaImplementationProvider.java   (with props)
    incubator/tuscany/java/sca/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/implementation/java/invocation/RuntimeJavaImplementationFactory.java   (with props)
    incubator/tuscany/java/sca/samples/implementation-crud/src/main/java/crud/CRUDReferenceImpl.java   (with props)
Removed:
    incubator/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/core/wire/OptimizedWireObjectFactory.java
    incubator/tuscany/java/sca/modules/core/src/test/java/org/apache/tuscany/core/wire/OptimizedWireObjectFactoryTestCase.java
    incubator/tuscany/java/sca/modules/host-embedded/src/test/java/org/apache/tuscany/container/
    incubator/tuscany/java/sca/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/implementation/java/context/JavaComponent.java
    incubator/tuscany/java/sca/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/implementation/java/context/PojoComponent.java
    incubator/tuscany/java/sca/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/implementation/java/context/PojoComponentTestCase.java
Modified:
    incubator/tuscany/java/sca/itest/spec-api/src/test/java/org/apache/tuscany/sca/test/spec/ComponentContextTestCase.java
    incubator/tuscany/java/sca/modules/binding-rmi/src/test/java/helloworld/HelloWorldRmiImpl.java
    incubator/tuscany/java/sca/modules/core-spi/src/main/java/org/apache/tuscany/core/ImplementationActivator.java
    incubator/tuscany/java/sca/modules/core-spi/src/main/java/org/apache/tuscany/core/ImplementationProvider.java
    incubator/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/core/builder/BuilderRegistryImpl.java
    incubator/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/core/component/ComponentContextImpl.java
    incubator/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/core/deployer/DeployerImpl.java
    incubator/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/core/wire/WireImpl.java
    incubator/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/core/wire/WireObjectFactory.java
    incubator/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/core/wire/WireUtils.java
    incubator/tuscany/java/sca/modules/core/src/test/java/org/apache/tuscany/core/wire/WireOptimizationTestCase.java
    incubator/tuscany/java/sca/modules/core/src/test/java/org/apache/tuscany/core/wire/WireUtilsTestCase.java
    incubator/tuscany/java/sca/modules/host-embedded/src/main/java/org/apache/tuscany/host/embedded/impl/SimpleCompositeContextImpl.java
    incubator/tuscany/java/sca/modules/host-embedded/src/test/java/org/apache/tuscany/host/embedded/SCARuntimeTestCase.java
    incubator/tuscany/java/sca/modules/host-embedded/src/test/java/org/apache/tuscany/host/embedded/impl/SimpleRuntimeImplTestCase.java
    incubator/tuscany/java/sca/modules/host-embedded/src/test/resources/META-INF/services/org.apache.tuscany.core.ModuleActivator
    incubator/tuscany/java/sca/modules/host-embedded/src/test/resources/crud.composite
    incubator/tuscany/java/sca/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/implementation/java/context/PojoAtomicComponent.java
    incubator/tuscany/java/sca/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/implementation/java/module/JavaRuntimeModuleActivator.java
    incubator/tuscany/java/sca/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/implementation/java/proxy/JDKInvocationHandlerProxyTestCase.java
    incubator/tuscany/java/sca/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/implementation/java/proxy/JDKInvocationHandlerTestCase.java
    incubator/tuscany/java/sca/modules/implementation-java-xml/src/main/java/org/apache/tuscany/implementation/java/xml/JavaImplementationProcessor.java
    incubator/tuscany/java/sca/samples/implementation-crud/pom.xml
    incubator/tuscany/java/sca/samples/implementation-crud/src/main/java/crud/CRUDAtomicComponent.java
    incubator/tuscany/java/sca/samples/implementation-crud/src/main/java/crud/CRUDComponentBuilder.java
    incubator/tuscany/java/sca/samples/implementation-crud/src/main/java/crud/CRUDImplementation.java
    incubator/tuscany/java/sca/samples/implementation-crud/src/main/java/crud/CRUDImplementationProcessor.java
    incubator/tuscany/java/sca/samples/implementation-crud/src/main/java/crud/CRUDModuleActivator.java
    incubator/tuscany/java/sca/samples/implementation-crud/src/main/java/crud/CRUDTargetInvoker.java
    incubator/tuscany/java/sca/samples/implementation-crud/src/test/java/crud/CRUDTestCase.java

Modified: incubator/tuscany/java/sca/itest/spec-api/src/test/java/org/apache/tuscany/sca/test/spec/ComponentContextTestCase.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/itest/spec-api/src/test/java/org/apache/tuscany/sca/test/spec/ComponentContextTestCase.java?view=diff&rev=534302&r1=534301&r2=534302
==============================================================================
--- incubator/tuscany/java/sca/itest/spec-api/src/test/java/org/apache/tuscany/sca/test/spec/ComponentContextTestCase.java (original)
+++ incubator/tuscany/java/sca/itest/spec-api/src/test/java/org/apache/tuscany/sca/test/spec/ComponentContextTestCase.java Tue May  1 21:33:36 2007
@@ -29,7 +29,7 @@
     public void testCreateSelfReference() {
     	
     	ComponentContext context = SCARuntime.getComponentContext("MyService");        
-        ServiceReference<MyService> service = context.createSelfReference(MyService.class);
+        ServiceReference<MyService> service = context.createSelfReference(MyService.class, "MyService");
         MyService myService = service.getService();
         
         assertNotNull(myService);

Modified: incubator/tuscany/java/sca/modules/binding-rmi/src/test/java/helloworld/HelloWorldRmiImpl.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/binding-rmi/src/test/java/helloworld/HelloWorldRmiImpl.java?view=diff&rev=534302&r1=534301&r2=534302
==============================================================================
--- incubator/tuscany/java/sca/modules/binding-rmi/src/test/java/helloworld/HelloWorldRmiImpl.java (original)
+++ incubator/tuscany/java/sca/modules/binding-rmi/src/test/java/helloworld/HelloWorldRmiImpl.java Tue May  1 21:33:36 2007
@@ -26,7 +26,6 @@
  */
 @Service(HelloWorldRmiService.class)
 public class HelloWorldRmiImpl implements HelloWorldRmiService {
-    @Reference
     private HelloWorldService extService;
 
     public HelloWorldService getExtService() {

Modified: incubator/tuscany/java/sca/modules/core-spi/src/main/java/org/apache/tuscany/core/ImplementationActivator.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/core-spi/src/main/java/org/apache/tuscany/core/ImplementationActivator.java?view=diff&rev=534302&r1=534301&r2=534302
==============================================================================
--- incubator/tuscany/java/sca/modules/core-spi/src/main/java/org/apache/tuscany/core/ImplementationActivator.java (original)
+++ incubator/tuscany/java/sca/modules/core-spi/src/main/java/org/apache/tuscany/core/ImplementationActivator.java Tue May  1 21:33:36 2007
@@ -19,7 +19,6 @@
 
 package org.apache.tuscany.core;
 
-import org.apache.tuscany.assembly.Component;
 
 /**
  * A component implementation can optionally implement this interface to control
@@ -34,7 +33,7 @@
      * 
      * @param component The component to be started
      */
-    void start(Component component);
+    void start(RuntimeComponent component);
 
     /**
      * This method will be invoked when a component implemented by this
@@ -42,5 +41,5 @@
      * 
      * @param component The component to be stopped
      */
-    void stop(Component component);
+    void stop(RuntimeComponent component);
 }

Modified: incubator/tuscany/java/sca/modules/core-spi/src/main/java/org/apache/tuscany/core/ImplementationProvider.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/core-spi/src/main/java/org/apache/tuscany/core/ImplementationProvider.java?view=diff&rev=534302&r1=534301&r2=534302
==============================================================================
--- incubator/tuscany/java/sca/modules/core-spi/src/main/java/org/apache/tuscany/core/ImplementationProvider.java (original)
+++ incubator/tuscany/java/sca/modules/core-spi/src/main/java/org/apache/tuscany/core/ImplementationProvider.java Tue May  1 21:33:36 2007
@@ -19,7 +19,6 @@
 
 package org.apache.tuscany.core;
 
-import org.apache.tuscany.assembly.Component;
 import org.apache.tuscany.assembly.ComponentService;
 import org.apache.tuscany.interfacedef.InterfaceContract;
 import org.apache.tuscany.interfacedef.Operation;
@@ -45,7 +44,7 @@
      * @return An interceptor that handles the invocation logic, null should be
      *         returned if no interceptor is required
      */
-    Interceptor createInterceptor(Component component, ComponentService service, Operation operation, boolean isCallback);
+    Interceptor createInterceptor(RuntimeComponent component, ComponentService service, Operation operation, boolean isCallback);
 
     /**
      * Get the effective interface contract imposed by the implementation.

Added: incubator/tuscany/java/sca/modules/core-spi/src/main/java/org/apache/tuscany/invocation/AbstractInvocationHandler.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/core-spi/src/main/java/org/apache/tuscany/invocation/AbstractInvocationHandler.java?view=auto&rev=534302
==============================================================================
--- incubator/tuscany/java/sca/modules/core-spi/src/main/java/org/apache/tuscany/invocation/AbstractInvocationHandler.java (added)
+++ incubator/tuscany/java/sca/modules/core-spi/src/main/java/org/apache/tuscany/invocation/AbstractInvocationHandler.java Tue May  1 21:33:36 2007
@@ -0,0 +1,144 @@
+/*
+ * 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.invocation;
+
+import java.lang.reflect.InvocationTargetException;
+import java.net.URI;
+import java.util.LinkedList;
+
+import org.apache.tuscany.interfacedef.Interface;
+import org.apache.tuscany.interfacedef.Operation;
+import org.apache.tuscany.spi.component.WorkContext;
+import org.apache.tuscany.spi.wire.Interceptor;
+import org.apache.tuscany.spi.wire.InvocationChain;
+import org.apache.tuscany.spi.wire.Message;
+import org.apache.tuscany.spi.wire.MessageImpl;
+import org.apache.tuscany.spi.wire.TargetInvoker;
+import org.apache.tuscany.spi.wire.Wire;
+
+/**
+ * Base class for performing invocations on a wire. Subclasses are responsible for retrieving and supplying the
+ * appropriate chain, target invoker, and invocation arguments.
+ *
+ * @version $Rev$ $Date$
+ */
+public abstract class AbstractInvocationHandler {
+    protected boolean conversational;
+    private boolean conversationStarted;
+
+    protected AbstractInvocationHandler(boolean conversational) {
+        this.conversational = conversational;
+    }
+
+    public AbstractInvocationHandler() {
+    }
+
+    protected Object invoke(InvocationChain chain,
+                            TargetInvoker invoker,
+                            Object[] args,
+                            Object correlationId,
+                            LinkedList<URI> callbackUris, WorkContext workContext)
+        throws Throwable {
+        Interceptor headInterceptor = chain.getHeadInterceptor();
+        if (headInterceptor == null) {
+            try {
+                // short-circuit the dispatch and invoke the target directly
+                TargetInvoker targetInvoker = chain.getTargetInvoker();
+                if (targetInvoker == null) {
+                    String name = chain.getTargetOperation().getName();
+                    throw new AssertionError("No target invoker [" + name + "]");
+                }
+                return targetInvoker.invokeTarget(args, TargetInvoker.NONE, workContext);
+            } catch (InvocationTargetException e) {
+                // the cause was thrown by the target so throw it
+                throw e.getCause();
+            }
+        } else {
+            Message msg = new MessageImpl();
+            msg.setWorkContext(workContext);
+            msg.setTargetInvoker(invoker);
+            msg.setCorrelationId(workContext.getCorrelationId());
+            msg.setCallbackUris(workContext.getCallbackUris());
+            Operation operation = chain.getTargetOperation();
+            Interface contract = operation.getInterface();
+            if (contract != null && contract.isConversational()) {
+                Operation.ConversationSequence sequence = chain.getTargetOperation().getConversationSequence();
+                if (sequence == Operation.ConversationSequence.CONVERSATION_END) {
+                    msg.setConversationSequence(TargetInvoker.END);
+                    conversationStarted = false;
+                } else if (sequence == Operation.ConversationSequence.CONVERSATION_CONTINUE) {
+                    if (conversationStarted) {
+                        msg.setConversationSequence(TargetInvoker.CONTINUE);
+                    } else {
+                        conversationStarted = true;
+                        msg.setConversationSequence(TargetInvoker.START);
+                    }
+                }
+            }
+            msg.setBody(args);
+            // dispatch the wire down the chain and get the response
+            Message resp = headInterceptor.invoke(msg);
+            Object body = resp.getBody();
+            if (resp.isFault()) {
+                throw (Throwable) body;
+            }
+            return body;
+        }
+    }
+
+    protected Object invokeTarget(InvocationChain chain,
+                                  Object[] args,
+                                  Object correlationId,
+                                  LinkedList<Wire> callbackWires)
+        throws Throwable {
+        Interceptor headInterceptor = chain.getHeadInterceptor();
+        assert headInterceptor != null;
+        Message msg = new MessageImpl();
+        if (correlationId != null) {
+            msg.setCorrelationId(correlationId);
+        }
+        if (callbackWires != null) {
+            msg.setCallbackWires(callbackWires);
+        }
+        Operation operation = chain.getTargetOperation();
+        if (conversational) {
+            Operation.ConversationSequence sequence = operation.getConversationSequence();
+            if (sequence == Operation.ConversationSequence.CONVERSATION_END) {
+                msg.setConversationSequence(TargetInvoker.END);
+                conversationStarted = false;
+            } else if (sequence == Operation.ConversationSequence.CONVERSATION_CONTINUE) {
+                if (conversationStarted) {
+                    msg.setConversationSequence(TargetInvoker.CONTINUE);
+                } else {
+                    conversationStarted = true;
+                    msg.setConversationSequence(TargetInvoker.START);
+                }
+            }
+        }
+        msg.setBody(args);
+        // dispatch the wire down the chain and get the response
+        Message resp = headInterceptor.invoke(msg);
+        Object body = resp.getBody();
+        if (resp.isFault()) {
+            throw (Throwable) body;
+        }
+        return body;
+    }
+
+}

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

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

Added: incubator/tuscany/java/sca/modules/core-spi/src/main/java/org/apache/tuscany/invocation/ProxyCreationException.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/core-spi/src/main/java/org/apache/tuscany/invocation/ProxyCreationException.java?view=auto&rev=534302
==============================================================================
--- incubator/tuscany/java/sca/modules/core-spi/src/main/java/org/apache/tuscany/invocation/ProxyCreationException.java (added)
+++ incubator/tuscany/java/sca/modules/core-spi/src/main/java/org/apache/tuscany/invocation/ProxyCreationException.java Tue May  1 21:33:36 2007
@@ -0,0 +1,53 @@
+/*
+ * 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.invocation;
+
+import org.apache.tuscany.spi.CoreRuntimeException;
+
+/**
+ * Denotes an error creating a proxy
+ *
+ * @version $$Rev$$ $$Date$$
+ */
+public class ProxyCreationException extends CoreRuntimeException {
+    private static final long serialVersionUID = 8002454344828513781L;
+
+    public ProxyCreationException() {
+    }
+
+    public ProxyCreationException(String message) {
+        super(message);
+    }
+
+    public ProxyCreationException(String message, String identifier) {
+        super(message, identifier);
+    }
+
+    public ProxyCreationException(String message, Throwable cause) {
+        super(message, cause);
+    }
+
+    public ProxyCreationException(String message, String identifier, Throwable cause) {
+        super(message, identifier, cause);
+    }
+
+    public ProxyCreationException(Throwable cause) {
+        super(cause);
+    }
+}

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

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

Added: incubator/tuscany/java/sca/modules/core-spi/src/main/java/org/apache/tuscany/invocation/ProxyFactory.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/core-spi/src/main/java/org/apache/tuscany/invocation/ProxyFactory.java?view=auto&rev=534302
==============================================================================
--- incubator/tuscany/java/sca/modules/core-spi/src/main/java/org/apache/tuscany/invocation/ProxyFactory.java (added)
+++ incubator/tuscany/java/sca/modules/core-spi/src/main/java/org/apache/tuscany/invocation/ProxyFactory.java Tue May  1 21:33:36 2007
@@ -0,0 +1,61 @@
+/*
+ * 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.invocation;
+
+import java.util.List;
+
+import org.apache.tuscany.core.RuntimeWire;
+import org.osoa.sca.CallableReference;
+
+/**
+ * Creates proxies that implement Java interfaces and invocation handlers for fronting wires
+ *
+ * @version $$Rev$$ $$Date$$
+ */
+
+public interface ProxyFactory {
+
+    /**
+     * Creates a Java proxy for the given wire
+     *
+     * @param interfaze the interface the proxy implements
+     * @param wire      the wire to proxy @return the proxy
+     * @throws ProxyCreationException
+     */
+    <T> T createProxy(Class<T> interfaze, RuntimeWire wire) throws ProxyCreationException;
+
+    /**
+     * Creates a Java proxy for the service contract callback
+     *
+     * @param interfaze the interface the proxy should implement
+     * @return the proxy
+     * @throws ProxyCreationException
+     */
+    Object createCallbackProxy(Class<?> interfaze, List<RuntimeWire> wires) throws ProxyCreationException;
+
+    /**
+     * Cast a proxy to a CallableReference.
+     *
+     * @param target a proxy generated by this implementation
+     * @return a CallableReference (or subclass) equivalent to this prozy
+     * @throws IllegalArgumentException if the object supplied is not a proxy
+     */
+    <B, R extends CallableReference<B>> R cast(B target) throws IllegalArgumentException;
+
+}

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

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

Added: incubator/tuscany/java/sca/modules/core-spi/src/main/java/org/apache/tuscany/invocation/TargetInvokerInterceptor.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/core-spi/src/main/java/org/apache/tuscany/invocation/TargetInvokerInterceptor.java?view=auto&rev=534302
==============================================================================
--- incubator/tuscany/java/sca/modules/core-spi/src/main/java/org/apache/tuscany/invocation/TargetInvokerInterceptor.java (added)
+++ incubator/tuscany/java/sca/modules/core-spi/src/main/java/org/apache/tuscany/invocation/TargetInvokerInterceptor.java Tue May  1 21:33:36 2007
@@ -0,0 +1,61 @@
+/*
+ * 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.invocation;
+
+import org.apache.tuscany.spi.wire.Interceptor;
+import org.apache.tuscany.spi.wire.InvocationRuntimeException;
+import org.apache.tuscany.spi.wire.Message;
+import org.apache.tuscany.spi.wire.TargetInvoker;
+
+/**
+ * Serves as a tail interceptor on a target wire chain. This implementation dispatches to the target invoker passed
+ * inside the wire message. Target invokers are passed from the source in order to allow for caching of target
+ * instances.
+ *
+ * @version $Rev$ $Date$
+ * @Deprecated
+ * @see org.apache.tuscany.spi.wire.TargetInvoker
+ */
+public class TargetInvokerInterceptor implements Interceptor {
+    private TargetInvoker invoker;
+    
+    public TargetInvokerInterceptor(TargetInvoker invoker) {
+        this.invoker = invoker;
+    }
+
+    public Message invoke(Message msg) throws InvocationRuntimeException {
+        if (invoker == null) {
+            throw new InvocationRuntimeException("No target invoker specified on message");
+        }
+        return invoker.invoke(msg);
+    }
+
+    public void setNext(Interceptor next) {
+        throw new IllegalStateException("This interceptor must be the last one in an target interceptor chain");
+    }
+
+    public Interceptor getNext() {
+        return null;
+    }
+
+    public boolean isOptimizable() {
+        return true;
+    }
+
+}

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

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

Added: incubator/tuscany/java/sca/modules/core-spi/src/main/java/org/apache/tuscany/spi/component/Scopeable.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/core-spi/src/main/java/org/apache/tuscany/spi/component/Scopeable.java?view=auto&rev=534302
==============================================================================
--- incubator/tuscany/java/sca/modules/core-spi/src/main/java/org/apache/tuscany/spi/component/Scopeable.java (added)
+++ incubator/tuscany/java/sca/modules/core-spi/src/main/java/org/apache/tuscany/spi/component/Scopeable.java Tue May  1 21:33:36 2007
@@ -0,0 +1,39 @@
+/*
+ * 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.spi.component;
+
+import org.apache.tuscany.spi.Scope;
+
+/**
+ * Represents a component implementation that supports scopes
+ * 
+ * @version $Rev$ $Date$
+ */
+public interface Scopeable {
+    /**
+     * @param scope
+     */
+    void setScope(Scope scope);
+
+    /**
+     * @return
+     */
+    Scope getScope();
+}

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

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

Modified: incubator/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/core/builder/BuilderRegistryImpl.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/core/builder/BuilderRegistryImpl.java?view=diff&rev=534302&r1=534301&r2=534302
==============================================================================
--- incubator/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/core/builder/BuilderRegistryImpl.java (original)
+++ incubator/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/core/builder/BuilderRegistryImpl.java Tue May  1 21:33:36 2007
@@ -48,6 +48,7 @@
 import org.apache.tuscany.spi.component.SCAObject;
 import org.apache.tuscany.spi.component.ScopeContainer;
 import org.apache.tuscany.spi.component.ScopeRegistry;
+import org.apache.tuscany.spi.component.Scopeable;
 import org.apache.tuscany.spi.component.ServiceBinding;
 import org.apache.tuscany.spi.deployer.DeploymentContext;
 import org.osoa.sca.annotations.EagerInit;
@@ -130,9 +131,11 @@
         
         componentManager.add(component, componentDef);
 
-        // FIXME: How to deal scopes?
-        // Scope scope = componentDef.getImplementation().getScope();
         Scope scope = Scope.STATELESS;
+        Implementation implementation = componentDef.getImplementation();
+        if(implementation instanceof Scopeable) {
+            scope = ((Scopeable) implementation).getScope();
+        }
 
         if (scope == Scope.SYSTEM || scope == Scope.COMPOSITE) {
             component.setScopeContainer(context.getCompositeScope());

Modified: incubator/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/core/component/ComponentContextImpl.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/core/component/ComponentContextImpl.java?view=diff&rev=534302&r1=534301&r2=534302
==============================================================================
--- incubator/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/core/component/ComponentContextImpl.java (original)
+++ incubator/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/core/component/ComponentContextImpl.java Tue May  1 21:33:36 2007
@@ -18,9 +18,7 @@
  */
 package org.apache.tuscany.core.component;
 
-import org.apache.tuscany.spi.ObjectFactory;
 import org.apache.tuscany.spi.TuscanyRuntimeException;
-import org.apache.tuscany.spi.component.AtomicComponent;
 import org.osoa.sca.CallableReference;
 import org.osoa.sca.ComponentContext;
 import org.osoa.sca.RequestContext;
@@ -80,13 +78,14 @@
     }
 
     public <B> ServiceReference<B> createSelfReference(Class<B> businessInterface) {
+        return getServiceReference(businessInterface, "$self$.");
         // FIXME: How to get the ObjectFactory?
-        ObjectFactory<B> factory = ((AtomicComponent) component).createObjectFactory();
-        return new ServiceReferenceImpl<B>(businessInterface, factory);
+        // ObjectFactory<B> factory = ((AtomicComponent) component).createObjectFactory();
+        // return new ServiceReferenceImpl<B>(businessInterface, factory);
     }
 
     public <B> ServiceReference<B> createSelfReference(Class<B> businessInterface, String serviceName) {
-        return null;
+        return getServiceReference(businessInterface, "$self$."+serviceName);
     }
 
     public RequestContext getRequestContext() {

Modified: incubator/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/core/deployer/DeployerImpl.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/core/deployer/DeployerImpl.java?view=diff&rev=534302&r1=534301&r2=534302
==============================================================================
--- incubator/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/core/deployer/DeployerImpl.java (original)
+++ incubator/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/core/deployer/DeployerImpl.java Tue May  1 21:33:36 2007
@@ -39,6 +39,7 @@
 import org.apache.tuscany.core.builder.ComponentNotFoundException;
 import org.apache.tuscany.core.builder.IncompatibleInterfacesException;
 import org.apache.tuscany.core.builder.WireCreationException;
+import org.apache.tuscany.core.runtime.DefaultCompositeActivator;
 import org.apache.tuscany.core.wire.InvocationChainImpl;
 import org.apache.tuscany.core.wire.InvokerInterceptor;
 import org.apache.tuscany.core.wire.NonBlockingInterceptor;
@@ -155,7 +156,7 @@
         
         // Adjust the composite graph and wire the references with SCA bindings
         processSCABinding(composite);
-
+        
         builder.build(componentDef, deploymentContext);
         
         // Register all components with the component manager
@@ -393,7 +394,7 @@
             }
             /* lresende */
             chain.addInterceptor(new InvokerInterceptor());
-            wire.addInvocationChain(chain);
+            wire.getInvocationChains().add(chain);
 
         }
         if (sourceContract.getCallbackInterface() != null) {
@@ -406,7 +407,7 @@
                 }
                 /* lresende */
                 chain.addInterceptor(new InvokerInterceptor());
-                wire.addCallbackInvocationChain(chain);
+                wire.getCallbackInvocationChains().add(chain);
             }
         }
         return wire;

Added: incubator/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/core/invocation/JDKInvocationHandler.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/core/invocation/JDKInvocationHandler.java?view=auto&rev=534302
==============================================================================
--- incubator/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/core/invocation/JDKInvocationHandler.java (added)
+++ incubator/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/core/invocation/JDKInvocationHandler.java Tue May  1 21:33:36 2007
@@ -0,0 +1,106 @@
+/*
+ * 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.core.invocation;
+
+import java.lang.reflect.InvocationHandler;
+import java.lang.reflect.Method;
+import java.lang.reflect.Proxy;
+import java.util.List;
+
+import org.apache.tuscany.core.RuntimeWire;
+import org.apache.tuscany.interfacedef.DataType;
+import org.apache.tuscany.interfacedef.Operation;
+import org.apache.tuscany.invocation.AbstractInvocationHandler;
+import org.apache.tuscany.spi.component.WorkContext;
+import org.apache.tuscany.spi.wire.InvocationChain;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class JDKInvocationHandler extends AbstractInvocationHandler implements InvocationHandler {
+    private Class<?> proxyInterface;
+    private RuntimeWire wire;
+    private WorkContext workContext;
+
+    public JDKInvocationHandler(Class<?> proxyInterface, RuntimeWire wire, WorkContext workContext) {
+        super();
+        this.proxyInterface = proxyInterface;
+        this.wire = wire;
+        this.workContext = workContext;
+    }
+
+    public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
+        if (method.getParameterTypes().length == 0 && "toString".equals(method.getName())) {
+            return "[Proxy - " + Integer.toHexString(hashCode()) + "]";
+        } else if (method.getDeclaringClass().equals(Object.class) && "equals".equals(method.getName())) {
+            Object obj = args[0];
+            if (obj == null) {
+                return false;
+            }
+            if (!Proxy.isProxyClass(obj.getClass())) {
+                return false;
+            }
+            return equals(Proxy.getInvocationHandler(obj));
+        } else if (Object.class.equals(method.getDeclaringClass()) && "hashCode".equals(method.getName())) {
+            return hashCode();
+        }
+        InvocationChain chain = getInvocationChain(method);
+        if (chain == null) {
+            throw new IllegalArgumentException("No matching opeeration is found: " + method);
+        }
+
+        return invokeTarget(chain, args, null, null);
+    }
+
+    /**
+     * Determines if the given operation matches the given method
+     * 
+     * @return true if the operation matches, false if does not
+     */
+    private static boolean match(Operation operation, Method method) {
+        Class<?>[] params = method.getParameterTypes();
+        DataType<List<DataType>> inputType = operation.getInputType();
+        List<DataType> types = inputType.getLogical();
+        boolean matched = true;
+        if (types.size() == params.length && method.getName().equals(operation.getName())) {
+            for (int i = 0; i < params.length; i++) {
+                Class<?> clazz = params[i];
+                if (!clazz.equals(operation.getInputType().getLogical().get(i).getPhysical())) {
+                    matched = false;
+                }
+            }
+        } else {
+            matched = false;
+        }
+        return matched;
+
+    }
+
+    private InvocationChain getInvocationChain(Method method) {
+        for (InvocationChain chain : wire.getInvocationChains()) {
+            Operation operation = chain.getSourceOperation();
+            if (match(operation, method)) {
+                return chain;
+            }
+        }
+        return null;
+    }
+
+}

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

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

Added: incubator/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/core/invocation/JDKProxyService.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/core/invocation/JDKProxyService.java?view=auto&rev=534302
==============================================================================
--- incubator/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/core/invocation/JDKProxyService.java (added)
+++ incubator/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/core/invocation/JDKProxyService.java Tue May  1 21:33:36 2007
@@ -0,0 +1,92 @@
+/*
+ * 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.core.invocation;
+
+import java.lang.reflect.Method;
+import java.lang.reflect.Proxy;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.tuscany.core.RuntimeWire;
+import org.apache.tuscany.interfacedef.InterfaceContractMapper;
+import org.apache.tuscany.invocation.ProxyFactory;
+import org.apache.tuscany.spi.component.WorkContext;
+import org.apache.tuscany.spi.wire.ChainHolder;
+import org.apache.tuscany.spi.wire.ProxyCreationException;
+import org.osoa.sca.CallableReference;
+
+/**
+ * the default implementation of a wire service that uses JDK dynamic proxies
+ * 
+ * @version $$Rev$$ $$Date: 2007-04-11 18:59:43 -0700 (Wed, 11 Apr
+ *          2007) $$
+ */
+public class JDKProxyService implements ProxyFactory {
+    protected WorkContext context;
+    protected InterfaceContractMapper contractMapper;
+
+    public JDKProxyService() {
+        this(null, null);
+    }
+
+    public JDKProxyService(WorkContext context, InterfaceContractMapper mapper) {
+        this.context = context;
+        this.contractMapper = mapper;
+    }
+
+    public <T> T createProxy(Class<T> interfaze, RuntimeWire wire) throws ProxyCreationException {
+        assert interfaze != null;
+        assert wire != null;
+        JDKInvocationHandler handler = new JDKInvocationHandler(interfaze, wire, context);
+        ClassLoader cl = interfaze.getClassLoader();
+        return interfaze.cast(Proxy.newProxyInstance(cl, new Class[] {interfaze}, handler));
+    }
+
+    public <T> T createProxy(Class<T> interfaze, RuntimeWire wire, Map<Method, ChainHolder> mapping)
+        throws ProxyCreationException {
+        assert interfaze != null;
+        assert wire != null;
+        assert mapping != null;
+        JDKInvocationHandler handler = new JDKInvocationHandler(interfaze, wire, context);
+        ClassLoader cl = interfaze.getClassLoader();
+        return interfaze.cast(Proxy.newProxyInstance(cl, new Class[] {interfaze}, handler));
+    }
+
+    public Object createCallbackProxy(Class<?> interfaze, List<RuntimeWire> wires) throws ProxyCreationException {
+        return null;
+        /*
+        ClassLoader cl = interfaze.getClassLoader();
+        JDKCallbackInvocationHandler handler = new JDKCallbackInvocationHandler(wires, context);
+        return interfaze.cast(Proxy.newProxyInstance(cl, new Class[] {interfaze}, handler));
+        */
+    }
+
+    public <B, R extends CallableReference<B>> R cast(B target) throws IllegalArgumentException {
+        throw new UnsupportedOperationException();
+        /*
+         * InvocationHandler handler = Proxy.getInvocationHandler(target); if
+         * (handler instanceof JDKInvocationHandler) { // TODO return a
+         * ServiceReference throw new UnsupportedOperationException(); } else if
+         * (handler instanceof JDKCallbackInvocationHandler) { // TODO return a
+         * CallbackReference throw new UnsupportedOperationException(); } else {
+         * throw new IllegalArgumentException("Not a Tuscany SCA proxy"); }
+         */
+
+    }
+}

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

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

Added: incubator/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/core/invocation/WireObjectFactory.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/core/invocation/WireObjectFactory.java?view=auto&rev=534302
==============================================================================
--- incubator/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/core/invocation/WireObjectFactory.java (added)
+++ incubator/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/core/invocation/WireObjectFactory.java Tue May  1 21:33:36 2007
@@ -0,0 +1,91 @@
+/*
+ * 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.core.invocation;
+
+import java.lang.reflect.Method;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.tuscany.core.RuntimeWire;
+import org.apache.tuscany.core.wire.NoMethodForOperationException;
+import org.apache.tuscany.core.wire.WireUtils;
+import org.apache.tuscany.interfacedef.Interface;
+import org.apache.tuscany.interfacedef.java.JavaInterface;
+import org.apache.tuscany.invocation.ProxyFactory;
+import org.apache.tuscany.spi.ObjectCreationException;
+import org.apache.tuscany.spi.ObjectFactory;
+import org.apache.tuscany.spi.component.TargetResolutionException;
+import org.apache.tuscany.spi.wire.ChainHolder;
+import org.apache.tuscany.spi.wire.ProxyService;
+
+/**
+ * Uses a wire to return an object instance
+ * 
+ * @version $Rev$ $Date$
+ */
+public class WireObjectFactory<T> implements ObjectFactory<T> {
+    private Class<T> interfaze;
+    private RuntimeWire wire;
+    private ProxyFactory proxyService;
+    private boolean optimizable;
+
+    /**
+     * Constructor.
+     * 
+     * @param interfaze the interface to inject on the client
+     * @param wire the backing wire
+     * @param proxyService the wire service to create the proxy
+     * @throws NoMethodForOperationException
+     */
+    public WireObjectFactory(Class<T> interfaze, RuntimeWire wire, ProxyFactory proxyService)
+        throws NoMethodForOperationException {
+        this.interfaze = interfaze;
+        this.wire = wire;
+        this.proxyService = proxyService;
+        /*
+        if (wire.isOptimizable()) {
+            Interface iface = wire.getSource().getInterfaceContract().getInterface();
+            if (iface instanceof JavaInterface) {
+                Class type = ((JavaInterface)iface).getJavaClass();
+                if (interfaze.isAssignableFrom(type)) {
+                    optimizable = true;
+                }
+            }
+        }
+        */
+
+    }
+
+    public T getInstance() throws ObjectCreationException {
+        /*
+        if (optimizable) {
+            try {
+                return interfaze.cast(wire.getTargetInstance());
+            } catch (TargetResolutionException e) {
+                throw new ObjectCreationException(e);
+            }
+        } else {
+        */
+            return interfaze.cast(proxyService.createProxy(interfaze, wire));
+            /*
+        }
+        */
+    }
+
+}

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

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

Added: incubator/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/core/runtime/ActivationException.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/core/runtime/ActivationException.java?view=auto&rev=534302
==============================================================================
--- incubator/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/core/runtime/ActivationException.java (added)
+++ incubator/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/core/runtime/ActivationException.java Tue May  1 21:33:36 2007
@@ -0,0 +1,37 @@
+/*
+ * 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.core.runtime;
+
+
+/**
+ * Denotes an error starting the runtime
+ *
+ * @version $Rev$ $Date$
+ */
+public class ActivationException extends Exception {
+    private static final long serialVersionUID = 8612661660934426123L;
+
+    public ActivationException(String message) {
+        super(message);
+    }
+
+    public ActivationException(Throwable cause) {
+        super(cause);
+    }
+}

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

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

Added: incubator/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/core/runtime/CompositeActivator.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/core/runtime/CompositeActivator.java?view=auto&rev=534302
==============================================================================
--- incubator/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/core/runtime/CompositeActivator.java (added)
+++ incubator/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/core/runtime/CompositeActivator.java Tue May  1 21:33:36 2007
@@ -0,0 +1,42 @@
+/*
+ * 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.core.runtime;
+
+import org.apache.tuscany.assembly.Composite;
+
+/**
+ * Start/stop a composite
+ * 
+ * @version $Rev$ $Date$
+ */
+public interface CompositeActivator {
+    /**
+     * Start a composite
+     * @param composite
+     */
+    void start(Composite composite) throws ActivationException;
+
+    /**
+     * Stop a composite
+     * @param composite
+     */
+    void stop(Composite composite) throws ActivationException;
+
+}

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

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

Added: incubator/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/core/runtime/DefaultCompositeActivator.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/core/runtime/DefaultCompositeActivator.java?view=auto&rev=534302
==============================================================================
--- incubator/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/core/runtime/DefaultCompositeActivator.java (added)
+++ incubator/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/core/runtime/DefaultCompositeActivator.java Tue May  1 21:33:36 2007
@@ -0,0 +1,413 @@
+/*
+ * 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.core.runtime;
+
+import java.lang.reflect.Method;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.tuscany.assembly.AssemblyFactory;
+import org.apache.tuscany.assembly.Base;
+import org.apache.tuscany.assembly.Binding;
+import org.apache.tuscany.assembly.Component;
+import org.apache.tuscany.assembly.ComponentReference;
+import org.apache.tuscany.assembly.ComponentService;
+import org.apache.tuscany.assembly.Composite;
+import org.apache.tuscany.assembly.Implementation;
+import org.apache.tuscany.assembly.Multiplicity;
+import org.apache.tuscany.assembly.SCABinding;
+import org.apache.tuscany.assembly.util.CompositeUtil;
+import org.apache.tuscany.assembly.util.PrintUtil;
+import org.apache.tuscany.core.ImplementationActivator;
+import org.apache.tuscany.core.ImplementationProvider;
+import org.apache.tuscany.core.ReferenceBindingActivator;
+import org.apache.tuscany.core.ReferenceBindingProvider;
+import org.apache.tuscany.core.RuntimeComponent;
+import org.apache.tuscany.core.RuntimeComponentReference;
+import org.apache.tuscany.core.RuntimeWire;
+import org.apache.tuscany.core.ServiceBindingActivator;
+import org.apache.tuscany.core.component.WorkContextImpl;
+import org.apache.tuscany.core.util.JavaIntrospectionHelper;
+import org.apache.tuscany.core.wire.InvocationChainImpl;
+import org.apache.tuscany.core.wire.NonBlockingInterceptor;
+import org.apache.tuscany.core.work.Jsr237WorkScheduler;
+import org.apache.tuscany.core.work.ThreadPoolWorkManager;
+import org.apache.tuscany.interfacedef.IncompatibleInterfaceContractException;
+import org.apache.tuscany.interfacedef.InterfaceContract;
+import org.apache.tuscany.interfacedef.InterfaceContractMapper;
+import org.apache.tuscany.interfacedef.Operation;
+import org.apache.tuscany.spi.Scope;
+import org.apache.tuscany.spi.component.WorkContext;
+import org.apache.tuscany.spi.services.work.WorkScheduler;
+import org.apache.tuscany.spi.wire.Interceptor;
+import org.apache.tuscany.spi.wire.InvocationChain;
+import org.apache.tuscany.spi.wire.WirePostProcessorRegistry;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class DefaultCompositeActivator implements CompositeActivator {
+
+    private AssemblyFactory assemblyFactory;
+    private InterfaceContractMapper interfaceContractMapper;
+    private WorkContext workContext = new WorkContextImpl();
+    private WorkScheduler workScheduler = new Jsr237WorkScheduler(new ThreadPoolWorkManager(10));
+    private WirePostProcessorRegistry wirePostProcessorRegistry;
+
+    /**
+     * @param assemblyFactory
+     * @param interfaceContractMapper
+     * @param workContext
+     * @param workScheduler
+     * @param wirePostProcessorRegistry
+     */
+    public DefaultCompositeActivator(AssemblyFactory assemblyFactory,
+                                     InterfaceContractMapper interfaceContractMapper,
+                                     WorkContext workContext,
+                                     WorkScheduler workScheduler,
+                                     WirePostProcessorRegistry wirePostProcessorRegistry) {
+        super();
+        this.assemblyFactory = assemblyFactory;
+        this.interfaceContractMapper = interfaceContractMapper;
+        this.workContext = workContext;
+        this.workScheduler = workScheduler;
+        this.wirePostProcessorRegistry = wirePostProcessorRegistry;
+    }
+
+    public static <T> T getContract(Object target, Class<T> interfaceClass) {
+        if (interfaceClass.isInstance(target)) {
+            return interfaceClass.cast(target);
+        } else {
+            try {
+                String methodName = JavaIntrospectionHelper.toGetter(interfaceClass.getSimpleName());
+                Method method = target.getClass().getMethod(methodName, new Class[] {});
+                return interfaceClass.cast(method.invoke(target, new Object[] {}));
+            } catch (Exception e) {
+                return null;
+            }
+        }
+    }
+
+    public void start(Composite composite) {
+        for (Component component : composite.getComponents()) {
+
+            for (ComponentService service : component.getServices()) {
+                for (Binding binding : service.getBindings()) {
+                    if(binding instanceof ServiceBindingActivator) {
+                        ServiceBindingActivator bindingActivator = (ServiceBindingActivator) binding;
+                        bindingActivator.start(component, service);
+                    }
+                }
+            }
+            for (ComponentReference reference : component.getReferences()) {
+                for (Binding binding : reference.getBindings()) {
+                    if(binding instanceof ReferenceBindingActivator) {
+                        ReferenceBindingActivator bindingActivator = (ReferenceBindingActivator) binding;
+                        bindingActivator.start(component, reference);
+                    }
+                }
+            }
+            Implementation implementation = component.getImplementation();
+            if (implementation instanceof Composite) {
+                start((Composite)implementation);
+            } else if(implementation instanceof ImplementationActivator) {
+                ((ImplementationActivator) implementation).start((RuntimeComponent) component); 
+            }
+        }
+
+    }
+
+    public void stop(Composite composite) {
+        for (Component component : composite.getComponents()) {
+
+            for (ComponentService service : component.getServices()) {
+                for (Binding binding : service.getBindings()) {
+                    if(binding instanceof ServiceBindingActivator) {
+                        ServiceBindingActivator bindingActivator = (ServiceBindingActivator) binding;
+                        bindingActivator.stop(component, service);
+                    }
+                }
+            }
+            for (ComponentReference reference : component.getReferences()) {
+                for (Binding binding : reference.getBindings()) {
+                    if(binding instanceof ReferenceBindingActivator) {
+                        ReferenceBindingActivator bindingActivator = (ReferenceBindingActivator) binding;
+                        bindingActivator.stop(component, reference);
+                    }
+                }
+            }
+            Implementation implementation = component.getImplementation();
+            if (implementation instanceof Composite) {
+                start((Composite)implementation);
+            } else if(implementation instanceof ImplementationActivator) {
+                ((ImplementationActivator) implementation).stop((RuntimeComponent) component); 
+            }
+        }
+
+    }    
+    public void createRuntimeWires(Composite composite) throws IncompatibleInterfaceContractException {
+        for (Component component : composite.getComponents()) {
+
+            Implementation implementation = component.getImplementation();
+            if (implementation instanceof Composite) {
+                createRuntimeWires((Composite)implementation);
+            } else {
+                // createSelfReferences(component);
+                for (ComponentReference reference : component.getReferences()) {
+                    for (Binding binding : reference.getBindings()) {
+                        createWires(component, reference, binding);
+                    }
+                }
+            }
+        }
+    }
+
+    public void createSelfReferences(Component component) {
+        for (ComponentService service : component.getServices()) {
+            ComponentReference ref = assemblyFactory.createComponentReference();
+            ref.setName("$self$_" + service.getName());
+            ref.getBindings().addAll(service.getBindings());
+            ref.getTargets().add(service);
+            ref.getPolicySets().addAll(service.getPolicySets());
+            ref.getRequiredIntents().addAll(service.getRequiredIntents());
+            ref.setInterfaceContract(service.getInterfaceContract());
+            ref.setMultiplicity(Multiplicity.ONE_ONE);
+            component.getReferences().add(ref);
+        }
+    }
+
+    private void createWires(Component component, ComponentReference reference, Binding binding) {
+        if (!(binding instanceof ReferenceBindingProvider)) {
+            return;
+        }
+
+        RuntimeComponentReference wireSource = (RuntimeComponentReference)reference;
+        ReferenceBindingProvider provider = (ReferenceBindingProvider)binding;
+        for (ComponentService service : reference.getTargets()) {
+            // FIXME: Need a way to find the owning component of a component
+            // service
+            Component target = null;
+            SCABinding scaBinding = service.getBinding(SCABinding.class);
+            if (scaBinding != null) {
+                target = scaBinding.getComponent();
+            }
+
+            RuntimeWire wire = new RuntimeWireImpl(reference, service);
+
+            InterfaceContract sourceContract = provider.getBindingInterfaceContract(reference);
+            InterfaceContract targetContract = service.getInterfaceContract();
+            for (Operation operation : sourceContract.getInterface().getOperations()) {
+                Operation targetOperation = interfaceContractMapper.map(targetContract.getInterface(), operation);
+                InvocationChain chain = new InvocationChainImpl(operation, targetOperation);
+                /* lresende */
+                if (operation.isNonBlocking()) {
+                    chain.addInterceptor(new NonBlockingInterceptor(workScheduler, workContext));
+                }
+
+                addBindingIntercepor(component, reference, binding, chain, operation, false);
+
+                if (target != null) {
+                    addImplementationInterceptor(target, service, chain, operation, false);
+                }
+                wire.getInvocationChains().add(chain);
+            }
+            if (sourceContract.getCallbackInterface() != null) {
+                for (Operation operation : sourceContract.getCallbackInterface().getOperations()) {
+                    Operation targetOperation = interfaceContractMapper.map(targetContract.getCallbackInterface(),
+                                                                            operation);
+                    InvocationChain chain = new InvocationChainImpl(operation, targetOperation);
+                    /* lresende */
+                    if (operation.isNonBlocking()) {
+                        chain.addInterceptor(new NonBlockingInterceptor(workScheduler, workContext));
+                    }
+                    addBindingIntercepor(component, reference, binding, chain, operation, true);
+                    addImplementationInterceptor(target, service, chain, operation, false);
+                    wire.getCallbackInvocationChains().add(chain);
+                }
+            }
+
+            wireSource.addRuntimeWire(wire);
+        }
+    }
+
+    private void addImplementationInterceptor(Component component,
+                                              ComponentService service,
+                                              InvocationChain chain,
+                                              Operation operation,
+                                              boolean isCallback) {
+        if (component.getImplementation() instanceof ImplementationProvider) {
+            ImplementationProvider factory = (ImplementationProvider)component.getImplementation();
+            Interceptor interceptor = factory.createInterceptor((RuntimeComponent)component,
+                                                                service,
+                                                                operation,
+                                                                isCallback);
+            chain.addInterceptor(interceptor);
+        }
+    }
+
+    private void addBindingIntercepor(Component component,
+                                      ComponentReference reference,
+                                      Binding binding,
+                                      InvocationChain chain,
+                                      Operation operation,
+                                      boolean isCallback) {
+        if (binding instanceof ReferenceBindingProvider) {
+            ReferenceBindingProvider factory = (ReferenceBindingProvider)binding;
+            Interceptor interceptor = factory.createInterceptor(component, reference, operation, isCallback);
+            if (interceptor != null) {
+                chain.addInterceptor(interceptor);
+            }
+        }
+    }
+
+    private Scope getScope(Component component) {
+        Implementation impl = component.getImplementation();
+        if (impl instanceof ImplementationProvider) {
+            ImplementationProvider provider = (ImplementationProvider)impl;
+            Scope scope = provider.getScope();
+            if (scope == null) {
+                return Scope.STATELESS;
+            }
+        }
+        return Scope.STATELESS;
+    }
+
+    private void optimize(Component source, Component target, RuntimeWire wire) {
+        boolean optimizableScopes = isOptimizable(getScope(source), getScope(target));
+        if (optimizableScopes && isOptimizable(wire)) {
+            // wire.setOptimizable(true);
+        } else {
+            // wire.setOptimizable(false);
+        }
+    }
+
+    /**
+     * Determines if the given wire is optimizable, i.e. its invocation chains
+     * may be bypassed during an invocation. This is typically calculated during
+     * the connect phase to optimize away invocation chains.
+     * 
+     * @param wire the wire
+     * @return true if the wire is optimizable
+     */
+    public static boolean isOptimizable(RuntimeWire wire) {
+        for (InvocationChain chain : wire.getInvocationChains()) {
+            if (chain.getHeadInterceptor() != null) {
+                Interceptor current = chain.getHeadInterceptor();
+                if (current == null) {
+                    break;
+                }
+                while (current != null) {
+                    if (!current.isOptimizable()) {
+                        return false;
+                    }
+                    current = current.getNext();
+                }
+            }
+        }
+        // if there is a callback, the wire is never optimizable since the
+        // callback target needs to be disambiguated
+        return wire.getCallbackInvocationChains().isEmpty();
+    }
+
+    private boolean isOptimizable(Scope pReferrer, Scope pReferee) {
+        if (pReferrer == Scope.UNDEFINED || pReferee == Scope.UNDEFINED
+            || pReferrer == Scope.CONVERSATION
+            || pReferee == Scope.CONVERSATION) {
+            return false;
+        }
+        if (pReferee == pReferrer) {
+            return true;
+        } else if (pReferrer == Scope.STATELESS) {
+            return true;
+        } else if (pReferee == Scope.STATELESS) {
+            return false;
+        } else if (pReferrer == Scope.REQUEST && pReferee == Scope.SESSION) {
+            return true;
+        } else if (pReferrer == Scope.REQUEST && pReferee == Scope.COMPOSITE) {
+            return true;
+        } else if (pReferrer == Scope.REQUEST && pReferee == Scope.SYSTEM) {
+            return true;
+        } else if (pReferrer == Scope.SESSION && pReferee == Scope.COMPOSITE) {
+            return true;
+        } else if (pReferrer == Scope.SESSION && pReferee == Scope.SYSTEM) {
+            return true;
+        } else // noinspection SimplifiableIfStatement
+        if (pReferrer == Scope.SYSTEM && pReferee == Scope.COMPOSITE) {
+            // case where a service context points to a composite scoped
+            // component
+            return true;
+        } else {
+            return pReferrer == Scope.COMPOSITE && pReferee == Scope.SYSTEM;
+        }
+    }
+
+    private void wire(Composite composite,
+                      AssemblyFactory assemblyFactory,
+                      InterfaceContractMapper interfaceContractMapper) {
+        CompositeUtil compositeUtil = new CompositeUtil(assemblyFactory, interfaceContractMapper);
+
+        List<Base> problems = new ArrayList<Base>() {
+            private static final long serialVersionUID = 4819831446590718923L;
+
+            @Override
+            public boolean add(Base o) {
+                // TODO Use a monitor to report configuration problems
+
+                // Uncommenting the following two lines can be useful to detect
+                // and troubleshoot SCA assembly XML composite configuration
+                // problems.
+
+                System.err.println("Composite configuration problem:");
+                new PrintUtil(System.err).print(o);
+                return super.add(o);
+            }
+        };
+
+        // Collect and fuse includes
+        compositeUtil.fuseIncludes(composite, problems);
+
+        // Expand nested composites
+        compositeUtil.expandComposites(composite, problems);
+
+        // Configure all components
+        compositeUtil.configureComponents(composite, problems);
+
+        // Wire the composite
+        compositeUtil.wireComposite(composite, problems);
+
+        // Activate composite services
+        compositeUtil.activateCompositeServices(composite, problems);
+
+        // Wire composite references
+        compositeUtil.wireCompositeReferences(composite, problems);
+
+        // if (!problems.isEmpty()) {
+        // throw new VariantRuntimeException(new RuntimeException("Problems in
+        // the composite..."));
+        // }
+    }
+
+    public void activate(Composite composite) throws IncompatibleInterfaceContractException {
+        wire(composite, assemblyFactory, interfaceContractMapper);
+        createRuntimeWires(composite);
+        start(composite);
+    }
+
+}

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

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

Added: incubator/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/core/runtime/RuntimeActivator.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/core/runtime/RuntimeActivator.java?view=auto&rev=534302
==============================================================================
--- incubator/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/core/runtime/RuntimeActivator.java (added)
+++ incubator/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/core/runtime/RuntimeActivator.java Tue May  1 21:33:36 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.core.runtime;
+
+import org.apache.tuscany.contribution.Contribution;
+import org.apache.tuscany.host.RuntimeInfo;
+import org.apache.tuscany.host.runtime.ShutdownException;
+import org.osoa.sca.ComponentContext;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public interface RuntimeActivator<I extends RuntimeInfo> {
+    /**
+     * Initialize a runtime.
+     *
+     * @throws ActivationException if there is an error initializing the runtime
+     */
+    void start() throws ActivationException;
+
+    /**
+     * Destroy the runtime. Any further invocations should result in an error.
+     *
+     * @throws ShutdownException if there is an error destroying the runtime
+     */
+    void stop() throws ActivationException;
+    
+    void start(Contribution contribution) throws ActivationException;
+    void stop(Contribution contribution) throws ActivationException;
+
+    /**
+     * Returns the ComponentContext for the designated component.
+     *
+     * @param componentName The name of the top-level component in the SCA domain
+     * @return the ComponentContext for the designated component
+     */
+    ComponentContext getComponentContext(String componentName);
+}

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

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



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