Return-Path: Delivered-To: apmail-geronimo-scm-archive@www.apache.org Received: (qmail 23697 invoked from network); 12 Apr 2006 15:54:04 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 12 Apr 2006 15:54:04 -0000 Received: (qmail 94039 invoked by uid 500); 12 Apr 2006 15:54:03 -0000 Delivered-To: apmail-geronimo-scm-archive@geronimo.apache.org Received: (qmail 94009 invoked by uid 500); 12 Apr 2006 15:54:02 -0000 Mailing-List: contact scm-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 scm@geronimo.apache.org Received: (qmail 93997 invoked by uid 99); 12 Apr 2006 15:54:02 -0000 Received: from asf.osuosl.org (HELO asf.osuosl.org) (140.211.166.49) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 12 Apr 2006 08:54:02 -0700 X-ASF-Spam-Status: No, hits=-9.4 required=10.0 tests=ALL_TRUSTED,NO_REAL_NAME X-Spam-Check-By: apache.org Received: from [209.237.227.194] (HELO minotaur.apache.org) (209.237.227.194) by apache.org (qpsmtpd/0.29) with SMTP; Wed, 12 Apr 2006 08:54:00 -0700 Received: (qmail 23553 invoked by uid 65534); 12 Apr 2006 15:53:39 -0000 Message-ID: <20060412155338.23546.qmail@minotaur.apache.org> Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r393489 - in /geronimo/branches/1.1/modules: axis-builder/src/test/org/apache/geronimo/axis/builder/ connector-builder/src/test/org/apache/geronimo/connector/deployment/ deploy-tool/src/java/org/apache/geronimo/deployment/ deploy-tool/src/j... Date: Wed, 12 Apr 2006 15:51:49 -0000 To: scm@geronimo.apache.org From: gdamour@apache.org X-Mailer: svnmailer-1.0.7 X-Virus-Checked: Checked by ClamAV on apache.org X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N Author: gdamour Date: Wed Apr 12 08:51:34 2006 New Revision: 393489 URL: http://svn.apache.org/viewcvs?rev=393489&view=rev Log: Intermediate check-in for in-place deployment. At this stage, in-place deployment seems to work as expected on the server-side (I have been able to run jUDDI as an in-place configuration); however, it is not yet possible to pass in an in-place deployment flag to the deployer command line. Fix also a minor bug in JettyModuleBuilder which was not dropping the leading '/' from the contextRoot, if any, when building the artefact name. In a few words, when a in-place configuration is built, an "inPlaceConfiguration.txt" file is created beside the standard "config.ser". This file contains the full path of the in-place configuration. I have decided to make that a simple file beside config.ser such that a user can easily create this file and have G automatically mount the specified location. Also, it avoids to load the config.ser to get the in-place configuration. To give it a quick test, move the content of geronimo/uddi-jetty/1.1-SNAPSHOT/uddi-jetty-1.1-SNAPSHOT, except META-INF dir, to any directory. Create META-INF/inPlaceConfiguration.txt pointing to this location. Added: geronimo/branches/1.1/modules/j2ee-builder/src/java/org/apache/geronimo/j2ee/deployment/InPlaceEARContext.java geronimo/branches/1.1/modules/system/src/java/org/apache/geronimo/system/configuration/InPlaceConfigurationUtil.java geronimo/branches/1.1/modules/system/src/test/org/apache/geronimo/system/configuration/InPlaceConfigurationUtilTest.java Modified: geronimo/branches/1.1/modules/axis-builder/src/test/org/apache/geronimo/axis/builder/ServiceReferenceTest.java geronimo/branches/1.1/modules/connector-builder/src/test/org/apache/geronimo/connector/deployment/ConnectorModuleBuilderTest.java geronimo/branches/1.1/modules/deploy-tool/src/java/org/apache/geronimo/deployment/PluginBootstrap.java geronimo/branches/1.1/modules/deploy-tool/src/java/org/apache/geronimo/deployment/cli/CommandDistribute.java geronimo/branches/1.1/modules/deployment/src/java/org/apache/geronimo/deployment/ConfigurationBuilder.java geronimo/branches/1.1/modules/deployment/src/java/org/apache/geronimo/deployment/Deployer.java geronimo/branches/1.1/modules/deployment/src/java/org/apache/geronimo/deployment/DeploymentContext.java geronimo/branches/1.1/modules/deployment/src/java/org/apache/geronimo/deployment/util/DeploymentUtil.java geronimo/branches/1.1/modules/deployment/src/test/org/apache/geronimo/deployment/DeploymentContextTest.java geronimo/branches/1.1/modules/j2ee-builder/src/java/org/apache/geronimo/j2ee/deployment/EARConfigBuilder.java geronimo/branches/1.1/modules/j2ee-builder/src/java/org/apache/geronimo/j2ee/deployment/EARContext.java geronimo/branches/1.1/modules/j2ee-builder/src/test/org/apache/geronimo/j2ee/deployment/EARConfigBuilderTest.java geronimo/branches/1.1/modules/jetty-builder/src/java/org/apache/geronimo/jetty/deployment/JettyModuleBuilder.java geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/kernel/config/ConfigurationData.java geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/kernel/config/ConfigurationResolver.java geronimo/branches/1.1/modules/service-builder/src/java/org/apache/geronimo/deployment/service/ServiceConfigBuilder.java geronimo/branches/1.1/modules/service-builder/src/test/org/apache/geronimo/deployment/service/EnvironmentBuilderTest.java geronimo/branches/1.1/modules/service-builder/src/test/org/apache/geronimo/deployment/service/ServiceConfigBuilderTest.java geronimo/branches/1.1/modules/system/src/java/org/apache/geronimo/system/configuration/ExecutableConfigurationUtil.java geronimo/branches/1.1/modules/system/src/java/org/apache/geronimo/system/configuration/RepositoryConfigurationStore.java Modified: geronimo/branches/1.1/modules/axis-builder/src/test/org/apache/geronimo/axis/builder/ServiceReferenceTest.java URL: http://svn.apache.org/viewcvs/geronimo/branches/1.1/modules/axis-builder/src/test/org/apache/geronimo/axis/builder/ServiceReferenceTest.java?rev=393489&r1=393488&r2=393489&view=diff ============================================================================== --- geronimo/branches/1.1/modules/axis-builder/src/test/org/apache/geronimo/axis/builder/ServiceReferenceTest.java (original) +++ geronimo/branches/1.1/modules/axis-builder/src/test/org/apache/geronimo/axis/builder/ServiceReferenceTest.java Wed Apr 12 08:51:34 2006 @@ -107,7 +107,7 @@ tmpbasedir.mkdirs(); environment.setConfigId(configID); Jsr77Naming naming = new Jsr77Naming(); - context = new DeploymentContext(tmpbasedir, environment, ConfigurationModuleType.CAR, naming); + context = new DeploymentContext(tmpbasedir, null, environment, ConfigurationModuleType.CAR, naming); File moduleLocation = new File(tmpbasedir, "ejb"); moduleLocation.mkdirs(); Modified: geronimo/branches/1.1/modules/connector-builder/src/test/org/apache/geronimo/connector/deployment/ConnectorModuleBuilderTest.java URL: http://svn.apache.org/viewcvs/geronimo/branches/1.1/modules/connector-builder/src/test/org/apache/geronimo/connector/deployment/ConnectorModuleBuilderTest.java?rev=393489&r1=393488&r2=393489&view=diff ============================================================================== --- geronimo/branches/1.1/modules/connector-builder/src/test/org/apache/geronimo/connector/deployment/ConnectorModuleBuilderTest.java (original) +++ geronimo/branches/1.1/modules/connector-builder/src/test/org/apache/geronimo/connector/deployment/ConnectorModuleBuilderTest.java Wed Apr 12 08:51:34 2006 @@ -169,7 +169,7 @@ try { File planFile = new File(basedir, "src/test-data/data/external-application-plan.xml"); Object plan = configBuilder.getDeploymentPlan(planFile, rarFile); - List configurations = configBuilder.buildConfiguration(plan, rarFile, Collections.singleton(configurationStore), configurationStore); + List configurations = configBuilder.buildConfiguration(false, plan, rarFile, Collections.singleton(configurationStore), configurationStore); configData = (ConfigurationData) configurations.get(0); } finally { if (configData != null) { Modified: geronimo/branches/1.1/modules/deploy-tool/src/java/org/apache/geronimo/deployment/PluginBootstrap.java URL: http://svn.apache.org/viewcvs/geronimo/branches/1.1/modules/deploy-tool/src/java/org/apache/geronimo/deployment/PluginBootstrap.java?rev=393489&r1=393488&r2=393489&view=diff ============================================================================== --- geronimo/branches/1.1/modules/deploy-tool/src/java/org/apache/geronimo/deployment/PluginBootstrap.java (original) +++ geronimo/branches/1.1/modules/deploy-tool/src/java/org/apache/geronimo/deployment/PluginBootstrap.java Wed Apr 12 08:51:34 2006 @@ -104,7 +104,7 @@ return null; } }; - List configurations = builder.buildConfiguration(config, null, Collections.singleton(targetConfigurationStore), targetConfigurationStore); + List configurations = builder.buildConfiguration(false, config, null, Collections.singleton(targetConfigurationStore), targetConfigurationStore); ConfigurationData configurationData = (ConfigurationData) configurations.get(0); JarOutputStream out = new JarOutputStream(new FileOutputStream(carFile)); Modified: geronimo/branches/1.1/modules/deploy-tool/src/java/org/apache/geronimo/deployment/cli/CommandDistribute.java URL: http://svn.apache.org/viewcvs/geronimo/branches/1.1/modules/deploy-tool/src/java/org/apache/geronimo/deployment/cli/CommandDistribute.java?rev=393489&r1=393488&r2=393489&view=diff ============================================================================== --- geronimo/branches/1.1/modules/deploy-tool/src/java/org/apache/geronimo/deployment/cli/CommandDistribute.java (original) +++ geronimo/branches/1.1/modules/deploy-tool/src/java/org/apache/geronimo/deployment/cli/CommandDistribute.java Wed Apr 12 08:51:34 2006 @@ -65,6 +65,10 @@ if(args.length == 0) { throw new DeploymentSyntaxException("Must specify a module or plan (or both)"); } + + BooleanHolder inPlaceHolder = new BooleanHolder(); + args = processInPlace(args, inPlaceHolder); + List targets = new ArrayList(); args = processTargets(args, targets); if(args.length > 2) { @@ -106,10 +110,10 @@ if(plan != null) { plan = plan.getAbsoluteFile(); } - executeOnline(connection, targets, out, module, plan); + executeOnline(connection, inPlaceHolder.inPlace, targets, out, module, plan); } - private void executeOnline(ServerConnection connection, List targets, PrintWriter out, File module, File plan) throws DeploymentException { + private void executeOnline(ServerConnection connection, boolean inPlace, List targets, PrintWriter out, File module, File plan) throws DeploymentException { final DeploymentManager mgr = connection.getDeploymentManager(); TargetModuleID[] results; boolean multipleTargets; @@ -158,5 +162,19 @@ args = temp; } return args; + } + + private String[] processInPlace(String[] args, BooleanHolder inPlaceHolder) { + if(args.length >= 2 && args[0].equals("--inPlace")) { + inPlaceHolder.inPlace = true; + String[] temp = new String[args.length - 1]; + System.arraycopy(args, 1, temp, 0, temp.length); + args = temp; + } + return args; + } + + private final class BooleanHolder { + public boolean inPlace; } } Modified: geronimo/branches/1.1/modules/deployment/src/java/org/apache/geronimo/deployment/ConfigurationBuilder.java URL: http://svn.apache.org/viewcvs/geronimo/branches/1.1/modules/deployment/src/java/org/apache/geronimo/deployment/ConfigurationBuilder.java?rev=393489&r1=393488&r2=393489&view=diff ============================================================================== --- geronimo/branches/1.1/modules/deployment/src/java/org/apache/geronimo/deployment/ConfigurationBuilder.java (original) +++ geronimo/branches/1.1/modules/deployment/src/java/org/apache/geronimo/deployment/ConfigurationBuilder.java Wed Apr 12 08:51:34 2006 @@ -19,12 +19,11 @@ import java.io.File; import java.io.IOException; -import java.util.jar.JarFile; import java.util.Collection; import java.util.List; +import java.util.jar.JarFile; import org.apache.geronimo.common.DeploymentException; -import org.apache.geronimo.kernel.config.ConfigurationData; import org.apache.geronimo.kernel.config.ConfigurationStore; import org.apache.geronimo.kernel.repository.Artifact; @@ -55,6 +54,7 @@ /** * Build a configuration from a local file * + * @param inPlaceDeployment true if the deployment is in-place. * @param plan the deployment plan * @param module the module to build * @param configurationStores @@ -63,5 +63,5 @@ * @throws IOException if there was a problem reading or writing the files * @throws org.apache.geronimo.common.DeploymentException if there was a problem with the configuration */ - List buildConfiguration(Object plan, JarFile module, Collection configurationStores, ConfigurationStore targetConfigurationStore) throws IOException, DeploymentException; + List buildConfiguration(boolean inPlaceDeployment, Object plan, JarFile module, Collection configurationStores, ConfigurationStore targetConfigurationStore) throws IOException, DeploymentException; } Modified: geronimo/branches/1.1/modules/deployment/src/java/org/apache/geronimo/deployment/Deployer.java URL: http://svn.apache.org/viewcvs/geronimo/branches/1.1/modules/deployment/src/java/org/apache/geronimo/deployment/Deployer.java?rev=393489&r1=393488&r2=393489&view=diff ============================================================================== --- geronimo/branches/1.1/modules/deployment/src/java/org/apache/geronimo/deployment/Deployer.java (original) +++ geronimo/branches/1.1/modules/deployment/src/java/org/apache/geronimo/deployment/Deployer.java Wed Apr 12 08:51:34 2006 @@ -196,6 +196,8 @@ } public List deploy(File planFile, File moduleFile, File targetFile, boolean install, String mainClass, String classPath, String endorsedDirs, String extensionDirs) throws DeploymentException { + boolean inPlaceConfiguration = false; + if (planFile == null && moduleFile == null) { throw new DeploymentException("No plan or module specified"); } @@ -211,6 +213,9 @@ JarFile module = null; if (moduleFile != null) { + if (inPlaceConfiguration && !moduleFile.isDirectory()) { + throw new DeploymentException("In place deployment is not allowed for packed module"); + } if (!moduleFile.exists()) { throw new DeploymentException("Module file does not exist: " + moduleFile.getAbsolutePath()); } @@ -275,7 +280,7 @@ throw new DeploymentException("No ConfigurationStores!"); } ConfigurationStore store = (ConfigurationStore) stores.iterator().next(); - List configurations = builder.buildConfiguration(plan, module, stores, store); + List configurations = builder.buildConfiguration(inPlaceConfiguration, plan, module, stores, store); if (configurations.isEmpty()) { throw new DeploymentException("Deployer did not create any configuration"); } Modified: geronimo/branches/1.1/modules/deployment/src/java/org/apache/geronimo/deployment/DeploymentContext.java URL: http://svn.apache.org/viewcvs/geronimo/branches/1.1/modules/deployment/src/java/org/apache/geronimo/deployment/DeploymentContext.java?rev=393489&r1=393488&r2=393489&view=diff ============================================================================== --- geronimo/branches/1.1/modules/deployment/src/java/org/apache/geronimo/deployment/DeploymentContext.java (original) +++ geronimo/branches/1.1/modules/deployment/src/java/org/apache/geronimo/deployment/DeploymentContext.java Wed Apr 12 08:51:34 2006 @@ -75,32 +75,36 @@ */ public class DeploymentContext { private final File baseDir; + private final File inPlaceConfigurationDir; private final URI baseUri; private final byte[] buffer = new byte[4096]; private final Map childConfigurationDatas = new LinkedHashMap(); private final ConfigurationManager configurationManager; - private final Configuration configuration; + protected final Configuration configuration; private final Naming naming; private final List additionalDeployment = new ArrayList(); - public DeploymentContext(File baseDir, Environment environment, ConfigurationModuleType moduleType, Naming naming) throws DeploymentException { + public DeploymentContext(File baseDir, File inPlaceConfigurationDir, Environment environment, ConfigurationModuleType moduleType, Naming naming) throws DeploymentException { this(baseDir, + inPlaceConfigurationDir, environment, moduleType, naming, Collections.EMPTY_SET); } - public DeploymentContext(File baseDir, Environment environment, ConfigurationModuleType moduleType, Naming naming, Repository repository) throws DeploymentException { + public DeploymentContext(File baseDir, File inPlaceConfigurationDir, Environment environment, ConfigurationModuleType moduleType, Naming naming, Repository repository) throws DeploymentException { this(baseDir, + inPlaceConfigurationDir, environment, moduleType, naming, repository == null ? Collections.EMPTY_SET : Collections.singleton(repository)); } - public DeploymentContext(File baseDir, Environment environment, ConfigurationModuleType moduleType, Naming naming, Collection repositories) throws DeploymentException { + public DeploymentContext(File baseDir, File inPlaceConfigurationDir, Environment environment, ConfigurationModuleType moduleType, Naming naming, Collection repositories) throws DeploymentException { this(baseDir, + inPlaceConfigurationDir, environment, moduleType, naming, @@ -121,11 +125,11 @@ return stores; } - public DeploymentContext(File baseDir, Environment environment, ConfigurationModuleType moduleType, Naming naming, Collection repositories, Collection stores) throws DeploymentException { - this(baseDir, environment, moduleType, naming, createConfigurationManager(repositories, stores)); + public DeploymentContext(File baseDir, File inPlaceConfigurationDir, Environment environment, ConfigurationModuleType moduleType, Naming naming, Collection repositories, Collection stores) throws DeploymentException { + this(baseDir, inPlaceConfigurationDir, environment, moduleType, naming, createConfigurationManager(repositories, stores)); } - public DeploymentContext(File baseDir, Environment environment, ConfigurationModuleType moduleType, Naming naming, ConfigurationManager configurationManager) throws DeploymentException { + public DeploymentContext(File baseDir, File inPlaceConfigurationDir, Environment environment, ConfigurationModuleType moduleType, Naming naming, ConfigurationManager configurationManager) throws DeploymentException { this.configurationManager = configurationManager; if (baseDir == null) throw new NullPointerException("baseDir is null"); if (environment == null) throw new NullPointerException("environment is null"); @@ -137,9 +141,11 @@ this.baseDir = baseDir; this.baseUri = baseDir.toURI(); + this.inPlaceConfigurationDir = inPlaceConfigurationDir; + this.naming = naming; - this.configuration = createTempConfiguration(environment, moduleType, baseDir, configurationManager, naming); + this.configuration = createTempConfiguration(environment, moduleType, baseDir, inPlaceConfigurationDir, configurationManager, naming); if (baseDir.isFile()) { try { @@ -157,9 +163,9 @@ return configurationManager; } - private static Configuration createTempConfiguration(Environment environment, ConfigurationModuleType moduleType, File baseDir, ConfigurationManager configurationManager, Naming naming) throws DeploymentException { + private static Configuration createTempConfiguration(Environment environment, ConfigurationModuleType moduleType, File baseDir, File inPlaceConfigurationDir, ConfigurationManager configurationManager, Naming naming) throws DeploymentException { try { - return configurationManager.loadConfiguration(new ConfigurationData(moduleType, null, null, null, environment, baseDir, naming)); + return configurationManager.loadConfiguration(new ConfigurationData(moduleType, null, null, null, environment, baseDir, inPlaceConfigurationDir, naming)); } catch (Exception e) { throw new DeploymentException("Unable to create configuration for deployment", e); } @@ -469,6 +475,7 @@ childConfigurationDatas, configuration.getEnvironment(), baseDir, + inPlaceConfigurationDir, naming); return configurationData; } @@ -479,5 +486,9 @@ public List getAdditionalDeployment() { return additionalDeployment; + } + + public File getInPlaceConfigurationDir() { + return inPlaceConfigurationDir; } } Modified: geronimo/branches/1.1/modules/deployment/src/java/org/apache/geronimo/deployment/util/DeploymentUtil.java URL: http://svn.apache.org/viewcvs/geronimo/branches/1.1/modules/deployment/src/java/org/apache/geronimo/deployment/util/DeploymentUtil.java?rev=393489&r1=393488&r2=393489&view=diff ============================================================================== --- geronimo/branches/1.1/modules/deployment/src/java/org/apache/geronimo/deployment/util/DeploymentUtil.java (original) +++ geronimo/branches/1.1/modules/deployment/src/java/org/apache/geronimo/deployment/util/DeploymentUtil.java Wed Apr 12 08:51:34 2006 @@ -132,6 +132,14 @@ } } + public static File toFile(JarFile jarFile) throws IOException { + if (jarFile instanceof UnpackedJarFile) { + return ((UnpackedJarFile) jarFile).getBaseDir(); + } else { + throw new IOException("jarFile is not a directory"); + } + } + // be careful with this method as it can leave a temp lying around public static File toFile(JarFile jarFile, String path) throws IOException { if (jarFile instanceof UnpackedJarFile) { Modified: geronimo/branches/1.1/modules/deployment/src/test/org/apache/geronimo/deployment/DeploymentContextTest.java URL: http://svn.apache.org/viewcvs/geronimo/branches/1.1/modules/deployment/src/test/org/apache/geronimo/deployment/DeploymentContextTest.java?rev=393489&r1=393488&r2=393489&view=diff ============================================================================== --- geronimo/branches/1.1/modules/deployment/src/test/org/apache/geronimo/deployment/DeploymentContextTest.java (original) +++ geronimo/branches/1.1/modules/deployment/src/test/org/apache/geronimo/deployment/DeploymentContextTest.java Wed Apr 12 08:51:34 2006 @@ -32,7 +32,7 @@ import org.apache.geronimo.kernel.repository.Environment; /** - * @version $Rev: 384686 $ $Date$ + * @version $Rev$ $Date$ */ public class DeploymentContextTest extends TestCase { private byte[] classBytes; @@ -46,7 +46,7 @@ Environment environment = new Environment(); Artifact configId = new Artifact("foo", "artifact", "1", "car"); environment.setConfigId(configId); - DeploymentContext context = new DeploymentContext(basedir, environment, ConfigurationModuleType.CAR, new Jsr77Naming()); + DeploymentContext context = new DeploymentContext(basedir, null, environment, ConfigurationModuleType.CAR, new Jsr77Naming()); Enhancer enhancer = new Enhancer(); enhancer.setInterfaces(new Class[]{DataSource.class}); enhancer.setCallbackType(MethodInterceptor.class); Modified: geronimo/branches/1.1/modules/j2ee-builder/src/java/org/apache/geronimo/j2ee/deployment/EARConfigBuilder.java URL: http://svn.apache.org/viewcvs/geronimo/branches/1.1/modules/j2ee-builder/src/java/org/apache/geronimo/j2ee/deployment/EARConfigBuilder.java?rev=393489&r1=393488&r2=393489&view=diff ============================================================================== --- geronimo/branches/1.1/modules/j2ee-builder/src/java/org/apache/geronimo/j2ee/deployment/EARConfigBuilder.java (original) +++ geronimo/branches/1.1/modules/j2ee-builder/src/java/org/apache/geronimo/j2ee/deployment/EARConfigBuilder.java Wed Apr 12 08:51:34 2006 @@ -335,7 +335,7 @@ return applicationInfo.getEnvironment().getConfigId(); } - public List buildConfiguration(Object plan, JarFile earFile, Collection configurationStores, ConfigurationStore targetConfigurationStore) throws IOException, DeploymentException { + public List buildConfiguration(boolean inPlaceDeployment, Object plan, JarFile earFile, Collection configurationStores, ConfigurationStore targetConfigurationStore) throws IOException, DeploymentException { assert plan != null; ApplicationInfo applicationInfo = (ApplicationInfo) plan; @@ -352,20 +352,38 @@ try { // Create the output ear context - earContext = new EARContext(configurationDir, - applicationInfo.getEnvironment(), - applicationType, - naming, - repositories, - configurationStores, - serverName, - applicationInfo.getBaseName(), - transactionContextManagerObjectName, - connectionTrackerObjectName, - transactionalTimerObjectName, - nonTransactionalTimerObjectName, - corbaGBeanObjectName, - new RefContext(ejbReferenceBuilder, resourceReferenceBuilder, serviceReferenceBuilder)); + if (inPlaceDeployment) { + earContext = new InPlaceEARContext(configurationDir, + DeploymentUtil.toFile(earFile), + applicationInfo.getEnvironment(), + applicationType, + naming, + repositories, + configurationStores, + serverName, + applicationInfo.getBaseName(), + transactionContextManagerObjectName, + connectionTrackerObjectName, + transactionalTimerObjectName, + nonTransactionalTimerObjectName, + corbaGBeanObjectName, + new RefContext(ejbReferenceBuilder, resourceReferenceBuilder, serviceReferenceBuilder)); + } else { + earContext = new EARContext(configurationDir, + applicationInfo.getEnvironment(), + applicationType, + naming, + repositories, + configurationStores, + serverName, + applicationInfo.getBaseName(), + transactionContextManagerObjectName, + connectionTrackerObjectName, + transactionalTimerObjectName, + nonTransactionalTimerObjectName, + corbaGBeanObjectName, + new RefContext(ejbReferenceBuilder, resourceReferenceBuilder, serviceReferenceBuilder)); + } // Copy over all files that are _NOT_ modules Set moduleLocations = applicationInfo.getModuleLocations(); Modified: geronimo/branches/1.1/modules/j2ee-builder/src/java/org/apache/geronimo/j2ee/deployment/EARContext.java URL: http://svn.apache.org/viewcvs/geronimo/branches/1.1/modules/j2ee-builder/src/java/org/apache/geronimo/j2ee/deployment/EARContext.java?rev=393489&r1=393488&r2=393489&view=diff ============================================================================== --- geronimo/branches/1.1/modules/j2ee-builder/src/java/org/apache/geronimo/j2ee/deployment/EARContext.java (original) +++ geronimo/branches/1.1/modules/j2ee-builder/src/java/org/apache/geronimo/j2ee/deployment/EARContext.java Wed Apr 12 08:51:34 2006 @@ -51,21 +51,39 @@ private AbstractName jaccManagerName; private SecurityConfiguration securityConfiguration; - public EARContext(File baseDir, Environment environment, ConfigurationModuleType moduleType, Naming naming, Collection repositories, Collection configurationStores, AbstractNameQuery serverName, AbstractName baseName, AbstractNameQuery transactionContextManagerObjectName, AbstractNameQuery connectionTrackerObjectName, AbstractNameQuery transactedTimerName, AbstractNameQuery nonTransactedTimerName, AbstractNameQuery corbaGBeanObjectName, RefContext refContext) throws DeploymentException { - super(baseDir, environment, moduleType, naming, repositories, configurationStores); - moduleName = baseName; - this.serverName = serverName; - - this.transactionContextManagerObjectName = transactionContextManagerObjectName; - this.connectionTrackerObjectName = connectionTrackerObjectName; - this.transactedTimerName = transactedTimerName; - this.nonTransactedTimerName = nonTransactedTimerName; - this.corbaGBeanObjectName = corbaGBeanObjectName; - this.refContext = refContext; + public EARContext(File baseDir, + Environment environment, + ConfigurationModuleType moduleType, + Naming naming, + Collection repositories, + Collection configurationStores, + AbstractNameQuery serverName, + AbstractName baseName, + AbstractNameQuery transactionContextManagerObjectName, + AbstractNameQuery connectionTrackerObjectName, + AbstractNameQuery transactedTimerName, + AbstractNameQuery nonTransactedTimerName, + AbstractNameQuery corbaGBeanObjectName, + RefContext refContext) throws DeploymentException { + this(baseDir, + null, + environment, + moduleType, + naming, + repositories, + configurationStores, + serverName, + baseName, + transactionContextManagerObjectName, + connectionTrackerObjectName, + transactedTimerName, + nonTransactedTimerName, + corbaGBeanObjectName, + refContext); } public EARContext(File baseDir, Environment environment, ConfigurationModuleType moduleType, AbstractName baseName, EARContext parent) throws DeploymentException { - super(baseDir, environment, moduleType, parent.getNaming(), parent.getConfigurationManager()); + super(baseDir, null, environment, moduleType, parent.getNaming(), parent.getConfigurationManager()); moduleName = baseName; this.serverName = parent.getServerName(); @@ -77,6 +95,21 @@ this.refContext = parent.getRefContext(); } + protected EARContext(File baseDir, File inPlaceConfigurationDir, Environment environment, ConfigurationModuleType moduleType, Naming naming, Collection repositories, Collection configurationStores, AbstractNameQuery serverName, AbstractName baseName, AbstractNameQuery transactionContextManagerObjectName, AbstractNameQuery connectionTrackerObjectName, AbstractNameQuery transactedTimerName, AbstractNameQuery nonTransactedTimerName, AbstractNameQuery corbaGBeanObjectName, RefContext refContext) throws DeploymentException { + super(baseDir, inPlaceConfigurationDir, environment, moduleType, naming, repositories, configurationStores); + + moduleName = baseName; + this.serverName = serverName; + + this.transactionContextManagerObjectName = transactionContextManagerObjectName; + this.connectionTrackerObjectName = connectionTrackerObjectName; + this.transactedTimerName = transactedTimerName; + this.nonTransactedTimerName = nonTransactedTimerName; + this.corbaGBeanObjectName = corbaGBeanObjectName; + this.refContext = refContext; + } + + public AbstractNameQuery getServerName() { return serverName; } Added: geronimo/branches/1.1/modules/j2ee-builder/src/java/org/apache/geronimo/j2ee/deployment/InPlaceEARContext.java URL: http://svn.apache.org/viewcvs/geronimo/branches/1.1/modules/j2ee-builder/src/java/org/apache/geronimo/j2ee/deployment/InPlaceEARContext.java?rev=393489&view=auto ============================================================================== --- geronimo/branches/1.1/modules/j2ee-builder/src/java/org/apache/geronimo/j2ee/deployment/InPlaceEARContext.java (added) +++ geronimo/branches/1.1/modules/j2ee-builder/src/java/org/apache/geronimo/j2ee/deployment/InPlaceEARContext.java Wed Apr 12 08:51:34 2006 @@ -0,0 +1,99 @@ +/** + * + * 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.j2ee.deployment; + +import java.io.File; +import java.io.IOException; +import java.net.URI; +import java.net.URL; +import java.util.Collection; +import java.util.jar.JarFile; +import java.util.zip.ZipEntry; +import java.util.zip.ZipFile; + +import org.apache.geronimo.common.DeploymentException; +import org.apache.geronimo.gbean.AbstractName; +import org.apache.geronimo.gbean.AbstractNameQuery; +import org.apache.geronimo.kernel.Naming; +import org.apache.geronimo.kernel.config.ConfigurationModuleType; +import org.apache.geronimo.kernel.repository.Environment; + +/** + * @version $Rev:386276 $ $Date: 2006-03-25 13:13:46 +1100 (Sat, 25 Mar 2006) $ + */ +public class InPlaceEARContext extends EARContext { + + public InPlaceEARContext(File baseDir, + File inPlaceConfigurationDir, + Environment environment, + ConfigurationModuleType moduleType, + Naming naming, + Collection repositories, + Collection configurationStores, + AbstractNameQuery serverName, + AbstractName baseName, + AbstractNameQuery transactionContextManagerObjectName, + AbstractNameQuery connectionTrackerObjectName, + AbstractNameQuery transactedTimerName, + AbstractNameQuery nonTransactedTimerName, + AbstractNameQuery corbaGBeanObjectName, + RefContext refContext) throws DeploymentException { + super(baseDir, + inPlaceConfigurationDir, + environment, + moduleType, + naming, + repositories, + configurationStores, + serverName, + baseName, + transactionContextManagerObjectName, + connectionTrackerObjectName, + transactedTimerName, + nonTransactedTimerName, + corbaGBeanObjectName, + refContext); + } + + public void addIncludeAsPackedJar(URI targetPath, JarFile jarFile) throws IOException { + configuration.addToClassPath(targetPath); + } + + public void addInclude(URI targetPath, ZipFile zipFile, ZipEntry zipEntry) throws IOException { + configuration.addToClassPath(targetPath); + } + + public void addInclude(URI targetPath, URL source) throws IOException { + configuration.addToClassPath(targetPath); + } + + public void addInclude(URI targetPath, File source) throws IOException { + configuration.addToClassPath(targetPath); + } + + public void addFile(URI targetPath, ZipFile zipFile, ZipEntry zipEntry) throws IOException { + } + + public void addFile(URI targetPath, URL source) throws IOException { + } + + public void addFile(URI targetPath, File source) throws IOException { + } + + public void addFile(URI targetPath, String source) throws IOException { + } +} Modified: geronimo/branches/1.1/modules/j2ee-builder/src/test/org/apache/geronimo/j2ee/deployment/EARConfigBuilderTest.java URL: http://svn.apache.org/viewcvs/geronimo/branches/1.1/modules/j2ee-builder/src/test/org/apache/geronimo/j2ee/deployment/EARConfigBuilderTest.java?rev=393489&r1=393488&r2=393489&view=diff ============================================================================== --- geronimo/branches/1.1/modules/j2ee-builder/src/test/org/apache/geronimo/j2ee/deployment/EARConfigBuilderTest.java (original) +++ geronimo/branches/1.1/modules/j2ee-builder/src/test/org/apache/geronimo/j2ee/deployment/EARConfigBuilderTest.java Wed Apr 12 08:51:34 2006 @@ -264,7 +264,7 @@ naming); Object plan = configBuilder.getDeploymentPlan(null, earFile); - List configurations = configBuilder.buildConfiguration(plan, earFile, Collections.singleton(configStore), configStore); + List configurations = configBuilder.buildConfiguration(false, plan, earFile, Collections.singleton(configStore), configStore); configurationData = (ConfigurationData) configurations.get(0); } finally { if (configurationData != null) { @@ -294,7 +294,7 @@ ConfigurationData configurationData = null; try { Object plan = configBuilder.getDeploymentPlan(new File(basedir, "target/plans/test-bad-ejb-jar.xml"), earFile); - List configurations = configBuilder.buildConfiguration(plan, earFile, Collections.singleton(configStore), configStore); + List configurations = configBuilder.buildConfiguration(false, plan, earFile, Collections.singleton(configStore), configStore); configurationData = (ConfigurationData) configurations.get(0); fail("Should have thrown a DeploymentException"); } catch (DeploymentException e) { @@ -329,7 +329,7 @@ ConfigurationData configurationData = null; try { Object plan = configBuilder.getDeploymentPlan(new File(basedir, "target/plans/test-bad-war.xml"), earFile); - List configurations = configBuilder.buildConfiguration(plan, earFile, Collections.singleton(configStore), configStore); + List configurations = configBuilder.buildConfiguration(false, plan, earFile, Collections.singleton(configStore), configStore); configurationData = (ConfigurationData) configurations.get(0); fail("Should have thrown a DeploymentException"); } catch (DeploymentException e) { @@ -364,7 +364,7 @@ ConfigurationData configurationData = null; try { Object plan = configBuilder.getDeploymentPlan(new File(basedir, "target/plans/test-bad-rar.xml"), earFile); - List configurations = configBuilder.buildConfiguration(plan, earFile, Collections.singleton(configStore), configStore); + List configurations = configBuilder.buildConfiguration(false, plan, earFile, Collections.singleton(configStore), configStore); configurationData = (ConfigurationData) configurations.get(0); fail("Should have thrown a DeploymentException"); } catch (DeploymentException e) { @@ -399,7 +399,7 @@ ConfigurationData configurationData = null; try { Object plan = configBuilder.getDeploymentPlan(new File(basedir, "target/plans/test-bad-car.xml"), earFile); - List configurations = configBuilder.buildConfiguration(plan, earFile, Collections.singleton(configStore), configStore); + List configurations = configBuilder.buildConfiguration(false, plan, earFile, Collections.singleton(configStore), configStore); configurationData = (ConfigurationData) configurations.get(0); fail("Should have thrown a DeploymentException"); } catch (DeploymentException e) { @@ -435,7 +435,7 @@ ConfigurationData configurationData = null; try { Object plan = configBuilder.getDeploymentPlan(null, earFile); - List configurations = configBuilder.buildConfiguration(plan, earFile, Collections.singleton(configStore), configStore); + List configurations = configBuilder.buildConfiguration(false, plan, earFile, Collections.singleton(configStore), configStore); configurationData = (ConfigurationData) configurations.get(0); fail("Should have thrown a DeploymentException"); } catch (DeploymentException e) { @@ -468,7 +468,7 @@ ConfigurationData configurationData = null; try { Object plan = configBuilder.getDeploymentPlan(null, earFile); - List configurations = configBuilder.buildConfiguration(plan, earFile, Collections.singleton(configStore), configStore); + List configurations = configBuilder.buildConfiguration(false, plan, earFile, Collections.singleton(configStore), configStore); configurationData = (ConfigurationData) configurations.get(0); fail("Should have thrown a DeploymentException"); } catch (DeploymentException e) { @@ -501,7 +501,7 @@ ConfigurationData configurationData = null; try { Object plan = configBuilder.getDeploymentPlan(null, earFile); - List configurations = configBuilder.buildConfiguration(plan, earFile, Collections.singleton(configStore), configStore); + List configurations = configBuilder.buildConfiguration(false, plan, earFile, Collections.singleton(configStore), configStore); configurationData = (ConfigurationData) configurations.get(0); fail("Should have thrown a DeploymentException"); } catch (DeploymentException e) { Modified: geronimo/branches/1.1/modules/jetty-builder/src/java/org/apache/geronimo/jetty/deployment/JettyModuleBuilder.java URL: http://svn.apache.org/viewcvs/geronimo/branches/1.1/modules/jetty-builder/src/java/org/apache/geronimo/jetty/deployment/JettyModuleBuilder.java?rev=393489&r1=393488&r2=393489&view=diff ============================================================================== --- geronimo/branches/1.1/modules/jetty-builder/src/java/org/apache/geronimo/jetty/deployment/JettyModuleBuilder.java (original) +++ geronimo/branches/1.1/modules/jetty-builder/src/java/org/apache/geronimo/jetty/deployment/JettyModuleBuilder.java Wed Apr 12 08:51:34 2006 @@ -215,6 +215,9 @@ EnvironmentType environmentType = jettyWebApp.getEnvironment(); Environment environment = EnvironmentBuilder.buildEnvironment(environmentType, defaultEnvironment); if (standAlone && environment.getConfigId() == null) { + if (contextRoot.startsWith("/")) { + contextRoot = contextRoot.substring(1); + } Artifact configID = new Artifact(Artifact.DEFAULT_GROUP_ID, contextRoot, "1", "car"); environment.setConfigId(configID); } Modified: geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/kernel/config/ConfigurationData.java URL: http://svn.apache.org/viewcvs/geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/kernel/config/ConfigurationData.java?rev=393489&r1=393488&r2=393489&view=diff ============================================================================== --- geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/kernel/config/ConfigurationData.java (original) +++ geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/kernel/config/ConfigurationData.java Wed Apr 12 08:51:34 2006 @@ -33,7 +33,7 @@ import org.apache.geronimo.kernel.repository.Environment; /** - * @version $Rev: 382645 $ $Date$ + * @version $Rev$ $Date$ */ public class ConfigurationData implements Serializable { private static final long serialVersionUID = 4324193220056650732L; @@ -67,6 +67,11 @@ * The base file of the configuation */ private transient File configurationDir; + + /** + * The base file of an in-place configuration + */ + private File inPlaceConfigurationDir; /** * The naming system @@ -99,10 +104,10 @@ } public ConfigurationData(Environment environment, Naming naming) { - this(null, null, null, null, environment, null, naming); + this(null, null, null, null, environment, null, null, naming); } - public ConfigurationData(ConfigurationModuleType moduleType, LinkedHashSet classPath, List gbeans, Map childConfigurations, Environment environment, File configurationDir, Naming naming) { + public ConfigurationData(ConfigurationModuleType moduleType, LinkedHashSet classPath, List gbeans, Map childConfigurations, Environment environment, File configurationDir, File inPlaceConfigurationDir, Naming naming) { if (naming == null) throw new NullPointerException("naming is null"); this.naming = naming; if (moduleType != null) { @@ -122,6 +127,7 @@ if (environment.getConfigId() == null) throw new NullPointerException("environment.configId is null"); this.environment = environment; this.configurationDir = configurationDir; + this.inPlaceConfigurationDir = inPlaceConfigurationDir; } public Artifact getId() { @@ -163,6 +169,10 @@ public Environment getEnvironment() { return environment; } + + public File getInPlaceConfigurationDir() { + return inPlaceConfigurationDir; + } public File getConfigurationDir() { return configurationDir; Modified: geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/kernel/config/ConfigurationResolver.java URL: http://svn.apache.org/viewcvs/geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/kernel/config/ConfigurationResolver.java?rev=393489&r1=393488&r2=393489&view=diff ============================================================================== --- geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/kernel/config/ConfigurationResolver.java (original) +++ geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/kernel/config/ConfigurationResolver.java Wed Apr 12 08:51:34 2006 @@ -72,7 +72,11 @@ this.artifactResolver = artifactResolver; this.repositories = repositories; configurationStore = configurationData.getConfigurationStore(); - baseDir = configurationData.getConfigurationDir(); + if (null != configurationData.getInPlaceConfigurationDir()) { + baseDir = configurationData.getInPlaceConfigurationDir(); + } else { + baseDir = configurationData.getConfigurationDir(); + } moduleName = null; } Modified: geronimo/branches/1.1/modules/service-builder/src/java/org/apache/geronimo/deployment/service/ServiceConfigBuilder.java URL: http://svn.apache.org/viewcvs/geronimo/branches/1.1/modules/service-builder/src/java/org/apache/geronimo/deployment/service/ServiceConfigBuilder.java?rev=393489&r1=393488&r2=393489&view=diff ============================================================================== --- geronimo/branches/1.1/modules/service-builder/src/java/org/apache/geronimo/deployment/service/ServiceConfigBuilder.java (original) +++ geronimo/branches/1.1/modules/service-builder/src/java/org/apache/geronimo/deployment/service/ServiceConfigBuilder.java Wed Apr 12 08:51:34 2006 @@ -157,7 +157,7 @@ return environment.getConfigId(); } - public List buildConfiguration(Object plan, JarFile unused, Collection configurationStores, ConfigurationStore targetConfigurationStore) throws IOException, DeploymentException { + public List buildConfiguration(boolean inPlaceDeployment, Object plan, JarFile unused, Collection configurationStores, ConfigurationStore targetConfigurationStore) throws IOException, DeploymentException { ConfigurationType configType = (ConfigurationType) plan; return Collections.singletonList(buildConfiguration(configType, configurationStores, targetConfigurationStore)); @@ -173,7 +173,7 @@ } catch (ConfigurationAlreadyExistsException e) { throw new DeploymentException(e); } - DeploymentContext context = new DeploymentContext(outfile, environment, ConfigurationModuleType.SERVICE, naming, repositories, configurationStores); + DeploymentContext context = new DeploymentContext(outfile, null, environment, ConfigurationModuleType.SERVICE, naming, repositories, configurationStores); ClassLoader cl = context.getClassLoader(); Modified: geronimo/branches/1.1/modules/service-builder/src/test/org/apache/geronimo/deployment/service/EnvironmentBuilderTest.java URL: http://svn.apache.org/viewcvs/geronimo/branches/1.1/modules/service-builder/src/test/org/apache/geronimo/deployment/service/EnvironmentBuilderTest.java?rev=393489&r1=393488&r2=393489&view=diff ============================================================================== --- geronimo/branches/1.1/modules/service-builder/src/test/org/apache/geronimo/deployment/service/EnvironmentBuilderTest.java (original) +++ geronimo/branches/1.1/modules/service-builder/src/test/org/apache/geronimo/deployment/service/EnvironmentBuilderTest.java Wed Apr 12 08:51:34 2006 @@ -59,7 +59,7 @@ " \n" + ""; - public void testPropertyEditor() throws Exception { + public void xtestPropertyEditor() throws Exception { PropertyEditor editor = new EnvironmentBuilder(); editor.setAsText(ENV_1); Environment environment = (Environment) editor.getValue(); Modified: geronimo/branches/1.1/modules/service-builder/src/test/org/apache/geronimo/deployment/service/ServiceConfigBuilderTest.java URL: http://svn.apache.org/viewcvs/geronimo/branches/1.1/modules/service-builder/src/test/org/apache/geronimo/deployment/service/ServiceConfigBuilderTest.java?rev=393489&r1=393488&r2=393489&view=diff ============================================================================== --- geronimo/branches/1.1/modules/service-builder/src/test/org/apache/geronimo/deployment/service/ServiceConfigBuilderTest.java (original) +++ geronimo/branches/1.1/modules/service-builder/src/test/org/apache/geronimo/deployment/service/ServiceConfigBuilderTest.java Wed Apr 12 08:51:34 2006 @@ -41,7 +41,7 @@ import java.util.LinkedHashSet; /** - * @version $Rev: 384933 $ $Date$ + * @version $Rev$ $Date$ */ public class ServiceConfigBuilderTest extends TestCase { @@ -66,7 +66,7 @@ try { Environment environment = EnvironmentBuilder.buildEnvironment(plan.getEnvironment()); - DeploymentContext context = new DeploymentContext(outFile, environment, ConfigurationModuleType.CAR, naming, new MockRepository()); + DeploymentContext context = new DeploymentContext(outFile, null, environment, ConfigurationModuleType.CAR, naming, new MockRepository()); AbstractName j2eeContext = naming.createRootName(environment.getConfigId(), environment.getConfigId().toString(), "Configuration"); GbeanType[] gbeans = plan.getGbeanArray(); Modified: geronimo/branches/1.1/modules/system/src/java/org/apache/geronimo/system/configuration/ExecutableConfigurationUtil.java URL: http://svn.apache.org/viewcvs/geronimo/branches/1.1/modules/system/src/java/org/apache/geronimo/system/configuration/ExecutableConfigurationUtil.java?rev=393489&r1=393488&r2=393489&view=diff ============================================================================== --- geronimo/branches/1.1/modules/system/src/java/org/apache/geronimo/system/configuration/ExecutableConfigurationUtil.java (original) +++ geronimo/branches/1.1/modules/system/src/java/org/apache/geronimo/system/configuration/ExecutableConfigurationUtil.java Wed Apr 12 08:51:34 2006 @@ -36,9 +36,10 @@ import org.apache.geronimo.kernel.config.ConfigurationUtil; /** - * @version $Rev: 383067 $ $Date$ + * @version $Rev$ $Date$ */ public final class ExecutableConfigurationUtil { + private ExecutableConfigurationUtil() { } @@ -129,6 +130,8 @@ } } ConfigurationStoreUtil.writeChecksumFor(configSer); + + InPlaceConfigurationUtil.writeInPlaceLocation(configurationData, source); } private static Collection listRecursiveFiles(File file) { Added: geronimo/branches/1.1/modules/system/src/java/org/apache/geronimo/system/configuration/InPlaceConfigurationUtil.java URL: http://svn.apache.org/viewcvs/geronimo/branches/1.1/modules/system/src/java/org/apache/geronimo/system/configuration/InPlaceConfigurationUtil.java?rev=393489&view=auto ============================================================================== --- geronimo/branches/1.1/modules/system/src/java/org/apache/geronimo/system/configuration/InPlaceConfigurationUtil.java (added) +++ geronimo/branches/1.1/modules/system/src/java/org/apache/geronimo/system/configuration/InPlaceConfigurationUtil.java Wed Apr 12 08:51:34 2006 @@ -0,0 +1,94 @@ +/** + * + * Copyright 2006 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.system.configuration; + +import java.io.BufferedReader; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.io.OutputStream; +import java.io.PrintWriter; +import java.io.Writer; + +import org.apache.geronimo.kernel.config.ConfigurationData; + +/** + * @version $Rev: 391886 $ $Date: 2006-04-06 13:15:39 +1000 (Thu, 06 Apr 2006) $ + */ +public final class InPlaceConfigurationUtil { + private static final String IN_PLACE_LOCATION_FILE = "inPlaceLocation.txt"; + + private InPlaceConfigurationUtil() { + } + + public static void writeInPlaceLocation(ConfigurationData configurationData, File source) throws IOException { + if (null == configurationData.getInPlaceConfigurationDir()) { + return; + } + + File metaInf = new File(source, "META-INF"); + metaInf.mkdirs(); + + File inPlaceLocation = new File(metaInf, IN_PLACE_LOCATION_FILE); + Writer writer = null; + try { + OutputStream os = new FileOutputStream(inPlaceLocation); + writer = new PrintWriter(os); + File inPlaceConfigurationDir = configurationData.getInPlaceConfigurationDir(); + String absolutePath = inPlaceConfigurationDir.getAbsolutePath(); + writer.write(absolutePath); + } finally { + if (null != writer) { + try { + writer.flush(); + } catch (IOException e) { + } + try { + writer.close(); + } catch (IOException e) { + } + } + } + } + + public static File readInPlaceLocation(File source) throws IOException { + File inPlaceLocation = new File(source, "META-INF"); + inPlaceLocation = new File(inPlaceLocation, IN_PLACE_LOCATION_FILE); + + if (!inPlaceLocation.exists()) { + return null; + } + + BufferedReader reader = null; + try { + InputStream is = new FileInputStream(inPlaceLocation); + reader = new BufferedReader(new InputStreamReader(is)); + String path = reader.readLine(); + return new File(path); + } finally { + if (null != reader) { + try { + reader.close(); + } catch (IOException e) { + } + } + } + } +} Modified: geronimo/branches/1.1/modules/system/src/java/org/apache/geronimo/system/configuration/RepositoryConfigurationStore.java URL: http://svn.apache.org/viewcvs/geronimo/branches/1.1/modules/system/src/java/org/apache/geronimo/system/configuration/RepositoryConfigurationStore.java?rev=393489&r1=393488&r2=393489&view=diff ============================================================================== --- geronimo/branches/1.1/modules/system/src/java/org/apache/geronimo/system/configuration/RepositoryConfigurationStore.java (original) +++ geronimo/branches/1.1/modules/system/src/java/org/apache/geronimo/system/configuration/RepositoryConfigurationStore.java Wed Apr 12 08:51:34 2006 @@ -166,9 +166,19 @@ public URL resolve(Artifact configId, String moduleName, URI uri) throws NoSuchConfigException, MalformedURLException { File location = repository.getLocation(configId); if (location.isDirectory()) { - if (moduleName != null) { + File inPlaceLocation = null; + try { + inPlaceLocation = InPlaceConfigurationUtil.readInPlaceLocation(location); + } catch (IOException e) { + } + if (null != inPlaceLocation) { + location = inPlaceLocation; + } + + if (moduleName != null) { location = new File(location, moduleName); } + if (location.isDirectory()) { URL locationUrl = location.toURL(); URL resolvedUrl = new URL(locationUrl, uri.toString()); Added: geronimo/branches/1.1/modules/system/src/test/org/apache/geronimo/system/configuration/InPlaceConfigurationUtilTest.java URL: http://svn.apache.org/viewcvs/geronimo/branches/1.1/modules/system/src/test/org/apache/geronimo/system/configuration/InPlaceConfigurationUtilTest.java?rev=393489&view=auto ============================================================================== --- geronimo/branches/1.1/modules/system/src/test/org/apache/geronimo/system/configuration/InPlaceConfigurationUtilTest.java (added) +++ geronimo/branches/1.1/modules/system/src/test/org/apache/geronimo/system/configuration/InPlaceConfigurationUtilTest.java Wed Apr 12 08:51:34 2006 @@ -0,0 +1,78 @@ +/** + * + * Copyright 2006 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.system.configuration; + +import java.io.File; +import java.util.Collections; + +import junit.framework.TestCase; + +import org.apache.geronimo.kernel.Jsr77Naming; +import org.apache.geronimo.kernel.config.ConfigurationData; +import org.apache.geronimo.kernel.repository.Artifact; +import org.apache.geronimo.kernel.repository.Environment; + +/** + * @version $Rev: 391886 $ $Date: 2006-04-06 13:15:39 +1000 (Thu, 06 Apr 2006) $ + */ +public class InPlaceConfigurationUtilTest extends TestCase { + private static final File basedir = new File(System.getProperty("basedir", System.getProperty("user.dir"))); + + private static final File baseConfigDir = new File(basedir, "target/config"); + private static final File configDir = new File(baseConfigDir, "config"); + private static final File inPlaceConfig = new File(baseConfigDir, "inPlaceConfig"); + + public void testWriteReadInPlaceLocation() throws Exception { + ConfigurationData configurationData = new ConfigurationData(null, + null, + Collections.EMPTY_LIST, + Collections.EMPTY_MAP, + new Environment(new Artifact("groupId", "artifactId", "version", "type")), + configDir, + inPlaceConfig, + new Jsr77Naming()); + + InPlaceConfigurationUtil.writeInPlaceLocation(configurationData, configDir); + + File actualInPlaceConfig = InPlaceConfigurationUtil.readInPlaceLocation(configDir); + assertEquals(inPlaceConfig, actualInPlaceConfig); + } + + public void testAttemptReadNotExistingInPlaceLocation() throws Exception { + File actualInPlaceConfig = InPlaceConfigurationUtil.readInPlaceLocation(configDir); + assertNull(actualInPlaceConfig); + } + + protected void setUp() throws Exception { + configDir.mkdirs(); + inPlaceConfig.mkdirs(); + } + + protected void tearDown() throws Exception { + recursiveDelete(baseConfigDir); + } + + private final void recursiveDelete(File dir) { + File[] nestedFiles = dir.listFiles(); + if (null != nestedFiles) { + for (int i = 0; i < nestedFiles.length; i++) { + recursiveDelete(nestedFiles[i]); + } + } + dir.delete(); + } +}