geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ammul...@apache.org
Subject cvs commit: incubator-geronimo/modules/core/src/java/org/apache/geronimo/enterprise/deploy/provider JmxServerConnection.java GeronimoDeploymentFactory.java GeronimoDeploymentManager.java ServerConnection.java
Date Wed, 01 Oct 2003 04:46:42 GMT
ammulder    2003/09/30 21:46:42

  Modified:    modules/core/src/conf boot-service.xml
               modules/core/src/java/org/apache/geronimo/console/cli
                        Deployer.java
               modules/core/src/java/org/apache/geronimo/enterprise/deploy/provider
                        GeronimoDeploymentFactory.java
                        GeronimoDeploymentManager.java
                        ServerConnection.java
  Added:       modules/core/src/java/org/apache/geronimo/deployment/app
                        ApplicationDeployer.java ServerTarget.java
               modules/core/src/java/org/apache/geronimo/enterprise/deploy/provider
                        JmxServerConnection.java
  Log:
   - Add the server-side JSR-88 MBean (it's about 5% implemented, though)
   - Update the DeploymentFactory to connect to the server if passed an
     appropriate URL (i.e. deployer:geronimo://localhost)
   - Update the JSR-88 internals to handle failures to communicate with a
     remote server
  
  Revision  Changes    Path
  1.15      +5 -1      incubator-geronimo/modules/core/src/conf/boot-service.xml
  
  Index: boot-service.xml
  ===================================================================
  RCS file: /home/cvs/incubator-geronimo/modules/core/src/conf/boot-service.xml,v
  retrieving revision 1.14
  retrieving revision 1.15
  diff -u -r1.14 -r1.15
  --- boot-service.xml	23 Sep 2003 02:34:27 -0000	1.14
  +++ boot-service.xml	1 Oct 2003 04:46:41 -0000	1.15
  @@ -42,4 +42,8 @@
               name="DeploymentController-DeploymentScanner"
               role="DeploymentScanner"/>
       </mbean>
  +
  +    <mbean code="org.apache.geronimo.deployment.app.ApplicationDeployer"
  +           name="geronimo.deployment:role=ApplicationDeployer">
  +    </mbean> 
   </components>
  
  
  
  1.3       +2 -2      incubator-geronimo/modules/core/src/java/org/apache/geronimo/console/cli/Deployer.java
  
  Index: Deployer.java
  ===================================================================
  RCS file: /home/cvs/incubator-geronimo/modules/core/src/java/org/apache/geronimo/console/cli/Deployer.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- Deployer.java	29 Sep 2003 14:08:01 -0000	1.2
  +++ Deployer.java	1 Oct 2003 04:46:41 -0000	1.3
  @@ -166,7 +166,7 @@
               if(url.equals("")) {
                   url = "deployer:geronimo:";
               }
  -            deployer = DeploymentFactoryManager.getInstance().getDisconnectedDeploymentManager(url);
  +            deployer = DeploymentFactoryManager.getInstance().getDeploymentManager(url,
null, null);
           } catch(DeploymentManagerCreationException e) {
               log.error("Can't create deployment manager",e);
               return false;
  
  
  
  1.1                  incubator-geronimo/modules/core/src/java/org/apache/geronimo/deployment/app/ApplicationDeployer.java
  
  Index: ApplicationDeployer.java
  ===================================================================
  /* ====================================================================
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 2003 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "Apache" and "Apache Software Foundation" and
   *    "Apache Geronimo" must not be used to endorse or promote products
   *    derived from this software without prior written permission. For
   *    written permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache",
   *    "Apache Geronimo", nor may "Apache" appear in their name, without
   *    prior written permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   *
   * ====================================================================
   */
  package org.apache.geronimo.deployment.app;
  
  import java.net.InetAddress;
  import java.net.UnknownHostException;
  import java.net.URL;
  import javax.management.MBeanRegistration;
  import javax.management.MBeanServer;
  import javax.management.ObjectName;
  import javax.enterprise.deploy.spi.Target;
  import javax.enterprise.deploy.spi.TargetModuleID;
  import javax.enterprise.deploy.shared.ModuleType;
  import org.apache.commons.logging.Log;
  import org.apache.commons.logging.LogFactory;
  
  /**
   * This is the server-side back end of the JSR-88 DeploymentManager.
   * Presumably, it will also be invoked by the local directory scanner
   * when a deployable J2EE module is encountered.
   *
   * @jmx:mbean
   *
   * @version $Revision: 1.1 $ $Date: 2003/10/01 04:46:41 $
   */
  public class ApplicationDeployer implements ApplicationDeployerMBean,MBeanRegistration {
      private final static Log log = LogFactory.getLog(ApplicationDeployer.class);
      private MBeanServer server;
  
      /**
       * Creates a new deployer
       *
       * @jmx:managed-constructor
       */
      public ApplicationDeployer() {
      }
  
      public ObjectName preRegister(MBeanServer mBeanServer, ObjectName objectName) throws
Exception {
          this.server = mBeanServer; // we will need this to invoke other JMX components (the
web server, etc.)
          return objectName;
      }
  
      public void postRegister(Boolean aBoolean) {
      }
  
      public void preDeregister() throws Exception {
      }
  
      public void postDeregister() {
      }
      
      /**
       * @jmx:managed-attribute
       */
      public Target[] getTargets() { // this should logically be an operation, but it seems
that operations must have arguments
          try {
              return new Target[]{new ServerTarget(InetAddress.getLocalHost().getHostName())};
          } catch(UnknownHostException e) {
              log.error("Unable to look up local hostname", e);
              return new Target[0];
          }
      }
  
      /**
       * @jmx:managed-operation
       */
      public TargetModuleID[] getRunningModules(ModuleType moduleType, Target[] targetList)
{
          return new TargetModuleID[0]; //todo: implement me
      }
  
      /**
       * @jmx:managed-operation
       */
      public TargetModuleID[] getNonRunningModules(ModuleType moduleType, Target[] targetList)
{
          return new TargetModuleID[0]; //todo: implement me
      }
  
      /**
       * @jmx:managed-operation
       */
      public TargetModuleID[] getAvailableModules(ModuleType moduleType, Target[] targetList)
{
          return new TargetModuleID[0]; //todo: implement me
      }
  
      /**
       * @jmx:managed-operation
       */
      public void distribute(Target[] targetList, URL moduleArchive, URL deploymentPlan) {
          //todo: what should this return?  Some sort of ID that the ProgressObject can poll?
 Perhaps it should use notifications instead?
          //todo: implement me
      }
  
      /**
       * @jmx:managed-operation
       */
      public void distribute(Target[] targetList, byte[] moduleArchive, byte[] deploymentPlan)
{
          //todo: what should this return?  Some sort of ID that the ProgressObject can poll?
 Perhaps it should use notifications instead?
          //todo: implement me
      }
  
      /**
       * @jmx:managed-operation
       */
      public void start(TargetModuleID[] moduleIDList) {
          //todo: what should this return?  Some sort of ID that the ProgressObject can poll?
 Perhaps it should use notifications instead?
          //todo: implement me
      }
  
      /**
       * @jmx:managed-operation
       */
      public void stop(TargetModuleID[] moduleIDList) {
          //todo: what should this return?  Some sort of ID that the ProgressObject can poll?
 Perhaps it should use notifications instead?
          //todo: implement me
      }
  
      /**
       * @jmx:managed-operation
       */
      public void undeploy(TargetModuleID[] moduleIDList) {
          //todo: what should this return?  Some sort of ID that the ProgressObject can poll?
 Perhaps it should use notifications instead?
          //todo: implement me
      }
  
      /**
       * @jmx:managed-operation
       */
      public void redeploy(TargetModuleID[] moduleIDList, URL moduleArchive, URL deploymentPlan)
{
          //todo: what should this return?  Some sort of ID that the ProgressObject can poll?
 Perhaps it should use notifications instead?
          //todo: implement me
      }
  
      /**
       * @jmx:managed-operation
       */
      public void redeploy(TargetModuleID[] moduleIDList, byte[] moduleArchive, byte[] deploymentPlan)
{
          //todo: what should this return?  Some sort of ID that the ProgressObject can poll?
 Perhaps it should use notifications instead?
          //todo: implement me
      }
  
      // ---------------------- Methods required to populate Property Editors ----------------------
  
      /**
       * Used to provide a list of security users/groups/roles that the deployer
       * can map a J2EE security role to.
       *
       * @param securityRealm The security realm in use by the application
       *
       * @return A list of security mapping options, or null if the current user
       *         is not authorized to retrieve that information, or the
       *         information is not available.
       *
       * @jmx:managed-operation
       */
      public String[] getSecurityRoleOptions(String securityRealm) {
          return new String[0]; //todo: implement me
      }
  
      /**
       * Gets a list of the JNDI names of global resources of a particular type
       * defined in the server.  For example, a list of all javax.sql.DataSource
       * resources.  Note that any resources tied to a particular application
       * will not be included.
       *
       * @param resourceClassName The name of the interface that the resource
       *                          should implement (e.g. javax.sql.DataSource).
       *
       * @return A list of the JNDI names of the available resources.  Returns
       *         null of no such resources are available, the current user is
       *         not authorized to retrieve the list, etc.
       *
       * @jmx:managed-operation
       */
      public String[] getResourceJndiNames(String resourceClassName) {
          return new String[0]; //todo: implement me
      }
  }
  
  
  
  1.1                  incubator-geronimo/modules/core/src/java/org/apache/geronimo/deployment/app/ServerTarget.java
  
  Index: ServerTarget.java
  ===================================================================
  package org.apache.geronimo.deployment.app;
  
  import java.io.Serializable;
  import javax.enterprise.deploy.spi.Target;
  
  /**
   * A target representing a single (non-clustered) Geronimo server.
   *
   * @version $Revision: 1.1 $
   */
  public class ServerTarget implements Target, Serializable {
      private String hostname;
  
      public ServerTarget(String hostname) {
          this.hostname = hostname;
      }
  
      public String getName() {
          return hostname;
      }
  
      public String getDescription() {
          return "Geronimo Server on "+hostname;
      }
  }
  
  
  
  1.2       +73 -4     incubator-geronimo/modules/core/src/java/org/apache/geronimo/enterprise/deploy/provider/GeronimoDeploymentFactory.java
  
  Index: GeronimoDeploymentFactory.java
  ===================================================================
  RCS file: /home/cvs/incubator-geronimo/modules/core/src/java/org/apache/geronimo/enterprise/deploy/provider/GeronimoDeploymentFactory.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- GeronimoDeploymentFactory.java	14 Aug 2003 09:37:23 -0000	1.1
  +++ GeronimoDeploymentFactory.java	1 Oct 2003 04:46:42 -0000	1.2
  @@ -94,6 +94,49 @@
       }
   
       /**
  +     * Validates that the entire URI is well-formed, by splitting it up into
  +     * it components.  Assumes that handlesURI has already returned true.
  +     *
  +     * @return The components of the URI, or <tt>null</tt> if the URI is not
valid.
  +     */
  +    private Address parseURI(String uri) {
  +        if(uri.equals(URI_PREFIX)) {
  +            return new Address();
  +        }
  +        if(!uri.startsWith(URI_PREFIX+"//")) {
  +            return null;
  +        }
  +        String end = uri.substring(URI_PREFIX.length()+2);
  +        String server = null, port = null, application = null;
  +        int pos = end.indexOf('/');
  +        if(pos > -1) { // includes an application
  +            if(end.indexOf(',', pos+1) > -1) {
  +                return null;
  +            }
  +            application = end.substring(pos+1);
  +            end = end.substring(0, pos);
  +        }
  +        pos = end.indexOf(':');
  +        if(pos > -1) { // includes a port
  +            if(end.indexOf(':', pos+1) > -1) {
  +                return null;
  +            }
  +            port = end.substring(pos+1);
  +            end = end.substring(0, pos);
  +        }
  +        server = end;
  +        Address add = new Address();
  +        add.server = server;
  +        try {
  +            add.port = port == null ? null : new Integer(port);
  +        } catch(NumberFormatException e) {
  +            return null;
  +        }
  +        add.application = application;
  +        return add;
  +    }
  +
  +    /**
        * Currently always returns a disconnected DeploymentManager, but will
        * eventually return a connected one.
        *
  @@ -103,9 +146,29 @@
        */
       public DeploymentManager getDeploymentManager(String uri, String username, String password)
throws DeploymentManagerCreationException {
           if(!handlesURI(uri)) {
  -            throw new DeploymentManagerCreationException("Invalid URI for "+getDisplayName()+"
"+getProductVersion()+" DeploymentFactory, expecting "+URI_PREFIX+"... got "+uri);
  +            throw new DeploymentManagerCreationException("Invalid URI for "+getDisplayName()+"
"+getProductVersion()+" DeploymentFactory ("+uri+"), expecting "+URI_PREFIX+"...");
  +        }
  +        Address add = parseURI(uri);
  +        if(add == null) {
  +            throw new DeploymentManagerCreationException("Invalid URI for "+getDisplayName()+"
"+getProductVersion()+" DeploymentFactory ("+uri+"), expecting "+URI_PREFIX+"//server:port/application");
  +        }
  +        if(add.server != null) {
  +            if(add.port != null || add.application != null) {
  +                System.err.println("WARNING: Currently, the port and application parts
of the URL are ignored.");
  +            }
  +            try {
  +                ClassLoader old = Thread.currentThread().getContextClassLoader();
  +                //todo: Figure out a way around this (either make everything try the current
CL as well as the TCCL, or set/unset the TCCL on every operation...)
  +                System.err.println("Replacing Context ClassLoader: "+old);
  +                Thread.currentThread().setContextClassLoader(getClass().getClassLoader());
  +                return new GeronimoDeploymentManager(new JmxServerConnection(add.server));
  +            } catch(Exception e) {
  +                e.printStackTrace();
  +                throw new DeploymentManagerCreationException("Unable to connect to Geronimo
server at "+uri+": "+e.getMessage());
  +            }
  +        } else {
  +            return new GeronimoDeploymentManager(new NoServerConnection());
           }
  -        return new GeronimoDeploymentManager(new NoServerConnection());
       }
   
       /**
  @@ -116,7 +179,7 @@
        */
       public DeploymentManager getDisconnectedDeploymentManager(String uri) throws DeploymentManagerCreationException
{
           if(!handlesURI(uri)) {
  -            throw new DeploymentManagerCreationException("Invalid URI for "+getDisplayName()+"
"+getProductVersion()+" DeploymentFactory, expecting "+URI_PREFIX+"... got "+uri);
  +            throw new DeploymentManagerCreationException("Invalid URI for "+getDisplayName()+"
"+getProductVersion()+" DeploymentFactory ("+uri+"), expecting "+URI_PREFIX+"...");
           }
           return new GeronimoDeploymentManager(new NoServerConnection());
       }
  @@ -149,5 +212,11 @@
   
       public String toString() {
           return getDisplayName()+" "+getProductVersion()+" DeploymentFactory";
  +    }
  +
  +    private static class Address {
  +        public String server;
  +        public Integer port;
  +        public String application;
       }
   }
  
  
  
  1.4       +86 -16    incubator-geronimo/modules/core/src/java/org/apache/geronimo/enterprise/deploy/provider/GeronimoDeploymentManager.java
  
  Index: GeronimoDeploymentManager.java
  ===================================================================
  RCS file: /home/cvs/incubator-geronimo/modules/core/src/java/org/apache/geronimo/enterprise/deploy/provider/GeronimoDeploymentManager.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- GeronimoDeploymentManager.java	22 Aug 2003 19:16:34 -0000	1.3
  +++ GeronimoDeploymentManager.java	1 Oct 2003 04:46:42 -0000	1.4
  @@ -58,6 +58,7 @@
   import java.io.File;
   import java.io.InputStream;
   import java.util.Locale;
  +import java.rmi.RemoteException;
   import javax.enterprise.deploy.spi.DeploymentManager;
   import javax.enterprise.deploy.spi.Target;
   import javax.enterprise.deploy.spi.TargetModuleID;
  @@ -87,7 +88,7 @@
       }
   
       public DeploymentConfiguration createConfiguration(DeployableObject dObj) throws InvalidModuleException
{
  -        if (dObj.getType().getValue() == ModuleType.EJB.getValue()) {
  +        if(dObj.getType().getValue() == ModuleType.EJB.getValue()) {
               return new EjbJarDeploymentConfiguration(dObj, new EjbJarRoot(dObj.getDDBeanRoot()));
           } else {
               throw new InvalidModuleException("Can't handle modules of type " + dObj.getType());
  @@ -124,7 +125,7 @@
        *         not the default locale, as changing Locales is not supported.
        */
       public void setLocale(Locale locale) throws UnsupportedOperationException {
  -        if (!locale.equals(Locale.getDefault())) {
  +        if(!locale.equals(Locale.getDefault())) {
               throw new UnsupportedOperationException();
           }
       }
  @@ -164,58 +165,127 @@
        *         version is not 1.4.
        */
       public void setDConfigBeanVersion(DConfigBeanVersionType version) throws DConfigBeanVersionUnsupportedException
{
  -        if (version.getValue() != DConfigBeanVersionType.V1_4.getValue()) {
  +        if(version.getValue() != DConfigBeanVersionType.V1_4.getValue()) {
               throw new DConfigBeanVersionUnsupportedException("This implementation only
supports J2EE 1.4");
           }
       }
   
  +    private void handleRemoteException(RemoteException e) {
  +        if(e.getCause() != null) {
  +            e.getCause().printStackTrace();
  +        } else {
  +            e.printStackTrace();
  +        }
  +        release();
  +    }
  +
       // ---- All of the methods below are handled by the ServerConnection -----
   
       public Target[] getTargets() throws IllegalStateException {
  -        return server.getTargets();
  +        try {
  +            return server.getTargets();
  +        } catch(RemoteException e) {
  +            handleRemoteException(e);
  +            throw new IllegalStateException("Connection to server lost");
  +        }
       }
   
       public TargetModuleID[] getRunningModules(ModuleType moduleType, Target[] targetList)
throws TargetException, IllegalStateException {
  -        return server.getRunningModules(moduleType, targetList);
  +        try {
  +            return server.getRunningModules(moduleType, targetList);
  +        } catch(RemoteException e) {
  +            handleRemoteException(e);
  +            throw new IllegalStateException("Connection to server lost");
  +        }
       }
   
       public TargetModuleID[] getNonRunningModules(ModuleType moduleType, Target[] targetList)
throws TargetException, IllegalStateException {
  -        return server.getNonRunningModules(moduleType, targetList);
  +        try {
  +            return server.getNonRunningModules(moduleType, targetList);
  +        } catch(RemoteException e) {
  +            handleRemoteException(e);
  +            throw new IllegalStateException("Connection to server lost");
  +        }
       }
   
       public TargetModuleID[] getAvailableModules(ModuleType moduleType, Target[] targetList)
throws TargetException, IllegalStateException {
  -        return server.getAvailableModules(moduleType, targetList);
  +        try {
  +            return server.getAvailableModules(moduleType, targetList);
  +        } catch(RemoteException e) {
  +            handleRemoteException(e);
  +            throw new IllegalStateException("Connection to server lost");
  +        }
       }
   
       public ProgressObject distribute(Target[] targetList, File moduleArchive, File deploymentPlan)
throws IllegalStateException {
  -        return server.distribute(targetList, moduleArchive, deploymentPlan);
  +        try {
  +            return server.distribute(targetList, moduleArchive, deploymentPlan);
  +        } catch(RemoteException e) {
  +            handleRemoteException(e);
  +            throw new IllegalStateException("Connection to server lost");
  +        }
       }
   
       public ProgressObject distribute(Target[] targetList, InputStream moduleArchive, InputStream
deploymentPlan) throws IllegalStateException {
  -        return server.distribute(targetList, moduleArchive, deploymentPlan);
  +        try {
  +            return server.distribute(targetList, moduleArchive, deploymentPlan);
  +        } catch(RemoteException e) {
  +            handleRemoteException(e);
  +            throw new IllegalStateException("Connection to server lost");
  +        }
       }
   
       public ProgressObject start(TargetModuleID[] moduleIDList) throws IllegalStateException
{
  -        return server.start(moduleIDList);
  +        try {
  +            return server.start(moduleIDList);
  +        } catch(RemoteException e) {
  +            handleRemoteException(e);
  +            throw new IllegalStateException("Connection to server lost");
  +        }
       }
   
       public ProgressObject stop(TargetModuleID[] moduleIDList) throws IllegalStateException
{
  -        return server.stop(moduleIDList);
  +        try {
  +            return server.stop(moduleIDList);
  +        } catch(RemoteException e) {
  +            handleRemoteException(e);
  +            throw new IllegalStateException("Connection to server lost");
  +        }
       }
   
       public ProgressObject undeploy(TargetModuleID[] moduleIDList) throws IllegalStateException
{
  -        return server.undeploy(moduleIDList);
  +        try {
  +            return server.undeploy(moduleIDList);
  +        } catch(RemoteException e) {
  +            handleRemoteException(e);
  +            throw new IllegalStateException("Connection to server lost");
  +        }
       }
   
       public boolean isRedeploySupported() {
  -        return server.isRedeploySupported();
  +        try {
  +            return server.isRedeploySupported();
  +        } catch(RemoteException e) {
  +            handleRemoteException(e);
  +            return false;
  +        }
       }
   
       public ProgressObject redeploy(TargetModuleID[] moduleIDList, File moduleArchive, File
deploymentPlan) throws UnsupportedOperationException, IllegalStateException {
  -        return server.redeploy(moduleIDList, moduleArchive, deploymentPlan);
  +        try {
  +            return server.redeploy(moduleIDList, moduleArchive, deploymentPlan);
  +        } catch(RemoteException e) {
  +            handleRemoteException(e);
  +            throw new IllegalStateException("Connection to server lost");
  +        }
       }
   
       public ProgressObject redeploy(TargetModuleID[] moduleIDList, InputStream moduleArchive,
InputStream deploymentPlan) throws UnsupportedOperationException, IllegalStateException {
  -        return server.redeploy(moduleIDList, moduleArchive, deploymentPlan);
  +        try {
  +            return server.redeploy(moduleIDList, moduleArchive, deploymentPlan);
  +        } catch(RemoteException e) {
  +            handleRemoteException(e);
  +            throw new IllegalStateException("Connection to server lost");
  +        }
       }
   }
  
  
  
  1.3       +16 -15    incubator-geronimo/modules/core/src/java/org/apache/geronimo/enterprise/deploy/provider/ServerConnection.java
  
  Index: ServerConnection.java
  ===================================================================
  RCS file: /home/cvs/incubator-geronimo/modules/core/src/java/org/apache/geronimo/enterprise/deploy/provider/ServerConnection.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- ServerConnection.java	22 Aug 2003 19:16:34 -0000	1.2
  +++ ServerConnection.java	1 Oct 2003 04:46:42 -0000	1.3
  @@ -57,6 +57,7 @@
   
   import java.io.File;
   import java.io.InputStream;
  +import java.rmi.RemoteException;
   import javax.enterprise.deploy.spi.Target;
   import javax.enterprise.deploy.spi.TargetModuleID;
   import javax.enterprise.deploy.spi.status.ProgressObject;
  @@ -83,62 +84,62 @@
       /**
        * @see javax.enterprise.deploy.spi.DeploymentManager#getTargets
        */
  -    public Target[] getTargets() throws IllegalStateException;
  +    public Target[] getTargets() throws IllegalStateException, RemoteException;
   
       /**
        * @see javax.enterprise.deploy.spi.DeploymentManager#getRunningModules
        */
  -    public TargetModuleID[] getRunningModules(ModuleType moduleType, Target[] targetList)
throws TargetException, IllegalStateException;
  +    public TargetModuleID[] getRunningModules(ModuleType moduleType, Target[] targetList)
throws TargetException, IllegalStateException, RemoteException;
   
       /**
        * @see javax.enterprise.deploy.spi.DeploymentManager#getNonRunningModules
        */
  -    public TargetModuleID[] getNonRunningModules(ModuleType moduleType, Target[] targetList)
throws TargetException, IllegalStateException;
  +    public TargetModuleID[] getNonRunningModules(ModuleType moduleType, Target[] targetList)
throws TargetException, IllegalStateException, RemoteException;
   
       /**
        * @see javax.enterprise.deploy.spi.DeploymentManager#getAvailableModules
        */
  -    public TargetModuleID[] getAvailableModules(ModuleType moduleType, Target[] targetList)
throws TargetException, IllegalStateException;
  +    public TargetModuleID[] getAvailableModules(ModuleType moduleType, Target[] targetList)
throws TargetException, IllegalStateException, RemoteException;
   
       /**
        * @see javax.enterprise.deploy.spi.DeploymentManager#distribute(javax.enterprise.deploy.spi.Target[],
java.io.File, java.io.File)
        */
  -    public ProgressObject distribute(Target[] targetList, File moduleArchive, File deploymentPlan)
throws IllegalStateException;
  +    public ProgressObject distribute(Target[] targetList, File moduleArchive, File deploymentPlan)
throws IllegalStateException, RemoteException;
   
       /**
        * @see javax.enterprise.deploy.spi.DeploymentManager#distribute(javax.enterprise.deploy.spi.Target[],
java.io.InputStream, java.io.InputStream)
        */
  -    public ProgressObject distribute(Target[] targetList, InputStream moduleArchive, InputStream
deploymentPlan) throws IllegalStateException;
  +    public ProgressObject distribute(Target[] targetList, InputStream moduleArchive, InputStream
deploymentPlan) throws IllegalStateException, RemoteException;
   
       /**
        * @see javax.enterprise.deploy.spi.DeploymentManager#start
        */
  -    public ProgressObject start(TargetModuleID[] moduleIDList) throws IllegalStateException;
  +    public ProgressObject start(TargetModuleID[] moduleIDList) throws IllegalStateException,
RemoteException;
   
       /**
        * @see javax.enterprise.deploy.spi.DeploymentManager#stop
        */
  -    public ProgressObject stop(TargetModuleID[] moduleIDList) throws IllegalStateException;
  +    public ProgressObject stop(TargetModuleID[] moduleIDList) throws IllegalStateException,
RemoteException;
   
       /**
        * @see javax.enterprise.deploy.spi.DeploymentManager#undeploy
        */
  -    public ProgressObject undeploy(TargetModuleID[] moduleIDList) throws IllegalStateException;
  +    public ProgressObject undeploy(TargetModuleID[] moduleIDList) throws IllegalStateException,
RemoteException;
   
       /**
        * @see javax.enterprise.deploy.spi.DeploymentManager#isRedeploySupported
        */
  -    public boolean isRedeploySupported();
  +    public boolean isRedeploySupported() throws RemoteException;
   
       /**
        * @see javax.enterprise.deploy.spi.DeploymentManager#redeploy(javax.enterprise.deploy.spi.TargetModuleID[],
java.io.File, java.io.File)
        */
  -    public ProgressObject redeploy(TargetModuleID[] moduleIDList, File moduleArchive, File
deploymentPlan) throws UnsupportedOperationException, IllegalStateException;
  +    public ProgressObject redeploy(TargetModuleID[] moduleIDList, File moduleArchive, File
deploymentPlan) throws UnsupportedOperationException, IllegalStateException, RemoteException;
   
       /**
        * @see javax.enterprise.deploy.spi.DeploymentManager#redeploy(javax.enterprise.deploy.spi.TargetModuleID[],
java.io.InputStream, java.io.InputStream)
        */
  -    public ProgressObject redeploy(TargetModuleID[] moduleIDList, InputStream moduleArchive,
InputStream deploymentPlan) throws UnsupportedOperationException, IllegalStateException;
  +    public ProgressObject redeploy(TargetModuleID[] moduleIDList, InputStream moduleArchive,
InputStream deploymentPlan) throws UnsupportedOperationException, IllegalStateException, RemoteException;
   
       // ---------------------- Methods required to populate Property Editors ----------------------
   
  @@ -152,7 +153,7 @@
        *         is not authorized to retrieve that information, or the
        *         information is not available.
        */
  -    public String[] getSecurityRoleOptions(String securityRealm);
  +    public String[] getSecurityRoleOptions(String securityRealm) throws RemoteException;
   
       /**
        * Gets a list of the JNDI names of global resources of a particular type
  @@ -167,5 +168,5 @@
        *         null of no such resources are available, the current user is
        *         not authorized to retrieve the list, etc.
        */
  -    public String[] getResourceJndiNames(String resourceClassName);
  +    public String[] getResourceJndiNames(String resourceClassName) throws RemoteException;
   }
  
  
  
  1.1                  incubator-geronimo/modules/core/src/java/org/apache/geronimo/enterprise/deploy/provider/JmxServerConnection.java
  
  Index: JmxServerConnection.java
  ===================================================================
  package org.apache.geronimo.enterprise.deploy.provider;
  
  import java.io.File;
  import java.io.InputStream;
  import java.io.ByteArrayOutputStream;
  import java.io.IOException;
  import java.io.FileInputStream;
  import java.io.BufferedInputStream;
  import java.net.URISyntaxException;
  import java.rmi.RemoteException;
  import javax.enterprise.deploy.spi.status.ProgressObject;
  import javax.enterprise.deploy.spi.Target;
  import javax.enterprise.deploy.spi.TargetModuleID;
  import javax.enterprise.deploy.spi.exceptions.TargetException;
  import javax.enterprise.deploy.shared.ModuleType;
  import javax.management.MBeanServer;
  import javax.management.ObjectName;
  import org.apache.geronimo.remoting.jmx.RemoteMBeanServerFactory;
  import org.apache.geronimo.kernel.jmx.JMXUtil;
  
  /**
   * Knows how to execute all the relevant JSR-88 operations on a remote
   * Geronimo server via JMX.  Doesn't currently handle clusters.
   *
   * @version $Revision: 1.1 $
   */
  public class JmxServerConnection implements ServerConnection {
      private final static ObjectName DEPLOYER_NAME = JMXUtil.getObjectName("geronimo.deployment:role=ApplicationDeployer");
      private MBeanServer server;
  
      public JmxServerConnection(String hostname) throws URISyntaxException, RemoteException
{
          server = RemoteMBeanServerFactory.create(hostname);
          getTargets(); // Make sure the connection works
      }
  
      public void close() {
          //todo: is there some way to close the BlockingServer, ChannelPool, etc.?
          server = null;
      }
  
      public Target[] getTargets() throws IllegalStateException, RemoteException {
          try {
              return (Target[]) server.getAttribute(DEPLOYER_NAME, "Targets");
          } catch(Exception e) {
              throw new RemoteException("Server request failed", e);
          }
      }
  
      public TargetModuleID[] getAvailableModules(ModuleType moduleType, Target[] targetList)
throws TargetException, IllegalStateException, RemoteException {
          try {
              return (TargetModuleID[]) server.invoke(DEPLOYER_NAME, "getAvailableModules",
new Object[]{moduleType, targetList},
                                   new String[]{"javax.enterprise.deploy.shared.ModuleType","javax.enterprise.deploy.spi.Target[]"});
          } catch(Exception e) {
              throw new RemoteException("Server request failed", e);
          }
      }
  
      public TargetModuleID[] getNonRunningModules(ModuleType moduleType, Target[] targetList)
throws TargetException, IllegalStateException, RemoteException {
          try {
              return (TargetModuleID[]) server.invoke(DEPLOYER_NAME, "getNonRunningModules",
new Object[]{moduleType, targetList},
                                   new String[]{"javax.enterprise.deploy.shared.ModuleType","javax.enterprise.deploy.spi.Target[]"});
          } catch(Exception e) {
              throw new RemoteException("Server request failed", e);
          }
      }
  
      public TargetModuleID[] getRunningModules(ModuleType moduleType, Target[] targetList)
throws TargetException, IllegalStateException, RemoteException {
          try {
              return (TargetModuleID[]) server.invoke(DEPLOYER_NAME, "getNonRunningModules",
new Object[]{moduleType, targetList},
                                                      new String[]{"javax.enterprise.deploy.shared.ModuleType","javax.enterprise.deploy.spi.Target[]"});
          } catch(Exception e) {
              throw new RemoteException("Server request failed", e);
          }
      }
  
      public boolean isRedeploySupported() {
          return true;
      }
  
      public ProgressObject distribute(Target[] targetList, File moduleArchive, File deploymentPlan)
throws IllegalStateException, RemoteException {
          //todo: find a way to stream the content to the server
          try {
              //todo: figure out if the targets are all local and place the files and pass
URLs via JMX
              server.invoke(DEPLOYER_NAME, "distribute", new Object[]{getBytes(new BufferedInputStream(new
FileInputStream(moduleArchive))),
                                                                      getBytes(new BufferedInputStream(new
FileInputStream(deploymentPlan)))},
                            new String[]{"byte[]", "byte[]"});
              return null; //todo: return a proper P.O. based on whatever the server ends
up returning
          } catch(Exception e) {
              throw new RemoteException("Server request failed", e);
          }
      }
  
      public ProgressObject distribute(Target[] targetList, InputStream moduleArchive, InputStream
deploymentPlan) throws IllegalStateException, RemoteException {
          //todo: find a way to stream the content to the server
          try {
              //todo: figure out if the targets are all local and place the files and pass
URLs via JMX
              server.invoke(DEPLOYER_NAME, "distribute", new Object[]{getBytes(moduleArchive),getBytes(deploymentPlan)},
new String[]{"byte[]", "byte[]"});
              return null; //todo: return a proper P.O. based on whatever the server ends
up returning
          } catch(Exception e) {
              throw new RemoteException("Server request failed", e);
          }
      }
  
      public ProgressObject redeploy(TargetModuleID[] moduleIDList, File moduleArchive, File
deploymentPlan) throws UnsupportedOperationException, IllegalStateException, RemoteException
{
          //todo: find a way to stream the content to the server
          try {
              //todo: figure out if the targets are all local and place the files and pass
URLs via JMX
              server.invoke(DEPLOYER_NAME, "redeploy", new Object[]{getBytes(new BufferedInputStream(new
FileInputStream(moduleArchive))),
                                                                    getBytes(new BufferedInputStream(new
FileInputStream(deploymentPlan)))},
                            new String[]{"byte[]", "byte[]"});
              return null; //todo: return a proper P.O. based on whatever the server ends
up returning
          } catch(Exception e) {
              throw new RemoteException("Server request failed", e);
          }
      }
  
      public ProgressObject redeploy(TargetModuleID[] moduleIDList, InputStream moduleArchive,
InputStream deploymentPlan) throws UnsupportedOperationException, IllegalStateException, RemoteException
{
          //todo: find a way to stream the content to the server
          try {
              //todo: figure out if the targets are all local and place the files and pass
URLs via JMX
              server.invoke(DEPLOYER_NAME, "redeploy", new Object[]{getBytes(moduleArchive),getBytes(deploymentPlan)},
new String[]{"byte[]", "byte[]"});
              return null; //todo: return a proper P.O. based on whatever the server ends
up returning
          } catch(Exception e) {
              throw new RemoteException("Server request failed", e);
          }
      }
  
      public ProgressObject start(TargetModuleID[] moduleIDList) throws IllegalStateException,
RemoteException {
          try {
              server.invoke(DEPLOYER_NAME, "start", new Object[]{moduleIDList},
                            new String[]{"javax.enterprise.deploy.spi.TargetModuleID[]"});
              return null; //todo: return a proper P.O. based on whatever the server ends
up returning
          } catch(Exception e) {
              throw new RemoteException("Server request failed", e);
          }
      }
  
      public ProgressObject stop(TargetModuleID[] moduleIDList) throws IllegalStateException,
RemoteException {
          try {
              server.invoke(DEPLOYER_NAME, "stop", new Object[]{moduleIDList},
                            new String[]{"javax.enterprise.deploy.spi.TargetModuleID[]"});
              return null; //todo: return a proper P.O. based on whatever the server ends
up returning
          } catch(Exception e) {
              throw new RemoteException("Server request failed", e);
          }
      }
  
      public ProgressObject undeploy(TargetModuleID[] moduleIDList) throws IllegalStateException,
RemoteException {
          try {
              server.invoke(DEPLOYER_NAME, "undeploy", new Object[]{moduleIDList},
                            new String[]{"javax.enterprise.deploy.spi.TargetModuleID[]"});
              return null; //todo: return a proper P.O. based on whatever the server ends
up returning
          } catch(Exception e) {
              throw new RemoteException("Server request failed", e);
          }
      }
  
      public String[] getResourceJndiNames(String resourceClassName) throws RemoteException
{
          try {
              return (String[]) server.invoke(DEPLOYER_NAME, "getResourceJndiNames", new Object[]{resourceClassName},
                                              new String[]{"java.lang.String"});
          } catch(Exception e) {
              throw new RemoteException("Server request failed", e);
          }
      }
  
      public String[] getSecurityRoleOptions(String securityRealm) throws RemoteException
{
          try {
              return (String[]) server.invoke(DEPLOYER_NAME, "getResourceJndiNames", new Object[]{securityRealm},
                                              new String[]{"java.lang.String"});
          } catch(Exception e) {
              throw new RemoteException("Server request failed", e);
          }
      }
  
      private Object getBytes(InputStream in) throws IOException {
          ByteArrayOutputStream out = new ByteArrayOutputStream();
          byte[] buf = new byte[1024];
          int count;
          while((count = in.read(buf)) > -1) {
              out.write(buf, 0, count);
          }
          in.close();
          out.close();
          return out.toByteArray();
      }
  }
  
  
  

Mime
View raw message