You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tuscany.apache.org by jm...@apache.org on 2006/04/14 20:55:02 UTC

svn commit: r394173 - in /incubator/tuscany/java/sca: containers/container.java/src/test/java/org/apache/tuscany/container/java/context/ containers/container.java/src/test/java/org/apache/tuscany/container/java/mock/components/ core/src/main/java/org/a...

Author: jmarino
Date: Fri Apr 14 11:54:59 2006
New Revision: 394173

URL: http://svn.apache.org/viewcvs?rev=394173&view=rev
Log:
lifecycle test case; additional Javadoc

Modified:
    incubator/tuscany/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/context/PojoLifecycleTestCase.java
    incubator/tuscany/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/mock/components/ModuleScopeInitDestroyComponent.java
    incubator/tuscany/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/mock/components/ModuleScopeInitOnlyComponent.java
    incubator/tuscany/java/sca/core/src/main/java/org/apache/tuscany/core/context/AutowireContext.java
    incubator/tuscany/java/sca/core/src/main/java/org/apache/tuscany/core/context/QualifiedName.java

Modified: incubator/tuscany/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/context/PojoLifecycleTestCase.java
URL: http://svn.apache.org/viewcvs/incubator/tuscany/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/context/PojoLifecycleTestCase.java?rev=394173&r1=394172&r2=394173&view=diff
==============================================================================
--- incubator/tuscany/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/context/PojoLifecycleTestCase.java (original)
+++ incubator/tuscany/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/context/PojoLifecycleTestCase.java Fri Apr 14 11:54:59 2006
@@ -21,6 +21,7 @@
 
 import org.apache.tuscany.container.java.mock.MockFactory;
 import org.apache.tuscany.container.java.mock.components.ModuleScopeInitOnlyComponent;
+import org.apache.tuscany.container.java.mock.components.ModuleScopeInitDestroyComponent;
 import org.apache.tuscany.core.context.CompositeContext;
 import org.apache.tuscany.core.context.impl.CompositeContextImpl;
 import org.apache.tuscany.model.assembly.Scope;
@@ -68,4 +69,17 @@
         context.stop();
     }
 
+
+    public void testDestroy() throws Exception {
+        CompositeContext mc = new CompositeContextImpl();
+        mc.setName("mc");
+        JavaComponentContext context = MockFactory.createPojoContext("TestServiceInit",
+                ModuleScopeInitDestroyComponent.class, Scope.MODULE, mc);
+        context.start();
+        ModuleScopeInitDestroyComponent instance = (ModuleScopeInitDestroyComponent) context.getInstance(null);
+        Assert.assertNotNull(instance);
+        context.destroy();
+        Assert.assertTrue(instance.isDestroyed());
+        context.stop();
+    }
 }

Modified: incubator/tuscany/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/mock/components/ModuleScopeInitDestroyComponent.java
URL: http://svn.apache.org/viewcvs/incubator/tuscany/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/mock/components/ModuleScopeInitDestroyComponent.java?rev=394173&r1=394172&r2=394173&view=diff
==============================================================================
--- incubator/tuscany/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/mock/components/ModuleScopeInitDestroyComponent.java (original)
+++ incubator/tuscany/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/mock/components/ModuleScopeInitDestroyComponent.java Fri Apr 14 11:54:59 2006
@@ -28,6 +28,9 @@
 
     @Destroy
     public void destroy() {
+        if (destroyed){
+            throw new AssertionError("Destroy called more than once");
+        }
         destroyed = true;
     }
 

Modified: incubator/tuscany/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/mock/components/ModuleScopeInitOnlyComponent.java
URL: http://svn.apache.org/viewcvs/incubator/tuscany/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/mock/components/ModuleScopeInitOnlyComponent.java?rev=394173&r1=394172&r2=394173&view=diff
==============================================================================
--- incubator/tuscany/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/mock/components/ModuleScopeInitOnlyComponent.java (original)
+++ incubator/tuscany/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/mock/components/ModuleScopeInitOnlyComponent.java Fri Apr 14 11:54:59 2006
@@ -32,6 +32,9 @@
 
     @Init
     public void init() {
+        if (initialized){
+            throw new AssertionError("Init called more than once");
+        }
         initialized = true;
     }
 

Modified: incubator/tuscany/java/sca/core/src/main/java/org/apache/tuscany/core/context/AutowireContext.java
URL: http://svn.apache.org/viewcvs/incubator/tuscany/java/sca/core/src/main/java/org/apache/tuscany/core/context/AutowireContext.java?rev=394173&r1=394172&r2=394173&view=diff
==============================================================================
--- incubator/tuscany/java/sca/core/src/main/java/org/apache/tuscany/core/context/AutowireContext.java (original)
+++ incubator/tuscany/java/sca/core/src/main/java/org/apache/tuscany/core/context/AutowireContext.java Fri Apr 14 11:54:59 2006
@@ -23,8 +23,8 @@
 public interface AutowireContext extends CompositeContext {
 
     /**
-     * Used by child contexts to return an an autowire target. Resolved targets may be entry points or components in the parent
-     * or its ancestors, or entry points in a sibling context
+     * Invoked by child contexts to return an an autowire target. Resolved targets may be entry points or
+     * components in the parent or its ancestors, or entry points in a sibling context
      *
      * @param instanceInterface the type of service being requested
      * @return a reference to the requested service or null if none can be found
@@ -33,10 +33,14 @@
     <T> T resolveInstance(Class<T> instanceInterface) throws AutowireResolutionException;
 
     /**
-     * Used by 
-     * @param instanceInterface
-     * @return
-     * @throws AutowireResolutionException
+     * Invoked by a parent context to return an autowire target in a child. Resolved targets must be entry points.
+     * For example, given a parent P and two siblings, A and B, A would request an autowire by invoking
+     * {@link #resolveInstance(Class<T>)} on P, which in turn could invoke the present method on B in order to resolve
+     * a target.
+     *
+     * @param instanceInterface the type of service being requested
+     * @return a reference to the requested service or null if none can be found
+     * @throws AutowireResolutionException if an error occurs attempting to resolve an autowire
      */
     <T> T resolveExternalInstance(Class<T> instanceInterface) throws AutowireResolutionException;
 

Modified: incubator/tuscany/java/sca/core/src/main/java/org/apache/tuscany/core/context/QualifiedName.java
URL: http://svn.apache.org/viewcvs/incubator/tuscany/java/sca/core/src/main/java/org/apache/tuscany/core/context/QualifiedName.java?rev=394173&r1=394172&r2=394173&view=diff
==============================================================================
--- incubator/tuscany/java/sca/core/src/main/java/org/apache/tuscany/core/context/QualifiedName.java (original)
+++ incubator/tuscany/java/sca/core/src/main/java/org/apache/tuscany/core/context/QualifiedName.java Fri Apr 14 11:54:59 2006
@@ -33,7 +33,8 @@
     public static final String NAME_SEPARATOR = "/";
 
     /**
-     * Constructs a new qualified name
+     * Constructs a new qualified name in the form of part/port where part is the parent context and port represents a
+     * child, which is either a service in the case of an atomic context or a contained context in the case of a composite.  
      * 
      * @throws InvalidNameException if the name is in an invalid format
      */