geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ga...@apache.org
Subject svn commit: r1136627 - in /geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core: GeronimoConnectionFactory.java GeronimoServerBehaviour.java
Date Thu, 16 Jun 2011 19:49:45 GMT
Author: gawor
Date: Thu Jun 16 19:49:45 2011
New Revision: 1136627

URL: http://svn.apache.org/viewvc?rev=1136627&view=rev
Log:
Use kernel from DeploymentManager to get the publish directory

Modified:
    geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/GeronimoConnectionFactory.java
    geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/GeronimoServerBehaviour.java

Modified: geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/GeronimoConnectionFactory.java
URL: http://svn.apache.org/viewvc/geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/GeronimoConnectionFactory.java?rev=1136627&r1=1136626&r2=1136627&view=diff
==============================================================================
--- geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/GeronimoConnectionFactory.java
(original)
+++ geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/GeronimoConnectionFactory.java
Thu Jun 16 19:49:45 2011
@@ -16,8 +16,9 @@
  */
 package org.apache.geronimo.st.v30.core;
 
+import java.util.Collections;
 import java.util.HashMap;
-import java.util.Iterator;
+import java.util.Map;
 
 import javax.enterprise.deploy.spi.DeploymentManager;
 import javax.enterprise.deploy.spi.exceptions.DeploymentManagerCreationException;
@@ -27,14 +28,14 @@ import javax.naming.Context;
 import org.apache.geronimo.st.v30.core.internal.Trace;
 import org.eclipse.core.runtime.NullProgressMonitor;
 import org.eclipse.wst.server.core.IServer;
-import org.eclipse.wst.server.core.ServerCore;
 
 /**
  * @version $Rev$ $Date$
  */
 public class GeronimoConnectionFactory {
 
-    private HashMap connections = new HashMap();
+    private Map<String, DeploymentManager> connections = 
+        Collections.synchronizedMap(new HashMap<String, DeploymentManager>());
 
     private static GeronimoConnectionFactory instance;
 
@@ -49,24 +50,22 @@ public class GeronimoConnectionFactory {
         return instance;
     }
 
-    public DeploymentManager getDeploymentManager(IServer server)
-            throws DeploymentManagerCreationException {
-
+    public DeploymentManager getDeploymentManager(IServer server) throws DeploymentManagerCreationException
{
         System.setProperty(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.rmi.registry.RegistryContextFactory");
-        DeploymentManager dm = (DeploymentManager) connections.get(server.getId());
 
+        DeploymentManager dm = (DeploymentManager) connections.get(server.getId());
+        IGeronimoServer geronimoServer = getGeronimoServer(server);
         if (dm == null) {
-            DeploymentFactory factory = getGeronimoServer(server).getDeploymentFactory();
-            String deployerURL = getGeronimoServer(server).getDeployerURL();
+            DeploymentFactory factory = geronimoServer.getDeploymentFactory();
+            String deployerURL = geronimoServer.getDeployerURL();
             Trace.trace(Trace.INFO, "DeployerURL: " + deployerURL, Activator.traceCore);
-            String user = getGeronimoServer(server).getAdminID();
-            String pw = getGeronimoServer(server).getAdminPassword();
+            String user = geronimoServer.getAdminID();
+            String pw = geronimoServer.getAdminPassword();
             dm = factory.getDeploymentManager(deployerURL, user, pw);
             connections.put(server.getId(), dm);
         }
-        
-        getGeronimoServer(server).configureDeploymentManager(dm);
-        
+        geronimoServer.configureDeploymentManager(dm);
+
         return dm;
     }
 
@@ -77,25 +76,13 @@ public class GeronimoConnectionFactory {
         }
         return gServer;
     }
-
-    public IGeronimoServer getGeronimoServer(DeploymentManager dm) {
-        if (dm != null && connections.containsValue(dm)) {
-            Iterator i = connections.keySet().iterator();
-            while (i.hasNext()) {
-                String serverId = (String) i.next();
-                Object o = connections.get(serverId);
-                if (dm.equals(o)) {
-                    IServer server = ServerCore.findServer(serverId);
-                    if (server != null)
-                        return getGeronimoServer(server);
-                }
-            }
-        }
-        return null;
-    }
-
+ 
     public void destroy(IServer server) {
         Trace.trace(Trace.INFO, "deploymentManager destroy", Activator.traceCore);
-        connections.remove(server.getId());
+        DeploymentManager manager = connections.remove(server.getId());        
+        if (manager != null) {
+            // TODO: need to do reference counting or something else before releasing the
connection
+            // manager.release();
+        }
     }
 }

Modified: geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/GeronimoServerBehaviour.java
URL: http://svn.apache.org/viewvc/geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/GeronimoServerBehaviour.java?rev=1136627&r1=1136626&r2=1136627&view=diff
==============================================================================
--- geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/GeronimoServerBehaviour.java
(original)
+++ geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/GeronimoServerBehaviour.java
Thu Jun 16 19:49:45 2011
@@ -22,9 +22,11 @@ import java.util.List;
 import java.util.Map;
 import java.util.Set;
 
+import javax.enterprise.deploy.spi.exceptions.DeploymentManagerCreationException;
 import javax.management.MBeanServerConnection;
 import javax.naming.directory.NoSuchAttributeException;
 
+import org.apache.geronimo.deployment.plugin.jmx.JMXDeploymentManager;
 import org.apache.geronimo.gbean.AbstractName;
 import org.apache.geronimo.gbean.AbstractNameQuery;
 import org.apache.geronimo.gbean.GBeanData;
@@ -234,8 +236,25 @@ public class GeronimoServerBehaviour ext
          return list;
     }
  
+    private Kernel getDeploymentManagerKernel() {
+        GeronimoConnectionFactory connectionFactory = GeronimoConnectionFactory.getInstance();
+        try {
+            JMXDeploymentManager manager =
+                (JMXDeploymentManager) connectionFactory.getDeploymentManager(getServer());
+            return manager.getKernel();
+        } catch (DeploymentManagerCreationException e) {
+            Trace.trace(Trace.WARNING, "Error getting kernel from deployment manager", e,
Activator.logCore);
+            return null;
+        }
+    }
+    
     // TODO: this can be cached 
     public String getWebModuleDocumentBase(String contextPath) {
+        Kernel kernel = getDeploymentManagerKernel();
+        if (kernel == null) {
+            Trace.trace(Trace.WARNING, "Error getting web module document base - no kernel",
null, Activator.logCore);
+            return null;
+        }
         Map<String, String> map = Collections.singletonMap("j2eeType", "WebModule");
         AbstractNameQuery query = new AbstractNameQuery(null, map, Collections.EMPTY_SET);
         Set<AbstractName> webModuleNames = kernel.listGBeans(query);



Mime
View raw message