geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jlaskow...@apache.org
Subject svn commit: r552634 - in /geronimo/sandbox/geronimo-netbeans-plugin/src/main/java/org/apache/geronimo/netbeans: ./ nodes/
Date Tue, 03 Jul 2007 01:00:00 GMT
Author: jlaskowski
Date: Mon Jul  2 17:59:58 2007
New Revision: 552634

URL: http://svn.apache.org/viewvc?view=rev&rev=552634
Log:
Start Geronimo, open NetBeans IDE 6, register the server (the plugin will notice the server
is up), unfold the server node, unfold Web Applications node and voila the list of available
web modules will be displayed, stop the server instance from within NB

Modified:
    geronimo/sandbox/geronimo-netbeans-plugin/src/main/java/org/apache/geronimo/netbeans/GeronimoDeploymentFactory.java
    geronimo/sandbox/geronimo-netbeans-plugin/src/main/java/org/apache/geronimo/netbeans/GeronimoDeploymentManager.java
    geronimo/sandbox/geronimo-netbeans-plugin/src/main/java/org/apache/geronimo/netbeans/nodes/GeronimoEarModulesChildren.java
    geronimo/sandbox/geronimo-netbeans-plugin/src/main/java/org/apache/geronimo/netbeans/nodes/GeronimoWebApplicationsChildren.java
    geronimo/sandbox/geronimo-netbeans-plugin/src/main/java/org/apache/geronimo/netbeans/nodes/GeronimoWebModuleNode.java
    geronimo/sandbox/geronimo-netbeans-plugin/src/main/java/org/apache/geronimo/netbeans/nodes/Util.java

Modified: geronimo/sandbox/geronimo-netbeans-plugin/src/main/java/org/apache/geronimo/netbeans/GeronimoDeploymentFactory.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/geronimo-netbeans-plugin/src/main/java/org/apache/geronimo/netbeans/GeronimoDeploymentFactory.java?view=diff&rev=552634&r1=552633&r2=552634
==============================================================================
--- geronimo/sandbox/geronimo-netbeans-plugin/src/main/java/org/apache/geronimo/netbeans/GeronimoDeploymentFactory.java
(original)
+++ geronimo/sandbox/geronimo-netbeans-plugin/src/main/java/org/apache/geronimo/netbeans/GeronimoDeploymentFactory.java
Mon Jul  2 17:59:58 2007
@@ -67,9 +67,9 @@
 
     final static Logger logger = Logger.getLogger(GeronimoDeploymentFactory.class.toString());
 
-    public static final String URI_PREFIX = "deployer:geronimo:";
+    public static final String URI_PREFIX = "deployer:geronimo:jmx";
 
-    private static final String DISCONNECTED_URI = "deployer:geronimo::localhost:8080";
+    private static final String DISCONNECTED_URI = "deployer:geronimo:jmx:localhost:8080";
 
     private static final String DEPLOYMENT_FACTORY_CLASS_NAME = "org.apache.geronimo.deployment.plugin.factories.DeploymentFactoryImpl";
 
@@ -131,6 +131,17 @@
             }
             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();

Modified: geronimo/sandbox/geronimo-netbeans-plugin/src/main/java/org/apache/geronimo/netbeans/GeronimoDeploymentManager.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/geronimo-netbeans-plugin/src/main/java/org/apache/geronimo/netbeans/GeronimoDeploymentManager.java?view=diff&rev=552634&r1=552633&r2=552634
==============================================================================
--- geronimo/sandbox/geronimo-netbeans-plugin/src/main/java/org/apache/geronimo/netbeans/GeronimoDeploymentManager.java
(original)
+++ geronimo/sandbox/geronimo-netbeans-plugin/src/main/java/org/apache/geronimo/netbeans/GeronimoDeploymentManager.java
Mon Jul  2 17:59:58 2007
@@ -17,10 +17,12 @@
 package org.apache.geronimo.netbeans;
 
 import java.io.File;
+import java.io.IOException;
 import java.io.InputStream;
+import java.net.MalformedURLException;
 import java.net.URLClassLoader;
 import java.util.Collections;
-import java.util.Hashtable;
+import java.util.HashMap;
 import java.util.Locale;
 import java.util.Map;
 import java.util.WeakHashMap;
@@ -37,9 +39,9 @@
 import javax.enterprise.deploy.spi.exceptions.TargetException;
 import javax.enterprise.deploy.spi.status.ProgressObject;
 import javax.management.MBeanServerConnection;
-import javax.naming.InitialContext;
-import javax.naming.NameNotFoundException;
-import javax.naming.NamingException;
+import javax.management.remote.JMXConnector;
+import javax.management.remote.JMXConnectorFactory;
+import javax.management.remote.JMXServiceURL;
 
 import org.apache.geronimo.netbeans.ide.GeronimoJ2eePlatformFactory;
 import org.apache.geronimo.netbeans.ide.ui.GeronimoPluginProperties;
@@ -119,23 +121,17 @@
                 Thread.currentThread().setContextClassLoader(loader);
 
                 GeronimoProperties props = getProperties();
-                Hashtable<String, Object> env = new Hashtable<String, Object>();
-
-                final String JAVA_SEC_AUTH_LOGIN_CONF = "java.security.auth.login.config";
// NOI18N
-                String oldAuthConf = System.getProperty(JAVA_SEC_AUTH_LOGIN_CONF);
-
-                InitialContext ctx = new InitialContext(env);
-
-                // restore java.security.auth.login.config system property
-                if (oldAuthConf != null) {
-                    System.setProperty(JAVA_SEC_AUTH_LOGIN_CONF, oldAuthConf);
-                } else {
-                    System.clearProperty(JAVA_SEC_AUTH_LOGIN_CONF);
-                }
-                rmiServer = (MBeanServerConnection) ctx.lookup("/jmx/invoker/RMIAdaptor");
-            } catch (NameNotFoundException ex) {
-            } catch (NamingException ex) {
-                // Nothing to do
+                Map<String, String[]> env = new HashMap<String, String[]>();
+                String[] credentials = new String[] { props.getUsername(), props.getPassword()
};
+                env.put(JMXConnector.CREDENTIALS, credentials);
+
+                JMXServiceURL address = new JMXServiceURL("service:jmx:rmi:///jndi/rmi://localhost/JMXConnector");
+                JMXConnector jmxConnector = JMXConnectorFactory.connect(address, env);
+                rmiServer = (MBeanServerConnection) jmxConnector.getMBeanServerConnection();
+            } catch (MalformedURLException mue) {
+                mue.printStackTrace();
+            } catch (IOException ioe) {
+                ioe.printStackTrace();
             } finally {
                 if (oldLoader != null)
                     Thread.currentThread().setContextClassLoader(oldLoader);
@@ -219,14 +215,12 @@
 
     public TargetModuleID[] getAvailableModules(ModuleType moduleType, Target[] target) throws
TargetException,
             IllegalStateException {
-        // return dm.getAvailableModules(moduleType, target);
-        return new TargetModuleID[] {};
+        return dm.getAvailableModules(moduleType, target);
     }
 
     public TargetModuleID[] getNonRunningModules(ModuleType moduleType, Target[] target)
throws TargetException,
             IllegalStateException {
-        // return dm.getNonRunningModules(moduleType, target);
-        return new TargetModuleID[] {};
+        return dm.getNonRunningModules(moduleType, target);
     }
 
     public TargetModuleID[] getRunningModules(ModuleType moduleType, Target[] target) throws
TargetException,

Modified: geronimo/sandbox/geronimo-netbeans-plugin/src/main/java/org/apache/geronimo/netbeans/nodes/GeronimoEarModulesChildren.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/geronimo-netbeans-plugin/src/main/java/org/apache/geronimo/netbeans/nodes/GeronimoEarModulesChildren.java?view=diff&rev=552634&r1=552633&r2=552634
==============================================================================
--- geronimo/sandbox/geronimo-netbeans-plugin/src/main/java/org/apache/geronimo/netbeans/nodes/GeronimoEarModulesChildren.java
(original)
+++ geronimo/sandbox/geronimo-netbeans-plugin/src/main/java/org/apache/geronimo/netbeans/nodes/GeronimoEarModulesChildren.java
Mon Jul  2 17:59:58 2007
@@ -57,8 +57,7 @@
                                 keys.add(new GeronimoEjbModuleNode(name, lookup));
                             else if (elem.getKeyProperty("j2eeType").equals("WebModule"))
{
                                 String url = "http://" + dm.getHost() + ":" + dm.getPort();
-                                String context = Util.getWebContextRoot((String) Util.getMBeanParameter(dm,
-                                        "geronimoWebDeploymentDescriptor", elem.getCanonicalName()));
+                                String context = "FIXME - GeronimoEarModulesChildren";
                                 keys.add(new GeronimoWebModuleNode(name, lookup, (context
== null) ? null : url
                                         + context));
                             }

Modified: geronimo/sandbox/geronimo-netbeans-plugin/src/main/java/org/apache/geronimo/netbeans/nodes/GeronimoWebApplicationsChildren.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/geronimo-netbeans-plugin/src/main/java/org/apache/geronimo/netbeans/nodes/GeronimoWebApplicationsChildren.java?view=diff&rev=552634&r1=552633&r2=552634
==============================================================================
--- geronimo/sandbox/geronimo-netbeans-plugin/src/main/java/org/apache/geronimo/netbeans/nodes/GeronimoWebApplicationsChildren.java
(original)
+++ geronimo/sandbox/geronimo-netbeans-plugin/src/main/java/org/apache/geronimo/netbeans/nodes/GeronimoWebApplicationsChildren.java
Mon Jul  2 17:59:58 2007
@@ -1,14 +1,18 @@
 package org.apache.geronimo.netbeans.nodes;
 
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Comparator;
 import java.util.Iterator;
+import java.util.List;
 import java.util.Set;
-import java.util.Vector;
 import java.util.logging.Level;
 import java.util.logging.Logger;
 
+import javax.management.MBeanServerConnection;
 import javax.management.ObjectInstance;
 import javax.management.ObjectName;
-import javax.management.QueryExp;
 
 import org.apache.geronimo.netbeans.GeronimoDeploymentManager;
 import org.apache.geronimo.netbeans.nodes.actions.Refreshable;
@@ -34,56 +38,27 @@
         setKeys(new Object[] { Util.WAIT_NODE });
 
         RequestProcessor.getDefault().post(new Runnable() {
-            Vector keys = new Vector();
+            List<GeronimoWebModuleNode> keys = new ArrayList<GeronimoWebModuleNode>();
 
             public void run() {
                 try {
-                    ObjectName searchPattern;
-                    if (isRemoteManagementSupported()) {
-                        searchPattern = new ObjectName(
-                                "geronimo.management.local:j2eeType=WebModule,J2EEApplication=null,*");
// NOI18N
-                    } else {
-                        searchPattern = new ObjectName("geronimo.web:j2eeType=WebModule,J2EEApplication=none,*");
// NOI18N
-                    }
+                    ObjectName searchPattern = new ObjectName("geronimo:j2eeType=WebModule,J2EEApplication=null,*");
 
-                    Object server = Util.getRMIServer(lookup);
-                    Set managedObj = (Set) server.getClass().getMethod("queryMBeans",
-                            new Class[] { ObjectName.class, QueryExp.class }).invoke(server,
-                            new Object[] { searchPattern, null });
+                    MBeanServerConnection server = Util.getRMIServer(lookup);
+                    Set<ObjectInstance> managedObjSet = (Set<ObjectInstance>)
server.queryMBeans(searchPattern, null);
 
-                    Iterator it = managedObj.iterator();
+                    Iterator<ObjectInstance> it = managedObjSet.iterator();
 
                     GeronimoDeploymentManager dm = (GeronimoDeploymentManager) lookup
                             .lookup(GeronimoDeploymentManager.class);
 
-                    // Query results processing
                     while (it.hasNext()) {
                         try {
-                            ObjectName elem = ((ObjectInstance) it.next()).getObjectName();
-                            String name = elem.getKeyProperty("name");
-                            String url = "http://" + dm.getHost() + ":" + dm.getPort();
-                            String context = "";
-                            if (isRemoteManagementSupported()) {
-                                if ("jmx-console.war".equals(name)) {
-                                    continue;
-                                }
-                                String descr = (String) Util.getMBeanParameter(dm, "geronimoWebDeploymentDescriptor",
-                                        elem.getCanonicalName()); // NOI18N
-                                context = Util.getWebContextRoot(descr);
-                            } else {
-                                if (name.startsWith("//localhost/")) { // NOI18N
-                                    name = name.substring("//localhost/".length()); // NOI18N
-                                }
-                                // excluding system packages
-                                if ("".equals(name) || "jmx-console".equals(name) || "geronimows".equals(name)
-                                        || "web-console".equals(name) || "invoker".equals(name))
{
-                                    continue;
-                                }
-                                name += ".war"; // NOI18N
-
-                                context = (String) Util.getMBeanParameter(dm, "path", elem.getCanonicalName());
// NOI18N
-                            }
-                            keys.add(new GeronimoWebModuleNode(name, lookup, (context ==
null ? null : url + context)));
+                            ObjectName webModule = it.next().getObjectName();
+                            String name = (String) Util.getMBeanParameter(dm, "WARName",
webModule);
+                            String url = ((URL) Util.getMBeanParameter(dm, "URLFor", webModule)).toString();
+                            String context = (String) Util.getMBeanParameter(dm, "contextPath",
webModule);
+                            keys.add(new GeronimoWebModuleNode(context, lookup, url));
                         } catch (Exception ex) {
                             Logger.getLogger("global").log(Level.INFO, null, ex);
                         }
@@ -91,7 +66,11 @@
                 } catch (Exception ex) {
                     Logger.getLogger("global").log(Level.INFO, null, ex);
                 }
-
+                Collections.sort(keys, new Comparator<GeronimoWebModuleNode>() {
+                    public int compare(GeronimoWebModuleNode node1, GeronimoWebModuleNode
node2) {
+                        return node1.getDisplayName().compareTo(node2.getDisplayName());
+                    }
+                });
                 setKeys(keys);
             }
         }, 0);

Modified: geronimo/sandbox/geronimo-netbeans-plugin/src/main/java/org/apache/geronimo/netbeans/nodes/GeronimoWebModuleNode.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/geronimo-netbeans-plugin/src/main/java/org/apache/geronimo/netbeans/nodes/GeronimoWebModuleNode.java?view=diff&rev=552634&r1=552633&r2=552634
==============================================================================
--- geronimo/sandbox/geronimo-netbeans-plugin/src/main/java/org/apache/geronimo/netbeans/nodes/GeronimoWebModuleNode.java
(original)
+++ geronimo/sandbox/geronimo-netbeans-plugin/src/main/java/org/apache/geronimo/netbeans/nodes/GeronimoWebModuleNode.java
Mon Jul  2 17:59:58 2007
@@ -1,3 +1,19 @@
+/**
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
 package org.apache.geronimo.netbeans.nodes;
 
 import java.awt.Image;
@@ -15,19 +31,21 @@
 
 /**
  * Node which describes Web Module.
+ * 
+ * @version $Rev$ $Date$
  */
 public class GeronimoWebModuleNode extends AbstractNode {
 
     final boolean isRemoteManagementSupported;
 
-    public GeronimoWebModuleNode(String fileName, Lookup lookup, String url) {
-        super(new GeronimoServletsChildren(fileName, lookup));
-        setDisplayName(fileName.substring(0, fileName.indexOf('.')));
+    public GeronimoWebModuleNode(String name, Lookup lookup, String url) {
+        super(new GeronimoServletsChildren(name, lookup));
+        setDisplayName(name);
         isRemoteManagementSupported = Util.isRemoteManagementSupported(lookup);
         if (isRemoteManagementSupported) {
             // we cannot find out the .war name w/o the management support, thus
             // we cannot enable the Undeploy action
-            getCookieSet().add(new UndeployModuleCookieImpl(fileName, ModuleType.WAR, lookup));
+            getCookieSet().add(new UndeployModuleCookieImpl(name, ModuleType.WAR, lookup));
         }
 
         if (url != null)

Modified: geronimo/sandbox/geronimo-netbeans-plugin/src/main/java/org/apache/geronimo/netbeans/nodes/Util.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/geronimo-netbeans-plugin/src/main/java/org/apache/geronimo/netbeans/nodes/Util.java?view=diff&rev=552634&r1=552633&r2=552634
==============================================================================
--- geronimo/sandbox/geronimo-netbeans-plugin/src/main/java/org/apache/geronimo/netbeans/nodes/Util.java
(original)
+++ geronimo/sandbox/geronimo-netbeans-plugin/src/main/java/org/apache/geronimo/netbeans/nodes/Util.java
Mon Jul  2 17:59:58 2007
@@ -1,6 +1,5 @@
 package org.apache.geronimo.netbeans.nodes;
 
-import java.io.ByteArrayInputStream;
 import java.io.IOException;
 import java.lang.reflect.InvocationTargetException;
 import java.util.Set;
@@ -16,8 +15,6 @@
 import javax.management.ObjectName;
 import javax.management.QueryExp;
 import javax.management.ReflectionException;
-import javax.xml.parsers.DocumentBuilderFactory;
-import javax.xml.parsers.ParserConfigurationException;
 
 import org.apache.geronimo.netbeans.GeronimoDeploymentManager;
 import org.openide.nodes.AbstractNode;
@@ -25,8 +22,6 @@
 import org.openide.nodes.Node;
 import org.openide.util.Lookup;
 import org.openide.util.NbBundle;
-import org.w3c.dom.Document;
-import org.xml.sax.SAXException;
 
 public class Util {
     public static final String WAIT_NODE = "wait_node"; // NOI18N
@@ -69,31 +64,23 @@
     public static boolean isRemoteManagementSupported(Lookup lookup) {
 
         try {
-            Object server = Util.getRMIServer(lookup);
-            ObjectName searchPattern;
-            searchPattern = new ObjectName("geronimo.management.local:*");
-            Set managedObj = (Set) server.getClass().getMethod("queryMBeans",
-                    new Class[] { ObjectName.class, QueryExp.class }).invoke(server,
-                    new Object[] { searchPattern, null });
-
-            if (managedObj.size() == 0)
+            MBeanServerConnection server = Util.getRMIServer(lookup);
+            ObjectName searchPattern = new ObjectName("geronimo:*");
+            Set managedObjSet = (Set) server.queryMBeans(searchPattern, null);
+            if (managedObjSet.size() == 0) {
                 return false;
+            }
         } catch (SecurityException ex) {
             Logger.getLogger("global").log(Level.INFO, null, ex);
         } catch (IllegalArgumentException ex) {
             Logger.getLogger("global").log(Level.INFO, null, ex);
-        } catch (IllegalAccessException ex) {
-            Logger.getLogger("global").log(Level.INFO, null, ex);
-        } catch (InvocationTargetException ex) {
-            Logger.getLogger("global").log(Level.INFO, null, ex);
-        } catch (NoSuchMethodException ex) {
-            Logger.getLogger("global").log(Level.INFO, null, ex);
         } catch (MalformedObjectNameException ex) {
             Logger.getLogger("global").log(Level.INFO, null, ex);
         } catch (NullPointerException ex) {
             Logger.getLogger("global").log(Level.INFO, null, ex);
+        } catch (IOException ioe) {
+            Logger.getLogger("global").log(Level.INFO, null, ioe);
         }
-
         return true;
     }
 
@@ -143,15 +130,25 @@
      * @return MBean attribute
      */
     public static Object getMBeanParameter(GeronimoDeploymentManager dm, String name, String
targetObject) {
+        Object value = null;
+        try {
+            value = getMBeanParameter(dm, name, new ObjectName(targetObject));
+        } catch (MalformedObjectNameException e) {
+            Logger.getLogger("global").log(Level.INFO, null, e);
+        } catch (NullPointerException e) {
+            Logger.getLogger("global").log(Level.INFO, null, e);
+        }
+        return value;
+    }
+
+    public static Object getMBeanParameter(GeronimoDeploymentManager dm, String name, ObjectName
targetObject) {
         MBeanServerConnection server = dm.refreshRMIServer();
         try {
-            return server.getAttribute(new ObjectName(targetObject), name);
+            return server.getAttribute(targetObject, name);
         } catch (InstanceNotFoundException ex) {
             Logger.getLogger("global").log(Level.INFO, null, ex);
         } catch (AttributeNotFoundException ex) {
             Logger.getLogger("global").log(Level.INFO, null, ex);
-        } catch (MalformedObjectNameException ex) {
-            Logger.getLogger("global").log(Level.INFO, null, ex);
         } catch (NullPointerException ex) {
             // it's normal behaviour when the server is not running
         } catch (IllegalArgumentException ex) {
@@ -165,36 +162,5 @@
         }
 
         return null;
-    }
-
-    /*
-     * Parse web application's deployment descriptor and returns context root
-     * 
-     * @return context-root of web application
-     */
-    public static String getWebContextRoot(String dd) {
-
-        if (dd == null) {
-            return null;
-        }
-
-        Document doc = null;
-
-        try {
-            doc = DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(
-                    new ByteArrayInputStream(dd.getBytes()));
-        } catch (SAXException ex) {
-            Logger.getLogger("global").log(Level.INFO, null, ex);
-            return null;
-        } catch (IOException ex) {
-            Logger.getLogger("global").log(Level.INFO, null, ex);
-            return null;
-        } catch (ParserConfigurationException ex) {
-            Logger.getLogger("global").log(Level.INFO, null, ex);
-        }
-
-        org.w3c.dom.Node node = doc.getElementsByTagName("context-root").item(0);
-
-        return node.getTextContent();
     }
 }



Mime
View raw message