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/system/src/java/org/apache/geronimo/system/configuration LocalConfigStore.java
Date Wed, 23 Jun 2004 22:44:49 GMT
jboynes     2004/06/23 15:44:49

  Modified:    modules/assembly/src/plan j2ee-server-plan.xml
               modules/deployment/src/java/org/apache/geronimo/deployment
                        Deployer.java
               modules/deployment/src/java/org/apache/geronimo/deployment/plugin/jmx
                        JMXDeploymentManager.java
               modules/deployment/src/java/org/apache/geronimo/deployment/plugin/local
                        DistributeCommand.java
               modules/kernel/src/java/org/apache/geronimo/kernel/config
                        ConfigurationStore.java
               modules/system/src/java/org/apache/geronimo/system/configuration
                        LocalConfigStore.java
  Removed:     modules/deployment/src/java/org/apache/geronimo/deployment/plugin/local
                        LocalServer.java
  Log:
  Support distribute command allowing hot deployment
  
  Revision  Changes    Path
  1.29      +42 -0     incubator-geronimo/modules/assembly/src/plan/j2ee-server-plan.xml
  
  Index: j2ee-server-plan.xml
  ===================================================================
  RCS file: /home/cvs/incubator-geronimo/modules/assembly/src/plan/j2ee-server-plan.xml,v
  retrieving revision 1.28
  retrieving revision 1.29
  diff -u -r1.28 -r1.29
  --- j2ee-server-plan.xml	23 Jun 2004 09:03:38 -0000	1.28
  +++ j2ee-server-plan.xml	23 Jun 2004 22:44:49 -0000	1.29
  @@ -77,6 +77,21 @@
           <uri>regexp/jars/regexp-1.3.jar</uri>
       </dependency>
   
  +    <!-- needed for online deployment -->
  +    <dependency>
  +        <uri>geronimo-spec/jars/geronimo-spec-j2eeschema-1.0-SNAPSHOT.jar</uri>
  +    </dependency>
  +    <dependency>
  +        <uri>geronimo/jars/geronimo-deployment-1.0-SNAPSHOT.jar</uri>
  +    </dependency>
  +    <dependency>
  +        <uri>geronimo/jars/geronimo-common-1.0-SNAPSHOT.jar</uri>
  +    </dependency>
  +    <dependency>
  +        <uri>xmlbeans/jars/xbean-apache-1.0-DEV.jar</uri>
  +    </dependency>
  +
  +
       <!-- Default security realm using properties files -->
       <gbean name="geronimo.security:type=SecurityRealm,realm=geronimo-properties-realm"
class="org.apache.geronimo.security.realm.providers.PropertiesFileSecurityRealm">
           <attribute name="RealmName" type="java.lang.String">geronimo-properties-realm</attribute>
  @@ -206,4 +221,31 @@
           <attribute name="URL" type="java.lang.String">service:jmx:rmi://localhost/jndi/rmi:/JMXConnector</attribute>
           <attribute name="ApplicationConfigName" type="java.lang.String">JMX</attribute>
       </gbean>
  +
  +    <!-- todo move to child config once we sort out the packaging -->
  +    <gbean name="geronimo.deployment:role=Deployer,config=org/apache/geronimo/Server"
class="org.apache.geronimo.deployment.Deployer">
  +        <reference name="Builders">geronimo.deployer:role=Builder,config=org/apache/geronimo/Server,*</reference>
  +        <reference name="Store">geronimo.system:role=ConfigurationStore,type=Local</reference>
  +    </gbean>
  +
  +    <gbean name="geronimo.deployer:role=Builder,type=Service,config=org/apache/geronimo/Server"
class="org.apache.geronimo.deployment.service.ServiceConfigBuilder">
  +        <reference name="Repository">*:role=Repository,*</reference>
  +    </gbean>
  +
  +    <gbean name="geronimo.deployer:role=Builder,type=EAR,config=org/apache/geronimo/Server"
class="org.apache.geronimo.j2ee.deployment.EARConfigBuilder">
  +        <reference name="Repository">*:role=Repository,*</reference>
  +        <attribute name="j2eeServer" type="javax.management.ObjectName">geronimo.server:j2eeType=J2EEServer,name=geronimo</attribute>
  +        <reference name="EJBConfigBuilder">geronimo.deployer:role=ModuleBuilder,type=EJB,config=org/apache/geronimo/Server</reference>
  +        <reference name="WebConfigBuilder">geronimo.deployer:role=ModuleBuilder,type=Web,config=org/apache/geronimo/Server</reference>
  +        <reference name="ConnectorConfigBuilder">geronimo.deployer:role=ModuleBuilder,type=Connector,config=org/apache/geronimo/Server</reference>
  +        <attribute name="transactionManagerObjectName" type="javax.management.ObjectName">geronimo.server:type=TransactionManager</attribute>
  +        <attribute name="connectionTrackerObjectName" type="javax.management.ObjectName">geronimo.server:type=ConnectionTracker</attribute>
  +    </gbean>
  +
  +    <gbean name="geronimo.deployer:role=ModuleBuilder,type=Web,config=org/apache/geronimo/Server"
class="org.apache.geronimo.jetty.deployment.JettyModuleBuilder"/>
  +
  +    <gbean name="geronimo.deployer:role=ModuleBuilder,type=EJB,config=org/apache/geronimo/Server"
class="org.openejb.deployment.OpenEJBModuleBuilder"/>
  +
  +    <gbean name="geronimo.deployer:role=ModuleBuilder,type=Connector,config=org/apache/geronimo/Server"
class="org.apache.geronimo.connector.deployment.ConnectorModuleBuilder"/>
  +    <!-- end deployment block -->
   </configuration>
  
  
  
  1.21      +51 -1     incubator-geronimo/modules/deployment/src/java/org/apache/geronimo/deployment/Deployer.java
  
  Index: Deployer.java
  ===================================================================
  RCS file: /home/cvs/incubator-geronimo/modules/deployment/src/java/org/apache/geronimo/deployment/Deployer.java,v
  retrieving revision 1.20
  retrieving revision 1.21
  diff -u -r1.20 -r1.21
  --- Deployer.java	2 Jun 2004 05:33:02 -0000	1.20
  +++ Deployer.java	23 Jun 2004 22:44:49 -0000	1.21
  @@ -46,6 +46,7 @@
   import org.apache.xmlbeans.SchemaTypeLoader;
   import org.apache.xmlbeans.XmlBeans;
   import org.apache.xmlbeans.XmlObject;
  +import org.apache.xmlbeans.XmlException;
   
   /**
    * Command line based deployment utility which combines multiple deployable modules
  @@ -62,6 +63,54 @@
           this.store = store;
       }
   
  +    public URI deploy(File moduleFile, File deploymentPlan) throws DeploymentException
{
  +        URL moduleURL;
  +        try {
  +            moduleURL = moduleFile.toURL();
  +        } catch (MalformedURLException e) {
  +            throw new DeploymentException(e);
  +        }
  +        ConfigurationBuilder builder = null;
  +
  +        XmlObject plan = null;
  +        for (Iterator i = builders.iterator(); i.hasNext();) {
  +            ConfigurationBuilder candidate = (ConfigurationBuilder) i.next();
  +            try {
  +                plan = candidate.getDeploymentPlan(moduleURL);
  +                if (!plan.validate()) {
  +                    throw new DeploymentException("Unable to parse plan");
  +                }
  +            } catch (XmlException e) {
  +                throw new DeploymentException(e);
  +            }
  +            if (plan != null) {
  +                builder = candidate;
  +                break;
  +            }
  +        }
  +        if (builder == null) {
  +            throw new DeploymentException("No deployer found for this module type: " +
moduleFile);
  +        }
  +
  +        try {
  +            File carfile = File.createTempFile("deployer", ".car");
  +            try {
  +
  +                Manifest manifest = new Manifest();
  +                Attributes mainAttributes = manifest.getMainAttributes();
  +                mainAttributes.putValue(Attributes.Name.MANIFEST_VERSION.toString(), "1.0");
  +                builder.buildConfiguration(carfile, manifest, moduleFile, plan);
  +                return store.install(carfile.toURL());
  +            } catch (InvalidConfigException e) {
  +                throw new DeploymentException(e);
  +            } finally {
  +                carfile.delete();
  +            }
  +        } catch (IOException e) {
  +            throw new DeploymentException(e);
  +        }
  +    }
  +
       /**
        * GBean entry point invoked from an executable CAR.
        *
  @@ -249,6 +298,7 @@
           GBeanInfoFactory infoFactory = new GBeanInfoFactory(Deployer.class);
   
           infoFactory.addOperation("deploy", new Class[]{String[].class});
  +        infoFactory.addOperation("deploy", new Class[]{File.class, File.class});
   
           infoFactory.addReference("Builders", ConfigurationBuilder.class);
           infoFactory.addReference("Store", ConfigurationStore.class);
  
  
  
  1.5       +8 -2      incubator-geronimo/modules/deployment/src/java/org/apache/geronimo/deployment/plugin/jmx/JMXDeploymentManager.java
  
  Index: JMXDeploymentManager.java
  ===================================================================
  RCS file: /home/cvs/incubator-geronimo/modules/deployment/src/java/org/apache/geronimo/deployment/plugin/jmx/JMXDeploymentManager.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- JMXDeploymentManager.java	2 Jun 2004 19:58:02 -0000	1.4
  +++ JMXDeploymentManager.java	23 Jun 2004 22:44:49 -0000	1.5
  @@ -41,6 +41,7 @@
   import org.apache.geronimo.deployment.plugin.TargetModuleIDImpl;
   import org.apache.geronimo.deployment.plugin.local.StartCommand;
   import org.apache.geronimo.deployment.plugin.local.StopCommand;
  +import org.apache.geronimo.deployment.plugin.local.DistributeCommand;
   import org.apache.geronimo.kernel.Kernel;
   import org.apache.geronimo.kernel.KernelMBean;
   import org.apache.geronimo.kernel.config.ConfigurationInfo;
  @@ -149,7 +150,12 @@
       }
   
       public ProgressObject distribute(Target[] targetList, File moduleArchive, File deploymentPlan)
{
  -        throw new UnsupportedOperationException();
  +        if (kernel == null) {
  +            throw new IllegalStateException("Disconnected");
  +        }
  +        DistributeCommand command = new DistributeCommand(kernel, targetList, moduleArchive,
deploymentPlan);
  +        new Thread(command).start();
  +        return command;
       }
   
       public ProgressObject distribute(Target[] targetList, InputStream moduleArchive, InputStream
deploymentPlan) {
  
  
  
  1.11      +33 -27    incubator-geronimo/modules/deployment/src/java/org/apache/geronimo/deployment/plugin/local/DistributeCommand.java
  
  Index: DistributeCommand.java
  ===================================================================
  RCS file: /home/cvs/incubator-geronimo/modules/deployment/src/java/org/apache/geronimo/deployment/plugin/local/DistributeCommand.java,v
  retrieving revision 1.10
  retrieving revision 1.11
  diff -u -r1.10 -r1.11
  --- DistributeCommand.java	23 Apr 2004 03:08:28 -0000	1.10
  +++ DistributeCommand.java	23 Jun 2004 22:44:49 -0000	1.11
  @@ -18,49 +18,55 @@
   package org.apache.geronimo.deployment.plugin.local;
   
   import java.io.File;
  -import java.io.InputStream;
  +import java.util.Iterator;
  +import java.util.Set;
  +import java.net.URI;
   import javax.enterprise.deploy.shared.CommandType;
  +import javax.enterprise.deploy.spi.Target;
  +import javax.enterprise.deploy.spi.TargetModuleID;
  +import javax.management.ObjectName;
   
  -import org.apache.geronimo.deployment.ConfigurationBuilder;
  -import org.apache.geronimo.kernel.config.ConfigurationStore;
  -import org.apache.xmlbeans.XmlObject;
  +import org.apache.geronimo.kernel.KernelMBean;
  +import org.apache.geronimo.deployment.plugin.TargetModuleIDImpl;
   
   /**
  - *
  - *
    * @version $Revision$ $Date$
    */
   public class DistributeCommand extends CommandSupport {
  -    private final ConfigurationStore store;
  -    private final ConfigurationBuilder builder;
  -    private final InputStream in;
  -    private final XmlObject plan;
  +    private static final String[] DEPLOY_SIG = {File.class.getName(), File.class.getName()};
  +    private final KernelMBean kernel;
  +    private final Target[] targetList;
  +    private final File moduleArchive;
  +    private final File deploymentPlan;
   
  -    public DistributeCommand(ConfigurationStore store, ConfigurationBuilder builder, InputStream
in, XmlObject plan) {
  +    public DistributeCommand(KernelMBean kernel, Target[] targetList, File moduleArchive,
File deploymentPlan) {
           super(CommandType.DISTRIBUTE);
  -        this.store = store;
  -        this.builder = builder;
  -        this.in = in;
  -        this.plan = plan;
  +        this.kernel = kernel;
  +        this.targetList = targetList;
  +        this.moduleArchive = moduleArchive;
  +        this.deploymentPlan = deploymentPlan;
       }
   
       public void run() {
  -        File configFile = null;
           try {
  -            // create some working space
  -            configFile = File.createTempFile("deploy", ".car");
  -            builder.buildConfiguration(configFile, null, in, plan);
  +            Set deployers = kernel.listGBeans(new ObjectName("geronimo.deployment:role=Deployer,*"));
  +            if (deployers.isEmpty()) {
  +                fail("No deployer present in kernel");
  +                return;
  +            }
  +            Iterator i = deployers.iterator();
  +            ObjectName deployer = (ObjectName) i.next();
  +            if (i.hasNext()) {
  +                throw new UnsupportedOperationException("More than one deployer found");
  +            }
   
  -            // install in our local server
  -            store.install(configFile.toURL());
  -            //addModule(targetID);
  +            Object[] args = {moduleArchive, deploymentPlan};
  +            URI configId = (URI) kernel.invoke(deployer, "deploy", args, DEPLOY_SIG);
  +            TargetModuleID moduleID = new TargetModuleIDImpl(targetList[0], configId.toString());
  +            addModule(moduleID);
               complete("Completed");
           } catch (Exception e) {
               fail(e.getMessage());
  -        } finally {
  -            if (configFile != null) {
  -                configFile.delete();
  -            }
           }
       }
   }
  
  
  
  1.9       +2 -2      incubator-geronimo/modules/kernel/src/java/org/apache/geronimo/kernel/config/ConfigurationStore.java
  
  Index: ConfigurationStore.java
  ===================================================================
  RCS file: /home/cvs/incubator-geronimo/modules/kernel/src/java/org/apache/geronimo/kernel/config/ConfigurationStore.java,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- ConfigurationStore.java	5 Jun 2004 00:37:16 -0000	1.8
  +++ ConfigurationStore.java	23 Jun 2004 22:44:49 -0000	1.9
  @@ -37,7 +37,7 @@
        * @throws IOException if the CAR could not be read
        * @throws InvalidConfigException if there is a configuration problem with the CAR
        */
  -    void install(URL source) throws IOException, InvalidConfigException;
  +    URI install(URL source) throws IOException, InvalidConfigException;
   
       /**
        * Determines if the store contains a configuration with the spedified ID.
  
  
  
  1.10      +6 -4      incubator-geronimo/modules/system/src/java/org/apache/geronimo/system/configuration/LocalConfigStore.java
  
  Index: LocalConfigStore.java
  ===================================================================
  RCS file: /home/cvs/incubator-geronimo/modules/system/src/java/org/apache/geronimo/system/configuration/LocalConfigStore.java,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- LocalConfigStore.java	5 Jun 2004 07:53:22 -0000	1.9
  +++ LocalConfigStore.java	23 Jun 2004 22:44:49 -0000	1.10
  @@ -131,7 +131,7 @@
           }
       }
   
  -    public void install(URL source) throws IOException, InvalidConfigException {
  +    public URI install(URL source) throws IOException, InvalidConfigException {
           String newId;
           synchronized (this) {
               newId = Integer.toString(++maxId);
  @@ -144,9 +144,11 @@
           } finally {
               is.close();
           }
  +        URI configId;
           try {
               GBeanMBean config = loadConfig(bundleRoot);
  -            index.setProperty(config.getAttribute("ID").toString(), newId);
  +            configId = (URI) config.getAttribute("ID");
  +            index.setProperty(configId.toString(), newId);
           } catch (Exception e) {
               delete(bundleRoot);
               throw new InvalidConfigException("Unable to get ID from downloaded configuration",
e);
  @@ -154,7 +156,7 @@
           synchronized (this) {
               saveIndex();
           }
  -
  +        return configId;
       }
   
       public synchronized GBeanMBean getConfiguration(URI configID) throws NoSuchConfigException,
IOException, InvalidConfigException {
  
  
  

Mime
View raw message