Return-Path: Delivered-To: apmail-geronimo-dev-archive@www.apache.org Received: (qmail 18922 invoked from network); 6 Dec 2005 23:45:07 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 6 Dec 2005 23:45:07 -0000 Received: (qmail 49130 invoked by uid 500); 6 Dec 2005 23:45:01 -0000 Delivered-To: apmail-geronimo-dev-archive@geronimo.apache.org Received: (qmail 48845 invoked by uid 500); 6 Dec 2005 23:45:00 -0000 Mailing-List: contact dev-help@geronimo.apache.org; run by ezmlm Precedence: bulk list-help: list-unsubscribe: List-Post: Reply-To: dev@geronimo.apache.org List-Id: Delivered-To: mailing list dev@geronimo.apache.org Received: (qmail 48823 invoked by uid 99); 6 Dec 2005 23:44:59 -0000 Received: from asf.osuosl.org (HELO asf.osuosl.org) (140.211.166.49) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 06 Dec 2005 15:44:59 -0800 X-ASF-Spam-Status: No, hits=0.0 required=10.0 tests= X-Spam-Check-By: apache.org Received-SPF: unknown (asf.osuosl.org: error in processing during lookup of toby@caboteria.org) Received: from [207.172.4.61] (HELO smtp01.mrf.mail.rcn.net) (207.172.4.61) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 06 Dec 2005 15:44:58 -0800 Received: from 207-172-209-236.c3-0.ded-ubr1.sbo-ded.ma.cable.rcn.com (HELO mail.caboteria.org) ([207.172.209.236]) by smtp01.mrf.mail.rcn.net with ESMTP; 06 Dec 2005 18:44:36 -0500 X-IronPort-AV: i="3.99,223,1131339600"; d="scan'208"; a="138567432:sNHT36441618" Received: by mail.caboteria.org (Postfix, from userid 1000) id 9DD5EC402E; Tue, 6 Dec 2005 18:44:35 -0500 (EST) Date: Tue, 6 Dec 2005 18:44:35 -0500 From: toby cabot To: dev@geronimo.apache.org Subject: Re: list-targets command (proof of concept) Message-ID: <20051206234435.GA19656@caboteria.org> References: <74e15baa0511211124o7aaf36fcv6cfbac33f1a5598f@mail.gmail.com> <20051202201220.GA16035@caboteria.org> <1a4017e818c64eaf8fa311bc94fb84ed@yahoo.com> <20051205215327.GA25287@caboteria.org> <383e66675130d4d70427f94263d253d7@yahoo.com> <20051205224151.GA26176@caboteria.org> <74e15baa0512051500y561bfce7i8cf29ff3a75dbff0@mail.gmail.com> <20051205233349.GB26304@caboteria.org> <74e15baa0512051709x7bd1eec9i2e45e2e9e1df8eae@mail.gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <74e15baa0512051709x7bd1eec9i2e45e2e9e1df8eae@mail.gmail.com> User-Agent: Mutt/1.5.11 X-Virus-Checked: Checked by ClamAV on apache.org X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N 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 @@ Bootstrapping service deployer + ServerInfo + + config-store2 + + ServerInfo + + 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 + * ConfigurationStore, specified by its name. + * + * @param targetName a String value that must be the + * ObjectName of a ConfigurationStore + * @param moduleFile a File value + * @param planFile a File value + * @return a List of URI-format String. + * @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 + * ConfigurationStore. + * + * @param store a ConfigurationStore value + * @param moduleFile a File value + * @param planFile a File value + * @return a List of URI-format String. + * @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 String value that describes a + * target, usually one of the entries that comes back from the + * deployer list-targets command, + * e.g. geronimo.server:J2EEApplication=null,J2EEModule=geronimo/system/1.0-SNAPSHOT/car,J2EEServer=geronimo,j2eeType=ConfigurationStore,name=Local + * @return a ConfigurationStore 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;