geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jlaskow...@apache.org
Subject svn commit: r559229 - in /geronimo/sandbox/geronimo-netbeans-plugin/src/org/apache/geronimo/netbeans: ./ status/ util/ wizard/
Date Tue, 24 Jul 2007 21:35:50 GMT
Author: jlaskowski
Date: Tue Jul 24 14:35:48 2007
New Revision: 559229

URL: http://svn.apache.org/viewvc?view=rev&rev=559229
Log:
Some (unnecessary) changes that I think should go to the repo though - one functional improvement
is the ability to recognize when a server is up and running

Modified:
    geronimo/sandbox/geronimo-netbeans-plugin/src/org/apache/geronimo/netbeans/GeronimoDeploymentFactory.java
    geronimo/sandbox/geronimo-netbeans-plugin/src/org/apache/geronimo/netbeans/GeronimoDeploymentManager.java
    geronimo/sandbox/geronimo-netbeans-plugin/src/org/apache/geronimo/netbeans/GeronimoInstantiatingIterator.java
    geronimo/sandbox/geronimo-netbeans-plugin/src/org/apache/geronimo/netbeans/GeronimoPluginProperties.java
    geronimo/sandbox/geronimo-netbeans-plugin/src/org/apache/geronimo/netbeans/GeronimoPluginUtils.java
    geronimo/sandbox/geronimo-netbeans-plugin/src/org/apache/geronimo/netbeans/GeronimoStartServer.java
    geronimo/sandbox/geronimo-netbeans-plugin/src/org/apache/geronimo/netbeans/status/GeronimoDeploymentStatus.java
    geronimo/sandbox/geronimo-netbeans-plugin/src/org/apache/geronimo/netbeans/util/GeronimoTailer.java
    geronimo/sandbox/geronimo-netbeans-plugin/src/org/apache/geronimo/netbeans/wizard/Bundle.properties

Modified: geronimo/sandbox/geronimo-netbeans-plugin/src/org/apache/geronimo/netbeans/GeronimoDeploymentFactory.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/geronimo-netbeans-plugin/src/org/apache/geronimo/netbeans/GeronimoDeploymentFactory.java?view=diff&rev=559229&r1=559228&r2=559229
==============================================================================
--- geronimo/sandbox/geronimo-netbeans-plugin/src/org/apache/geronimo/netbeans/GeronimoDeploymentFactory.java
(original)
+++ geronimo/sandbox/geronimo-netbeans-plugin/src/org/apache/geronimo/netbeans/GeronimoDeploymentFactory.java
Tue Jul 24 14:35:48 2007
@@ -16,12 +16,8 @@
  */
 package org.apache.geronimo.netbeans;
 
-import java.io.File;
-import java.net.URL;
 import java.net.URLClassLoader;
-import java.util.ArrayList;
 import java.util.HashMap;
-import java.util.List;
 import java.util.Map;
 import java.util.logging.Level;
 import java.util.logging.Logger;
@@ -29,7 +25,6 @@
 import javax.enterprise.deploy.spi.DeploymentManager;
 import javax.enterprise.deploy.spi.exceptions.DeploymentManagerCreationException;
 import javax.enterprise.deploy.spi.factories.DeploymentFactory;
-import org.netbeans.modules.j2ee.deployment.plugins.api.InstanceProperties;
 import org.openide.util.NbBundle;
 
 /**
@@ -43,12 +38,6 @@
 
     private static final Logger logger = Logger.getLogger(GeronimoDeploymentFactory.class.getName());
 
-    private static final String DEPLOYER_JAR_PATH = "/bin/deployer.jar";
-
-    private static final String SERVER_JAR_PATH = "/bin/server.jar";
-
-    private static final String DEPLOY_JSR88_PARTIAL_JAR_PATH = "/repository/org/apache/geronimo/modules/geronimo-deploy-jsr88/";
-
     private static DeploymentFactory instance;
 
     /**
@@ -105,16 +94,14 @@
         try {
             String serverDir = GeronimoPluginUtils.getInstanceProperties(uri).getProperty(GeronimoPluginProperties.PROPERTY_SERVER_DIR);
 
-            // According to other serverplugins modules:
-            // It happens when we're in a server instance registration process
-            // so InstanceProperties doesn't hold the value, but the singleton does
+            // FIXME: When it's null
             if (serverDir == null) {
                 serverDir = GeronimoPluginProperties.getInstance().getInstallLocation();
             }
             
             factory = factories.get(serverDir);
             if (factory == null) {
-                URLClassLoader loader = getGeronimoClassLoader(serverDir);
+                URLClassLoader loader = GeronimoPluginUtils.getGeronimoClassLoader(serverDir);
                 factory = (DeploymentFactory) loader.loadClass(DEPLOYMENT_FACTORY_CLASS_NAME).newInstance();
                 factories.put(serverDir, factory);
             }
@@ -124,48 +111,4 @@
         return factory;
     }
 
-    private static URLClassLoader getGeronimoClassLoader(String serverRoot) {
-        URLClassLoader loader = null;
-        try {
-            List<URL> urlList = new ArrayList<URL>();
-            {
-                File[] libs = new File(serverRoot + "/lib").listFiles();
-                for (File lib : libs) {
-                    urlList.add(lib.toURI().toURL());
-                }
-            }
-            urlList.add(new File(serverRoot + DEPLOYER_JAR_PATH).toURI().toURL());
-            urlList.add(new File(serverRoot + SERVER_JAR_PATH).toURI().toURL());
-            // FIXME: Remove the static, hardcoded paths
-            final String geronimo_deploy_config_jar = "/repository/org/apache/geronimo/modules/geronimo-deploy-config/2.0-SNAPSHOT/geronimo-deploy-config-2.0-SNAPSHOT.jar";
-            urlList.add(new File(serverRoot + geronimo_deploy_config_jar).toURI().toURL());
-            final String geronimo_system_jar = "/repository/org/apache/geronimo/modules/geronimo-system/2.0-SNAPSHOT/geronimo-system-2.0-SNAPSHOT.jar";
-            urlList.add(new File(serverRoot + geronimo_system_jar).toURI().toURL());
-            final String commons_logging_jar = "/repository/commons-logging/commons-logging/1.0.4/commons-logging-1.0.4.jar";
-            urlList.add(new File(serverRoot + commons_logging_jar).toURI().toURL());
-            final String geronimo_deploy_jsr88 = "/repository/org/apache/geronimo/modules/geronimo-deploy-jsr88/2.0-SNAPSHOT/geronimo-deploy-jsr88-2.0-SNAPSHOT.jar";
-            urlList.add(new File(serverRoot + geronimo_deploy_jsr88).toURI().toURL());
-            final String geronimo_javaee_deployment_spec_jar = "/repository/org/apache/geronimo/specs/geronimo-javaee-deployment_1.1MR3_spec/1.0-SNAPSHOT/geronimo-javaee-deployment_1.1MR3_spec-1.0-SNAPSHOT.jar";
-            urlList.add(new File(serverRoot + geronimo_javaee_deployment_spec_jar).toURI().toURL());
-            // FIXME: Fix the mess with jar versioning
-            {
-                File[] libs = new File(serverRoot + DEPLOY_JSR88_PARTIAL_JAR_PATH).listFiles();
-                String version = "2.0-M6"; // the latest official version
-                for (File lib : libs) {
-                    URL jsr88DirUrl = lib.toURI().toURL();
-                    urlList.add(jsr88DirUrl);
-                    String[] pathParts = jsr88DirUrl.toString().split("/");
-                    version = pathParts[pathParts.length - 1]; // 2.0-SNAPSHOT
-                }
-                File deployJsr88Jar = new File(serverRoot + DEPLOY_JSR88_PARTIAL_JAR_PATH
+ version + File.separator + "geronimo-deploy-jsr88-" + version + ".jar");
-                if (deployJsr88Jar.exists()) {
-                    urlList.add(deployJsr88Jar.toURI().toURL());
-                }
-            }
-            loader = new URLClassLoader(urlList.toArray(new URL[]{}), GeronimoDeploymentFactory.class.getClassLoader());
-        } catch (Exception e) {
-            logger.log(Level.WARNING, e.getLocalizedMessage(), e);
-        }
-        return loader;
-    }
 }

Modified: geronimo/sandbox/geronimo-netbeans-plugin/src/org/apache/geronimo/netbeans/GeronimoDeploymentManager.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/geronimo-netbeans-plugin/src/org/apache/geronimo/netbeans/GeronimoDeploymentManager.java?view=diff&rev=559229&r1=559228&r2=559229
==============================================================================
--- geronimo/sandbox/geronimo-netbeans-plugin/src/org/apache/geronimo/netbeans/GeronimoDeploymentManager.java
(original)
+++ geronimo/sandbox/geronimo-netbeans-plugin/src/org/apache/geronimo/netbeans/GeronimoDeploymentManager.java
Tue Jul 24 14:35:48 2007
@@ -43,7 +43,7 @@
     private DeploymentManager dm;
 
     private String uri;
-    
+
     private InstanceProperties instanceProperties;
 
     public GeronimoDeploymentManager(DeploymentManager dm, String uri) {
@@ -59,19 +59,23 @@
     }
 
     public Target[] getTargets() throws IllegalStateException {
-        return null;
+        Target[] targets = new Target[0];
+        if (dm != null) {
+            targets = dm.getTargets();
+        }
+        return targets;
     }
 
     public TargetModuleID[] getRunningModules(ModuleType moduleType, Target[] target) throws
TargetException, IllegalStateException {
-        return null;
+        return dm.getRunningModules(moduleType, target);
     }
 
     public TargetModuleID[] getNonRunningModules(ModuleType moduleType, Target[] target)
throws TargetException, IllegalStateException {
-        return null;
+        return dm.getNonRunningModules(moduleType, target);
     }
 
     public TargetModuleID[] getAvailableModules(ModuleType moduleType, Target[] target) throws
TargetException, IllegalStateException {
-        return null;
+        return dm.getAvailableModules(moduleType, target);
     }
 
     public DeploymentConfiguration createConfiguration(DeployableObject deployableObject)
throws InvalidModuleException {
@@ -79,23 +83,23 @@
     }
 
     public ProgressObject distribute(Target[] target, File file, File file2) throws IllegalStateException
{
-        return null;
+        return dm.distribute(target, file, file2);
     }
 
     public ProgressObject distribute(Target[] target, InputStream is, InputStream is2) throws
IllegalStateException {
-        return null;
+        return dm.distribute(target, is, is2);
     }
 
     public ProgressObject distribute(Target[] target, ModuleType moduleType, InputStream
is, InputStream is2) throws IllegalStateException {
-        return null;
+        return dm.distribute(target, moduleType, is2, is2);
     }
 
     public ProgressObject start(TargetModuleID[] targetModuleId) throws IllegalStateException
{
-        return null;
+        return dm.start(targetModuleId);
     }
 
     public ProgressObject stop(TargetModuleID[] targetModuleId) throws IllegalStateException
{
-        return null;
+        return dm.stop(targetModuleId);
     }
 
     public ProgressObject undeploy(TargetModuleID[] targetModuleId) throws IllegalStateException
{

Modified: geronimo/sandbox/geronimo-netbeans-plugin/src/org/apache/geronimo/netbeans/GeronimoInstantiatingIterator.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/geronimo-netbeans-plugin/src/org/apache/geronimo/netbeans/GeronimoInstantiatingIterator.java?view=diff&rev=559229&r1=559228&r2=559229
==============================================================================
--- geronimo/sandbox/geronimo-netbeans-plugin/src/org/apache/geronimo/netbeans/GeronimoInstantiatingIterator.java
(original)
+++ geronimo/sandbox/geronimo-netbeans-plugin/src/org/apache/geronimo/netbeans/GeronimoInstantiatingIterator.java
Tue Jul 24 14:35:48 2007
@@ -53,12 +53,17 @@
     public Set instantiate() throws IOException {
         Set<InstanceProperties> result = new HashSet<InstanceProperties>();
         String displayName = (String) wizard.getProperty(PROP_DISPLAY_NAME);
-        String url = GeronimoDeploymentFactory.URI_PREFIX + ":localhost:8080";
-        String username = "username";
-        String password = "password";
+        String username = "system";
+        String password = "manager";
+        String hostname = "localhost";
+        String httpPort = "8080";
+        String url = GeronimoDeploymentFactory.URI_PREFIX + ":" + hostname + ":" + httpPort;
         try {
             InstanceProperties ip = InstanceProperties.createInstanceProperties(url, username,
password, displayName);
             ip.setProperty(GeronimoPluginProperties.PROPERTY_SERVER_DIR, installLocation);
+            ip.setProperty(GeronimoPluginProperties.PROPERTY_HOSTNAME, hostname);
+            // FIXME: Some parameters are in IP and some in GPP
+            ip.setProperty(InstanceProperties.HTTP_PORT_NUMBER, httpPort);
             result.add(ip);
         } catch (Exception ex) {
             String msg = NbBundle.getMessage(GeronimoInstantiatingIterator.class, "MSG_InstanceRegistrationFailed",
displayName);

Modified: geronimo/sandbox/geronimo-netbeans-plugin/src/org/apache/geronimo/netbeans/GeronimoPluginProperties.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/geronimo-netbeans-plugin/src/org/apache/geronimo/netbeans/GeronimoPluginProperties.java?view=diff&rev=559229&r1=559228&r2=559229
==============================================================================
--- geronimo/sandbox/geronimo-netbeans-plugin/src/org/apache/geronimo/netbeans/GeronimoPluginProperties.java
(original)
+++ geronimo/sandbox/geronimo-netbeans-plugin/src/org/apache/geronimo/netbeans/GeronimoPluginProperties.java
Tue Jul 24 14:35:48 2007
@@ -33,7 +33,9 @@
 public class GeronimoPluginProperties {
 
     public static final String PROPERTY_SERVER_DIR = "server-dir";
-    public static final String RMI_PORT_NUMBER = "rmiportnumber";
+    public static final String PROPERTY_RMI_PORT_NUMBER = "rmiportnumber";
+    // FIXME: Handle the settings - save/restore
+    public static final String PROPERTY_HOSTNAME = "hostname";
 
     private static final Logger logger = Logger.getLogger(GeronimoPluginProperties.class.getName());
 

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=559229&r1=559228&r2=559229
==============================================================================
--- 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
Tue Jul 24 14:35:48 2007
@@ -18,12 +18,28 @@
 
 import java.io.File;
 import java.io.IOException;
+import java.net.MalformedURLException;
 import java.net.ServerSocket;
+import java.net.URL;
+import java.net.URLClassLoader;
+import java.security.AllPermission;
+import java.security.CodeSource;
+import java.security.PermissionCollection;
+import java.security.Permissions;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Enumeration;
+import java.util.HashMap;
 import java.util.Iterator;
 import java.util.LinkedList;
 import java.util.List;
+import java.util.Map;
 import java.util.logging.Level;
 import java.util.logging.Logger;
+import javax.management.MBeanServerConnection;
+import javax.management.remote.JMXConnector;
+import javax.management.remote.JMXConnectorFactory;
+import javax.management.remote.JMXServiceURL;
 import javax.swing.SwingUtilities;
 import org.netbeans.modules.j2ee.deployment.plugins.api.InstanceCreationException;
 import org.netbeans.modules.j2ee.deployment.plugins.api.InstanceProperties;
@@ -38,6 +54,12 @@
 
     private static final Logger logger = Logger.getLogger(GeronimoPluginUtils.class.getName());
 
+    private static final String DEPLOYER_JAR_PATH = "/bin/deployer.jar";
+
+    private static final String SERVER_JAR_PATH = "/bin/server.jar";
+
+    private static final String DEPLOY_JSR88_PARTIAL_JAR_PATH = "/repository/org/apache/geronimo/modules/geronimo-deploy-jsr88/";
+
     private static List<String> serverRequirements = new LinkedList<String>();
     static {
         serverRequirements.add("bin");
@@ -126,11 +148,103 @@
 
     public static void showInformation(final String msg, final String title) {
         SwingUtilities.invokeLater(new Runnable() {
+
             public void run() {
                 NotifyDescriptor d = new NotifyDescriptor.Message(msg, NotifyDescriptor.INFORMATION_MESSAGE);
                 d.setTitle(title);
                 DialogDisplayer.getDefault().notify(d);
             }
         });
+    }
+
+    public static MBeanServerConnection getRMIServer(String uri) {
+        MBeanServerConnection rmiServer = null;
+        try {
+            InstanceProperties ip = InstanceProperties.getInstanceProperties(uri);
+
+            Map<String, String[]> env = new HashMap<String, String[]>();
+            String username = ip.getProperty(InstanceProperties.USERNAME_ATTR);
+            String password = ip.getProperty(InstanceProperties.PASSWORD_ATTR);
+            String[] credentials = new String[]{username, password};
+            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);
+            rmiServer = jmxConnector.getMBeanServerConnection();
+        } catch (MalformedURLException mue) {
+            mue.printStackTrace();
+        } catch (IOException ioe) {
+            ioe.printStackTrace();
+        }
+        return rmiServer;
+    }
+
+    public static URLClassLoader getGeronimoClassLoader(String serverRoot) {
+        URLClassLoader loader = null;
+        try {
+            List<URL> urlList = new ArrayList<URL>();
+            {
+                File[] libs = new File(serverRoot + "/lib").listFiles();
+                for (File lib : libs) {
+                    urlList.add(lib.toURI().toURL());
+                }
+            }
+            urlList.add(new File(serverRoot + DEPLOYER_JAR_PATH).toURI().toURL());
+            urlList.add(new File(serverRoot + SERVER_JAR_PATH).toURI().toURL());
+            // FIXME: Remove the static, hardcoded paths
+            final String geronimo_deploy_config_jar = "/repository/org/apache/geronimo/modules/geronimo-deploy-config/2.0-SNAPSHOT/geronimo-deploy-config-2.0-SNAPSHOT.jar";
+            urlList.add(new File(serverRoot + geronimo_deploy_config_jar).toURI().toURL());
+            final String geronimo_system_jar = "/repository/org/apache/geronimo/modules/geronimo-system/2.0-SNAPSHOT/geronimo-system-2.0-SNAPSHOT.jar";
+            urlList.add(new File(serverRoot + geronimo_system_jar).toURI().toURL());
+            final String geronimo_deploy_jsr88 = "/repository/org/apache/geronimo/modules/geronimo-deploy-jsr88/2.0-SNAPSHOT/geronimo-deploy-jsr88-2.0-SNAPSHOT.jar";
+            urlList.add(new File(serverRoot + geronimo_deploy_jsr88).toURI().toURL());
+            final String geronimo_javaee_deployment_spec_jar = "/repository/org/apache/geronimo/specs/geronimo-javaee-deployment_1.1MR3_spec/1.0-SNAPSHOT/geronimo-javaee-deployment_1.1MR3_spec-1.0-SNAPSHOT.jar";
+            urlList.add(new File(serverRoot + geronimo_javaee_deployment_spec_jar).toURI().toURL());
+            // FIXME: Fix the mess with jar versioning
+            {
+                File[] libs = new File(serverRoot + DEPLOY_JSR88_PARTIAL_JAR_PATH).listFiles();
+                String version = "2.0-M6"; // the latest official version
+                for (File lib : libs) {
+                    URL jsr88DirUrl = lib.toURI().toURL();
+                    urlList.add(jsr88DirUrl);
+                    String[] pathParts = jsr88DirUrl.toString().split("/");
+                    version = pathParts[pathParts.length - 1]; // 2.0-SNAPSHOT
+                }
+                File deployJsr88Jar = new File(serverRoot + DEPLOY_JSR88_PARTIAL_JAR_PATH
+ version + File.separator + "geronimo-deploy-jsr88-" + version + ".jar");
+                if (deployJsr88Jar.exists()) {
+                    urlList.add(deployJsr88Jar.toURI().toURL());
+                }
+            }
+            loader = new GeronimoClassLoader(urlList.toArray(new URL[0]), GeronimoDeploymentFactory.class.getClassLoader());
+        } catch (Exception e) {
+            logger.log(Level.WARNING, e.getLocalizedMessage(), e);
+        }
+        return loader;
+    }
+
+    public static class GeronimoClassLoader extends URLClassLoader {
+
+        public GeronimoClassLoader(URL[] urls, ClassLoader parent) throws MalformedURLException,
RuntimeException {
+            super(urls, parent);
+        }
+
+        @Override
+        protected PermissionCollection getPermissions(CodeSource codeSource) {
+            Permissions p = new Permissions();
+            p.add(new AllPermission());
+            return p;
+        }
+
+        @Override
+        public Enumeration<URL> getResources(String name) throws IOException {
+            // get rid of annoying warnings
+            if (name.indexOf("jndi.properties") != -1 || name.indexOf("log4j.xml") != -1)
{
+                return Collections.enumeration(Collections.<URL>emptyList());
+            }
+            return super.getResources(name);
+        }
     }
 }

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=559229&r1=559228&r2=559229
==============================================================================
--- 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
Tue Jul 24 14:35:48 2007
@@ -17,12 +17,19 @@
 package org.apache.geronimo.netbeans;
 
 import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.util.Set;
 import java.util.logging.Level;
 import java.util.logging.Logger;
 import javax.enterprise.deploy.shared.StateType;
 import javax.enterprise.deploy.spi.DeploymentManager;
 import javax.enterprise.deploy.spi.Target;
 import javax.enterprise.deploy.spi.status.ProgressObject;
+import javax.management.MBeanServerConnection;
+import javax.management.ObjectName;
 import org.apache.geronimo.netbeans.status.GeronimoProgressObject;
 import org.apache.geronimo.netbeans.util.GeronimoTailer;
 import org.netbeans.modules.j2ee.deployment.plugins.api.InstanceProperties;
@@ -38,10 +45,6 @@
  */
 public class GeronimoStartServer extends StartServer {
 
-    enum ACTION_STATUS {
-        SUCCESS, FAILURE, UNKNOWN
-    }
-
     private GeronimoDeploymentManager dm;
 
     public GeronimoStartServer(DeploymentManager dm) {
@@ -89,7 +92,35 @@
         return false;
     }
 
+    // FIXME: It should check out more enterprise services than kernel alone
+    // FIXME: Disabled due to Failed to retrieve RMIServer stub: javax.naming.NoInitialContextException
+    public boolean XisRunning() {
+        boolean result = false;
+        try {
+            InstanceProperties ip = dm.getInstanceProperties();
+            String uri = ip.getProperty(InstanceProperties.URL_ATTR);
+
+            MBeanServerConnection mbServerConn = GeronimoPluginUtils.getRMIServer(uri);
+            ObjectName searchPattern = new ObjectName(":role=Kernel");
+            Set<ObjectName> kernel = mbServerConn.queryNames(searchPattern, null);
+            ObjectName kernelObjectName = kernel.iterator().next();
+            result = (Boolean) mbServerConn.getAttribute(kernelObjectName, "running");
+        } catch (Exception ignored) {
+            ignored.printStackTrace();
+        }
+        return result;
+    }
+
     public boolean isRunning() {
+        try {
+            // FIXME: Hardcoded url - use JMX or/and MEJB
+            URL url = new URL("http://localhost:8080");
+            InputStream inputStream = url.openStream();
+            inputStream.read();
+            return true;
+        } catch (MalformedURLException ignored) {
+        } catch (IOException ignored) {
+        }
         return false;
     }
 
@@ -145,23 +176,21 @@
             // dm.getInstanceProperties().getProperty(InstanceProperties.DISPLAY_NAME_ATTR)
             final String uri = dm.getInstanceProperties().getProperty(InstanceProperties.URL_ATTR);
             GeronimoTailer tailer = new GeronimoTailer(serverProcess.getInputStream(), uri);
-            tailer.run();
+            tailer.start();
 
             String serverName = dm.getInstanceProperties().getProperty(InstanceProperties.DISPLAY_NAME_ATTR);
 
             while (System.currentTimeMillis() - startTime < TIMEOUT) {
-                try {
-                    serverProcess.exitValue(); // it throws exception when the subprocess
finished; that's how we know it's started up
-                    try {
-                        Thread.sleep(DELAY);
-                    } catch (InterruptedException e) {
-                    }
-                } catch (IllegalThreadStateException itse) {
-                    fireStateChange(StateType.COMPLETED, NbBundle.getMessage(GeronimoStartServer.class,
"MSG_ServerStarted", serverName));
+                if (isRunning()) {
+                    fireStateChange(StateType.COMPLETED, "MSG_ServerStarted", serverName);
                     return;
                 }
+                try {
+                    Thread.sleep(DELAY);
+                } catch (InterruptedException e) {
+                }
             }
-            fireStateChange(StateType.FAILED, NbBundle.getMessage(GeronimoStartServer.class,
"MSG_StartServerTimeout"));
+            fireStateChange(StateType.FAILED, "MSG_StartServerTimeout");
         }
 
         private boolean checkPorts(final InstanceProperties ip) {
@@ -177,7 +206,7 @@
                     return false;
                 }
 
-                String rmiPortStr = ip.getProperty(GeronimoPluginProperties.RMI_PORT_NUMBER);
+                String rmiPortStr = ip.getProperty(GeronimoPluginProperties.PROPERTY_RMI_PORT_NUMBER);
                 int rmiPort = new Integer(rmiPortStr).intValue();
                 if (!GeronimoPluginUtils.isPortFree(rmiPort)) {
                     String msg = NbBundle.getMessage(GeronimoStartServer.class, "MSG_RmiPortInUse",
serverName, rmiPort);
@@ -199,43 +228,39 @@
 
             //String[] envp = createEnvironment(ip);
             String[] envp = null;
-
             try {
                 return pd.exec(null, envp, true, null);
             } catch (java.io.IOException ioe) {
                 logger.log(Level.INFO, ioe.getLocalizedMessage(), ioe);
-
-                final String serverLocation = ip.getProperty(GeronimoPluginProperties.PROPERTY_SERVER_DIR);
-                final String serverRunFileName = serverLocation + (Utilities.isWindows()
? STARTUP_BAT : STARTUP_SH);
-
-                String serverName = ip.getProperty(InstanceProperties.DISPLAY_NAME_ATTR);
-
-                String msg = NbBundle.getMessage(GeronimoStartServer.class, "MSG_ProcessExecutionFailed",
serverName, serverRunFileName);
-                progressObject.changeState(StateType.FAILED, msg);
-
+                String startupScriptName = getStartupScriptName(ip);
+                final String serverName = ip.getProperty(InstanceProperties.DISPLAY_NAME_ATTR);
+                fireStateChange(StateType.FAILED, "MSG_ProcessExecutionFailed", serverName,
startupScriptName);
                 return null;
             }
         }
 
         private NbProcessDescriptor createProcessDescriptor(InstanceProperties ip) {
-
-            final String serverLocation = ip.getProperty(GeronimoPluginProperties.PROPERTY_SERVER_DIR);
-            final String serverRunFileName = serverLocation + (Utilities.isWindows() ? STARTUP_BAT
: STARTUP_SH);
-            if (!new File(serverRunFileName).exists()) {
+            String startupScriptName = getStartupScriptName(ip);
+            if (!new File(startupScriptName).exists()) {
                 final String serverName = ip.getProperty(InstanceProperties.DISPLAY_NAME_ATTR);
-                String msg = NbBundle.getMessage(GeronimoStartServer.class, "MSG_StartupScriptNotFound",
serverName, serverRunFileName);
-                progressObject.changeState(StateType.FAILED, msg);
+                fireStateChange(StateType.FAILED, "MSG_StartupScriptNotFound", serverName,
startupScriptName);
                 return null;
             }
             String args = "run -vv";
-            return new NbProcessDescriptor(serverRunFileName, args);
+            return new NbProcessDescriptor(startupScriptName, args);
         }
 
-        private void fireStateChange(StateType stateType, String messageKey, String... msgParam)
{
+        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, messageKey, serverName,
msgParam);
+            String msg = NbBundle.getMessage(GeronimoStartServer.class, msgKey, serverName,
msgParams);
             progressObject.changeState(stateType, msg);
+        }
+
+        private String getStartupScriptName(InstanceProperties ip) {
+            String serverLocation = ip.getProperty(GeronimoPluginProperties.PROPERTY_SERVER_DIR);
+            String startupScriptName = serverLocation + (Utilities.isWindows() ? STARTUP_BAT
: STARTUP_SH);
+            return startupScriptName;
         }
     }
 }

Modified: geronimo/sandbox/geronimo-netbeans-plugin/src/org/apache/geronimo/netbeans/status/GeronimoDeploymentStatus.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/geronimo-netbeans-plugin/src/org/apache/geronimo/netbeans/status/GeronimoDeploymentStatus.java?view=diff&rev=559229&r1=559228&r2=559229
==============================================================================
--- geronimo/sandbox/geronimo-netbeans-plugin/src/org/apache/geronimo/netbeans/status/GeronimoDeploymentStatus.java
(original)
+++ geronimo/sandbox/geronimo-netbeans-plugin/src/org/apache/geronimo/netbeans/status/GeronimoDeploymentStatus.java
Tue Jul 24 14:35:48 2007
@@ -39,17 +39,17 @@
         this.state = state;
         this.message = message;
     }
-    
+
     public boolean isCompleted() {
-        return StateType.COMPLETED == state;
+        return StateType.COMPLETED.equals(state);
     }
 
     public boolean isFailed() {
-        return StateType.FAILED == state;
+        return StateType.FAILED.equals(state);
     }
 
     public boolean isRunning() {
-        return StateType.RUNNING == state;
+        return StateType.RUNNING.equals(state);
     }
 
     public StateType getState() {

Modified: geronimo/sandbox/geronimo-netbeans-plugin/src/org/apache/geronimo/netbeans/util/GeronimoTailer.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/geronimo-netbeans-plugin/src/org/apache/geronimo/netbeans/util/GeronimoTailer.java?view=diff&rev=559229&r1=559228&r2=559229
==============================================================================
--- geronimo/sandbox/geronimo-netbeans-plugin/src/org/apache/geronimo/netbeans/util/GeronimoTailer.java
(original)
+++ geronimo/sandbox/geronimo-netbeans-plugin/src/org/apache/geronimo/netbeans/util/GeronimoTailer.java
Tue Jul 24 14:35:48 2007
@@ -31,6 +31,7 @@
 public class GeronimoTailer extends Thread {
 
     private static final Logger logger = Logger.getLogger(GeronimoTailer.class.getName());
+
     /**
      * Input stream to be sent to a console referenced by io
      */
@@ -44,19 +45,29 @@
     /**
      * Delay between checking for file content changes
      */
-    private static final int delay = 1000;
+    private static final int DELAY = 1000;
 
     public GeronimoTailer(InputStream inputStream, String uri) {
+        this(inputStream, uri, true);
+    }
+
+    /**
+     * For booting Geronimo with the <i>run</i> command line option; optionally
clean the output window
+     */
+    public GeronimoTailer(InputStream inputStream, String uri, boolean reset) {
         super();
+        setDaemon(true);
         this.inputStream = inputStream;
         io = UISupport.getServerIO(uri);
         if (io == null) {
             return; // null if there is no registered server instance with the given url.
         }
-        try {
+        if (reset) {
             // Clear the output pane
-            io.getOut().reset();
-        } catch (IOException ioe) {
+            try {
+                io.getOut().reset();
+            } catch (IOException ioe) {
+            }
         }
         // Ensure this pane is visible.
         io.select();
@@ -79,7 +90,7 @@
                     }
                 }
                 try {
-                    Thread.sleep(delay);
+                    Thread.sleep(DELAY);
                 } catch (InterruptedException e) {
                     // do nothing
                 }

Modified: geronimo/sandbox/geronimo-netbeans-plugin/src/org/apache/geronimo/netbeans/wizard/Bundle.properties
URL: http://svn.apache.org/viewvc/geronimo/sandbox/geronimo-netbeans-plugin/src/org/apache/geronimo/netbeans/wizard/Bundle.properties?view=diff&rev=559229&r1=559228&r2=559229
==============================================================================
--- geronimo/sandbox/geronimo-netbeans-plugin/src/org/apache/geronimo/netbeans/wizard/Bundle.properties
(original)
+++ geronimo/sandbox/geronimo-netbeans-plugin/src/org/apache/geronimo/netbeans/wizard/Bundle.properties
Tue Jul 24 14:35:48 2007
@@ -23,4 +23,6 @@
 ACSD_locationBrowseButton=Browse for the server location
 ACSD_locationField=Server Location
 DIRECTORIES_FILTER_NAME=Directories
-ERR_InvalidServerLocation=The entered installation directory is not a valid Geronimo 2.0
directory
\ No newline at end of file
+ERR_InvalidServerLocation=The entered installation directory is not a valid Geronimo 2.0
directory
+
+MSG_SpecifyInstallationFolder=Specify the installation folder (Geronimo Home) and login details



Mime
View raw message