You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tuscany.apache.org by me...@apache.org on 2007/01/01 15:55:14 UTC

svn commit: r491580 - in /incubator/tuscany/java/sca/runtime/standalone/server.start: ./ src/main/java/org/apache/tuscany/standalone/server/ src/main/java/org/apache/tuscany/standalone/server/management/jmx/

Author: meerajk
Date: Mon Jan  1 06:55:13 2007
New Revision: 491580

URL: http://svn.apache.org/viewvc?view=rev&rev=491580
Log:
Intermediary checin for registration in composite component 
extension. Need to move the JMX implementation out of core. 
Runtime and RuntimeInfo implementations need to be from the 
boot and system classloaders respectively.

Modified:
    incubator/tuscany/java/sca/runtime/standalone/server.start/pom.xml
    incubator/tuscany/java/sca/runtime/standalone/server.start/src/main/java/org/apache/tuscany/standalone/server/TuscanyServer.java
    incubator/tuscany/java/sca/runtime/standalone/server.start/src/main/java/org/apache/tuscany/standalone/server/management/jmx/AbstractAgent.java
    incubator/tuscany/java/sca/runtime/standalone/server.start/src/main/java/org/apache/tuscany/standalone/server/management/jmx/Agent.java

Modified: incubator/tuscany/java/sca/runtime/standalone/server.start/pom.xml
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/runtime/standalone/server.start/pom.xml?view=diff&rev=491580&r1=491579&r2=491580
==============================================================================
--- incubator/tuscany/java/sca/runtime/standalone/server.start/pom.xml (original)
+++ incubator/tuscany/java/sca/runtime/standalone/server.start/pom.xml Mon Jan  1 06:55:13 2007
@@ -44,6 +44,12 @@
             <scope>compile</scope>
         </dependency>
         <dependency>
+            <groupId>org.apache.tuscany.sca.kernel</groupId>
+            <artifactId>core</artifactId>
+            <version>${sca.version}</version>
+            <scope>compile</scope>
+        </dependency>
+        <dependency>
             <groupId>junit</groupId>
             <artifactId>junit</artifactId>
         </dependency>

Modified: incubator/tuscany/java/sca/runtime/standalone/server.start/src/main/java/org/apache/tuscany/standalone/server/TuscanyServer.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/runtime/standalone/server.start/src/main/java/org/apache/tuscany/standalone/server/TuscanyServer.java?view=diff&rev=491580&r1=491579&r2=491580
==============================================================================
--- incubator/tuscany/java/sca/runtime/standalone/server.start/src/main/java/org/apache/tuscany/standalone/server/TuscanyServer.java (original)
+++ incubator/tuscany/java/sca/runtime/standalone/server.start/src/main/java/org/apache/tuscany/standalone/server/TuscanyServer.java Mon Jan  1 06:55:13 2007
@@ -27,15 +27,18 @@
 import java.util.Map;
 import java.util.concurrent.ConcurrentHashMap;
 
+import javax.management.MBeanServer;
+
+import org.apache.tuscany.host.RuntimeInfo;
 import org.apache.tuscany.host.runtime.InitializationException;
 import org.apache.tuscany.host.runtime.ShutdownException;
 import org.apache.tuscany.host.runtime.TuscanyRuntime;
 import org.apache.tuscany.host.util.LaunchHelper;
-import org.apache.tuscany.runtime.standalone.StandaloneRuntimeInfo;
-import org.apache.tuscany.runtime.standalone.StandaloneRuntimeInfoImpl;
 import org.apache.tuscany.standalone.server.management.jmx.Agent;
 import org.apache.tuscany.standalone.server.management.jmx.RmiAgent;
 
+import org.apache.tuscany.core.services.management.jmx.runtime.JmxRuntimeInfoImpl;
+
 /**
  * This class provides the commandline interface for starting the 
  * tuscany standalone server. 
@@ -66,27 +69,27 @@
  *
  */
 public class TuscanyServer implements TuscanyServerMBean {
-    
+
     /** Agent */
     private final Agent agent;
-    
+
     /** Install directory */
     private final File installDirectory;
-    
+
     /** Base Url */
     private final URL baseUrl;
-    
+
     /** Started runtimes. */
     private final Map<String, TuscanyRuntime> bootedRuntimes = new ConcurrentHashMap<String, TuscanyRuntime>();
-    
+
     /**
      * 
      * @param args Commandline arguments.
      */
-    public static void main(String[] args) throws Exception {  
+    public static void main(String[] args) throws Exception {
         new TuscanyServer().start();
     }
-    
+
     /**
      * Constructor initializes all the required classloaders.
      * @throws MalformedURLException 
@@ -94,41 +97,43 @@
      */
     private TuscanyServer() throws MalformedURLException {
         installDirectory = DirectoryHelper.getInstallDirectory();
-        baseUrl = installDirectory.toURI().toURL(); 
+        baseUrl = installDirectory.toURI().toURL();
         agent = RmiAgent.getInstance();
     }
-    
+
     /**
      * @see org.apache.tuscany.standalone.server.TuscanyServerMBean#startRuntime(java.lang.String, boolean)
      */
     public final void startRuntime(final String bootPath, final boolean online, final String managementDomain) {
-        
+
         try {
-            
+
             final File bootDirectory = DirectoryHelper.getBootDirectory(installDirectory, bootPath);
-            
-            final StandaloneRuntimeInfo runtimeInfo = new StandaloneRuntimeInfoImpl(baseUrl, installDirectory, installDirectory, online);
+
+            final MBeanServer mBeanServer = agent.getMBeanServer();
+            final RuntimeInfo runtimeInfo = new JmxRuntimeInfoImpl(baseUrl, installDirectory, online, mBeanServer, managementDomain);
 
             final ClassLoader hostClassLoader = ClassLoader.getSystemClassLoader();
             final ClassLoader bootClassLoader = getTuscanyClassLoader(bootDirectory);
-            
+
             final URL systemScdl = getSystemScdl(bootClassLoader);
-            if(systemScdl == null) {
+            if (systemScdl == null) {
                 throw new TuscanyServerException("Unable to find system scdl");
             }
 
-            final String className = System.getProperty("tuscany.launcherClass",
-                "org.apache.tuscany.runtime.standalone.host.StandaloneRuntimeImpl");
-            final TuscanyRuntime runtime = (TuscanyRuntime) Beans.instantiate(bootClassLoader, className);
+            final String className =
+                System.getProperty("tuscany.launcherClass",
+                                   "org.apache.tuscany.core.services.management.jmx.runtime.JmxRuntimeImpl");
+            final TuscanyRuntime runtime = (TuscanyRuntime)Beans.instantiate(bootClassLoader, className);
             runtime.setMonitorFactory(runtime.createDefaultMonitorFactory());
             runtime.setSystemScdl(systemScdl);
             runtime.setHostClassLoader(hostClassLoader);
-            
+
             runtime.setRuntimeInfo(runtimeInfo);
             runtime.initialize();
-            
+
             bootedRuntimes.put(bootPath, runtime);
-            
+
         } catch (InitializationException ex) {
             throw new TuscanyServerException(ex);
         } catch (IOException ex) {
@@ -136,42 +141,42 @@
         } catch (ClassNotFoundException ex) {
             throw new TuscanyServerException(ex);
         }
-        
+
         System.err.println("Started");
-        
+
     }
 
     /**
      * @see org.apache.tuscany.standalone.server.TuscanyServerMBean#shutdownRuntime(java.lang.String)
      */
     public final void shutdownRuntime(String bootPath) {
-        
+
         try {
             TuscanyRuntime runtime = bootedRuntimes.get(bootPath);
-            if(runtime != null) {
+            if (runtime != null) {
                 runtime.destroy();
                 bootedRuntimes.remove(runtime);
                 runtime = null;
             }
-        } catch(ShutdownException ex) {
+        } catch (ShutdownException ex) {
             throw new TuscanyServerException(ex);
         }
-        
+
     }
-    
+
     /**
      * Starts the server.
      *
      */
     public final void shutdown() {
-        
-        for(String bootPath : bootedRuntimes.keySet()) {
+
+        for (String bootPath : bootedRuntimes.keySet()) {
             shutdownRuntime(bootPath);
         }
         agent.shutdown();
         System.err.println("Shutdown");
         System.exit(0);
-        
+
     }
 
     /**
@@ -193,13 +198,13 @@
         String resource = System.getProperty("tuscany.systemScdlPath", "META-INF/tuscany/system.scdl");
         return bootClassLoader.getResource(resource);
     }
-    
+
     /**
      * Starts the server and starts the JMX agent.
      *
      */
-    private void start() {       
-        agent.start();        
+    private void start() {
+        agent.start();
         agent.register(this, "tuscany:type=server,name=tuscanyServer");
     }
 

Modified: incubator/tuscany/java/sca/runtime/standalone/server.start/src/main/java/org/apache/tuscany/standalone/server/management/jmx/AbstractAgent.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/runtime/standalone/server.start/src/main/java/org/apache/tuscany/standalone/server/management/jmx/AbstractAgent.java?view=diff&rev=491580&r1=491579&r2=491580
==============================================================================
--- incubator/tuscany/java/sca/runtime/standalone/server.start/src/main/java/org/apache/tuscany/standalone/server/management/jmx/AbstractAgent.java (original)
+++ incubator/tuscany/java/sca/runtime/standalone/server.start/src/main/java/org/apache/tuscany/standalone/server/management/jmx/AbstractAgent.java Mon Jan  1 06:55:13 2007
@@ -55,6 +55,13 @@
     protected AbstractAgent() throws ManagementException {        
         mBeanServer = MBeanServerFactory.createMBeanServer(DOMAIN);        
     }
+    
+    /**
+     * @see org.apache.tuscany.standalone.server.management.jmx.Agent#getMBeanServer()
+     */
+    public MBeanServer getMBeanServer() {
+        return mBeanServer;
+    }
 
     /**
      * @see org.apache.tuscany.standalone.server.management.jmx.Agent#register(java.lang.Object, java.lang.String)

Modified: incubator/tuscany/java/sca/runtime/standalone/server.start/src/main/java/org/apache/tuscany/standalone/server/management/jmx/Agent.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/runtime/standalone/server.start/src/main/java/org/apache/tuscany/standalone/server/management/jmx/Agent.java?view=diff&rev=491580&r1=491579&r2=491580
==============================================================================
--- incubator/tuscany/java/sca/runtime/standalone/server.start/src/main/java/org/apache/tuscany/standalone/server/management/jmx/Agent.java (original)
+++ incubator/tuscany/java/sca/runtime/standalone/server.start/src/main/java/org/apache/tuscany/standalone/server/management/jmx/Agent.java Mon Jan  1 06:55:13 2007
@@ -18,6 +18,8 @@
  */
 package org.apache.tuscany.standalone.server.management.jmx;
 
+import javax.management.MBeanServer;
+
 /**
  * Interface to a JMX agent.
  * @version $Revision$ $Date$
@@ -44,5 +46,11 @@
      * @throws ManagementException If unable to shutdown the server.
      */
     void shutdown() throws ManagementException;
+    
+    /**
+     * Gets the MBean server used by the agent.
+     * @return MBean server used by the agent.
+     */
+    MBeanServer getMBeanServer();
 
 }



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