tuscany-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rf...@apache.org
Subject svn commit: r1172881 - in /tuscany/sca-java-2.x/trunk/modules: core-spi/src/main/java/org/apache/tuscany/sca/invocation/ node-api/src/main/java/org/apache/tuscany/sca/node/ node-api/src/main/java/org/apache/tuscany/sca/node/extensibility/ node-impl/src...
Date Mon, 19 Sep 2011 22:55:38 GMT
Author: rfeng
Date: Mon Sep 19 22:55:37 2011
New Revision: 1172881

URL: http://svn.apache.org/viewvc?rev=1172881&view=rev
Log:
Add the ablity to load the contributions/composite for a given node configuration without
starting the node

Modified:
    tuscany/sca-java-2.x/trunk/modules/core-spi/src/main/java/org/apache/tuscany/sca/invocation/Message.java
    tuscany/sca-java-2.x/trunk/modules/node-api/src/main/java/org/apache/tuscany/sca/node/NodeFactory.java
    tuscany/sca-java-2.x/trunk/modules/node-api/src/main/java/org/apache/tuscany/sca/node/extensibility/NodeExtension.java
    tuscany/sca-java-2.x/trunk/modules/node-impl/src/main/java/org/apache/tuscany/sca/node/impl/NodeFactoryImpl.java
    tuscany/sca-java-2.x/trunk/modules/node-impl/src/main/java/org/apache/tuscany/sca/node/impl/NodeImpl.java

Modified: tuscany/sca-java-2.x/trunk/modules/core-spi/src/main/java/org/apache/tuscany/sca/invocation/Message.java
URL: http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/modules/core-spi/src/main/java/org/apache/tuscany/sca/invocation/Message.java?rev=1172881&r1=1172880&r2=1172881&view=diff
==============================================================================
--- tuscany/sca-java-2.x/trunk/modules/core-spi/src/main/java/org/apache/tuscany/sca/invocation/Message.java
(original)
+++ tuscany/sca-java-2.x/trunk/modules/core-spi/src/main/java/org/apache/tuscany/sca/invocation/Message.java
Mon Sep 19 22:55:37 2011
@@ -18,7 +18,6 @@
  */
 package org.apache.tuscany.sca.invocation;
 
-import java.util.List;
 import java.util.Map;
 
 import org.apache.tuscany.sca.assembly.Endpoint;

Modified: tuscany/sca-java-2.x/trunk/modules/node-api/src/main/java/org/apache/tuscany/sca/node/NodeFactory.java
URL: http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/modules/node-api/src/main/java/org/apache/tuscany/sca/node/NodeFactory.java?rev=1172881&r1=1172880&r2=1172881&view=diff
==============================================================================
--- tuscany/sca-java-2.x/trunk/modules/node-api/src/main/java/org/apache/tuscany/sca/node/NodeFactory.java
(original)
+++ tuscany/sca-java-2.x/trunk/modules/node-api/src/main/java/org/apache/tuscany/sca/node/NodeFactory.java
Mon Sep 19 22:55:37 2011
@@ -39,9 +39,11 @@ import java.util.List;
 import java.util.Map;
 import java.util.Properties;
 
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
 import org.apache.tuscany.sca.node.configuration.DefaultNodeConfigurationFactory;
 import org.apache.tuscany.sca.node.configuration.NodeConfiguration;
 import org.apache.tuscany.sca.node.configuration.NodeConfigurationFactory;
+import org.apache.tuscany.sca.node.extensibility.NodeExtension;
 import org.oasisopen.sca.ServiceReference;
 import org.oasisopen.sca.ServiceRuntimeException;
 
@@ -633,10 +635,27 @@ public abstract class NodeFactory extend
      */
     public abstract NodeConfiguration loadConfiguration(InputStream xml, URL base);
 
-    public abstract <T> T getExtensionPointRegistry();
+    /**
+     * Get the ExtensionPointRegistry
+     * @return
+     */
+    public abstract ExtensionPointRegistry getExtensionPointRegistry();
 
+    /**
+     * Initialize the factory
+     */
     public abstract void init();
 
-    public void setAutoDestroy(boolean b) {
-    }
+    /**
+     * Set auto destroy flag when all nodes are stopped
+     * @param b
+     */
+    public abstract void setAutoDestroy(boolean b);
+    
+    /**
+     * Create and load the node for the purpose of metadata introspection
+     * @param configuration
+     * @return The extended Node
+     */
+    public abstract NodeExtension loadNode(NodeConfiguration configuration);
 }

Modified: tuscany/sca-java-2.x/trunk/modules/node-api/src/main/java/org/apache/tuscany/sca/node/extensibility/NodeExtension.java
URL: http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/modules/node-api/src/main/java/org/apache/tuscany/sca/node/extensibility/NodeExtension.java?rev=1172881&r1=1172880&r2=1172881&view=diff
==============================================================================
--- tuscany/sca-java-2.x/trunk/modules/node-api/src/main/java/org/apache/tuscany/sca/node/extensibility/NodeExtension.java
(original)
+++ tuscany/sca-java-2.x/trunk/modules/node-api/src/main/java/org/apache/tuscany/sca/node/extensibility/NodeExtension.java
Mon Sep 19 22:55:37 2011
@@ -24,15 +24,39 @@ import org.apache.tuscany.sca.core.Exten
 import org.apache.tuscany.sca.node.Node;
 import org.apache.tuscany.sca.node.configuration.NodeConfiguration;
 
+/**
+ * An extended Node interface to provide more metadata for Tuscany extensions 
+ * @version $Rev $Date$
+ * @tuscany.spi.extension.asclient
+ */
 public interface NodeExtension extends Node {
 
+    /**
+     * Get the node URI
+     * @return The Tuscany node URI
+     */
     String getURI();
 
+    /**
+     * Get the domain URI
+     * @return The SCA domain URI
+     */
     String getDomainURI();
 
+    /**
+     * Get the node configuration
+     * @return The node cofiguration
+     */
     NodeConfiguration getConfiguration();
 
+    /**
+     * Get the domain composite
+     * @return The domain composite
+     */
     Composite getDomainComposite();
-
+    
+    /**
+     * Get the extension point registry
+     */
     ExtensionPointRegistry getExtensionPointRegistry();
 }

Modified: tuscany/sca-java-2.x/trunk/modules/node-impl/src/main/java/org/apache/tuscany/sca/node/impl/NodeFactoryImpl.java
URL: http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/modules/node-impl/src/main/java/org/apache/tuscany/sca/node/impl/NodeFactoryImpl.java?rev=1172881&r1=1172880&r2=1172881&view=diff
==============================================================================
--- tuscany/sca-java-2.x/trunk/modules/node-impl/src/main/java/org/apache/tuscany/sca/node/impl/NodeFactoryImpl.java
(original)
+++ tuscany/sca-java-2.x/trunk/modules/node-impl/src/main/java/org/apache/tuscany/sca/node/impl/NodeFactoryImpl.java
Mon Sep 19 22:55:37 2011
@@ -73,6 +73,7 @@ import org.apache.tuscany.sca.node.confi
 import org.apache.tuscany.sca.node.configuration.DeploymentComposite;
 import org.apache.tuscany.sca.node.configuration.NodeConfiguration;
 import org.apache.tuscany.sca.node.configuration.NodeConfigurationFactory;
+import org.apache.tuscany.sca.node.extensibility.NodeExtension;
 import org.apache.tuscany.sca.runtime.DomainRegistryFactory;
 import org.apache.tuscany.sca.runtime.ExtensibleDomainRegistryFactory;
 import org.apache.tuscany.sca.runtime.RuntimeProperties;
@@ -482,4 +483,22 @@ public class NodeFactoryImpl extends Nod
         autoDestroy = b;
     }
     
+    /**
+     * Create and load a node
+     * @param configuration
+     * @return The node
+     */
+    public NodeExtension loadNode(NodeConfiguration configuration) {
+        Node node = createNode(configuration);
+        
+        try {
+            NodeImpl nodeImpl = ((NodeImpl) node);
+            nodeImpl.load();
+            return nodeImpl;
+        } catch (Throwable e) {
+            throw new ServiceRuntimeException(e);
+        } 
+    }
+    
+    
 }

Modified: tuscany/sca-java-2.x/trunk/modules/node-impl/src/main/java/org/apache/tuscany/sca/node/impl/NodeImpl.java
URL: http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/modules/node-impl/src/main/java/org/apache/tuscany/sca/node/impl/NodeImpl.java?rev=1172881&r1=1172880&r2=1172881&view=diff
==============================================================================
--- tuscany/sca-java-2.x/trunk/modules/node-impl/src/main/java/org/apache/tuscany/sca/node/impl/NodeImpl.java
(original)
+++ tuscany/sca-java-2.x/trunk/modules/node-impl/src/main/java/org/apache/tuscany/sca/node/impl/NodeImpl.java
Mon Sep 19 22:55:37 2011
@@ -53,8 +53,8 @@ import org.apache.tuscany.sca.node.exten
 import org.apache.tuscany.sca.node.extensibility.NodeExtension;
 import org.apache.tuscany.sca.runtime.ActivationException;
 import org.apache.tuscany.sca.runtime.CompositeActivator;
-import org.apache.tuscany.sca.runtime.DomainRegistryFactory;
 import org.apache.tuscany.sca.runtime.DomainRegistry;
+import org.apache.tuscany.sca.runtime.DomainRegistryFactory;
 import org.apache.tuscany.sca.runtime.ExtensibleDomainRegistryFactory;
 import org.apache.tuscany.sca.runtime.RuntimeComponent;
 import org.apache.tuscany.sca.runtime.RuntimeComponentService;
@@ -114,50 +114,29 @@ public class NodeImpl implements Node, N
     public Node start() {
         logger.log(nodeFactory.quietLogging? Level.FINE : Level.INFO, "Starting node: " +
configuration.getURI() + " domain: " + configuration.getDomainURI());
 
-        nodeFactory.init();
-        nodeFactory.addNode(configuration, this);
-        this.proxyFactory = nodeFactory.proxyFactory;
-
         try {
-            Monitor monitor = nodeFactory.monitorFactory.createMonitor();
-            ProcessorContext context = new ProcessorContext(monitor);
-
-            // Set up the thead context monitor
-            Monitor tcm = nodeFactory.monitorFactory.setContextMonitor(monitor);
-            try {
-                // Use the lack of the contributions collection as an indicator for when
the node
-                // is being started for the first time. If it is the first time do all the
work
-                // to read the contributions and create the domain composite
-                if (contributions == null) {
-                    contributions = nodeFactory.loadContributions(configuration, context);
-                }
-
-                if (domainComposite == null) {
-
-                    UtilityExtensionPoint utilities = nodeFactory.registry.getExtensionPoint(UtilityExtensionPoint.class);
-                    this.compositeActivator = utilities.getUtility(CompositeActivator.class);
+            load();
 
-                    domainComposite = nodeFactory.configureNode(configuration, contributions,
context);
+            nodeFactory.addNode(configuration, this);
+            this.proxyFactory = nodeFactory.proxyFactory;
 
-                    DomainRegistryFactory domainRegistryFactory = ExtensibleDomainRegistryFactory.getInstance(nodeFactory.registry);
-                    DomainRegistry domainRegistry =
-                        domainRegistryFactory.getEndpointRegistry(configuration.getDomainRegistryURI(),
configuration.getDomainURI());
-
-                    this.compositeContext =
-                        new CompositeContext(nodeFactory.registry,
-                                             domainRegistry,
-                                             domainComposite,
-                                             configuration.getDomainURI(),
-                                             configuration.getURI(),
-                                             nodeFactory.getDeployer().getSystemDefinitions());
-                    // Pass down the context attributes
-                    compositeContext.getAttributes().putAll(configuration.getAttributes());
-                }
-
-            } finally {
-                // Reset the thread context monitor
-                nodeFactory.monitorFactory.setContextMonitor(tcm);
-            }
+            // Set up the node context
+            UtilityExtensionPoint utilities = nodeFactory.registry.getExtensionPoint(UtilityExtensionPoint.class);
+            this.compositeActivator = utilities.getUtility(CompositeActivator.class);
+
+            DomainRegistryFactory domainRegistryFactory =
+                ExtensibleDomainRegistryFactory.getInstance(nodeFactory.registry);
+            DomainRegistry domainRegistry =
+                domainRegistryFactory.getEndpointRegistry(configuration.getDomainRegistryURI(),
+                                                          configuration.getDomainURI());
+
+            this.compositeContext =
+                new CompositeContext(nodeFactory.registry, domainRegistry, domainComposite,
+                                     configuration.getDomainURI(), configuration.getURI(),
nodeFactory
+                                         .getDeployer().getSystemDefinitions());
+            // Pass down the context attributes
+            compositeContext.getAttributes().putAll(configuration.getAttributes());
+            
 
             // Activate the composite
             compositeActivator.activate(compositeContext, domainComposite);
@@ -197,6 +176,33 @@ public class NodeImpl implements Node, N
 
     }
 
+    public void load() throws Throwable {
+        nodeFactory.init();
+
+        Monitor monitor = nodeFactory.monitorFactory.createMonitor();
+        ProcessorContext context = new ProcessorContext(monitor);
+
+        // Set up the thead context monitor
+        Monitor tcm = nodeFactory.monitorFactory.setContextMonitor(monitor);
+        try {
+            // Use the lack of the contributions collection as an indicator for when the
node
+            // is being started for the first time. If it is the first time do all the work
+            // to read the contributions and create the domain composite
+            if (contributions == null) {
+                contributions = nodeFactory.loadContributions(configuration, context);
+            }
+
+            if (domainComposite == null) {
+                domainComposite = nodeFactory.configureNode(configuration, contributions,
context);
+            }
+
+
+        } finally {
+            // Reset the thread context monitor
+            nodeFactory.monitorFactory.setContextMonitor(tcm);
+        }
+    }
+
     public void stop() {
         logger.log(nodeFactory.quietLogging? Level.FINE : Level.INFO, "Stopping node: " +
configuration.getURI());
 



Mime
View raw message