geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gdam...@apache.org
Subject svn commit: r519908 - in /geronimo/server/trunk: configs/jsr88-ear-configurer/ configs/jsr88-jar-configurer/ configs/jsr88-rar-configurer/ configs/jsr88-war-configurer/ modules/geronimo-deploy-jsr88/src/main/java/org/apache/geronimo/deployment/plugin/f...
Date Mon, 19 Mar 2007 11:03:36 GMT
Author: gdamour
Date: Mon Mar 19 04:03:35 2007
New Revision: 519908

URL: http://svn.apache.org/viewvc?view=rev&rev=519908
Log:
* Do not start jsr88-cli within the server. It defines a GBean implementing
the PluginInstaller type, GBean named ModuleConfigurerRegistry, which
is not intended to be used within a server as the other GBeans of this 
module. This causes a NPE during the installation of plugins via the command
line deployer: CommandInstallCAR tries to execute startInstall
against all the GBeans implementing the PluginInstaller type and this
invokation fails with a NPE against ModuleConfigurerRegistry.

* Push up the DeploymentFactoryImpl implementation to BaseDeploymentFactory,
such that DeploymentFactoryWithKernel can extend it instead of 
DeploymentFactoryImpl. This refactoring is done to ensure that 
DeploymentFactoryWithKernel does not register a DeploymentFactoryImpl
instance with DeploymentFactoryManager (done via a static block).

This fixes GERONIMO-2983 Installation of plugins via the command line is 
broken.

Added:
    geronimo/server/trunk/modules/geronimo-deploy-jsr88/src/main/java/org/apache/geronimo/deployment/plugin/factories/BaseDeploymentFactory.java
Modified:
    geronimo/server/trunk/configs/jsr88-ear-configurer/pom.xml
    geronimo/server/trunk/configs/jsr88-jar-configurer/pom.xml
    geronimo/server/trunk/configs/jsr88-rar-configurer/pom.xml
    geronimo/server/trunk/configs/jsr88-war-configurer/pom.xml
    geronimo/server/trunk/modules/geronimo-deploy-jsr88/src/main/java/org/apache/geronimo/deployment/plugin/factories/DeploymentFactoryImpl.java
    geronimo/server/trunk/modules/geronimo-deploy-jsr88/src/main/java/org/apache/geronimo/deployment/plugin/factories/DeploymentFactoryWithKernel.java

Modified: geronimo/server/trunk/configs/jsr88-ear-configurer/pom.xml
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/configs/jsr88-ear-configurer/pom.xml?view=diff&rev=519908&r1=519907&r2=519908
==============================================================================
--- geronimo/server/trunk/configs/jsr88-ear-configurer/pom.xml (original)
+++ geronimo/server/trunk/configs/jsr88-ear-configurer/pom.xml Mon Mar 19 04:03:35 2007
@@ -39,6 +39,7 @@
             <groupId>org.apache.geronimo.configs</groupId>
             <artifactId>jsr88-cli</artifactId>
             <version>${version}</version>
+            <scope>runtime</scope>
             <type>car</type>
         </dependency>
 

Modified: geronimo/server/trunk/configs/jsr88-jar-configurer/pom.xml
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/configs/jsr88-jar-configurer/pom.xml?view=diff&rev=519908&r1=519907&r2=519908
==============================================================================
--- geronimo/server/trunk/configs/jsr88-jar-configurer/pom.xml (original)
+++ geronimo/server/trunk/configs/jsr88-jar-configurer/pom.xml Mon Mar 19 04:03:35 2007
@@ -39,6 +39,7 @@
             <groupId>org.apache.geronimo.configs</groupId>
             <artifactId>jsr88-cli</artifactId>
             <version>${version}</version>
+            <scope>runtime</scope>
             <type>car</type>
         </dependency>
 

Modified: geronimo/server/trunk/configs/jsr88-rar-configurer/pom.xml
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/configs/jsr88-rar-configurer/pom.xml?view=diff&rev=519908&r1=519907&r2=519908
==============================================================================
--- geronimo/server/trunk/configs/jsr88-rar-configurer/pom.xml (original)
+++ geronimo/server/trunk/configs/jsr88-rar-configurer/pom.xml Mon Mar 19 04:03:35 2007
@@ -39,6 +39,7 @@
             <groupId>org.apache.geronimo.configs</groupId>
             <artifactId>jsr88-cli</artifactId>
             <version>${version}</version>
+            <scope>runtime</scope>
             <type>car</type>
         </dependency>
 

Modified: geronimo/server/trunk/configs/jsr88-war-configurer/pom.xml
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/configs/jsr88-war-configurer/pom.xml?view=diff&rev=519908&r1=519907&r2=519908
==============================================================================
--- geronimo/server/trunk/configs/jsr88-war-configurer/pom.xml (original)
+++ geronimo/server/trunk/configs/jsr88-war-configurer/pom.xml Mon Mar 19 04:03:35 2007
@@ -39,6 +39,7 @@
             <groupId>org.apache.geronimo.configs</groupId>
             <artifactId>jsr88-cli</artifactId>
             <version>${version}</version>
+            <scope>runtime</scope>
             <type>car</type>
         </dependency>
 

Added: geronimo/server/trunk/modules/geronimo-deploy-jsr88/src/main/java/org/apache/geronimo/deployment/plugin/factories/BaseDeploymentFactory.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-deploy-jsr88/src/main/java/org/apache/geronimo/deployment/plugin/factories/BaseDeploymentFactory.java?view=auto&rev=519908
==============================================================================
--- geronimo/server/trunk/modules/geronimo-deploy-jsr88/src/main/java/org/apache/geronimo/deployment/plugin/factories/BaseDeploymentFactory.java
(added)
+++ geronimo/server/trunk/modules/geronimo-deploy-jsr88/src/main/java/org/apache/geronimo/deployment/plugin/factories/BaseDeploymentFactory.java
Mon Mar 19 04:03:35 2007
@@ -0,0 +1,206 @@
+/**
+ *  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.deployment.plugin.factories;
+
+import java.io.IOException;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.enterprise.deploy.spi.DeploymentManager;
+import javax.enterprise.deploy.spi.exceptions.DeploymentManagerCreationException;
+import javax.enterprise.deploy.spi.factories.DeploymentFactory;
+import javax.management.remote.JMXConnector;
+import javax.management.remote.JMXConnectorFactory;
+import javax.management.remote.JMXServiceURL;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.geronimo.deployment.ModuleConfigurer;
+import org.apache.geronimo.deployment.plugin.DisconnectedDeploymentManager;
+import org.apache.geronimo.deployment.plugin.jmx.LocalDeploymentManager;
+import org.apache.geronimo.deployment.plugin.jmx.RemoteDeploymentManager;
+import org.apache.geronimo.kernel.KernelRegistry;
+
+/**
+ * Base implementation of JSR88 DeploymentFactory.
+ *
+ * This will create a DeploymentManager using a local Geronimo kernel
+ * to contain the GBeans that are responsible for deploying each module
+ * type.
+ *
+ * @version $Rev: 514067 $ $Date: 2007-03-03 15:17:02 +1100 (Sat, 03 Mar 2007) $
+ */
+public class BaseDeploymentFactory implements DeploymentFactory {
+    private static final Log log = LogFactory.getLog(BaseDeploymentFactory.class);
+
+    public static final String URI_PREFIX = "deployer:geronimo:";
+    private static final int DEFAULT_PORT = 1099;
+
+    public BaseDeploymentFactory() {
+    }
+
+    public String getDisplayName() {
+        return "Apache Geronimo";
+    }
+
+    public String getProductVersion() {
+        return "1.0";
+    }
+
+    public boolean handlesURI(String uri) {
+        return parseURI(uri) != null;
+    }
+
+    private ConnectParams parseURI(String uri) {
+        uri = uri.trim();
+        if(!uri.startsWith(URI_PREFIX)) {
+            return null;
+        }
+        uri = uri.substring(URI_PREFIX.length());
+        int pos = uri.indexOf(":");
+        String protocol = pos == -1 ? uri : uri.substring(0, pos);
+        uri = pos == -1 ? "" : uri.substring(pos+1);
+        if(protocol.equals("jmx")) {
+            if(!uri.startsWith("//")) {
+                return new ConnectParams(protocol, "localhost", DEFAULT_PORT);
+            }
+            uri = uri.substring(2);
+            pos = uri.indexOf(':');
+            if(pos == -1) {
+                return new ConnectParams(protocol, uri.equals("") ? "localhost" : uri, DEFAULT_PORT);
+            }
+            if(uri.indexOf('/', pos+1) > -1) {
+                return null;
+            }
+            if(uri.indexOf(':', pos+1) > -1) {
+                return null;
+            }
+            String host = uri.substring(0, pos);
+            String port = uri.substring(pos+1);
+            try {
+                return new ConnectParams(protocol, host.equals("") ? "localhost" : host,
Integer.parseInt(port));
+            } catch (NumberFormatException e) {
+                return null;
+            }
+        } else if(protocol.equals("inVM")) {
+            if(uri.startsWith("//")) {
+                String kernel = uri.substring(2);
+                return new ConnectParams(protocol, kernel, -1);
+            } else {
+                return new ConnectParams(protocol,
+                        KernelRegistry.getSingleKernel() == null ? null : KernelRegistry.getSingleKernel().getKernelName(),
+                        -1);
+            }
+        } else return null;
+    }
+
+    public DeploymentManager getDisconnectedDeploymentManager(String uri) throws DeploymentManagerCreationException
{
+        if (!handlesURI(uri)) {
+            return null;
+        }
+        
+        Collection<ModuleConfigurer> moduleConfigurers = getModuleConfigurers();
+        return new DisconnectedDeploymentManager(moduleConfigurers);
+    }
+
+    public DeploymentManager getDeploymentManager(String uri, String username, String password)
throws DeploymentManagerCreationException {
+        ConnectParams params = parseURI(uri);
+        if (params == null) {
+            return null;
+        }
+
+        try {
+            if (params.getProtocol().equals("jmx")) {
+                return newRemoteDeploymentManager(username, password, params);
+            } else if(params.getProtocol().equals("inVM")) {
+                return new LocalDeploymentManager(KernelRegistry.getKernel(params.getHost()));
+            } else {
+                throw new DeploymentManagerCreationException("Invalid URI: " + uri);
+            }
+        } catch (RuntimeException e) {
+            // some DeploymentManagerFactories suppress unchecked exceptions - log and rethrow
+            log.error(e.getMessage(), e);
+            throw e;
+        } catch (Error e) {
+            // some DeploymentManagerFactories suppress unchecked exceptions - log and rethrow
+            log.error(e.getMessage(), e);
+            throw e;
+        }
+    }
+
+    protected Collection<ModuleConfigurer> getModuleConfigurers() throws DeploymentManagerCreationException
{
+        return Collections.EMPTY_LIST;
+    }
+
+    protected DeploymentManager newRemoteDeploymentManager(String username, String password,
ConnectParams params) throws DeploymentManagerCreationException, AuthenticationFailedException
{
+        Map environment = new HashMap();
+        String[] credentials = new String[]{username, password};
+        environment.put(JMXConnector.CREDENTIALS, credentials);
+        environment.put(JMXConnectorFactory.DEFAULT_CLASS_LOADER, BaseDeploymentFactory.class.getClassLoader());
+        try {
+            JMXServiceURL address = new JMXServiceURL("service:jmx:rmi:///jndi/rmi://"+params.getHost()+":"+params.getPort()+"/JMXConnector");
+            JMXConnector jmxConnector = JMXConnectorFactory.connect(address, environment);
+            RemoteDeploymentManager manager = getRemoteDeploymentManager();
+            manager.init(jmxConnector, params.getHost());
+            if(!manager.isSameMachine()) {
+                manager.setAuthentication(username, password);
+            }
+            return manager;
+        } catch (IOException e) {
+            throw (DeploymentManagerCreationException)new DeploymentManagerCreationException(e.getMessage()).initCause(e);
+        } catch (SecurityException e) {
+            throw (AuthenticationFailedException) new AuthenticationFailedException("Invalid
login.").initCause(e);
+        }
+    }
+
+    protected RemoteDeploymentManager getRemoteDeploymentManager() throws DeploymentManagerCreationException
{
+        Collection<ModuleConfigurer> moduleConfigurers = getModuleConfigurers();
+        return new RemoteDeploymentManager(moduleConfigurers);
+    }
+
+    private final static class ConnectParams {
+        private String protocol;
+        private String host;
+        private int port;
+
+        public ConnectParams(String protocol, String host, int port) {
+            this.protocol = protocol;
+            this.host = host;
+            this.port = port;
+        }
+
+        public String getProtocol() {
+            return protocol;
+        }
+
+        public String getHost() {
+            return host;
+        }
+
+        public int getPort() {
+            return port;
+        }
+
+        public String toString() {
+            return protocol+" / "+host+" / "+port;
+        }
+    }
+
+}

Modified: geronimo/server/trunk/modules/geronimo-deploy-jsr88/src/main/java/org/apache/geronimo/deployment/plugin/factories/DeploymentFactoryImpl.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-deploy-jsr88/src/main/java/org/apache/geronimo/deployment/plugin/factories/DeploymentFactoryImpl.java?view=diff&rev=519908&r1=519907&r2=519908
==============================================================================
--- geronimo/server/trunk/modules/geronimo-deploy-jsr88/src/main/java/org/apache/geronimo/deployment/plugin/factories/DeploymentFactoryImpl.java
(original)
+++ geronimo/server/trunk/modules/geronimo-deploy-jsr88/src/main/java/org/apache/geronimo/deployment/plugin/factories/DeploymentFactoryImpl.java
Mon Mar 19 04:03:35 2007
@@ -17,27 +17,8 @@
 
 package org.apache.geronimo.deployment.plugin.factories;
 
-import java.io.IOException;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.Map;
-
 import javax.enterprise.deploy.shared.factories.DeploymentFactoryManager;
-import javax.enterprise.deploy.spi.DeploymentManager;
-import javax.enterprise.deploy.spi.exceptions.DeploymentManagerCreationException;
 import javax.enterprise.deploy.spi.factories.DeploymentFactory;
-import javax.management.remote.JMXConnector;
-import javax.management.remote.JMXConnectorFactory;
-import javax.management.remote.JMXServiceURL;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.geronimo.deployment.ModuleConfigurer;
-import org.apache.geronimo.deployment.plugin.DisconnectedDeploymentManager;
-import org.apache.geronimo.deployment.plugin.jmx.LocalDeploymentManager;
-import org.apache.geronimo.deployment.plugin.jmx.RemoteDeploymentManager;
-import org.apache.geronimo.kernel.KernelRegistry;
 
 /**
  * Implementation of JSR88 DeploymentFactory.
@@ -48,165 +29,11 @@
  *
  * @version $Rev$ $Date$
  */
-public class DeploymentFactoryImpl implements DeploymentFactory {
-    private static final Log log = LogFactory.getLog(DeploymentFactoryImpl.class);
-
-    public static final String URI_PREFIX = "deployer:geronimo:";
-    private static final int DEFAULT_PORT = 1099;
-
-    public DeploymentFactoryImpl() {
-    }
-
-    public String getDisplayName() {
-        return "Apache Geronimo";
-    }
-
-    public String getProductVersion() {
-        return "1.0";
-    }
-
-    public boolean handlesURI(String uri) {
-        return parseURI(uri) != null;
-    }
-
-    private ConnectParams parseURI(String uri) {
-        uri = uri.trim();
-        if(!uri.startsWith(URI_PREFIX)) {
-            return null;
-        }
-        uri = uri.substring(URI_PREFIX.length());
-        int pos = uri.indexOf(":");
-        String protocol = pos == -1 ? uri : uri.substring(0, pos);
-        uri = pos == -1 ? "" : uri.substring(pos+1);
-        if(protocol.equals("jmx")) {
-            if(!uri.startsWith("//")) {
-                return new ConnectParams(protocol, "localhost", DEFAULT_PORT);
-            }
-            uri = uri.substring(2);
-            pos = uri.indexOf(':');
-            if(pos == -1) {
-                return new ConnectParams(protocol, uri.equals("") ? "localhost" : uri, DEFAULT_PORT);
-            }
-            if(uri.indexOf('/', pos+1) > -1) {
-                return null;
-            }
-            if(uri.indexOf(':', pos+1) > -1) {
-                return null;
-            }
-            String host = uri.substring(0, pos);
-            String port = uri.substring(pos+1);
-            try {
-                return new ConnectParams(protocol, host.equals("") ? "localhost" : host,
Integer.parseInt(port));
-            } catch (NumberFormatException e) {
-                return null;
-            }
-        } else if(protocol.equals("inVM")) {
-            if(uri.startsWith("//")) {
-                String kernel = uri.substring(2);
-                return new ConnectParams(protocol, kernel, -1);
-            } else {
-                return new ConnectParams(protocol,
-                        KernelRegistry.getSingleKernel() == null ? null : KernelRegistry.getSingleKernel().getKernelName(),
-                        -1);
-            }
-        } else return null;
-    }
-
-    public DeploymentManager getDisconnectedDeploymentManager(String uri) throws DeploymentManagerCreationException
{
-        if (!handlesURI(uri)) {
-            return null;
-        }
-        
-        Collection<ModuleConfigurer> moduleConfigurers = getModuleConfigurers();
-        return new DisconnectedDeploymentManager(moduleConfigurers);
-    }
-
-    public DeploymentManager getDeploymentManager(String uri, String username, String password)
throws DeploymentManagerCreationException {
-        ConnectParams params = parseURI(uri);
-        if (params == null) {
-            return null;
-        }
-
-        try {
-            if (params.getProtocol().equals("jmx")) {
-                return newRemoteDeploymentManager(username, password, params);
-            } else if(params.getProtocol().equals("inVM")) {
-                return new LocalDeploymentManager(KernelRegistry.getKernel(params.getHost()));
-            } else {
-                throw new DeploymentManagerCreationException("Invalid URI: " + uri);
-            }
-        } catch (RuntimeException e) {
-            // some DeploymentManagerFactories suppress unchecked exceptions - log and rethrow
-            log.error(e.getMessage(), e);
-            throw e;
-        } catch (Error e) {
-            // some DeploymentManagerFactories suppress unchecked exceptions - log and rethrow
-            log.error(e.getMessage(), e);
-            throw e;
-        }
-    }
-
-    protected Collection<ModuleConfigurer> getModuleConfigurers() throws DeploymentManagerCreationException
{
-        return Collections.EMPTY_LIST;
-    }
-
-    protected DeploymentManager newRemoteDeploymentManager(String username, String password,
ConnectParams params) throws DeploymentManagerCreationException, AuthenticationFailedException
{
-        Map environment = new HashMap();
-        String[] credentials = new String[]{username, password};
-        environment.put(JMXConnector.CREDENTIALS, credentials);
-        environment.put(JMXConnectorFactory.DEFAULT_CLASS_LOADER, DeploymentFactoryImpl.class.getClassLoader());
-        try {
-            JMXServiceURL address = new JMXServiceURL("service:jmx:rmi:///jndi/rmi://"+params.getHost()+":"+params.getPort()+"/JMXConnector");
-            JMXConnector jmxConnector = JMXConnectorFactory.connect(address, environment);
-            RemoteDeploymentManager manager = getRemoteDeploymentManager();
-            manager.init(jmxConnector, params.getHost());
-            if(!manager.isSameMachine()) {
-                manager.setAuthentication(username, password);
-            }
-            return manager;
-        } catch (IOException e) {
-            throw (DeploymentManagerCreationException)new DeploymentManagerCreationException(e.getMessage()).initCause(e);
-        } catch (SecurityException e) {
-            throw (AuthenticationFailedException) new AuthenticationFailedException("Invalid
login.").initCause(e);
-        }
-    }
-
-    protected RemoteDeploymentManager getRemoteDeploymentManager() throws DeploymentManagerCreationException
{
-        Collection<ModuleConfigurer> moduleConfigurers = getModuleConfigurers();
-        return new RemoteDeploymentManager(moduleConfigurers);
-    }
+public class DeploymentFactoryImpl extends BaseDeploymentFactory implements DeploymentFactory
{
 
     static {
         DeploymentFactoryManager manager = DeploymentFactoryManager.getInstance();
         manager.registerDeploymentFactory(new DeploymentFactoryImpl());
-    }
-
-    private final static class ConnectParams {
-        private String protocol;
-        private String host;
-        private int port;
-
-        public ConnectParams(String protocol, String host, int port) {
-            this.protocol = protocol;
-            this.host = host;
-            this.port = port;
-        }
-
-        public String getProtocol() {
-            return protocol;
-        }
-
-        public String getHost() {
-            return host;
-        }
-
-        public int getPort() {
-            return port;
-        }
-
-        public String toString() {
-            return protocol+" / "+host+" / "+port;
-        }
     }
 
 }

Modified: geronimo/server/trunk/modules/geronimo-deploy-jsr88/src/main/java/org/apache/geronimo/deployment/plugin/factories/DeploymentFactoryWithKernel.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-deploy-jsr88/src/main/java/org/apache/geronimo/deployment/plugin/factories/DeploymentFactoryWithKernel.java?view=diff&rev=519908&r1=519907&r2=519908
==============================================================================
--- geronimo/server/trunk/modules/geronimo-deploy-jsr88/src/main/java/org/apache/geronimo/deployment/plugin/factories/DeploymentFactoryWithKernel.java
(original)
+++ geronimo/server/trunk/modules/geronimo-deploy-jsr88/src/main/java/org/apache/geronimo/deployment/plugin/factories/DeploymentFactoryWithKernel.java
Mon Mar 19 04:03:35 2007
@@ -37,7 +37,7 @@
  *
  * @version $Rev: 503905 $ $Date: 2007-02-06 09:20:49 +1100 (Tue, 06 Feb 2007) $
  */
-public class DeploymentFactoryWithKernel extends DeploymentFactoryImpl {
+public class DeploymentFactoryWithKernel extends BaseDeploymentFactory {
     private final Kernel kernel;
     
     public DeploymentFactoryWithKernel(Kernel kernel) {



Mime
View raw message