geronimo-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From toby cabot <t...@caboteria.org>
Subject Re: list-targets command (proof of concept)
Date Tue, 06 Dec 2005 23:44:35 GMT
Thanks for the pointers Aaron,

Here's a proof-of-concept that allows Geronimo to run with two
LocalConfigStores and respects the target that you provide on the
deployer command line.  It's only a proof-of-concept because it
doesn't address a few important issues:

o I didn't fix AppClientModuleBuilder, only allow it to run with two
config stores

o I don't think that the way the deployer chooses the default target
is ggod; it seems to be unpredicatble.  It might be better to have an
explicit "deploy to the default target" command that lets the server
choose which target to deploy to.

o From a user perspective we might want to make the target naming
simpler or allow the user to use "nicknames".

I'm sure there are lots of other "wanna-haves" but this indicates that
we're not that far off from having the basic functionality.  I've got
to work on some other stuff for the next couple of days, and you're
probably going to be busy getting 1.0 out the door, but it would be
great if we could revisit this at some point.

Thanks,
Toby

Index: modules/assembly/maven.xml
===================================================================
--- modules/assembly/maven.xml	(revision 354583)
+++ modules/assembly/maven.xml	(working copy)
@@ -340,6 +340,7 @@
         <ant:echo>Bootstrapping service deployer</ant:echo>
         <ant:mkdir dir="${geronimo.assembly.dir}/bin"/>
         <ant:mkdir dir="${geronimo.assembly.dir}/config-store"/>
+        <ant:mkdir dir="${geronimo.assembly.dir}/config-store2"/>
 
         <define:taglib uri="geronimo:bootstrap">
             <define:jellybean
Index: modules/assembly/src/plan/system-plan.xml
===================================================================
--- modules/assembly/src/plan/system-plan.xml	(revision 354583)
+++ modules/assembly/src/plan/system-plan.xml	(working copy)
@@ -65,6 +65,12 @@
             <name>ServerInfo</name>
         </reference>
     </gbean>
+    <gbean name="Local2" class="org.apache.geronimo.system.configuration.LocalConfigStore">
+        <attribute name="root">config-store2</attribute>
+        <reference name="ServerInfo">
+            <name>ServerInfo</name>
+        </reference>
+    </gbean>
 
     <!-- Repository -->
     <gbean name="Repository" class="org.apache.geronimo.system.repository.FileSystemRepository">
Index: modules/deployment/src/java/org/apache/geronimo/deployment/Deployer.java
===================================================================
--- modules/deployment/src/java/org/apache/geronimo/deployment/Deployer.java	(revision 354583)
+++ modules/deployment/src/java/org/apache/geronimo/deployment/Deployer.java	(working copy)
@@ -58,16 +58,55 @@
 public class Deployer {
     private static final Log log = LogFactory.getLog(Deployer.class);
     private final Collection builders;
-    private final ConfigurationStore store;
+    private final Collection stores;
+    private final ConfigurationStore defaultStore;
     private final Kernel kernel;
 
-    public Deployer(Collection builders, ConfigurationStore store, Kernel kernel) {
+    public Deployer(Collection builders, Collection stores, Kernel kernel) {
         this.builders = builders;
-        this.store = store;
+        this.stores = stores;
+        if (null != stores && stores.size() > 0) {
+            this.defaultStore = (ConfigurationStore)stores.iterator().next();
+        } else {
+            this.defaultStore = null;
+        }
         this.kernel = kernel;
     }
 
+
     public List deploy(File moduleFile, File planFile) throws DeploymentException {
+        return deploy(planFile, moduleFile, null, true, null, null, null, null, defaultStore);
+    }
+
+
+    /**
+     * Deploy the specified module/plan to the 
+     * <code>ConfigurationStore</code>, specified by its name.
+     *
+     * @param targetName a <code>String</code> value that must be the
+     * <code>ObjectName</code> of a <code>ConfigurationStore</code>
+     * @param moduleFile a <code>File</code> value
+     * @param planFile a <code>File</code> value
+     * @return a <code>List</code> of URI-format <code>String</code>.
+     * @exception DeploymentException if an error occurs
+     */
+    public List deploy(String targetName, File moduleFile, File planFile) throws DeploymentException
{
+        ConfigurationStore store = findConfigStore(targetName);
+        return deploy(planFile, moduleFile, null, true, null, null, null, null, store);
+    }
+
+
+    /**
+     * Deploy the specified module/plan to the specified
+     * <code>ConfigurationStore</code>.
+     *
+     * @param store a <code>ConfigurationStore</code> value
+     * @param moduleFile a <code>File</code> value
+     * @param planFile a <code>File</code> value
+     * @return a <code>List</code> of URI-format <code>String</code>.
+     * @exception DeploymentException if an error occurs
+     */
+    List deploy(ConfigurationStore store, File moduleFile, File planFile) throws DeploymentException
{
         File originalModuleFile = moduleFile;
         File tmpDir = null;
         if (moduleFile != null && !moduleFile.isDirectory()) {
@@ -88,7 +127,7 @@
         }
 
         try {
-            return deploy(planFile, moduleFile, null, true, null, null, null, null);
+            return deploy(planFile, moduleFile, null, true, null, null, null, null, store);
         } catch (DeploymentException e) {
             log.debug("Deployment failed: plan=" + planFile +", module=" + originalModuleFile,
e);
             throw e.cleanse();
@@ -172,6 +211,15 @@
     }
 
     public List deploy(File planFile, File moduleFile, File targetFile, boolean install,
String mainClass, String classPath, String endorsedDirs, String extensionDirs) throws DeploymentException
{
+        return deploy(planFile, moduleFile, targetFile, install, mainClass, classPath, endorsedDirs,
extensionDirs, this.defaultStore);
+    }
+
+
+    List deploy(File planFile, File moduleFile, File targetFile, boolean install, String
mainClass, String classPath, String endorsedDirs, String extensionDirs, ConfigurationStore
store) throws DeploymentException {
+        if (null == store) {
+            throw new DeploymentException("No configuration store specified.");
+        }
+
         if (planFile == null && moduleFile == null) {
             throw new DeploymentException("No plan or module specified");
         }
@@ -298,6 +346,29 @@
         }
     }
 
+
+    /**
+     * Finds the ConfigurationStore that matches the target name provided.
+     *
+     * @param target a <code>String</code> value that describes a
+     * target, usually one of the entries that comes back from the
+     * deployer list-targets command,
+     * e.g. <code>geronimo.server:J2EEApplication=null,J2EEModule=geronimo/system/1.0-SNAPSHOT/car,J2EEServer=geronimo,j2eeType=ConfigurationStore,name=Local</code>
+     * @return a <code>ConfigurationStore</code> value
+     * @exception DeploymentException if an error occurs, probably
+     * because the target provided didn't match any ConfigurationStore
+     */
+    ConfigurationStore findConfigStore(String target) throws DeploymentException {
+        for (Iterator i = stores.iterator(); i.hasNext(); ) {
+            ConfigurationStore candidate = (ConfigurationStore)i.next();
+            if (candidate.getObjectName().equals(target)) {
+                return candidate;
+            }
+        }
+        throw new DeploymentException("no configuration store matches the target name \""
+ target + "\"");
+    }
+
+
     public static final GBeanInfo GBEAN_INFO;
 
     private static final String DEPLOYER = "Deployer";
@@ -307,6 +378,7 @@
 
         infoFactory.addAttribute("kernel", Kernel.class, false);
         infoFactory.addAttribute("remoteDeployUploadURL", String.class, false);
+        infoFactory.addOperation("deploy", new Class[]{String.class, File.class, File.class});
         infoFactory.addOperation("deploy", new Class[]{File.class, File.class});
         infoFactory.addOperation("deploy", new Class[]{File.class, File.class, File.class,
boolean.class, String.class, String.class, String.class, String.class});
 
Index: modules/deploy-jsr88/src/java/org/apache/geronimo/deployment/plugin/local/AbstractDeployCommand.java
===================================================================
--- modules/deploy-jsr88/src/java/org/apache/geronimo/deployment/plugin/local/AbstractDeployCommand.java
(revision 354583)
+++ modules/deploy-jsr88/src/java/org/apache/geronimo/deployment/plugin/local/AbstractDeployCommand.java
(working copy)
@@ -42,7 +42,7 @@
     private final static String DEPLOYER_NAME = "*:name=Deployer,j2eeType=Deployer,*";
 
     protected final Kernel kernel;
-    private static final String[] DEPLOY_SIG = {File.class.getName(), File.class.getName()};
+    private static final String[] DEPLOY_SIG = {String.class.getName(), File.class.getName(),
File.class.getName()};
     protected final boolean spool;
     protected File moduleArchive;
     protected File deploymentPlan;
@@ -101,7 +101,7 @@
     }
 
     protected void doDeploy(Target target, boolean finished) throws Exception {
-        File[] args = {moduleArchive, deploymentPlan};
+        Object[] args = {target.getName(), moduleArchive, deploymentPlan};
         massageFileNames(args);
         List objectNames = (List) kernel.invoke(deployer, "deploy", args, DEPLOY_SIG);
         if (objectNames == null || objectNames.isEmpty()) {
@@ -132,7 +132,7 @@
         }
     }
 
-    protected void massageFileNames(File[] inputs) {
+    protected void massageFileNames(Object[] inputs) {
     }
 
     public URL getRemoteDeployUploadURL() throws Exception {
Index: modules/client-builder/src/java/org/apache/geronimo/client/builder/AppClientModuleBuilder.java
===================================================================
--- modules/client-builder/src/java/org/apache/geronimo/client/builder/AppClientModuleBuilder.java
(revision 354583)
+++ modules/client-builder/src/java/org/apache/geronimo/client/builder/AppClientModuleBuilder.java
(working copy)
@@ -117,7 +117,7 @@
                                   ModuleBuilder connectorModuleBuilder,
                                   ResourceReferenceBuilder resourceReferenceBuilder,
                                   ServiceReferenceBuilder serviceReferenceBuilder,
-                                  ConfigurationStore store,
+                                  Collection stores,
                                   Repository repository,
                                   Kernel kernel) throws DeploymentException {
         this.defaultClientParentId = defaultClientParentId == null? Collections.EMPTY_LIST:
Arrays.asList(defaultClientParentId);
@@ -125,7 +125,11 @@
         this.corbaGBeanObjectName = corbaGBeanObjectName;
         this.kernel = kernel;
         this.repository = repository;
-        this.store = store;
+        if (null != stores && stores.size() > 0) {
+            this.store = (ConfigurationStore)stores.iterator().next();
+        } else {
+            this.store = null;
+        }
         this.transactionContextManagerObjectName = transactionContextManagerObjectName;
         this.connectionTrackerObjectName = connectionTrackerObjectName;
         this.ejbReferenceBuilder = ejbReferenceBuilder;

Mime
View raw message