You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tuscany.apache.org by kw...@apache.org on 2007/05/10 18:49:57 UTC

svn commit: r536935 - in /incubator/tuscany/java/sca/modules/host-embedded/src/main/java/org/apache/tuscany/host/embedded: SCADomain.java impl/DefaultSCADomain.java

Author: kwilliams
Date: Thu May 10 09:49:56 2007
New Revision: 536935

URL: http://svn.apache.org/viewvc?view=rev&rev=536935
Log:
Initial support for SCADomain.connect

Modified:
    incubator/tuscany/java/sca/modules/host-embedded/src/main/java/org/apache/tuscany/host/embedded/SCADomain.java
    incubator/tuscany/java/sca/modules/host-embedded/src/main/java/org/apache/tuscany/host/embedded/impl/DefaultSCADomain.java

Modified: incubator/tuscany/java/sca/modules/host-embedded/src/main/java/org/apache/tuscany/host/embedded/SCADomain.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/host-embedded/src/main/java/org/apache/tuscany/host/embedded/SCADomain.java?view=diff&rev=536935&r1=536934&r2=536935
==============================================================================
--- incubator/tuscany/java/sca/modules/host-embedded/src/main/java/org/apache/tuscany/host/embedded/SCADomain.java (original)
+++ incubator/tuscany/java/sca/modules/host-embedded/src/main/java/org/apache/tuscany/host/embedded/SCADomain.java Thu May 10 09:49:56 2007
@@ -34,37 +34,54 @@
 
 /**
  * A handle to an SCA domain.
- *
+ * 
  * @version $Rev$ $Date$
  */
 public abstract class SCADomain {
-    
+
+    /**
+     * Static variable to hold the most recent instance of SCADomain
+     */
+    // TODO: Temporary support for SCADomain.connect() API
+    private static SCADomain theDomain;
+
     /**
-     * Returns a new instance of a local SCA domain. The specified deployable composites will
-     * be included in the SCA domain.
+     * Returns a new instance of a local SCA domain. The specified deployable
+     * composites will be included in the SCA domain.
      * 
      * @param domainURI the URI of the SCA domain
-     * @param contributionLocation the location of an SCA contribution 
+     * @param contributionLocation the location of an SCA contribution
      * @param composites the deployable composites to include in the SCA domain.
      * @return
      */
-    public static SCADomain newInstance(String domainURI, String contributionLocation, String...composites) {
+    public static SCADomain newInstance(String domainURI, String contributionLocation, String... composites) {
         return createNewInstance(domainURI, contributionLocation, composites);
     }
-    
+
+    /**
+     * Removes the specified local SCA Domain instance
+     * 
+     * @param domainInstance the instance to be removed
+     */
+    // TODO: Adding this as temporary support for the "connect" API
+    public static void removeInstance(SCADomain domainInstance) {
+        theDomain = null;
+    }
+
     /**
      * Returns an SCADomain representing a remote SCA domain.
      * 
      * @param domainURI the URI of the SCA domain
      * @return
      */
+    // TODO : this is a temporary implementation to get the capability working
     public static SCADomain connect(String domainURI) {
-        throw new UnsupportedOperationException();
+        return theDomain;
     }
-    
+
     /**
-     * Returns a new instance of a local SCA domain. The specified deployable composite will
-     * be included in the SCA domain.
+     * Returns a new instance of a local SCA domain. The specified deployable
+     * composite will be included in the SCA domain.
      * 
      * @param composite the deployable composite to include in the SCA domain.
      * @return
@@ -72,37 +89,42 @@
     public static SCADomain newInstance(String composite) {
         return createNewInstance("http://localhost", ".", composite);
     }
-    
+
     /**
      * Close the SCA domain.
      */
-    public abstract void close();
-    
+    public void close() {
+        // TODO: temporary to support initial SCADomain.connect capability
+        SCADomain.removeInstance(this);
+    }
+
     /**
      * Returns the URI of the SCA Domain.
-     *
+     * 
      * @return the URI of the SCA Domain
      */
     public abstract String getURI();
 
     /**
-     * Cast a type-safe reference to a CallableReference.
-     * Converts a type-safe reference to an equivalent CallableReference; if the target refers to a service
-     * then a ServiceReference will be returned, if the target refers to a callback then a CallableReference
-     * will be returned.
-     *
+     * Cast a type-safe reference to a CallableReference. Converts a type-safe
+     * reference to an equivalent CallableReference; if the target refers to a
+     * service then a ServiceReference will be returned, if the target refers to
+     * a callback then a CallableReference will be returned.
+     * 
      * @param target a reference proxy provided by the SCA runtime
      * @param <B> the Java type of the business interface for the reference
      * @param <R> the type of reference to be returned
      * @return a CallableReference equivalent for the proxy
-     * @throws IllegalArgumentException if the supplied instance is not a reference supplied by the SCA runtime
+     * @throws IllegalArgumentException if the supplied instance is not a
+     *             reference supplied by the SCA runtime
      */
     public abstract <B, R extends CallableReference<B>> R cast(B target) throws IllegalArgumentException;
 
     /**
      * Returns a proxy for a service provided by a component in the SCA domain.
-     *
-     * @param businessInterface the interface that will be used to invoke the service
+     * 
+     * @param businessInterface the interface that will be used to invoke the
+     *            service
      * @param serviceName the name of the service
      * @param <B> the Java type of the business interface for the service
      * @return an object that implements the business interface
@@ -110,9 +132,11 @@
     public abstract <B> B getService(Class<B> businessInterface, String serviceName);
 
     /**
-     * Returns a ServiceReference for a service provided by a component in the SCA domain.
-     *
-     * @param businessInterface the interface that will be used to invoke the service
+     * Returns a ServiceReference for a service provided by a component in the
+     * SCA domain.
+     * 
+     * @param businessInterface the interface that will be used to invoke the
+     *            service
      * @param serviceName the name of the service
      * @param <B> the Java type of the business interface for the service
      * @return a ServiceReference for the designated service
@@ -153,12 +177,12 @@
 
     /**
      * Returns an SCADomain instance. If the system property
-     * "org.apache.tuscany.host.embedded.SCADomain" is set, its value is used as the name
-     * of the implementation class. Otherwise, if the resource
-     * "META-INF/services/org.apache.tuscany.host.embedded.SCADomain" can be loaded from
-     * the supplied classloader. Otherwise, it will use
-     * "org.apache.tuscany.host.embedded.impl.DefaultSCADomain" as the default. The
-     * named class is loaded from the supplied classloader.
+     * "org.apache.tuscany.host.embedded.SCADomain" is set, its value is used as
+     * the name of the implementation class. Otherwise, if the resource
+     * "META-INF/services/org.apache.tuscany.host.embedded.SCADomain" can be
+     * loaded from the supplied classloader. Otherwise, it will use
+     * "org.apache.tuscany.host.embedded.impl.DefaultSCADomain" as the default.
+     * The named class is loaded from the supplied classloader.
      * 
      * @param classLoader
      * @param domainURI
@@ -166,12 +190,14 @@
      * @param composites
      * @return
      */
-    static SCADomain createNewInstance(String domainURI, String contributionLocation, String...composites) {
+    static SCADomain createNewInstance(String domainURI, String contributionLocation, String... composites) {
+
+        SCADomain domain = null;
 
         try {
             final ClassLoader runtimeClassLoader = SCADomain.class.getClassLoader();
             final ClassLoader applicationClassLoader = Thread.currentThread().getContextClassLoader();
-            
+
             final String name = SCADomain.class.getName();
             String className = AccessController.doPrivileged(new PrivilegedAction<String>() {
                 public String run() {
@@ -183,16 +209,23 @@
                 className = getServiceName(runtimeClassLoader, name);
             }
             if (className == null) {
-                return new DefaultSCADomain(runtimeClassLoader, applicationClassLoader,
-                                            domainURI, contributionLocation, composites);
+                domain =
+                    new DefaultSCADomain(runtimeClassLoader, applicationClassLoader, domainURI, contributionLocation,
+                                         composites);
+            } else {
+                Class cls = Class.forName(className, true, runtimeClassLoader);
+                Constructor<?> constructor = cls.getConstructor(String.class, String.class, String[].class);
+                domain =
+                    (SCADomain)constructor.newInstance(runtimeClassLoader,
+                                                       applicationClassLoader,
+                                                       domainURI,
+                                                       contributionLocation,
+                                                       composites);
             }
-            Class cls = Class.forName(className, true, runtimeClassLoader);
-            Constructor<?> constructor = cls.getConstructor(String.class, String.class, String[].class);
-            SCADomain domain = (SCADomain)constructor.newInstance(
-                                                                  runtimeClassLoader, applicationClassLoader,
-                                                                  domainURI, contributionLocation, composites);
+            // TODO: tempoarary support for connect() API
+            theDomain = domain;
             return domain;
-            
+
         } catch (Exception e) {
             throw new ServiceRuntimeException(e);
         }

Modified: incubator/tuscany/java/sca/modules/host-embedded/src/main/java/org/apache/tuscany/host/embedded/impl/DefaultSCADomain.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/host-embedded/src/main/java/org/apache/tuscany/host/embedded/impl/DefaultSCADomain.java?view=diff&rev=536935&r1=536934&r2=536935
==============================================================================
--- incubator/tuscany/java/sca/modules/host-embedded/src/main/java/org/apache/tuscany/host/embedded/impl/DefaultSCADomain.java (original)
+++ incubator/tuscany/java/sca/modules/host-embedded/src/main/java/org/apache/tuscany/host/embedded/impl/DefaultSCADomain.java Thu May 10 09:49:56 2007
@@ -147,6 +147,8 @@
 
     @Override
     public void close() {
+        
+        super.close();
 
         // Remove the contribution from the in-memory repository
         ContributionService contributionService = runtime.getContributionService();
@@ -155,7 +157,7 @@
         } catch (ContributionException e) {
             throw new ServiceRuntimeException(e);
         }
-
+        
         // Stop the SCA domain composite
         CompositeActivator compositeActivator = runtime.getCompositeActivator();
         try {



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