geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jlaskow...@apache.org
Subject svn commit: r559529 - in /geronimo/sandbox/geronimo-netbeans-plugin/src/org/apache/geronimo/netbeans: Bundle.properties GeronimoPluginUtils.java GeronimoStartServer.java
Date Wed, 25 Jul 2007 17:33:50 GMT
Author: jlaskowski
Date: Wed Jul 25 10:33:49 2007
New Revision: 559529

URL: http://svn.apache.org/viewvc?view=rev&rev=559529
Log:
Geronimo start/stop work fine (provided defaults are used)

Modified:
    geronimo/sandbox/geronimo-netbeans-plugin/src/org/apache/geronimo/netbeans/Bundle.properties
    geronimo/sandbox/geronimo-netbeans-plugin/src/org/apache/geronimo/netbeans/GeronimoPluginUtils.java
    geronimo/sandbox/geronimo-netbeans-plugin/src/org/apache/geronimo/netbeans/GeronimoStartServer.java

Modified: geronimo/sandbox/geronimo-netbeans-plugin/src/org/apache/geronimo/netbeans/Bundle.properties
URL: http://svn.apache.org/viewvc/geronimo/sandbox/geronimo-netbeans-plugin/src/org/apache/geronimo/netbeans/Bundle.properties?view=diff&rev=559529&r1=559528&r2=559529
==============================================================================
--- geronimo/sandbox/geronimo-netbeans-plugin/src/org/apache/geronimo/netbeans/Bundle.properties
(original)
+++ geronimo/sandbox/geronimo-netbeans-plugin/src/org/apache/geronimo/netbeans/Bundle.properties
Wed Jul 25 10:33:49 2007
@@ -28,6 +28,7 @@
 MSG_UnknownDeploymentManagerType=Unknown deployment manager type: {0}
 MSG_ExceptionThrownButShouldHaveNot=Exception {0} thrown but it must've not: {1}
 MSG_StartServerInProgress=Starting {0}
+MSG_StopServerInProgress=Stopping {0}
 MSG_HttpPortInUse={0} Start Failed. HTTP Connector port {1} is in use
 MSG_RmiPortInUse={0} Start Failed. RMI Naming Service port {1} is in use.
 MSG_ProcessExecutionFailed={0} Start Failed. Check whether the {1} script is executable.

Modified: geronimo/sandbox/geronimo-netbeans-plugin/src/org/apache/geronimo/netbeans/GeronimoPluginUtils.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/geronimo-netbeans-plugin/src/org/apache/geronimo/netbeans/GeronimoPluginUtils.java?view=diff&rev=559529&r1=559528&r2=559529
==============================================================================
--- geronimo/sandbox/geronimo-netbeans-plugin/src/org/apache/geronimo/netbeans/GeronimoPluginUtils.java
(original)
+++ geronimo/sandbox/geronimo-netbeans-plugin/src/org/apache/geronimo/netbeans/GeronimoPluginUtils.java
Wed Jul 25 10:33:49 2007
@@ -169,7 +169,7 @@
             env.put(JMXConnector.CREDENTIALS, credentials);
 
             Logger.getLogger("javax.management.remote.rmi").setLevel(Level.ALL);
-            
+
             // FIXME: Create the JMXServiceURL based on information provided by user - hostname
and port
             JMXServiceURL address = new JMXServiceURL("service:jmx:rmi:///jndi/rmi://localhost/JMXConnector");
             JMXConnector jmxConnector = JMXConnectorFactory.connect(address, env);

Modified: geronimo/sandbox/geronimo-netbeans-plugin/src/org/apache/geronimo/netbeans/GeronimoStartServer.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/geronimo-netbeans-plugin/src/org/apache/geronimo/netbeans/GeronimoStartServer.java?view=diff&rev=559529&r1=559528&r2=559529
==============================================================================
--- geronimo/sandbox/geronimo-netbeans-plugin/src/org/apache/geronimo/netbeans/GeronimoStartServer.java
(original)
+++ geronimo/sandbox/geronimo-netbeans-plugin/src/org/apache/geronimo/netbeans/GeronimoStartServer.java
Wed Jul 25 10:33:49 2007
@@ -45,6 +45,9 @@
  */
 public class GeronimoStartServer extends StartServer {
 
+    public static final String GERONIMO_SH = "/bin/geronimo.sh";
+    public static final String GERONIMO_BAT = "/bin/geronimo.bat";
+
     private GeronimoDeploymentManager dm;
 
     public GeronimoStartServer(DeploymentManager dm) {
@@ -77,7 +80,16 @@
     }
 
     public ProgressObject stopDeploymentManager() {
-        return null;
+        GeronimoProgressObject progressObject = new GeronimoProgressObject(this);
+
+        String serverName = dm.getInstanceProperties().getProperty(InstanceProperties.DISPLAY_NAME_ATTR);
+        String msg = NbBundle.getMessage(GeronimoStartServer.class, "MSG_StopServerInProgress",
serverName);
+
+        progressObject.changeState(StateType.RUNNING, msg);
+
+        RequestProcessor.getDefault().post(new GeronimoStopRunnable(progressObject), 0, Thread.NORM_PRIORITY);
+
+        return progressObject;
     }
 
     public boolean needsStartForConfigure() {
@@ -136,10 +148,14 @@
         return null;
     }
 
-    private class GeronimoStartRunnable implements Runnable {
+    private String getScriptName(InstanceProperties ip) {
+        String serverLocation = ip.getProperty(GeronimoPluginProperties.PROPERTY_SERVER_DIR);
+        String startupScriptName = serverLocation + (Utilities.isWindows() ? GERONIMO_BAT
: GERONIMO_SH);
+        return startupScriptName;
+    }
 
-        private static final String STARTUP_SH = "/bin/geronimo.sh";
-        private static final String STARTUP_BAT = "/bin/geronimo.bat";
+    // FIXME: GeronimoStartRunnable and GeronimoStopRunnable share much of their code - make
them a single class
+    private class GeronimoStartRunnable implements Runnable {
 
         /**
          * How long the thread will wait till the server has started up
@@ -178,11 +194,9 @@
             GeronimoTailer tailer = new GeronimoTailer(serverProcess.getInputStream(), uri);
             tailer.start();
 
-            String serverName = dm.getInstanceProperties().getProperty(InstanceProperties.DISPLAY_NAME_ATTR);
-
             while (System.currentTimeMillis() - startTime < TIMEOUT) {
                 if (isRunning()) {
-                    fireStateChange(StateType.COMPLETED, "MSG_ServerStarted", serverName);
+                    fireStateChange(StateType.COMPLETED, "MSG_ServerStarted");
                     return;
                 }
                 try {
@@ -230,24 +244,22 @@
             String[] envp = null;
             try {
                 return pd.exec(null, envp, true, null);
-            } catch (java.io.IOException ioe) {
+            } catch (IOException ioe) {
                 logger.log(Level.INFO, ioe.getLocalizedMessage(), ioe);
-                String startupScriptName = getStartupScriptName(ip);
-                final String serverName = ip.getProperty(InstanceProperties.DISPLAY_NAME_ATTR);
-                fireStateChange(StateType.FAILED, "MSG_ProcessExecutionFailed", serverName,
startupScriptName);
+                fireStateChange(StateType.FAILED, "MSG_ProcessExecutionFailed", pd.getProcessName());
                 return null;
             }
         }
 
         private NbProcessDescriptor createProcessDescriptor(InstanceProperties ip) {
-            String startupScriptName = getStartupScriptName(ip);
-            if (!new File(startupScriptName).exists()) {
-                final String serverName = ip.getProperty(InstanceProperties.DISPLAY_NAME_ATTR);
-                fireStateChange(StateType.FAILED, "MSG_StartupScriptNotFound", serverName,
startupScriptName);
+            String scriptName = getScriptName(ip);
+            if (!new File(scriptName).exists()) {
+                fireStateChange(StateType.FAILED, "MSG_StartupScriptNotFound", scriptName);
                 return null;
             }
+            // FIXME: Let user decide what params are used
             String args = "run -vv";
-            return new NbProcessDescriptor(startupScriptName, args);
+            return new NbProcessDescriptor(scriptName, args);
         }
 
         private void fireStateChange(StateType stateType, String msgKey, String... msgParams)
{
@@ -256,11 +268,90 @@
             String msg = NbBundle.getMessage(GeronimoStartServer.class, msgKey, serverName,
msgParams);
             progressObject.changeState(stateType, msg);
         }
+    }
+
+    private class GeronimoStopRunnable implements Runnable {
+
+        /**
+         * How long the thread will wait till the server has started up
+         */
+        private static final int TIMEOUT = 900000;
+
+        /**
+         * How long the thread will wait before doing its stuff again
+         */
+        private static final int DELAY = 5000;
+
+        private final Logger logger = Logger.getLogger(GeronimoStopRunnable.class.getName());
+
+        private GeronimoProgressObject progressObject;
+
+        public GeronimoStopRunnable(GeronimoProgressObject progressObject) {
+            this.progressObject = progressObject;
+        }
+
+        public void run() {
+            InstanceProperties ip = dm.getInstanceProperties();
+
+            final long startTime = System.currentTimeMillis();
+
+            Process serverProcess = createProcess(ip);
+            if (serverProcess == null) {
+                return;
+            }
+
+            // dm.getInstanceProperties().getProperty(InstanceProperties.DISPLAY_NAME_ATTR)
+            final String uri = dm.getInstanceProperties().getProperty(InstanceProperties.URL_ATTR);
+            GeronimoTailer tailer = new GeronimoTailer(serverProcess.getInputStream(), uri);
+            tailer.start();
+
+            while (System.currentTimeMillis() - startTime < TIMEOUT) {
+                if (!isRunning()) {
+                    fireStateChange(StateType.COMPLETED, "MSG_ServerStarted");
+                    return;
+                }
+                try {
+                    Thread.sleep(DELAY);
+                } catch (InterruptedException e) {
+                }
+            }
+            fireStateChange(StateType.FAILED, "MSG_StartServerTimeout");
+        }
+
+        private Process createProcess(InstanceProperties ip) {
+
+            NbProcessDescriptor pd = createProcessDescriptor(ip);
+            if (pd == null) {
+                return null;
+            }
+
+            //String[] envp = createEnvironment(ip);
+            String[] envp = null;
+            try {
+                return pd.exec(null, envp, true, null);
+            } catch (IOException ioe) {
+                logger.log(Level.INFO, ioe.getLocalizedMessage(), ioe);
+                fireStateChange(StateType.FAILED, "MSG_ProcessExecutionFailed", pd.getProcessName());
+                return null;
+            }
+        }
 
-        private String getStartupScriptName(InstanceProperties ip) {
-            String serverLocation = ip.getProperty(GeronimoPluginProperties.PROPERTY_SERVER_DIR);
-            String startupScriptName = serverLocation + (Utilities.isWindows() ? STARTUP_BAT
: STARTUP_SH);
-            return startupScriptName;
+        private NbProcessDescriptor createProcessDescriptor(InstanceProperties ip) {
+            String scriptName = getScriptName(ip);
+            if (!new File(scriptName).exists()) {
+                fireStateChange(StateType.FAILED, "MSG_StartupScriptNotFound", scriptName);
+                return null;
+            }
+            // FIXME: Let user decide what params are used
+            String args = "stop --user system --password manager --port 1099";
+            return new NbProcessDescriptor(scriptName, args);
+        }
+
+        private void fireStateChange(StateType stateType, String msgKey, String... msgParams)
{
+            InstanceProperties ip = dm.getInstanceProperties();
+            final String serverName = ip.getProperty(InstanceProperties.DISPLAY_NAME_ATTR);
+            String msg = NbBundle.getMessage(GeronimoStartServer.class, msgKey, serverName,
msgParams);
+            progressObject.changeState(stateType, msg);
         }
     }
 }



Mime
View raw message