You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tuscany.apache.org by lr...@apache.org on 2007/06/08 07:07:28 UTC

svn commit: r545411 - in /incubator/tuscany/java/sca/modules: core/src/main/java/org/apache/tuscany/sca/core/runtime/ host-embedded/src/main/java/org/apache/tuscany/sca/host/embedded/impl/ host-embedded/src/test/java/org/apache/tuscany/sca/host/embedde...

Author: lresende
Date: Thu Jun  7 22:07:27 2007
New Revision: 545411

URL: http://svn.apache.org/viewvc?view=rev&rev=545411
Log:
TUSCANY-1332 Modified the EmbeddedSCADomain to properly support wiring across multiple contributions

Modified:
    incubator/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/runtime/CompositeActivator.java
    incubator/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/runtime/CompositeActivatorImpl.java
    incubator/tuscany/java/sca/modules/host-embedded/src/main/java/org/apache/tuscany/sca/host/embedded/impl/EmbeddedSCADomain.java
    incubator/tuscany/java/sca/modules/host-embedded/src/test/java/org/apache/tuscany/sca/host/embedded/impl/EmbeddedSCADomainTestCase.java

Modified: incubator/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/runtime/CompositeActivator.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/runtime/CompositeActivator.java?view=diff&rev=545411&r1=545410&r2=545411
==============================================================================
--- incubator/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/runtime/CompositeActivator.java (original)
+++ incubator/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/runtime/CompositeActivator.java Thu Jun  7 22:07:27 2007
@@ -19,6 +19,7 @@
 
 package org.apache.tuscany.sca.core.runtime;
 
+import org.apache.tuscany.sca.assembly.Component;
 import org.apache.tuscany.sca.assembly.Composite;
 
 /**
@@ -42,14 +43,28 @@
 
     /**
      * Start a composite
+     * @deprecated
      * @param composite
      */
     void start(Composite composite) throws ActivationException;
 
     /**
      * Stop a composite
+     * @deprecated
      * @param composite
      */
     void stop(Composite composite) throws ActivationException;
+
+    /**
+     * Start a component
+     * @param component
+     */
+    void start(Component component) throws ActivationException;
+
+    /**
+     * Stop a composite
+     * @param composite
+     */
+    void stop(Component component) throws ActivationException;
 
 }

Modified: incubator/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/runtime/CompositeActivatorImpl.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/runtime/CompositeActivatorImpl.java?view=diff&rev=545411&r1=545410&r2=545411
==============================================================================
--- incubator/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/runtime/CompositeActivatorImpl.java (original)
+++ incubator/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/runtime/CompositeActivatorImpl.java Thu Jun  7 22:07:27 2007
@@ -166,90 +166,108 @@
      */
     protected void startComposite(Composite composite) {
         for (Component component : composite.getComponents()) {
+            startComponent(component);
+        }
+    }
 
-            for (ComponentService service : component.getServices()) {
-                for (Binding binding : service.getBindings()) {
-                    ServiceBindingProvider bindingProvider = ((RuntimeComponentService)service)
-                        .getBindingProvider(binding);
-                    if (bindingProvider != null) {
-                        bindingProvider.start();
-                    }
+    /**
+     * Stop a composite
+     */
+    public void stopComposite(Composite composite) {
+        for (Component component : composite.getComponents()) {
+            stopComponent(component);
+
+        }
+
+    }
+
+    /**
+     * Start a component
+     */
+    public void startComponent(Component component) {
+
+        for (ComponentService service : component.getServices()) {
+            for (Binding binding : service.getBindings()) {
+                ServiceBindingProvider bindingProvider = ((RuntimeComponentService)service)
+                    .getBindingProvider(binding);
+                if (bindingProvider != null) {
+                    bindingProvider.start();
                 }
             }
-            for (ComponentReference reference : component.getReferences()) {
-                for (Binding binding : reference.getBindings()) {
-                    ReferenceBindingProvider bindingProvider = ((RuntimeComponentReference)reference)
-                        .getBindingProvider(binding);
-                    if (bindingProvider != null) {
-                        bindingProvider.start();
-                    }
+        }
+        for (ComponentReference reference : component.getReferences()) {
+            for (Binding binding : reference.getBindings()) {
+                ReferenceBindingProvider bindingProvider = ((RuntimeComponentReference)reference)
+                    .getBindingProvider(binding);
+                if (bindingProvider != null) {
+                    bindingProvider.start();
                 }
             }
+        }
 
-            Implementation implementation = component.getImplementation();
-            if (implementation instanceof Composite) {
-                startComposite((Composite)implementation);
-            } else {
-                ImplementationProvider implementationProvider = ((RuntimeComponent)component)
-                    .getImplementationProvider();
-                if (implementationProvider != null) {
-                    implementationProvider.start();
-                }
+        Implementation implementation = component.getImplementation();
+        if (implementation instanceof Composite) {
+            startComposite((Composite)implementation);
+        } else {
+            ImplementationProvider implementationProvider = ((RuntimeComponent)component)
+                .getImplementationProvider();
+            if (implementationProvider != null) {
+                implementationProvider.start();
             }
+        }
 
-            if (component instanceof ScopedRuntimeComponent) {
-                ScopedRuntimeComponent runtimeComponent = (ScopedRuntimeComponent)component;
-                if (runtimeComponent.getScopeContainer() != null) {
-                    runtimeComponent.getScopeContainer().start();
-                }
+        if (component instanceof ScopedRuntimeComponent) {
+            ScopedRuntimeComponent runtimeComponent = (ScopedRuntimeComponent)component;
+            if (runtimeComponent.getScopeContainer() != null) {
+                runtimeComponent.getScopeContainer().start();
             }
-
         }
-    }
 
-    public void stop(Composite composite) {
-        for (Component component : composite.getComponents()) {
+    }
 
-            for (ComponentService service : component.getServices()) {
-                for (Binding binding : service.getBindings()) {
-                    ServiceBindingProvider bindingProvider = ((RuntimeComponentService)service)
-                        .getBindingProvider(binding);
-                    if (bindingProvider != null) {
-                        bindingProvider.stop();
-                    }
+    /**
+     * Stop a component
+     */
+    public void stopComponent(Component component) {
+        for (ComponentService service : component.getServices()) {
+            for (Binding binding : service.getBindings()) {
+                ServiceBindingProvider bindingProvider = ((RuntimeComponentService)service)
+                    .getBindingProvider(binding);
+                if (bindingProvider != null) {
+                    bindingProvider.stop();
                 }
             }
-            for (ComponentReference reference : component.getReferences()) {
-                for (Binding binding : reference.getBindings()) {
-                    ReferenceBindingProvider bindingProvider = ((RuntimeComponentReference)reference)
-                        .getBindingProvider(binding);
-                    if (bindingProvider != null) {
-                        bindingProvider.stop();
-                    }
+        }
+        for (ComponentReference reference : component.getReferences()) {
+            for (Binding binding : reference.getBindings()) {
+                ReferenceBindingProvider bindingProvider = ((RuntimeComponentReference)reference)
+                    .getBindingProvider(binding);
+                if (bindingProvider != null) {
+                    bindingProvider.stop();
                 }
             }
-            Implementation implementation = component.getImplementation();
-            if (implementation instanceof Composite) {
-                stop((Composite)implementation);
-            } else {
-                ImplementationProvider implementationProvider = ((RuntimeComponent)component)
-                    .getImplementationProvider();
-                if (implementationProvider != null) {
-                    implementationProvider.stop();
-                }
+        }
+        Implementation implementation = component.getImplementation();
+        if (implementation instanceof Composite) {
+            stopComposite((Composite)implementation);
+        } else {
+            ImplementationProvider implementationProvider = ((RuntimeComponent)component)
+                .getImplementationProvider();
+            if (implementationProvider != null) {
+                implementationProvider.stop();
             }
+        }
 
-            if (component instanceof ScopedRuntimeComponent) {
-                ScopedRuntimeComponent runtimeComponent = (ScopedRuntimeComponent)component;
-                if (runtimeComponent.getScopeContainer() != null) {
-                    runtimeComponent.getScopeContainer().stop();
-                }
+        if (component instanceof ScopedRuntimeComponent) {
+            ScopedRuntimeComponent runtimeComponent = (ScopedRuntimeComponent)component;
+            if (runtimeComponent.getScopeContainer() != null) {
+                runtimeComponent.getScopeContainer().stop();
             }
-
         }
 
     }
-
+    
+    
     /**
      * Create runtime wires for the composite
      * 
@@ -596,4 +614,28 @@
         }
     }
 
+    public void stop(Composite composite) throws ActivationException {
+        try{
+            stopComposite(composite);
+        } catch(Exception e) {
+            throw new ActivationException(e);
+        }
+    }
+
+    public void start(Component component) throws ActivationException {
+        try {
+            startComponent(component);
+        } catch (Exception e) {
+            throw new ActivationException(e);
+        }
+        
+    }
+    
+    public void stop(Component component) throws ActivationException {
+        try{
+            stopComponent(component);
+        } catch(Exception e) {
+            throw new ActivationException(e);
+        }        
+    }
 }

Modified: incubator/tuscany/java/sca/modules/host-embedded/src/main/java/org/apache/tuscany/sca/host/embedded/impl/EmbeddedSCADomain.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/host-embedded/src/main/java/org/apache/tuscany/sca/host/embedded/impl/EmbeddedSCADomain.java?view=diff&rev=545411&r1=545410&r2=545411
==============================================================================
--- incubator/tuscany/java/sca/modules/host-embedded/src/main/java/org/apache/tuscany/sca/host/embedded/impl/EmbeddedSCADomain.java (original)
+++ incubator/tuscany/java/sca/modules/host-embedded/src/main/java/org/apache/tuscany/sca/host/embedded/impl/EmbeddedSCADomain.java Thu Jun  7 22:07:27 2007
@@ -62,11 +62,11 @@
          */
         public Composite addComposite(Composite composite) throws ActivationException {
             domainComposite.getIncludes().add(composite);
-            CompositeActivator compositeActivator = runtime.getCompositeActivator();
-            compositeActivator.activate(composite);
-            for (Component component : composite.getComponents()) {
-                components.put(component.getName(), component);
-            }
+            //CompositeActivator compositeActivator = runtime.getCompositeActivator();
+            //compositeActivator.activate(composite);
+            //for (Component component : composite.getComponents()) {
+            //    components.put(component.getName(), component);
+            //}
             return composite;
         }
 
@@ -86,6 +86,7 @@
         
         /**
          * Start a composite
+         * @deprecated
          * @param composite
          * @throws ActivationException
          */
@@ -96,12 +97,55 @@
         
         /**
          * Stop a composite
+         * @deprecated
          * @param composite
          * @throws ActivationException
          */
         public void stopComposite(Composite composite) throws ActivationException {
             CompositeActivator compositeActivator = runtime.getCompositeActivator();
             compositeActivator.stop(composite);
+        }
+
+        /**
+         * Get a reference to a component by name
+         * @param componentName
+         * @return
+         */
+        public Component getComponent(String componentName){
+            return (Component) components.get(componentName);
+        }
+        
+        /**
+         * Start a component
+         * @param component
+         * @throws ActivationException
+         */
+        public void startComponent(Component component) throws ActivationException {
+            CompositeActivator compositeActivator = runtime.getCompositeActivator();
+            compositeActivator.start(component);
+        }
+        
+        /**
+         * Stop a component
+         * @param component
+         * @throws ActivationException
+         */
+        public void stopComponent(Component component) throws ActivationException {
+            CompositeActivator compositeActivator = runtime.getCompositeActivator();
+            compositeActivator.stop(component);
+        }        
+        
+        /**
+         * Activate SCA Domain
+         * @throws ActivationException
+         */
+        public void activateDomain() throws ActivationException {
+            CompositeActivator compositeActivator = runtime.getCompositeActivator();
+            compositeActivator.activate(domainComposite);
+            for (Component component : domainComposite.getComponents()) {
+                components.put(component.getName(), component);
+            }
+
         }
     }
 

Modified: incubator/tuscany/java/sca/modules/host-embedded/src/test/java/org/apache/tuscany/sca/host/embedded/impl/EmbeddedSCADomainTestCase.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/host-embedded/src/test/java/org/apache/tuscany/sca/host/embedded/impl/EmbeddedSCADomainTestCase.java?view=diff&rev=545411&r1=545410&r2=545411
==============================================================================
--- incubator/tuscany/java/sca/modules/host-embedded/src/test/java/org/apache/tuscany/sca/host/embedded/impl/EmbeddedSCADomainTestCase.java (original)
+++ incubator/tuscany/java/sca/modules/host-embedded/src/test/java/org/apache/tuscany/sca/host/embedded/impl/EmbeddedSCADomainTestCase.java Thu Jun  7 22:07:27 2007
@@ -47,7 +47,6 @@
     }
 
     public void testDomain() throws Exception {
-        
         // Start the domain
         domain.start();
         
@@ -69,8 +68,11 @@
         EmbeddedSCADomain.DomainCompositeHelper domainHelper = domain.getDomainCompositeHelper();
         domainHelper.addComposite(myComposite);
 
+        // Activate the SCA Domain
+        domainHelper.activateDomain();
+
         // Start the components in my composite
-        domainHelper.startComposite(myComposite);
+        domainHelper.startComponent(domainHelper.getComponent("CRUDServiceComponent"));
         
         // At this point the domain contains my contribution, my composite and
         // it's started, my application code can start using it



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