geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jboy...@apache.org
Subject cvs commit: incubator-geronimo/modules/deployment/src/test/org/apache/geronimo/deployment/plugin DeploymentConfigurationTest.java
Date Wed, 02 Jun 2004 06:50:41 GMT
jboynes     2004/06/01 23:50:41

  Modified:    modules/deployment project.xml
               modules/deployment/src/java/org/apache/geronimo/deployment/plugin/factories
                        DeploymentFactoryImpl.java
               modules/deployment/src/java/org/apache/geronimo/deployment/plugin/local
                        CommandSupport.java StartCommand.java
                        StopCommand.java
               modules/deployment/src/test/org/apache/geronimo/deployment/plugin
                        DeploymentConfigurationTest.java
  Added:       modules/deployment/src/java/org/apache/geronimo/deployment/plugin/jmx
                        JMXDeploymentManager.java
  Log:
  Beginning of JSR88 remote deployment support
  
  Revision  Changes    Path
  1.19      +7 -1      incubator-geronimo/modules/deployment/project.xml
  
  Index: project.xml
  ===================================================================
  RCS file: /home/cvs/incubator-geronimo/modules/deployment/project.xml,v
  retrieving revision 1.18
  retrieving revision 1.19
  diff -u -r1.18 -r1.19
  --- project.xml	27 May 2004 05:20:25 -0000	1.18
  +++ project.xml	2 Jun 2004 06:50:41 -0000	1.19
  @@ -94,6 +94,12 @@
           </dependency>
   
           <dependency>
  +            <groupId>mx4j</groupId>
  +            <artifactId>mx4j-remote</artifactId>
  +            <version>2.0.1</version>
  +        </dependency>
  +
  +        <dependency>
               <groupId>commons-logging</groupId>
               <artifactId>commons-logging</artifactId>
               <version>1.0.3</version>
  
  
  
  1.11      +28 -61    incubator-geronimo/modules/deployment/src/java/org/apache/geronimo/deployment/plugin/factories/DeploymentFactoryImpl.java
  
  Index: DeploymentFactoryImpl.java
  ===================================================================
  RCS file: /home/cvs/incubator-geronimo/modules/deployment/src/java/org/apache/geronimo/deployment/plugin/factories/DeploymentFactoryImpl.java,v
  retrieving revision 1.10
  retrieving revision 1.11
  diff -u -r1.10 -r1.11
  --- DeploymentFactoryImpl.java	26 May 2004 07:43:39 -0000	1.10
  +++ DeploymentFactoryImpl.java	2 Jun 2004 06:50:41 -0000	1.11
  @@ -17,19 +17,18 @@
   
   package org.apache.geronimo.deployment.plugin.factories;
   
  -import java.util.Collections;
  -
  +import java.io.IOException;
  +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.ObjectName;
  +import javax.management.remote.JMXConnector;
  +import javax.management.remote.JMXConnectorFactory;
  +import javax.management.remote.JMXServiceURL;
   
  -import org.apache.geronimo.deployment.plugin.DeploymentManagerImpl;
  -import org.apache.geronimo.deployment.plugin.DisconnectedServer;
  -import org.apache.geronimo.deployment.plugin.local.LocalServer;
  -import org.apache.geronimo.gbean.InvalidConfigurationException;
  -import org.apache.geronimo.gbean.jmx.GBeanMBean;
  -import org.apache.geronimo.kernel.Kernel;
  +import org.apache.geronimo.deployment.plugin.jmx.JMXDeploymentManager;
   
   /**
    * Implementation of JSR88 DeploymentFactory.
  @@ -60,12 +59,7 @@
               return null;
           }
   
  -        try {
  -            GBeanMBean server = new GBeanMBean(DisconnectedServer.GBEAN_INFO);
  -            return createManager(server);
  -        } catch (InvalidConfigurationException e) {
  -            throw (IllegalStateException) new IllegalStateException("Unable to create disconnected
server").initCause(e);
  -        }
  +        throw new DeploymentManagerCreationException("Not supported");
       }
   
       public DeploymentManager getDeploymentManager(String uri, String username, String password)
throws DeploymentManagerCreationException {
  @@ -73,55 +67,28 @@
               return null;
           }
   
  -        try {
  -            GBeanMBean server = new GBeanMBean(LocalServer.GBEAN_INFO);
  -            return createManager(server);
  -        } catch (InvalidConfigurationException e) {
  -            throw (IllegalStateException) new IllegalStateException("Unable to create disconnected
server").initCause(e);
  -        }
  -    }
  +        uri = uri.substring(URI_PREFIX.length());
  +        if (uri.startsWith("jmx")) {
   
  -    private DeploymentManager createManager(GBeanMBean server) throws DeploymentManagerCreationException
{
  -        Kernel kernel = new Kernel("geronimo.deployment", "geronimo.deployment");
  -        try {
  -            kernel.boot();
  -        } catch (Exception e) {
  -            throw (DeploymentManagerCreationException) new DeploymentManagerCreationException("Unable
to boot embedded kernel").initCause(e);
  -        }
  +            Map environment = new HashMap();
  +            String[] credentials = new String[]{username, password};
  +            environment.put(JMXConnector.CREDENTIALS, credentials);
  +
  +            try {
  +                JMXServiceURL address = new JMXServiceURL("service:" + uri);
  +                JMXConnector jmxConnector = JMXConnectorFactory.connect(address, environment);
  +                return new JMXDeploymentManager(jmxConnector);
  +            } catch (IOException e) {
  +                throw new DeploymentManagerCreationException(e.getMessage());
  +            }
  +        } else {
  +            throw new DeploymentManagerCreationException("Invalid URI: " + uri);
   
  -        GBeanMBean manager;
  -        try {
  -            ObjectName serverName = new ObjectName("geronimo.deployment:role=DeploymentServer");
  -            kernel.loadGBean(serverName, server);
  -            kernel.startGBean(serverName);
  -
  -            ObjectName managerName = new ObjectName("geronimo.deployment:role=DeploymentManager");
  -            manager = new GBeanMBean(DeploymentManagerImpl.GBEAN_INFO);
  -            manager.setReferencePatterns("Server", Collections.singleton(serverName));
  -            manager.setReferencePatterns("Configurers", Collections.singleton(new ObjectName("geronimo.deployment:role=Configurer,*")));
  -
  -            // @todo for now lets hard code the deployers to use - ultimately this should
use a predefined Configuration
  -
  -            kernel.loadGBean(managerName, manager);
  -            kernel.startGBean(managerName);
  -
  -        } catch (Exception e) {
  -            // this should not happen - we own this kernel!
  -            throw (IllegalStateException) new IllegalStateException("Unable to load DeploymentManager").initCause(e);
           }
  -        return (DeploymentManager) manager.getTarget();
       }
   
  -    private void loadFactory(Kernel kernel, GBeanMBean manager, String factory, String
className, String configurerClassName) throws Exception {
  -        ObjectName earFactoryName = new ObjectName("geronimo.deployment:role=Factory,type="+factory);
  -        GBeanMBean earFactory = new GBeanMBean(className);
  -        kernel.loadGBean(earFactoryName, earFactory);
  -        kernel.startGBean(earFactoryName);
  -        manager.setReferencePatterns(factory+"Factory", Collections.singleton(earFactoryName));
  -
  -        ObjectName configurerName = new ObjectName("geronimo.deployment:role=Configurer,type="+factory);
  -        GBeanMBean configurer = new GBeanMBean(configurerClassName);
  -        kernel.loadGBean(configurerName, configurer);
  -        kernel.startGBean(configurerName);
  +    static {
  +        DeploymentFactoryManager manager = DeploymentFactoryManager.getInstance();
  +        manager.registerDeploymentFactory(new DeploymentFactoryImpl());
       }
   }
  
  
  
  1.1                  incubator-geronimo/modules/deployment/src/java/org/apache/geronimo/deployment/plugin/jmx/JMXDeploymentManager.java
  
  Index: JMXDeploymentManager.java
  ===================================================================
  /**
   *
   * Copyright 2004 The Apache Software Foundation
   *
   *  Licensed 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.jmx;
  
  import java.io.File;
  import java.io.IOException;
  import java.io.InputStream;
  import java.util.Locale;
  import javax.enterprise.deploy.model.DeployableObject;
  import javax.enterprise.deploy.shared.DConfigBeanVersionType;
  import javax.enterprise.deploy.shared.ModuleType;
  import javax.enterprise.deploy.spi.DeploymentConfiguration;
  import javax.enterprise.deploy.spi.DeploymentManager;
  import javax.enterprise.deploy.spi.Target;
  import javax.enterprise.deploy.spi.TargetModuleID;
  import javax.enterprise.deploy.spi.exceptions.DConfigBeanVersionUnsupportedException;
  import javax.enterprise.deploy.spi.exceptions.InvalidModuleException;
  import javax.enterprise.deploy.spi.exceptions.TargetException;
  import javax.enterprise.deploy.spi.status.ProgressObject;
  import javax.management.remote.JMXConnector;
  import javax.management.MBeanServerConnection;
  
  import org.apache.geronimo.kernel.KernelMBean;
  import org.apache.geronimo.kernel.Kernel;
  import org.apache.geronimo.kernel.jmx.MBeanProxyFactory;
  import org.apache.geronimo.deployment.plugin.local.StartCommand;
  import org.apache.geronimo.deployment.plugin.local.StopCommand;
  import org.apache.geronimo.deployment.plugin.TargetImpl;
  
  /**
   * 
   * 
   * @version $Revision: 1.1 $ $Date: 2004/06/02 06:50:41 $
   */
  public class JMXDeploymentManager implements DeploymentManager {
      private JMXConnector jmxConnector;
      private MBeanServerConnection mbServerConnection;
      private KernelMBean kernel;
  
      public JMXDeploymentManager(JMXConnector jmxConnector) throws IOException {
          this.jmxConnector = jmxConnector;
          mbServerConnection = jmxConnector.getMBeanServerConnection();
          kernel = (KernelMBean) MBeanProxyFactory.getProxy(KernelMBean.class, mbServerConnection,
Kernel.KERNEL);
      }
  
      public void release() {
          try {
              jmxConnector.close();
          } catch (IOException e) {
              // can't do much with this
          } finally {
              mbServerConnection = null;
              kernel = null;
          }
      }
  
      public Target[] getTargets() {
          Target target = new TargetImpl("default", null);
          return new Target[]{target};
      }
  
      public TargetModuleID[] getAvailableModules(ModuleType moduleType, Target[] targetList)
throws TargetException {
          throw new UnsupportedOperationException();
      }
  
      public TargetModuleID[] getNonRunningModules(ModuleType moduleType, Target[] targetList)
throws TargetException {
          throw new UnsupportedOperationException();
      }
  
      public TargetModuleID[] getRunningModules(ModuleType moduleType, Target[] targetList)
throws TargetException{
          throw new UnsupportedOperationException();
      }
  
      public ProgressObject distribute(Target[] targetList, File moduleArchive, File deploymentPlan)
{
          throw new UnsupportedOperationException();
      }
  
      public ProgressObject distribute(Target[] targetList, InputStream moduleArchive, InputStream
deploymentPlan) {
          throw new UnsupportedOperationException();
      }
  
      public ProgressObject start(TargetModuleID[] moduleIDList) {
          StartCommand command = new StartCommand(kernel, moduleIDList);
          new Thread(command).start();
          return command;
      }
  
      public ProgressObject stop(TargetModuleID[] moduleIDList) {
          StopCommand command = new StopCommand(kernel, moduleIDList);
          new Thread(command).start();
          return command;
      }
  
      public ProgressObject undeploy(TargetModuleID[] moduleIDList) {
          throw new UnsupportedOperationException();
      }
  
      public boolean isRedeploySupported() {
          throw new UnsupportedOperationException();
      }
  
      public ProgressObject redeploy(TargetModuleID[] moduleIDList, File moduleArchive, File
deploymentPlan) {
          throw new UnsupportedOperationException();
      }
  
      public ProgressObject redeploy(TargetModuleID[] moduleIDList, InputStream moduleArchive,
InputStream deploymentPlan) {
          throw new UnsupportedOperationException();
      }
  
      public Locale[] getSupportedLocales() {
          throw new UnsupportedOperationException();
      }
  
      public Locale getCurrentLocale() {
          throw new UnsupportedOperationException();
      }
  
      public Locale getDefaultLocale() {
          throw new UnsupportedOperationException();
      }
  
      public boolean isLocaleSupported(Locale locale) {
          throw new UnsupportedOperationException();
      }
  
      public void setLocale(Locale locale) {
          throw new UnsupportedOperationException();
      }
  
      public DConfigBeanVersionType getDConfigBeanVersion() {
          throw new UnsupportedOperationException();
      }
  
      public boolean isDConfigBeanVersionSupported(DConfigBeanVersionType version) {
          throw new UnsupportedOperationException();
      }
  
      public void setDConfigBeanVersion(DConfigBeanVersionType version) throws DConfigBeanVersionUnsupportedException
{
          throw new UnsupportedOperationException();
      }
  
      public DeploymentConfiguration createConfiguration(DeployableObject dObj) throws InvalidModuleException
{
          throw new UnsupportedOperationException();
      }
  }
  
  
  
  1.5       +13 -32    incubator-geronimo/modules/deployment/src/java/org/apache/geronimo/deployment/plugin/local/CommandSupport.java
  
  Index: CommandSupport.java
  ===================================================================
  RCS file: /home/cvs/incubator-geronimo/modules/deployment/src/java/org/apache/geronimo/deployment/plugin/local/CommandSupport.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- CommandSupport.java	10 Mar 2004 09:58:49 -0000	1.4
  +++ CommandSupport.java	2 Jun 2004 06:50:41 -0000	1.5
  @@ -19,7 +19,6 @@
   
   import java.util.ArrayList;
   import java.util.HashSet;
  -import java.util.Iterator;
   import java.util.List;
   import java.util.Set;
   import javax.enterprise.deploy.shared.ActionType;
  @@ -93,47 +92,29 @@
           listeners.remove(pol);
       }
   
  -    protected void setState(StateType state) {
  -        Set toNotify;
  -        DeploymentStatus newStatus;
  -        synchronized (this) {
  -            this.state = state;
  -            newStatus = getDeploymentStatus();
  -            toNotify = listeners;
  -        }
  -        sendEvent(toNotify, newStatus);
  +    protected final void fail(String message) {
  +        sendEvent(message, StateType.FAILED);
       }
   
  -    protected void fail(String message) {
  -        Set toNotify;
  -        DeploymentStatus newStatus;
  -        synchronized (this) {
  -            this.message = message;
  -            this.state = StateType.FAILED;
  -            newStatus = getDeploymentStatus();
  -            toNotify = listeners;
  -        }
  -        sendEvent(toNotify, newStatus);
  +    protected final void complete(String message) {
  +        sendEvent(message, StateType.COMPLETED);
       }
   
  -    protected synchronized void complete(String message) {
  -        Set toNotify;
  +    private void sendEvent(String message, StateType state) {
  +        assert !Thread.holdsLock(this) : "Trying to send event whilst holding lock";
  +
  +        ProgressListener[] toNotify;
           DeploymentStatus newStatus;
           synchronized (this) {
               this.message = message;
  -            this.state = StateType.COMPLETED;
  +            this.state = state;
               newStatus = getDeploymentStatus();
  -            toNotify = listeners;
  +            toNotify = (ProgressListener[]) listeners.toArray(new ProgressListener[listeners.size()]);
           }
  -        sendEvent(toNotify, newStatus);
  -    }
   
  -    private void sendEvent(Set toNotify, DeploymentStatus newStatus) {
  -        assert !Thread.holdsLock(this) : "Trying to send event whilst holding lock";
           ProgressEvent event = new ProgressEvent(this, null, newStatus);
  -        for (Iterator i = toNotify.iterator(); i.hasNext();) {
  -            ProgressListener listener = (ProgressListener) i.next();
  -            listener.handleProgressEvent(event);
  +        for (int i = 0; i < toNotify.length; i++) {
  +            toNotify[i].handleProgressEvent(event);
           }
       }
   
  
  
  
  1.5       +5 -8      incubator-geronimo/modules/deployment/src/java/org/apache/geronimo/deployment/plugin/local/StartCommand.java
  
  Index: StartCommand.java
  ===================================================================
  RCS file: /home/cvs/incubator-geronimo/modules/deployment/src/java/org/apache/geronimo/deployment/plugin/local/StartCommand.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- StartCommand.java	10 Mar 2004 09:58:49 -0000	1.4
  +++ StartCommand.java	2 Jun 2004 06:50:41 -0000	1.5
  @@ -20,9 +20,8 @@
   import java.net.URI;
   import javax.enterprise.deploy.shared.CommandType;
   import javax.enterprise.deploy.spi.TargetModuleID;
  -import javax.management.ObjectName;
   
  -import org.apache.geronimo.kernel.Kernel;
  +import org.apache.geronimo.kernel.KernelMBean;
   
   /**
    *
  @@ -30,10 +29,10 @@
    * @version $Revision$ $Date$
    */
   public class StartCommand extends CommandSupport {
  -    private final Kernel kernel;
  +    private final KernelMBean kernel;
       private final TargetModuleID[] modules;
   
  -    public StartCommand(Kernel kernel, TargetModuleID modules[]) {
  +    public StartCommand(KernelMBean kernel, TargetModuleID modules[]) {
           super(CommandType.START);
           this.kernel = kernel;
           this.modules = modules;
  @@ -45,9 +44,7 @@
                   TargetModuleID module = modules[i];
   
                   URI moduleID = URI.create(module.getModuleID());
  -                ObjectName name = kernel.getConfigurationManager().load(moduleID);
  -
  -                kernel.startRecursiveGBean(name);
  +                kernel.startConfiguration(moduleID);
                   addModule(module);
               }
               complete("Completed");
  
  
  
  1.7       +5 -9      incubator-geronimo/modules/deployment/src/java/org/apache/geronimo/deployment/plugin/local/StopCommand.java
  
  Index: StopCommand.java
  ===================================================================
  RCS file: /home/cvs/incubator-geronimo/modules/deployment/src/java/org/apache/geronimo/deployment/plugin/local/StopCommand.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- StopCommand.java	1 Jun 2004 16:06:51 -0000	1.6
  +++ StopCommand.java	2 Jun 2004 06:50:41 -0000	1.7
  @@ -20,10 +20,8 @@
   import java.net.URI;
   import javax.enterprise.deploy.shared.CommandType;
   import javax.enterprise.deploy.spi.TargetModuleID;
  -import javax.management.ObjectName;
   
  -import org.apache.geronimo.kernel.Kernel;
  -import org.apache.geronimo.kernel.config.ConfigurationManager;
  +import org.apache.geronimo.kernel.KernelMBean;
   
   /**
    *
  @@ -31,10 +29,10 @@
    * @version $Revision$ $Date$
    */
   public class StopCommand extends CommandSupport {
  -    private final Kernel kernel;
  +    private final KernelMBean kernel;
       private final TargetModuleID[] modules;
   
  -    public StopCommand(Kernel kernel, TargetModuleID modules[]) {
  +    public StopCommand(KernelMBean kernel, TargetModuleID modules[]) {
           super(CommandType.START);
           this.kernel = kernel;
           this.modules = modules;
  @@ -46,9 +44,7 @@
                   TargetModuleID module = modules[i];
   
                   URI moduleID = URI.create(module.getModuleID());
  -                ConfigurationManager configurationManager = kernel.getConfigurationManager();
  -                ObjectName name = configurationManager.getConfigObjectName(moduleID);
  -                kernel.getMBeanServer().invoke(name, "stop", null, null);
  +                kernel.stopConfiguration(moduleID);
                   addModule(module);
               }
               complete("Completed");
  
  
  
  1.5       +2 -2      incubator-geronimo/modules/deployment/src/test/org/apache/geronimo/deployment/plugin/DeploymentConfigurationTest.java
  
  Index: DeploymentConfigurationTest.java
  ===================================================================
  RCS file: /home/cvs/incubator-geronimo/modules/deployment/src/test/org/apache/geronimo/deployment/plugin/DeploymentConfigurationTest.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- DeploymentConfigurationTest.java	10 Mar 2004 09:58:50 -0000	1.4
  +++ DeploymentConfigurationTest.java	2 Jun 2004 06:50:41 -0000	1.5
  @@ -36,7 +36,7 @@
       private Application deployable;
   
       public void testInit() throws Exception {
  -        DeploymentManager manager = factory.getDisconnectedDeploymentManager("deployer:geronimo:test");
  +//        DeploymentManager manager = factory.getDisconnectedDeploymentManager("deployer:geronimo:test");
           //DeploymentConfiguration config = manager.createConfiguration(deployable);
           //assertEquals(deployable, config.getDeployableObject());
           //assertNull(config.getDConfigBeanRoot(root));
  
  
  

Mime
View raw message