geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From djen...@apache.org
Subject cvs commit: incubator-geronimo/modules/maven-plugin/src/java/org/apache/geronimo/deployment/mavenplugin AbstractModuleCommand.java DeploymentClient.java DistributeModule.java StartModule.java StartServer.java StopModule.java StopServer.java UndeployModule.java
Date Sun, 25 Jul 2004 08:22:07 GMT
djencks     2004/07/25 01:22:07

  Modified:    modules/maven-plugin maven.xml plugin.jelly project.xml
  Added:       modules/maven-plugin/src/java/org/apache/geronimo/deployment/mavenplugin
                        AbstractModuleCommand.java DeploymentClient.java
                        DistributeModule.java StartModule.java
                        StartServer.java StopModule.java StopServer.java
                        UndeployModule.java
  Log:
  Revive the geronimo maven plugin. It now hot deploys/undeploys against a separate running
server. (Start/StopServer commands do not yet work from maven)
  
  Revision  Changes    Path
  1.5       +9 -7      incubator-geronimo/modules/maven-plugin/maven.xml
  
  Index: maven.xml
  ===================================================================
  RCS file: /home/cvs/incubator-geronimo/modules/maven-plugin/maven.xml,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- maven.xml	10 Mar 2004 09:59:05 -0000	1.4
  +++ maven.xml	25 Jul 2004 08:22:06 -0000	1.5
  @@ -6,16 +6,16 @@
       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.
   -->
  -  
  +
   
   <!-- $Revision$ $Date$ -->
   
  @@ -39,14 +39,16 @@
       <!-- ==================== -->
   
       <goal name="default">
  -        <attainGoal name="jar:jar"/>
  -        <ant:property name="pluginsDir" value="${maven.repo.local}/${pom.artifactDirectory}/plugins"/>
  +        <!--attainGoal name="jar:jar"/-->
  +        <attainGoal name="plugin:install"/>
  +        <attainGoal name="plugin:install-now"/>
  +        <!--ant:property name="pluginsDir" value="${maven.repo.local}/${pom.artifactDirectory}/plugins"/>
           <ant:mkdir dir="${pluginsDir}"/>
           <ant:copy
               file="${basedir}/target/${pom.artifactId}-${pom.currentVersion}.jar"
               todir="${pluginsDir}"
               overwrite="true"
  -            />
  +            /-->
       </goal>
   
       <goal name="build">
  
  
  
  1.3       +24 -69    incubator-geronimo/modules/maven-plugin/plugin.jelly
  
  Index: plugin.jelly
  ===================================================================
  RCS file: /home/cvs/incubator-geronimo/modules/maven-plugin/plugin.jelly,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- plugin.jelly	26 Jan 2004 18:02:15 -0000	1.2
  +++ plugin.jelly	25 Jul 2004 08:22:06 -0000	1.3
  @@ -12,75 +12,30 @@
       >
   
       <define:taglib uri="geronimo:deploy">
  -        <!-- DeployCommand  <configID> <outfile> <url>+ -->
  -        <!-- DeployCommand org/apache/geronimo/Default /tmp/default.car jetty-service.xml
-->
  -        <define:tag name="deploy" xmlns="jelly:ant">
  -            <j:if test="${deployconfigid == null}">
  -                <fail>Missing required attribute: deployconfigid</fail>
  -            </j:if>
  -            <j:if test="${deployoutfile == null}">
  -                <fail>Missing required attribute: deployoutfile</fail>
  -            </j:if>
  -            <j:if test="${deployurl == null}">
  -                <fail>Missing required attribute: deployurl</fail>
  -            </j:if>
  -            <j:invokeStatic var="dummy" className="org.apache.geronimo.deployment.tools.DeployCommand"
method="deploy">
  -                <j:arg type="java.lang.String" value="${deployconfigid}"/>
  -                <j:arg type="java.lang.String" value="${deployoutfile}"/>
  -                <j:arg type="java.lang.String" value="${deployurl}"/>
  -            </j:invokeStatic>
  -        </define:tag>
  -
  -        <define:tag name="install" xmlns="jelly:ant">
  -            <j:if test="${installDomain == null}">
  -                <fail>Missing required attribute: installDomain</fail>
  -            </j:if>
  -            <j:if test="${installStoreDir == null}">
  -                <fail>Missing required attribute: installStoreDir</fail>
  -            </j:if>
  -            <j:if test="${installConfig == null}">
  -                <fail>Missing required attribute: installConfig</fail>
  -            </j:if>
  -            <j:invokeStatic var="kernel" className="org.apache.geronimo.Geronimo" method="installPackage">
  -                <j:arg type="java.lang.String" value="${installDomain}"/>
  -                <j:arg type="java.lang.String" value="${installStoreDir}"/>
  -                <j:arg type="java.lang.String" value="${installConfig}"/>
  -            </j:invokeStatic>
  -        </define:tag>
  -
  -        <define:tag name="loadAndReturn" xmlns="jelly:ant">
  -            <j:if test="${runDomain == null}">
  -                <fail>Missing required attribute: runDomain</fail>
  -            </j:if>
  -            <j:if test="${runStoreDir == null}">
  -                <fail>Missing required attribute: runStoreDir</fail>
  -            </j:if>
  -            <j:if test="${runConfigID == null}">
  -                <fail>Missing required attribute: runConfigID</fail>
  -            </j:if>
  -            <j:invokeStatic var="kernel" className="org.apache.geronimo.Geronimo" method="load">
  -                <j:arg type="java.lang.String" value="${runDomain}"/>
  -                <j:arg type="java.lang.String" value="${runStoreDir}"/>
  -                <j:arg type="java.lang.String" value="${runConfigID}"/>
  -            </j:invokeStatic>
  -        </define:tag>
  -
  -        <define:tag name="loadAndWait" xmlns="jelly:ant">
  -            <j:if test="${runDomain == null}">
  -                <fail>Missing required attribute: runDomain</fail>
  -            </j:if>
  -            <j:if test="${runStoreDir == null}">
  -                <fail>Missing required attribute: runStoreDir</fail>
  -            </j:if>
  -            <j:if test="${runConfigID == null}">
  -                <fail>Missing required attribute: runConfigID</fail>
  -            </j:if>
  -            <j:invokeStatic var="kernel" className="org.apache.geronimo.Geronimo" method="loadAndWait">
  -                <j:arg type="java.lang.String" value="${runDomain}"/>
  -                <j:arg type="java.lang.String" value="${runStoreDir}"/>
  -                <j:arg type="java.lang.String" value="${runConfigID}"/>
  -            </j:invokeStatic>
  -        </define:tag>
  +        <define:jellybean
  +            name="distribute"
  +            className="org.apache.geronimo.deployment.mavenplugin.DistributeModule"
  +            method="execute"/>
  +        <define:jellybean
  +            name="start"
  +            className="org.apache.geronimo.deployment.mavenplugin.StartModule"
  +            method="execute"/>
  +        <define:jellybean
  +            name="stop"
  +            className="org.apache.geronimo.deployment.mavenplugin.StopModule"
  +            method="execute"/>
  +        <define:jellybean
  +            name="undeploy"
  +            className="org.apache.geronimo.deployment.mavenplugin.UndeployModule"
  +            method="execute"/>
  +        <define:jellybean
  +            name="startServer"
  +            className="org.apache.geronimo.deployment.mavenplugin.StartServer"
  +            method="execute"/>
  +        <define:jellybean
  +            name="stopServer"
  +            className="org.apache.geronimo.deployment.mavenplugin.StopServer"
  +            method="execute"/>
   
       </define:taglib>
   
  
  
  
  1.16      +12 -13    incubator-geronimo/modules/maven-plugin/project.xml
  
  Index: project.xml
  ===================================================================
  RCS file: /home/cvs/incubator-geronimo/modules/maven-plugin/project.xml,v
  retrieving revision 1.15
  retrieving revision 1.16
  diff -u -r1.15 -r1.16
  --- project.xml	24 Jun 2004 20:59:47 -0000	1.15
  +++ project.xml	25 Jul 2004 08:22:06 -0000	1.16
  @@ -6,16 +6,16 @@
       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.
   -->
  -  
  +
   <project>
       <pomVersion>3</pomVersion>
       <groupId>geronimo</groupId>
  @@ -32,11 +32,11 @@
       <logo></logo>
   
       <dependencies>
  -        <dependency>
  +        <!--dependency>
               <groupId>xml-resolver</groupId>
               <artifactId>xml-resolver</artifactId>
               <version>1.1</version>
  -        </dependency>
  +        </dependency-->
   
           <dependency>
               <groupId>geronimo</groupId>
  @@ -62,13 +62,6 @@
               <version>1.1-rc2</version>
           </dependency>
   
  -        <!-- TODO remove this stupid dependency -->
  -        <dependency>
  -            <groupId>geronimo</groupId>
  -            <artifactId>geronimo-core</artifactId>
  -            <version>${pom.currentVersion}</version>
  -        </dependency>
  -
           <dependency>
               <groupId>commons-cli</groupId>
               <artifactId>commons-cli</artifactId>
  @@ -97,6 +90,12 @@
           </dependency>
   
           <dependency>
  +            <groupId>mx4j</groupId>
  +            <artifactId>mx4j-remote</artifactId>
  +            <version>2.0.1</version>
  +        </dependency>
  +
  +        <dependency>
               <groupId>cglib</groupId>
               <artifactId>cglib-full</artifactId>
               <version>2.0</version>
  @@ -111,7 +110,7 @@
       </dependencies>
   
       <build>
  -        <sourceDirectory></sourceDirectory>
  +        <sourceDirectory>src/java</sourceDirectory>
           <unitTestSourceDirectory></unitTestSourceDirectory>
   
           <unitTest>
  
  
  
  1.1                  incubator-geronimo/modules/maven-plugin/src/java/org/apache/geronimo/deployment/mavenplugin/AbstractModuleCommand.java
  
  Index: AbstractModuleCommand.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.mavenplugin;
  
  import java.io.IOException;
  import java.io.File;
  import java.net.URL;
  import java.net.URLClassLoader;
  
  import javax.enterprise.deploy.spi.DeploymentManager;
  import javax.enterprise.deploy.spi.exceptions.DeploymentManagerCreationException;
  import javax.enterprise.deploy.shared.factories.DeploymentFactoryManager;
  
  import org.apache.geronimo.deployment.plugin.factories.DeploymentFactoryImpl;
  
  /**
   *
   *
   * @version $Revision: 1.1 $ $Date: 2004/07/25 08:22:07 $
   *
   * */
  public abstract class AbstractModuleCommand {
      private String uri;
      private String username;
      private String password;
  
      public String getUri() {
          return uri;
      }
  
      public void setUri(String uri) {
          this.uri = uri;
      }
  
      public String getUsername() {
          return username;
      }
  
      public void setUsername(String username) {
          this.username = username;
      }
  
      public String getPassword() {
          return password;
      }
  
      public void setPassword(String password) {
          this.password = password;
      }
  
      public abstract void execute() throws Exception;
  
      protected DeploymentManager getDeploymentManager() throws IOException, DeploymentManagerCreationException
{
          if (getUsername() == null) {
              throw new IllegalStateException("No user specified");
          }
          if (getPassword() == null) {
              throw new IllegalStateException("No password specified");
          }
          if (getUri() == null) {
              throw new IllegalStateException("No uri specified");
          }
          new DeploymentFactoryImpl();
  
          ClassLoader oldcl = Thread.currentThread().getContextClassLoader();
          try {
              Thread.currentThread().setContextClassLoader(this.getClass().getClassLoader());
              DeploymentFactoryManager factoryManager = DeploymentFactoryManager.getInstance();
              DeploymentManager manager = factoryManager.getDeploymentManager(getUri(), getUsername(),
getPassword());
              return manager;
          } finally {
              Thread.currentThread().setContextClassLoader(oldcl);
          }
      }
  }
  
  
  
  1.1                  incubator-geronimo/modules/maven-plugin/src/java/org/apache/geronimo/deployment/mavenplugin/DeploymentClient.java
  
  Index: DeploymentClient.java
  ===================================================================
  package org.apache.geronimo.deployment.mavenplugin;
  
  import java.io.IOException;
  import java.net.JarURLConnection;
  import java.net.URL;
  import java.net.URLClassLoader;
  import java.util.StringTokenizer;
  import java.util.jar.Attributes;
  import javax.enterprise.deploy.shared.factories.DeploymentFactoryManager;
  import javax.enterprise.deploy.spi.factories.DeploymentFactory;
  import javax.enterprise.deploy.spi.status.ProgressObject;
  import javax.enterprise.deploy.spi.status.ProgressListener;
  import javax.enterprise.deploy.spi.status.ProgressEvent;
  import javax.enterprise.deploy.spi.status.DeploymentStatus;
  
  public class DeploymentClient {
      private static final DeploymentFactoryManager FACTORY_MANAGER = DeploymentFactoryManager.getInstance();
  
      private URL provider;
  
      public URL getProvider() {
          return provider;
      }
  
      public void setProvider(URL provider) {
          this.provider = provider;
      }
  
      public void doIt() throws IOException {
          registerProvider(provider, null);
      }
  
      public static void registerProvider(URL provider, ClassLoader parent) throws IOException
{
          if (parent == null) {
              parent = Thread.currentThread().getContextClassLoader();
          }
          if (parent == null) {
              parent = DeploymentClient.class.getClassLoader();
          }
  
          // read manifest entry from provider
          URL url = new URL("jar:" + provider.toString() + "!/");
          JarURLConnection jarConnection = (JarURLConnection) url.openConnection();
          Attributes attrs = jarConnection.getMainAttributes();
          String factoryNames = attrs.getValue("J2EE-DeploymentFactory-Implementation-Class");
          if (factoryNames == null) {
              throw new IOException("No DeploymentFactory found in jar");
          }
  
          // register listed DeploymentFactories
          ClassLoader cl = new URLClassLoader(new URL[]{provider}, parent);
          for (StringTokenizer tokenizer = new StringTokenizer(factoryNames); tokenizer.hasMoreTokens();)
{
              String className = tokenizer.nextToken();
              try {
                  DeploymentFactory factory = (DeploymentFactory) cl.loadClass(className).newInstance();
                  FACTORY_MANAGER.registerDeploymentFactory(factory);
              } catch (Exception e) {
                  throw (IOException) new IOException("Unable to instantiate DeploymentFactory:
" + className).initCause(e);
              }
          }
      }
  
      public static void waitFor(final ProgressObject progress) throws InterruptedException
{
          ProgressListener listener = new ProgressListener() {
              public void handleProgressEvent(ProgressEvent event) {
                  DeploymentStatus status = event.getDeploymentStatus();
                  if (status.getMessage() != null) {
                      System.out.println(status.getMessage());
                  }
                  if (!status.isRunning()) {
                      synchronized (progress) {
                          progress.notify();
                      }
                  }
              }
          };
          progress.addProgressListener(listener);
          synchronized (progress) {
              while (progress.getDeploymentStatus().isRunning()) {
                  progress.wait();
              }
          }
      }
  }
  
  
  
  1.1                  incubator-geronimo/modules/maven-plugin/src/java/org/apache/geronimo/deployment/mavenplugin/DistributeModule.java
  
  Index: DistributeModule.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.mavenplugin;
  
  import java.io.File;
  import java.io.IOException;
  import java.net.MalformedURLException;
  
  import javax.enterprise.deploy.spi.DeploymentManager;
  import javax.enterprise.deploy.spi.Target;
  import javax.enterprise.deploy.spi.status.ProgressObject;
  
  /**
   *
   *
   * @version $Revision: 1.1 $ $Date: 2004/07/25 08:22:07 $
   *
   * */
  public class DistributeModule extends AbstractModuleCommand {
  
      private String module;
      private String plan;
      private String home;
  
      public String getModule() {
          return module;
      }
  
      public void setModule(String module) {
          this.module = module;
      }
  
      public String getPlan() {
          return plan;
      }
  
      public void setPlan(String plan) {
          this.plan = plan;
      }
  
      public void execute() throws Exception {
          DeploymentManager manager = getDeploymentManager();
  
          Target[] targets = manager.getTargets();
          File moduleFile = (getModule() == null)? null: getFile(getModule());
          File planFile = (getPlan() == null)? null: getFile((getPlan()));
          ProgressObject progress = manager.distribute(targets, moduleFile, planFile);
          DeploymentClient.waitFor(progress);
      }
  
      private File getFile(String location) throws MalformedURLException {
          File f = new File(location);
          if (f.exists() && f.canRead()) {
              try {
                  return f.getCanonicalFile();
              } catch (IOException e) {
                  throw (MalformedURLException) new MalformedURLException("Invalid location:
" + location).initCause(e);
              }
          }
          try {
              return new File(new File(getHome()).toURI().resolve(location).toURL().getFile());
          } catch (IllegalArgumentException e) {
              // thrown by URI.resolve if the location is not valid
              throw (MalformedURLException) new MalformedURLException("Invalid location: "
+ location).initCause(e);
          }
      }
  
      public String getHome() {
          return home;
      }
  
      public void setHome(String home) {
          this.home = home;
      }
  }
  
  
  
  1.1                  incubator-geronimo/modules/maven-plugin/src/java/org/apache/geronimo/deployment/mavenplugin/StartModule.java
  
  Index: StartModule.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.mavenplugin;
  
  import java.util.List;
  import java.util.ArrayList;
  
  import javax.enterprise.deploy.spi.DeploymentManager;
  import javax.enterprise.deploy.spi.Target;
  import javax.enterprise.deploy.spi.TargetModuleID;
  import javax.enterprise.deploy.spi.status.ProgressObject;
  
  /**
   *
   *
   * @version $Revision: 1.1 $ $Date: 2004/07/25 08:22:07 $
   *
   * */
  public class StartModule extends AbstractModuleCommand {
  
      private String id;
  
      public String getId() {
          return id;
      }
  
      public void setId(String id) {
          this.id = id;
      }
  
      public void execute() throws Exception {
          DeploymentManager manager = getDeploymentManager();
  
          Target[] targets = manager.getTargets();
          TargetModuleID moduleIds[] = manager.getNonRunningModules(null, targets);
          List toStart = new ArrayList(moduleIds.length);
          for (int i = 0; i < moduleIds.length; i++) {
              TargetModuleID moduleId = moduleIds[i];
              if (getId().equals(moduleId.getModuleID())) {
                  toStart.add(moduleId);
              }
          }
          if (toStart.size() == 0) {
              System.out.println("Module is already running or may not be deployed: " + getId());
              return;
          }
          moduleIds = (TargetModuleID[]) toStart.toArray(new TargetModuleID[toStart.size()]);
          ProgressObject progress = manager.start(moduleIds);
          DeploymentClient.waitFor(progress);
      }
  
  }
  
  
  
  1.1                  incubator-geronimo/modules/maven-plugin/src/java/org/apache/geronimo/deployment/mavenplugin/StartServer.java
  
  Index: StartServer.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.mavenplugin;
  
  import java.io.File;
  import java.io.ObjectInputStream;
  import java.net.URL;
  import java.net.URI;
  import java.util.Iterator;
  import java.util.List;
  import java.util.ArrayList;
  import java.util.StringTokenizer;
  
  import javax.management.ObjectName;
  
  import org.apache.geronimo.gbean.jmx.GBeanMBean;
  import org.apache.geronimo.kernel.config.Configuration;
  import org.apache.geronimo.kernel.config.ConfigurationManager;
  import org.apache.geronimo.kernel.Kernel;
  import org.apache.geronimo.kernel.log.GeronimoLogging;
  import org.apache.geronimo.system.url.GeronimoURLFactory;
  
  /**
   *
   *
   * @version $Revision: 1.1 $ $Date: 2004/07/25 08:22:07 $
   *
   * */
  public class StartServer {
  
      static {
          // This MUST be done before the first log is acquired
          GeronimoLogging.initialize(GeronimoLogging.INFO);
  
          // Install our url factory
          GeronimoURLFactory.install();
      }
  
      private String geronimoHome;
      private String kernelName;
      private String domainName;
      private String configs;
  
      public String getGeronimoHome() {
          return geronimoHome;
      }
  
      public void setGeronimoHome(String geronimoHome) {
          this.geronimoHome = geronimoHome;
      }
  
      public String getKernelName() {
          return kernelName;
      }
  
      public void setKernelName(String kernelName) {
          this.kernelName = kernelName;
      }
  
      public String getDomainName() {
          return domainName;
      }
  
      public void setDomainName(String domainName) {
          this.domainName = domainName;
      }
  
      public String getConfigs() {
          return configs;
      }
  
      public void setConfigs(String configs) {
          this.configs = configs;
      }
  
      public void execute() throws Exception {
          System.setProperty("geronimo.base.dir", getGeronimoHome());
          List configList = new ArrayList();
          for (StringTokenizer st = new StringTokenizer(configs); st.hasMoreTokens();) {
              configList.add(new URI(st.nextToken()));
          }
          File root = new File(getGeronimoHome());
          URL systemURL = new File(root, "bin/server.jar").toURL();
  //        System.out.println("systemURL = " + systemURL);
          URL configURL = new URL("jar:" + systemURL.toString() + "!/META-INF/config.ser");
          GBeanMBean configuration = new GBeanMBean(Configuration.GBEAN_INFO, this.getClass().getClassLoader());
          ObjectInputStream ois = new ObjectInputStream(configURL.openStream());
          try {
              Configuration.loadGMBeanState(configuration, ois);
          } finally {
              ois.close();
          }
  
          // build a basic kernel without a configuration-store, our configuration store is
          Kernel kernel = new Kernel(getKernelName(), getDomainName());
          kernel.boot();
  
          ConfigurationManager configurationManager = kernel.getConfigurationManager();
          ObjectName configName = configurationManager.load(configuration, systemURL);
          kernel.startRecursiveGBean(configName);
  
          // load the rest of the configuration listed on the command line
          for (Iterator i = configList.iterator(); i.hasNext();) {
              URI configID = (URI) i.next();
              List list = configurationManager.loadRecursive(configID);
              for (Iterator iterator = list.iterator(); iterator.hasNext();) {
                  ObjectName name = (ObjectName) iterator.next();
                  kernel.startRecursiveGBean(name);
                  System.out.println("started gbean: " + name);
              }
          }
  
  
      }
  }
  
  
  
  1.1                  incubator-geronimo/modules/maven-plugin/src/java/org/apache/geronimo/deployment/mavenplugin/StopModule.java
  
  Index: StopModule.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.mavenplugin;
  
  import java.util.List;
  import java.util.ArrayList;
  
  import javax.enterprise.deploy.spi.DeploymentManager;
  import javax.enterprise.deploy.spi.Target;
  import javax.enterprise.deploy.spi.TargetModuleID;
  import javax.enterprise.deploy.spi.status.ProgressObject;
  
  /**
   *
   *
   * @version $Revision: 1.1 $ $Date: 2004/07/25 08:22:07 $
   *
   * */
  public class StopModule extends AbstractModuleCommand {
      private String id;
  
      public String getId() {
          return id;
      }
  
      public void setId(String id) {
          this.id = id;
      }
  
      public void execute() throws Exception {
          DeploymentManager manager = getDeploymentManager();
  
          Target[] targets = manager.getTargets();
          TargetModuleID moduleIds[] = manager.getRunningModules(null, targets);
          List toStop = new ArrayList(moduleIds.length);
          for (int i = 0; i < moduleIds.length; i++) {
              TargetModuleID moduleId = moduleIds[i];
              if (getId().equals(moduleId.getModuleID())) {
                  toStop.add(moduleId);
              }
          }
          if (toStop.size() == 0) {
              System.out.println("Module is not running or not deployed: " + getId());
              return;
          }
          moduleIds = (TargetModuleID[]) toStop.toArray(new TargetModuleID[toStop.size()]);
          ProgressObject progress = manager.stop(moduleIds);
          DeploymentClient.waitFor(progress);
      }
  
  }
  
  
  
  1.1                  incubator-geronimo/modules/maven-plugin/src/java/org/apache/geronimo/deployment/mavenplugin/StopServer.java
  
  Index: StopServer.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.mavenplugin;
  
  import org.apache.geronimo.kernel.Kernel;
  
  /**
   *
   *
   * @version $Revision: 1.1 $ $Date: 2004/07/25 08:22:07 $
   *
   * */
  public class StopServer {
  
      private String kernelName;
  
      public String getKernelName() {
          return kernelName;
      }
  
      public void execute() throws Exception {
          Kernel kernel = Kernel.getKernel(getKernelName());
          kernel.shutdown();
      }
  
      public void setKernelName(String kernelName) {
          this.kernelName = kernelName;
      }
  }
  
  
  
  1.1                  incubator-geronimo/modules/maven-plugin/src/java/org/apache/geronimo/deployment/mavenplugin/UndeployModule.java
  
  Index: UndeployModule.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.mavenplugin;
  
  import java.util.List;
  import java.util.ArrayList;
  
  import javax.enterprise.deploy.spi.DeploymentManager;
  import javax.enterprise.deploy.spi.Target;
  import javax.enterprise.deploy.spi.TargetModuleID;
  import javax.enterprise.deploy.spi.status.ProgressObject;
  
  /**
   *
   *
   * @version $Revision: 1.1 $ $Date: 2004/07/25 08:22:07 $
   *
   * */
  public class UndeployModule extends AbstractModuleCommand {
  
      private String id;
  
      public String getId() {
          return id;
      }
  
      public void setId(String id) {
          this.id = id;
      }
  
      public void execute() throws Exception {
          DeploymentManager manager = getDeploymentManager();
  
          Target[] targets = manager.getTargets();
          TargetModuleID moduleIds[] = manager.getNonRunningModules(null, targets);
          List toUndeploy = new ArrayList(moduleIds.length);
          for (int i = 0; i < moduleIds.length; i++) {
              TargetModuleID moduleId = moduleIds[i];
              if (getId().equals(moduleId.getModuleID())) {
                  toUndeploy.add(moduleId);
              }
          }
          if (toUndeploy.size() == 0) {
              System.out.println("Module is running or not deployed: " + getId());
              return;
          }
          moduleIds = (TargetModuleID[]) toUndeploy.toArray(new TargetModuleID[toUndeploy.size()]);
          ProgressObject progress = manager.undeploy(moduleIds);
          DeploymentClient.waitFor(progress);
      }
  
  }
  
  
  

Mime
View raw message