Return-Path: Delivered-To: apmail-geronimo-scm-archive@www.apache.org Received: (qmail 71009 invoked from network); 25 Feb 2006 03:57:29 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 25 Feb 2006 03:57:29 -0000 Received: (qmail 37992 invoked by uid 500); 25 Feb 2006 03:57:29 -0000 Delivered-To: apmail-geronimo-scm-archive@geronimo.apache.org Received: (qmail 37976 invoked by uid 500); 25 Feb 2006 03:57:28 -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 37965 invoked by uid 99); 25 Feb 2006 03:57:28 -0000 Received: from asf.osuosl.org (HELO asf.osuosl.org) (140.211.166.49) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 24 Feb 2006 19:57:28 -0800 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; Fri, 24 Feb 2006 19:57:25 -0800 Received: (qmail 70951 invoked by uid 65534); 25 Feb 2006 03:57:04 -0000 Message-ID: <20060225035704.70948.qmail@minotaur.apache.org> Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r380891 - in /geronimo/branches/configid: configs/client-system/src/plan/ configs/j2ee-system/src/plan/ modules/client-builder/src/java/org/apache/geronimo/client/builder/ modules/deployment/src/java/org/apache/geronimo/deployment/ modules/... Date: Sat, 25 Feb 2006 03:56:59 -0000 To: scm@geronimo.apache.org From: dain@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: dain Date: Fri Feb 24 19:56:55 2006 New Revision: 380891 URL: http://svn.apache.org/viewcvs?rev=380891&view=rev Log: Configuration store uses local repository for storage Added: geronimo/branches/configid/modules/kernel/src/java/org/apache/geronimo/kernel/config/ConfigurationAlreadyExistsException.java geronimo/branches/configid/modules/kernel/src/java/org/apache/geronimo/kernel/repository/ArtifactTypeHandler.java geronimo/branches/configid/modules/kernel/src/java/org/apache/geronimo/kernel/repository/WritableListableRepository.java geronimo/branches/configid/modules/kernel/src/java/org/apache/geronimo/system/ geronimo/branches/configid/modules/kernel/src/java/org/apache/geronimo/system/repository/ geronimo/branches/configid/modules/system/src/java/org/apache/geronimo/system/configuration/RepositoryConfigurationStore.java geronimo/branches/configid/modules/system/src/java/org/apache/geronimo/system/repository/CopyArtifactTypeHandler.java geronimo/branches/configid/modules/system/src/java/org/apache/geronimo/system/repository/IOUtil.java geronimo/branches/configid/modules/system/src/java/org/apache/geronimo/system/repository/UnpackArtifactTypeHandler.java Removed: geronimo/branches/configid/modules/system/src/java/org/apache/geronimo/system/configuration/LocalConfigStore.java geronimo/branches/configid/modules/system/src/test/org/apache/geronimo/system/configuration/LocalConfigStoreTest.java geronimo/branches/configid/plugins/geronimo-packaging-plugin/src/java/org/apache/geronimo/plugin/packaging/JMXDistributor.java Modified: geronimo/branches/configid/configs/client-system/src/plan/plan.xml geronimo/branches/configid/configs/j2ee-system/src/plan/plan.xml geronimo/branches/configid/modules/client-builder/src/java/org/apache/geronimo/client/builder/AppClientModuleBuilder.java geronimo/branches/configid/modules/deployment/src/java/org/apache/geronimo/deployment/DeploymentContext.java geronimo/branches/configid/modules/j2ee-builder/src/java/org/apache/geronimo/j2ee/deployment/EARConfigBuilder.java geronimo/branches/configid/modules/jetty-builder/src/java/org/apache/geronimo/jetty/deployment/JettyModuleBuilder.java geronimo/branches/configid/modules/kernel/src/java/org/apache/geronimo/kernel/config/ConfigurationStore.java geronimo/branches/configid/modules/service-builder/src/java/org/apache/geronimo/deployment/service/ServiceConfigBuilder.java geronimo/branches/configid/modules/system/src/java/org/apache/geronimo/system/configuration/ConfigurationDump.java geronimo/branches/configid/modules/system/src/java/org/apache/geronimo/system/repository/AbstractRepository.java geronimo/branches/configid/modules/system/src/java/org/apache/geronimo/system/repository/Maven1Repository.java geronimo/branches/configid/modules/system/src/java/org/apache/geronimo/system/repository/Maven2Repository.java geronimo/branches/configid/plugins/geronimo-assembly-plugin/plugin.jelly geronimo/branches/configid/plugins/geronimo-assembly-plugin/src/java/org/apache/geronimo/plugin/assembly/LocalConfigInstaller.java geronimo/branches/configid/plugins/geronimo-assembly-plugin/src/java/org/apache/geronimo/plugin/assembly/RepoConfigInstaller.java geronimo/branches/configid/plugins/geronimo-packaging-plugin/plugin.jelly Modified: geronimo/branches/configid/configs/client-system/src/plan/plan.xml URL: http://svn.apache.org/viewcvs/geronimo/branches/configid/configs/client-system/src/plan/plan.xml?rev=380891&r1=380890&r2=380891&view=diff ============================================================================== --- geronimo/branches/configid/configs/client-system/src/plan/plan.xml (original) +++ geronimo/branches/configid/configs/client-system/src/plan/plan.xml Fri Feb 24 19:56:55 2006 @@ -59,10 +59,9 @@ - - config-store - - ServerInfo + + + Repository Modified: geronimo/branches/configid/configs/j2ee-system/src/plan/plan.xml URL: http://svn.apache.org/viewcvs/geronimo/branches/configid/configs/j2ee-system/src/plan/plan.xml?rev=380891&r1=380890&r2=380891&view=diff ============================================================================== --- geronimo/branches/configid/configs/j2ee-system/src/plan/plan.xml (original) +++ geronimo/branches/configid/configs/j2ee-system/src/plan/plan.xml Fri Feb 24 19:56:55 2006 @@ -63,10 +63,9 @@ - - config-store - - ServerInfo + + + Repository Modified: geronimo/branches/configid/modules/client-builder/src/java/org/apache/geronimo/client/builder/AppClientModuleBuilder.java URL: http://svn.apache.org/viewcvs/geronimo/branches/configid/modules/client-builder/src/java/org/apache/geronimo/client/builder/AppClientModuleBuilder.java?rev=380891&r1=380890&r2=380891&view=diff ============================================================================== --- geronimo/branches/configid/modules/client-builder/src/java/org/apache/geronimo/client/builder/AppClientModuleBuilder.java (original) +++ geronimo/branches/configid/modules/client-builder/src/java/org/apache/geronimo/client/builder/AppClientModuleBuilder.java Fri Feb 24 19:56:55 2006 @@ -46,6 +46,7 @@ import org.apache.geronimo.kernel.config.ConfigurationData; import org.apache.geronimo.kernel.config.ConfigurationModuleType; import org.apache.geronimo.kernel.config.ConfigurationStore; +import org.apache.geronimo.kernel.config.ConfigurationAlreadyExistsException; import org.apache.geronimo.kernel.repository.Artifact; import org.apache.geronimo.kernel.repository.Environment; import org.apache.geronimo.kernel.repository.Repository; @@ -261,7 +262,12 @@ Artifact configId = new Artifact(earConfigId.getGroupId(), earConfigId.getArtifactId() + "_" + module.getTargetPath(), earConfigId.getVersion(), "car"); clientEnvironment.setConfigId(configId); } - File appClientDir = configurationStore.createNewConfigurationDir(clientEnvironment.getConfigId()); + File appClientDir = null; + try { + appClientDir = configurationStore.createNewConfigurationDir(clientEnvironment.getConfigId()); + } catch (ConfigurationAlreadyExistsException e) { + throw new DeploymentException(e); + } // construct the app client deployment context... this is the same class used by the ear context try { Modified: geronimo/branches/configid/modules/deployment/src/java/org/apache/geronimo/deployment/DeploymentContext.java URL: http://svn.apache.org/viewcvs/geronimo/branches/configid/modules/deployment/src/java/org/apache/geronimo/deployment/DeploymentContext.java?rev=380891&r1=380890&r2=380891&view=diff ============================================================================== --- geronimo/branches/configid/modules/deployment/src/java/org/apache/geronimo/deployment/DeploymentContext.java (original) +++ geronimo/branches/configid/modules/deployment/src/java/org/apache/geronimo/deployment/DeploymentContext.java Fri Feb 24 19:56:55 2006 @@ -532,10 +532,6 @@ repositories, new ConfigurationStore() { - public Artifact install(URL source) { - return null; - } - public void install(ConfigurationData configurationData) { } Modified: geronimo/branches/configid/modules/j2ee-builder/src/java/org/apache/geronimo/j2ee/deployment/EARConfigBuilder.java URL: http://svn.apache.org/viewcvs/geronimo/branches/configid/modules/j2ee-builder/src/java/org/apache/geronimo/j2ee/deployment/EARConfigBuilder.java?rev=380891&r1=380890&r2=380891&view=diff ============================================================================== --- geronimo/branches/configid/modules/j2ee-builder/src/java/org/apache/geronimo/j2ee/deployment/EARConfigBuilder.java (original) +++ geronimo/branches/configid/modules/j2ee-builder/src/java/org/apache/geronimo/j2ee/deployment/EARConfigBuilder.java Fri Feb 24 19:56:55 2006 @@ -36,6 +36,7 @@ import org.apache.geronimo.kernel.config.ConfigurationData; import org.apache.geronimo.kernel.config.ConfigurationModuleType; import org.apache.geronimo.kernel.config.ConfigurationStore; +import org.apache.geronimo.kernel.config.ConfigurationAlreadyExistsException; import org.apache.geronimo.kernel.repository.Artifact; import org.apache.geronimo.kernel.repository.Environment; import org.apache.geronimo.kernel.repository.Repository; @@ -292,7 +293,12 @@ ConfigurationModuleType applicationType = applicationInfo.getType(); Environment environment = applicationInfo.getEnvironment(); Artifact configId = environment.getConfigId(); - File configurationDir = configurationStore.createNewConfigurationDir(configId); + File configurationDir = null; + try { + configurationDir = configurationStore.createNewConfigurationDir(configId); + } catch (ConfigurationAlreadyExistsException e) { + throw new DeploymentException(e); + } try { earContext = new EARContext(configurationDir, applicationInfo.getEnvironment(), Modified: geronimo/branches/configid/modules/jetty-builder/src/java/org/apache/geronimo/jetty/deployment/JettyModuleBuilder.java URL: http://svn.apache.org/viewcvs/geronimo/branches/configid/modules/jetty-builder/src/java/org/apache/geronimo/jetty/deployment/JettyModuleBuilder.java?rev=380891&r1=380890&r2=380891&view=diff ============================================================================== --- geronimo/branches/configid/modules/jetty-builder/src/java/org/apache/geronimo/jetty/deployment/JettyModuleBuilder.java (original) +++ geronimo/branches/configid/modules/jetty-builder/src/java/org/apache/geronimo/jetty/deployment/JettyModuleBuilder.java Fri Feb 24 19:56:55 2006 @@ -47,6 +47,7 @@ import org.apache.geronimo.kernel.config.ConfigurationData; import org.apache.geronimo.kernel.config.ConfigurationModuleType; import org.apache.geronimo.kernel.config.ConfigurationStore; +import org.apache.geronimo.kernel.config.ConfigurationAlreadyExistsException; import org.apache.geronimo.kernel.repository.Artifact; import org.apache.geronimo.kernel.repository.Environment; import org.apache.geronimo.kernel.repository.Repository; @@ -367,7 +368,12 @@ Artifact earConfigId = earContext.getConfigID(); Artifact configId = new Artifact(earConfigId.getGroupId(), earConfigId.getArtifactId() + "_" + module.getTargetPath(), earConfigId.getVersion(), "car"); environment.setConfigId(configId); - File configurationDir = configurationStore.createNewConfigurationDir(environment.getConfigId()); + File configurationDir = null; + try { + configurationDir = configurationStore.createNewConfigurationDir(environment.getConfigId()); + } catch (ConfigurationAlreadyExistsException e) { + throw new DeploymentException(e); + } // construct the web app deployment context... this is the same class used by the ear context try { Added: geronimo/branches/configid/modules/kernel/src/java/org/apache/geronimo/kernel/config/ConfigurationAlreadyExistsException.java URL: http://svn.apache.org/viewcvs/geronimo/branches/configid/modules/kernel/src/java/org/apache/geronimo/kernel/config/ConfigurationAlreadyExistsException.java?rev=380891&view=auto ============================================================================== --- geronimo/branches/configid/modules/kernel/src/java/org/apache/geronimo/kernel/config/ConfigurationAlreadyExistsException.java (added) +++ geronimo/branches/configid/modules/kernel/src/java/org/apache/geronimo/kernel/config/ConfigurationAlreadyExistsException.java Fri Feb 24 19:56:55 2006 @@ -0,0 +1,39 @@ +/** + * + * Copyright 2005 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.kernel.config; + +import org.apache.geronimo.gbean.InvalidConfigurationException; + +/** + * @version $Rev$ $Date$ + */ +public class ConfigurationAlreadyExistsException extends InvalidConfigurationException { + public ConfigurationAlreadyExistsException() { + } + + public ConfigurationAlreadyExistsException(String message) { + super(message); + } + + public ConfigurationAlreadyExistsException(String message, Throwable cause) { + super(message, cause); + } + + public ConfigurationAlreadyExistsException(Throwable cause) { + super(cause); + } +} Modified: geronimo/branches/configid/modules/kernel/src/java/org/apache/geronimo/kernel/config/ConfigurationStore.java URL: http://svn.apache.org/viewcvs/geronimo/branches/configid/modules/kernel/src/java/org/apache/geronimo/kernel/config/ConfigurationStore.java?rev=380891&r1=380890&r2=380891&view=diff ============================================================================== --- geronimo/branches/configid/modules/kernel/src/java/org/apache/geronimo/kernel/config/ConfigurationStore.java (original) +++ geronimo/branches/configid/modules/kernel/src/java/org/apache/geronimo/kernel/config/ConfigurationStore.java Fri Feb 24 19:56:55 2006 @@ -17,9 +17,6 @@ package org.apache.geronimo.kernel.config; -import org.apache.geronimo.gbean.GBeanData; -import org.apache.geronimo.kernel.repository.Artifact; - import java.io.File; import java.io.IOException; import java.net.MalformedURLException; @@ -27,6 +24,9 @@ import java.net.URL; import java.util.List; +import org.apache.geronimo.gbean.GBeanData; +import org.apache.geronimo.kernel.repository.Artifact; + /** * Interface to a store for Configurations. * @@ -34,15 +34,6 @@ */ public interface ConfigurationStore { /** - * Add the CAR at the supplied URL into this store - * - * @param source the URL of a CAR format archive - * @throws IOException if the CAR could not be read - * @throws InvalidConfigException if there is a configuration problem with the CAR - */ -// Artifact install(URL source) throws IOException, InvalidConfigException; - - /** * Move the unpacked configuration directory into this store * * @param configurationData the configuration data @@ -53,29 +44,29 @@ /** * Removes a configuration from the store - * @param configID the id of the configuration to remove + * @param configId the id of the configuration to remove * @throws NoSuchConfigException if the configuration is not contained in the store * @throws IOException if a problem occurs during the removal */ - void uninstall(Artifact configID) throws NoSuchConfigException, IOException; + void uninstall(Artifact configId) throws NoSuchConfigException, IOException; /** * Loads the specified configuration into the kernel * @param configId the id of the configuration to load - * @return the object name of the configuration in the kernel + * @return the the configuration object * @throws NoSuchConfigException if the configuration is not contained in the kernel * @throws IOException if a problem occurs loading the configuration from the store * @throws InvalidConfigException if the configuration is corrupt */ -// ObjectName loadConfiguration(Artifact configId) throws NoSuchConfigException, IOException, InvalidConfigException; + GBeanData loadConfiguration(Artifact configId) throws IOException, InvalidConfigException, NoSuchConfigException; /** * Determines if the store contains a configuration with the spedified ID. * - * @param configID the unique ID of the configuration + * @param configId the unique ID of the configuration * @return true if the store contains the configuration */ - boolean containsConfiguration(Artifact configID); + boolean containsConfiguration(Artifact configId); /** * Return the object name for the store. @@ -91,7 +82,13 @@ */ List listConfigurations(); - File createNewConfigurationDir(Artifact configId); + /** + * Creates an empty diretory for a new configuration with the specified configId + * @param configId the unique ID of the configuration + * @return the location of the new directory + * @throws ConfigurationAlreadyExistsException if the configuration already exists in this store + */ + File createNewConfigurationDir(Artifact configId) throws ConfigurationAlreadyExistsException; /** * Locate the classpath component for the supplied uri in the given artifact @@ -100,7 +97,4 @@ * @return URL for the configuration component. */ URL resolve(Artifact configId, URI uri) throws NoSuchConfigException, MalformedURLException; - - GBeanData loadConfiguration(Artifact configId) throws IOException, InvalidConfigException, NoSuchConfigException; - } Added: geronimo/branches/configid/modules/kernel/src/java/org/apache/geronimo/kernel/repository/ArtifactTypeHandler.java URL: http://svn.apache.org/viewcvs/geronimo/branches/configid/modules/kernel/src/java/org/apache/geronimo/kernel/repository/ArtifactTypeHandler.java?rev=380891&view=auto ============================================================================== --- geronimo/branches/configid/modules/kernel/src/java/org/apache/geronimo/kernel/repository/ArtifactTypeHandler.java (added) +++ geronimo/branches/configid/modules/kernel/src/java/org/apache/geronimo/kernel/repository/ArtifactTypeHandler.java Fri Feb 24 19:56:55 2006 @@ -0,0 +1,28 @@ +/** + * + * Copyright 2005 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.kernel.repository; + +import java.io.InputStream; +import java.io.File; +import java.io.IOException; + +/** + * @version $Rev$ $Date$ + */ +public interface ArtifactTypeHandler { + void install(InputStream source, Artifact artifactId, FileWriteMonitor monitor, File target) throws IOException; +} Added: geronimo/branches/configid/modules/kernel/src/java/org/apache/geronimo/kernel/repository/WritableListableRepository.java URL: http://svn.apache.org/viewcvs/geronimo/branches/configid/modules/kernel/src/java/org/apache/geronimo/kernel/repository/WritableListableRepository.java?rev=380891&view=auto ============================================================================== --- geronimo/branches/configid/modules/kernel/src/java/org/apache/geronimo/kernel/repository/WritableListableRepository.java (added) +++ geronimo/branches/configid/modules/kernel/src/java/org/apache/geronimo/kernel/repository/WritableListableRepository.java Fri Feb 24 19:56:55 2006 @@ -0,0 +1,23 @@ +/** + * + * Copyright 2005 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.kernel.repository; + +/** + * @version $Rev$ $Date$ + */ +public interface WritableListableRepository extends WriteableRepository, ListableRepository { +} Modified: geronimo/branches/configid/modules/service-builder/src/java/org/apache/geronimo/deployment/service/ServiceConfigBuilder.java URL: http://svn.apache.org/viewcvs/geronimo/branches/configid/modules/service-builder/src/java/org/apache/geronimo/deployment/service/ServiceConfigBuilder.java?rev=380891&r1=380890&r2=380891&view=diff ============================================================================== --- geronimo/branches/configid/modules/service-builder/src/java/org/apache/geronimo/deployment/service/ServiceConfigBuilder.java (original) +++ geronimo/branches/configid/modules/service-builder/src/java/org/apache/geronimo/deployment/service/ServiceConfigBuilder.java Fri Feb 24 19:56:55 2006 @@ -40,6 +40,7 @@ import org.apache.geronimo.kernel.config.ConfigurationData; import org.apache.geronimo.kernel.config.ConfigurationModuleType; import org.apache.geronimo.kernel.config.ConfigurationStore; +import org.apache.geronimo.kernel.config.ConfigurationAlreadyExistsException; import org.apache.geronimo.kernel.repository.Artifact; import org.apache.geronimo.kernel.repository.Environment; import org.apache.geronimo.kernel.repository.Repository; @@ -157,7 +158,12 @@ Environment environment = EnvironmentBuilder.buildEnvironment(configurationType.getEnvironment(), defaultEnvironment); Artifact configId = environment.getConfigId(); - File outfile = configurationStore.createNewConfigurationDir(configId); + File outfile; + try { + outfile = configurationStore.createNewConfigurationDir(configId); + } catch (ConfigurationAlreadyExistsException e) { + throw new DeploymentException(e); + } DeploymentContext context = new DeploymentContext(outfile, environment, ConfigurationModuleType.SERVICE, kernel); ClassLoader cl = context.getClassLoader(repository); Modified: geronimo/branches/configid/modules/system/src/java/org/apache/geronimo/system/configuration/ConfigurationDump.java URL: http://svn.apache.org/viewcvs/geronimo/branches/configid/modules/system/src/java/org/apache/geronimo/system/configuration/ConfigurationDump.java?rev=380891&r1=380890&r2=380891&view=diff ============================================================================== --- geronimo/branches/configid/modules/system/src/java/org/apache/geronimo/system/configuration/ConfigurationDump.java (original) +++ geronimo/branches/configid/modules/system/src/java/org/apache/geronimo/system/configuration/ConfigurationDump.java Fri Feb 24 19:56:55 2006 @@ -82,21 +82,20 @@ mavenRepositoryDir = new File(System.getProperty("user.home"), ".maven"); mavenRepositoryDir = new File(mavenRepositoryDir, "repository"); } + ObjectName mavenRepositoryName = new ObjectName("configdump:name=Repository,type=Maven"); if (mavenRepositoryDir.isDirectory()) { - ObjectName mavenRepositoryName = new ObjectName("configdump:name=Repository,type=Maven"); GBeanData mavenRepositoryData = new GBeanData(mavenRepositoryName, Maven2Repository.GBEAN_INFO); mavenRepositoryData.setAttribute("root", mavenRepositoryDir.getAbsoluteFile().toURI()); mavenRepositoryData.setReferencePattern("ServerInfo", serverInfoName); startGBean(kernel, mavenRepositoryData); } - ObjectName localConfigStoreName = new ObjectName("configdump:name=LocalConfigStore"); - GBeanData localConfigStoreData = new GBeanData(localConfigStoreName, LocalConfigStore.GBEAN_INFO); - localConfigStoreData.setAttribute("root", URI.create("config-store")); - localConfigStoreData.setReferencePattern("ServerInfo", serverInfoName); - startGBean(kernel, localConfigStoreData); + ObjectName configStoreName = new ObjectName("configdump:name=ConfigStore"); + GBeanData configStoreData = new GBeanData(configStoreName, RepositoryConfigurationStore.GBEAN_INFO); + configStoreData.setReferencePattern("Repository", mavenRepositoryName); + startGBean(kernel, configStoreData); - ConfigurationStore configurationStore = (ConfigurationStore) kernel.getProxyManager().createProxy(localConfigStoreName, classLoader); + ConfigurationStore configurationStore = (ConfigurationStore) kernel.getProxyManager().createProxy(configStoreName, classLoader); List configurationInfos = configurationStore.listConfigurations(); for (Iterator iterator = configurationInfos.iterator(); iterator.hasNext();) { ConfigurationInfo configurationInfo = (ConfigurationInfo) iterator.next(); @@ -271,18 +270,19 @@ } } - private static void loadRecursive(Kernel kernel, ConfigurationStore configurationStore, Artifact configID, LinkedList ancestors, Set preloaded) throws Exception { - ObjectName name = Configuration.getConfigurationObjectName(configID); + private static void loadRecursive(Kernel kernel, ConfigurationStore configurationStore, Artifact configId, LinkedList ancestors, Set preloaded) throws Exception { + ObjectName name = Configuration.getConfigurationObjectName(configId); if (preloaded.contains(name)) { return; } if (!kernel.isLoaded(name)) { - //TODO THIS IS NOW BROKEN -// configurationStore.loadConfiguration(configID); + GBeanData gbeanData = configurationStore.loadConfiguration(configId); + kernel.loadGBean(gbeanData, ConfigurationDump.class.getClassLoader()); + kernel.startGBean(name); } //put the earliest ancestors first, even if we have already started them. - ancestors.remove(configID); - ancestors.addFirst(configID); + ancestors.remove(configId); + ancestors.addFirst(configId); Artifact[] parents = (Artifact[]) kernel.getAttribute(name, "parentId"); if (parents != null) { for (int i = 0; i < parents.length; i++) { Added: geronimo/branches/configid/modules/system/src/java/org/apache/geronimo/system/configuration/RepositoryConfigurationStore.java URL: http://svn.apache.org/viewcvs/geronimo/branches/configid/modules/system/src/java/org/apache/geronimo/system/configuration/RepositoryConfigurationStore.java?rev=380891&view=auto ============================================================================== --- geronimo/branches/configid/modules/system/src/java/org/apache/geronimo/system/configuration/RepositoryConfigurationStore.java (added) +++ geronimo/branches/configid/modules/system/src/java/org/apache/geronimo/system/configuration/RepositoryConfigurationStore.java Fri Feb 24 19:56:55 2006 @@ -0,0 +1,322 @@ +/** + * + * Copyright 2005 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.io.FileInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.ObjectInputStream; +import java.net.MalformedURLException; +import java.net.URI; +import java.net.URL; +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; +import java.util.SortedSet; +import java.util.jar.JarFile; +import java.util.zip.ZipEntry; +import javax.management.ObjectName; + +import org.apache.geronimo.gbean.GBeanData; +import org.apache.geronimo.gbean.GBeanInfo; +import org.apache.geronimo.gbean.GBeanInfoBuilder; +import org.apache.geronimo.kernel.Kernel; +import org.apache.geronimo.kernel.jmx.JMXUtil; +import org.apache.geronimo.kernel.config.Configuration; +import org.apache.geronimo.kernel.config.ConfigurationData; +import org.apache.geronimo.kernel.config.ConfigurationInfo; +import org.apache.geronimo.kernel.config.ConfigurationModuleType; +import org.apache.geronimo.kernel.config.ConfigurationStore; +import org.apache.geronimo.kernel.config.InvalidConfigException; +import org.apache.geronimo.kernel.config.NoSuchConfigException; +import org.apache.geronimo.kernel.config.ConfigurationAlreadyExistsException; +import org.apache.geronimo.kernel.management.State; +import org.apache.geronimo.kernel.repository.Artifact; +import org.apache.geronimo.kernel.repository.WritableListableRepository; +import org.apache.geronimo.kernel.repository.FileWriteMonitor; +import org.apache.geronimo.system.repository.IOUtil; + +/** + * Implementation of ConfigurationStore that loads Configurations from a repository. + * This implementation is read-only on the assumption that a separate maven task will + * handle installation of a built package into the repository. + * + * @version $Rev: 378459 $ $Date: 2006-02-17 00:37:43 -0800 (Fri, 17 Feb 2006) $ + */ +public class RepositoryConfigurationStore implements ConfigurationStore { + private final Kernel kernel; + private final ObjectName objectName; + private final WritableListableRepository repository; + + public RepositoryConfigurationStore(WritableListableRepository repository) { + this(null, null, repository); + } + + public RepositoryConfigurationStore(Kernel kernel, String objectName, WritableListableRepository repository) { + this.kernel = kernel; + this.objectName = objectName == null ? null : JMXUtil.getObjectName(objectName); + this.repository = repository; + } + + public String getObjectName() { + return objectName.toString(); + } + + public GBeanData loadConfiguration(Artifact configId) throws NoSuchConfigException, IOException, InvalidConfigException { + File location = repository.getLocation(configId); + + if (!location.exists() && location.canRead()) { + throw new NoSuchConfigException("Configuration not found: " + configId); + } + + GBeanData config = new GBeanData(); + try { + if (location.isDirectory()) { + File serFile = new File(location, "META-INF"); + serFile = new File(serFile, "config.ser"); + + if (!serFile.exists()) { + throw new InvalidConfigException("Configuration does not contain a META-INF/config.ser file: " + serFile); + } else if (!serFile.canRead()) { + throw new InvalidConfigException("Can not read configuration META-INF/config.ser file: " + serFile); + } + + InputStream in = new FileInputStream(serFile); + try { + ObjectInputStream ois = new ObjectInputStream(in); + config.readExternal(ois); + } finally { + IOUtil.close(in); + } + } else { + JarFile jarFile = new JarFile(location); + ZipEntry entry = jarFile.getEntry("META-INF/config.ser"); + InputStream in = jarFile.getInputStream(entry); + try { + ObjectInputStream ois = new ObjectInputStream(in); + config.readExternal(ois); + } finally { + IOUtil.close(in); + IOUtil.close(jarFile); + } + } + } catch (ClassNotFoundException e) { + throw new InvalidConfigException("Unable to load class from config: " + configId, e); + } + + return config; + } + + + public boolean containsConfiguration(Artifact configId) { + File location = repository.getLocation(configId); + location = new File(location, "META-INF"); + location = new File(location, "config.ser"); + + return location.isFile() && location.canRead(); + } + + public File createNewConfigurationDir(Artifact configId) throws ConfigurationAlreadyExistsException { + File location = repository.getLocation(configId); + if (location.exists()) { + throw new ConfigurationAlreadyExistsException("Configuration already exists: " + configId); + } + location.mkdirs(); + if (!location.exists()) { + throw new ConfigurationAlreadyExistsException("Could not create configuration directory: " + location); + } + return location; + } + + public URL resolve(Artifact configId, URI uri) throws NoSuchConfigException, MalformedURLException { + File location = repository.getLocation(configId); + URL locationUrl = location.toURL(); + URL resolvedUrl = new URL(locationUrl, uri.toString()); + return resolvedUrl; + } + + public void install(InputStream in, Artifact configId, FileWriteMonitor fileWriteMonitor) throws IOException { + try { + repository.copyToRepository(in, configId, fileWriteMonitor); + } catch (IOException e) { + throw e; + } finally { + IOUtil.close(in); + } + } + + public void install(ConfigurationData configurationData) throws IOException, InvalidConfigException { + // determine the source file/dir + File source = configurationData.getConfigurationDir(); + if (!source.exists()) { + throw new InvalidConfigException("Source does not exist " + source); + } else if (source.canRead()) { + throw new InvalidConfigException("Source is not readable " + source); + } + + // determine the target location + Artifact configId = configurationData.getId(); + File destination = repository.getLocation(configId); + + if (destination.exists()) { + throw new ConfigurationAlreadyExistsException(configId.toString()); + } + + // if directory in the correct place -- noop + if (source.equals(destination)) { + return; + } + + if (source.isFile()) { + // Assume this is a jar file + // copy it into the repository; repository should unpack it + repository.copyToRepository(source, configId, null); + } else if (source.isDirectory()) { + // directory is in wrong place -- directory copy + IOUtil.recursiveCopy(source, destination); + } else { + throw new InvalidConfigException("Unable to install configuration from " + source); + } + } + + public void uninstall(Artifact configId) throws NoSuchConfigException, IOException { + File location = repository.getLocation(configId); + IOUtil.recursiveDelete(location); + } + + public List listConfigurations() { + SortedSet artifacts = repository.list(); + + List configs; + synchronized (this) { + configs = new ArrayList(); + for (Iterator i = artifacts.iterator(); i.hasNext();) { + Artifact configId = (Artifact) i.next(); + if (configId.getType().equals("car")) { + try { + ObjectName configName = Configuration.getConfigurationObjectName(configId); + State state; + if (kernel.isLoaded(configName)) { + try { + state = State.fromInt(kernel.getGBeanState(configName)); + } catch (Exception e) { + state = null; + } + } else { + // If the configuration is not loaded by the kernel + // and defined by the store, then it is stopped. + state = State.STOPPED; + } + + GBeanData bean = loadConfiguration(configId); + ConfigurationModuleType type = (ConfigurationModuleType) bean.getAttribute("type"); + + configs.add(new ConfigurationInfo(objectName, configId, state, type)); + } catch (Exception e) { + } + } + } + } + return configs; + } + +// /** +// * Thread to cleanup unused Config Store entries. +// * On Windows, open files can't be deleted. Until MultiParentClassLoaders +// * are GC'ed, we won't be able to delete Config Store directories/files. +// */ +// class ConfigStoreReaper implements Runnable { +// private final int reaperInterval; +// private volatile boolean done = false; +// +// public ConfigStoreReaper(int reaperInterval) { +// this.reaperInterval = reaperInterval; +// } +// +// public void close() { +// this.done = true; +// } +// +// public void run() { +// log.debug("ConfigStoreReaper started"); +// while (!done) { +// try { +// Thread.sleep(reaperInterval); +// } catch (InterruptedException e) { +// continue; +// } +// reap(); +// } +// } +// +// /** +// * For every directory in the pendingDeletionIndex, attempt to delete all +// * sub-directories and files. +// */ +// public void reap() { +// // return, if there's nothing to do +// if (pendingDeletionIndex.size() == 0) +// return; +// // Otherwise, attempt to delete all of the directories +// Enumeration list = pendingDeletionIndex.propertyNames(); +// boolean dirDeleted = false; +// while (list.hasMoreElements()) { +// String dirName = (String) list.nextElement(); +// File deleteFile = new File(dirName); +// try { +// delete(deleteFile); +// } +// catch (IOException ioe) { // ignore errors +// } +// if (!deleteFile.exists()) { +// String configName = pendingDeletionIndex.getProperty(dirName); +// pendingDeletionIndex.remove(dirName); +// dirDeleted = true; +// log.debug("Reaped configuration " + configName + " in directory " + dirName); +// } +// } +// // If we deleted any directories, persist the list of directories to disk... +// if (dirDeleted) { +// try { +// synchronized (pendingDeletionIndex) { +// saveDeleteIndex(); +// } +// } +// catch (IOException ioe) { +// log.warn("Error saving " + DELETE_NAME + " file.", ioe); +// } +// } +// } +// } +// + public static final GBeanInfo GBEAN_INFO; + + public static GBeanInfo getGBeanInfo() { + return GBEAN_INFO; + } + + static { + GBeanInfoBuilder builder = GBeanInfoBuilder.createStatic(RepositoryConfigurationStore.class, "ConfigurationStore"); + builder.addInterface(ConfigurationStore.class); + builder.addAttribute("kernel", Kernel.class, false); + builder.addAttribute("objectName", String.class, false); + builder.addReference("Repository", WritableListableRepository.class, "Repository"); + builder.setConstructor(new String[]{"kernel", "objectName", "Repository"}); + GBEAN_INFO = builder.getBeanInfo(); + } +} Modified: geronimo/branches/configid/modules/system/src/java/org/apache/geronimo/system/repository/AbstractRepository.java URL: http://svn.apache.org/viewcvs/geronimo/branches/configid/modules/system/src/java/org/apache/geronimo/system/repository/AbstractRepository.java?rev=380891&r1=380890&r2=380891&view=diff ============================================================================== --- geronimo/branches/configid/modules/system/src/java/org/apache/geronimo/system/repository/AbstractRepository.java (original) +++ geronimo/branches/configid/modules/system/src/java/org/apache/geronimo/system/repository/AbstractRepository.java Fri Feb 24 19:56:55 2006 @@ -16,9 +16,25 @@ */ package org.apache.geronimo.system.repository; +import java.io.File; +import java.io.FileInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.net.MalformedURLException; +import java.net.URI; +import java.net.URISyntaxException; +import java.net.URL; +import java.net.URLClassLoader; +import java.util.LinkedHashSet; +import java.util.Map; +import java.util.HashMap; +import javax.xml.parsers.DocumentBuilderFactory; +import javax.xml.parsers.ParserConfigurationException; + import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.apache.geronimo.kernel.repository.Artifact; +import org.apache.geronimo.kernel.repository.ArtifactTypeHandler; import org.apache.geronimo.kernel.repository.FileWriteMonitor; import org.apache.geronimo.kernel.repository.WriteableRepository; import org.apache.geronimo.system.serverinfo.ServerInfo; @@ -29,30 +45,14 @@ import org.xml.sax.InputSource; import org.xml.sax.SAXException; -import javax.xml.parsers.DocumentBuilderFactory; -import javax.xml.parsers.ParserConfigurationException; -import java.io.BufferedInputStream; -import java.io.BufferedOutputStream; -import java.io.File; -import java.io.FileInputStream; -import java.io.FileOutputStream; -import java.io.IOException; -import java.io.InputStream; -import java.net.MalformedURLException; -import java.net.URI; -import java.net.URISyntaxException; -import java.net.URL; -import java.net.URLClassLoader; -import java.util.LinkedHashSet; - /** * @version $Rev$ $Date$ */ public abstract class AbstractRepository implements WriteableRepository { protected static final Log log = LogFactory.getLog(AbstractRepository.class); - private final static int TRANSFER_NOTIFICATION_SIZE = 10240; // announce every this many bytes - private final static int TRANSFER_BUF_SIZE = 10240; // try this many bytes at a time + private final static ArtifactTypeHandler DEFAULT_TYPE_HANDLER = new CopyArtifactTypeHandler(); protected final File rootFile; + private final Map typeHandlers = new HashMap(); public AbstractRepository(URI root, ServerInfo serverInfo) { this(resolveRoot(root, serverInfo)); @@ -67,11 +67,12 @@ this.rootFile = rootFile; log.debug("Repository root is " + rootFile.getAbsolutePath()); + + typeHandlers.put("car", new UnpackArtifactTypeHandler()); } private static File resolveRoot(URI root, ServerInfo serverInfo) { if (root == null) throw new NullPointerException("root is null"); -// if (serverInfo == null) throw new NullPointerException("serverInfo is null"); if (!root.toString().endsWith("/")) { try { @@ -133,7 +134,6 @@ dependencies.add(new Artifact(groupId, artifactId, version, type)); } } catch (IOException e) { -// throw new DeploymentException("Unable to parse geronimo-service.xml file in " + url, e); throw (IllegalStateException)new IllegalStateException("Unable to parse geronimo-service.xml file in " + url).initCause(e); } catch (ParserConfigurationException e) { throw (IllegalStateException)new IllegalStateException("Unable to parse geronimo-service.xml file in " + url).initCause(e); @@ -181,40 +181,16 @@ throw new IllegalArgumentException("Destination " + location.getAbsolutePath() + " already exists!"); } - // assure that the target directory exists - File parent = location.getParentFile(); - if (!parent.exists() && !parent.mkdirs()) { - throw new RuntimeException("Unable to create directories from " + rootFile.getAbsolutePath() + " to " + parent.getAbsolutePath()); - } - - // copy it - if (monitor != null) { - monitor.writeStarted(destination.toString()); - } - int total = 0; - try { - int threshold = TRANSFER_NOTIFICATION_SIZE; - BufferedOutputStream out = new BufferedOutputStream(new FileOutputStream(location)); - BufferedInputStream in = new BufferedInputStream(source); - byte[] buf = new byte[TRANSFER_BUF_SIZE]; - int count; - while ((count = in.read(buf)) > -1) { - out.write(buf, 0, count); - if (monitor != null) { - total += count; - if (total > threshold) { - threshold += TRANSFER_NOTIFICATION_SIZE; - monitor.writeProgress(total); - } - } - } - out.flush(); - out.close(); - in.close(); - } finally { - if (monitor != null) { - monitor.writeComplete(total); - } + ArtifactTypeHandler typeHandler = (ArtifactTypeHandler) typeHandlers.get(destination.getType()); + if (typeHandler == null) typeHandler = DEFAULT_TYPE_HANDLER; + typeHandler.install(source, destination, monitor, location); + + if (destination.getType().equalsIgnoreCase("car")) { + System.out.println("############################################################"); + System.out.println("# Installed artifact"); + System.out.println("# id = " + destination); + System.out.println("# location = " + location); + System.out.println("############################################################"); } } } Added: geronimo/branches/configid/modules/system/src/java/org/apache/geronimo/system/repository/CopyArtifactTypeHandler.java URL: http://svn.apache.org/viewcvs/geronimo/branches/configid/modules/system/src/java/org/apache/geronimo/system/repository/CopyArtifactTypeHandler.java?rev=380891&view=auto ============================================================================== --- geronimo/branches/configid/modules/system/src/java/org/apache/geronimo/system/repository/CopyArtifactTypeHandler.java (added) +++ geronimo/branches/configid/modules/system/src/java/org/apache/geronimo/system/repository/CopyArtifactTypeHandler.java Fri Feb 24 19:56:55 2006 @@ -0,0 +1,74 @@ +/** + * + * Copyright 2005 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.repository; + +import java.io.InputStream; +import java.io.File; +import java.io.IOException; +import java.io.BufferedOutputStream; +import java.io.FileOutputStream; +import java.io.BufferedInputStream; + +import org.apache.geronimo.kernel.repository.ArtifactTypeHandler; +import org.apache.geronimo.kernel.repository.Artifact; +import org.apache.geronimo.kernel.repository.FileWriteMonitor; + +/** + * @version $Rev$ $Date$ + */ +public class CopyArtifactTypeHandler implements ArtifactTypeHandler { + private final static int TRANSFER_NOTIFICATION_SIZE = 10240; // announce every this many bytes + private final static int TRANSFER_BUF_SIZE = 10240; // try this many bytes at a time + + public void install(InputStream source, Artifact artifact, FileWriteMonitor monitor, File target) throws IOException { + // assure that the target directory exists + File parent = target.getParentFile(); + if (!parent.exists() && !parent.mkdirs()) { + throw new RuntimeException("Unable to create directory " + parent.getAbsolutePath()); + } + + // copy it + if (monitor != null) { + monitor.writeStarted(artifact.toString()); + } + int total = 0; + try { + int threshold = TRANSFER_NOTIFICATION_SIZE; + BufferedOutputStream out = new BufferedOutputStream(new FileOutputStream(target)); + BufferedInputStream in = new BufferedInputStream(source); + byte[] buf = new byte[TRANSFER_BUF_SIZE]; + int count; + while ((count = in.read(buf)) > -1) { + out.write(buf, 0, count); + if (monitor != null) { + total += count; + if (total > threshold) { + threshold += TRANSFER_NOTIFICATION_SIZE; + monitor.writeProgress(total); + } + } + } + out.flush(); + out.close(); + in.close(); + } finally { + if (monitor != null) { + monitor.writeComplete(total); + } + } + } +} Added: geronimo/branches/configid/modules/system/src/java/org/apache/geronimo/system/repository/IOUtil.java URL: http://svn.apache.org/viewcvs/geronimo/branches/configid/modules/system/src/java/org/apache/geronimo/system/repository/IOUtil.java?rev=380891&view=auto ============================================================================== --- geronimo/branches/configid/modules/system/src/java/org/apache/geronimo/system/repository/IOUtil.java (added) +++ geronimo/branches/configid/modules/system/src/java/org/apache/geronimo/system/repository/IOUtil.java Fri Feb 24 19:56:55 2006 @@ -0,0 +1,176 @@ +/** + * + * Copyright 2005 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.repository; + +import java.io.File; +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; +import java.io.FileInputStream; +import java.io.FileOutputStream; +import java.io.Writer; +import java.io.Reader; +import java.util.jar.JarFile; + +/** + * @version $Rev$ $Date$ + */ +public class IOUtil { + public static void recursiveCopy(File srcDir, File destDir) throws IOException { + if (srcDir == null) throw new NullPointerException("sourceDir is null"); + if (srcDir == null) throw new NullPointerException("destDir is null"); + if (!srcDir.isDirectory() || ! srcDir.canRead()) { + throw new IllegalArgumentException("Source directory must be a readable directory " + srcDir); + } + if (destDir.exists()) { + throw new IllegalArgumentException("Destination directory already exists " + destDir); + } + if (destDir.equals(destDir)) { + throw new IllegalArgumentException("Source and destination directory are the same " + srcDir); + } + + destDir.mkdirs(); + if (!destDir.exists()) { + throw new IOException("Could not create destination directory " + destDir); + } + + + File[] srcFiles = srcDir.listFiles(); + if (srcFiles != null) { + for (int i = 0; i < srcFiles.length; i++) { + File srcFile = srcFiles[i]; + File destFile = new File(destDir, srcFile.getName()); + if (srcFile.isDirectory()) { + recursiveCopy(srcFile, destFile); + } else { + copyFile(srcFile, destFile); + } + } + } + } + + public static void copyFile(File source, File destination) throws IOException { + File destinationDir = destination.getParentFile(); + if (!destinationDir.exists() && !destinationDir.mkdirs()) { + throw new IOException("Cannot create directory : " + destinationDir); + } + + InputStream in = null; + OutputStream out = null; + try { + in = new FileInputStream(source); + out = new FileOutputStream(destination); + writeAll(in, out); + } finally { + close(in); + close(out); + } + } + + public static void writeAll(InputStream in, OutputStream out) throws IOException { + byte[] buffer = new byte[4096]; + int count; + while ((count = in.read(buffer)) > 0) { + out.write(buffer, 0, count); + } + out.flush(); + } + + public static boolean recursiveDelete(File root) { + if (root == null) { + return true; + } + + if (root.isDirectory()) { + File[] files = root.listFiles(); + if (files != null) { + for (int i = 0; i < files.length; i++) { + File file = files[i]; + if (file.isDirectory()) { + recursiveDelete(file); + } else { + file.delete(); + } + } + } + } + return root.delete(); + } + + public static void flush(OutputStream thing) { + if (thing != null) { + try { + thing.flush(); + } catch(Exception ignored) { + } + } + } + + public static void flush(Writer thing) { + if (thing != null) { + try { + thing.flush(); + } catch(Exception ignored) { + } + } + } + + public static void close(JarFile thing) { + if (thing != null) { + try { + thing.close(); + } catch(Exception ignored) { + } + } + } + + public static void close(InputStream thing) { + if (thing != null) { + try { + thing.close(); + } catch(Exception ignored) { + } + } + } + + public static void close(OutputStream thing) { + if (thing != null) { + try { + thing.close(); + } catch(Exception ignored) { + } + } + } + + public static void close(Reader thing) { + if (thing != null) { + try { + thing.close(); + } catch(Exception ignored) { + } + } + } + + public static void close(Writer thing) { + if (thing != null) { + try { + thing.close(); + } catch(Exception ignored) { + } + } + } +} Modified: geronimo/branches/configid/modules/system/src/java/org/apache/geronimo/system/repository/Maven1Repository.java URL: http://svn.apache.org/viewcvs/geronimo/branches/configid/modules/system/src/java/org/apache/geronimo/system/repository/Maven1Repository.java?rev=380891&r1=380890&r2=380891&view=diff ============================================================================== --- geronimo/branches/configid/modules/system/src/java/org/apache/geronimo/system/repository/Maven1Repository.java (original) +++ geronimo/branches/configid/modules/system/src/java/org/apache/geronimo/system/repository/Maven1Repository.java Fri Feb 24 19:56:55 2006 @@ -29,13 +29,13 @@ import org.apache.geronimo.gbean.GBeanInfo; import org.apache.geronimo.gbean.GBeanInfoBuilder; import org.apache.geronimo.kernel.repository.Artifact; -import org.apache.geronimo.kernel.repository.ListableRepository; +import org.apache.geronimo.kernel.repository.WritableListableRepository; import org.apache.geronimo.system.serverinfo.ServerInfo; /** * @version $Rev$ $Date$ */ -public class Maven1Repository extends AbstractRepository implements ListableRepository { +public class Maven1Repository extends AbstractRepository implements WritableListableRepository { public Maven1Repository(URI root, ServerInfo serverInfo) { super(root, serverInfo); } @@ -118,7 +118,7 @@ public static final GBeanInfo GBEAN_INFO; static { - GBeanInfoBuilder infoFactory = GBeanInfoBuilder.createStatic(Maven1Repository.class, "GBean"); + GBeanInfoBuilder infoFactory = GBeanInfoBuilder.createStatic(Maven1Repository.class, "Repository"); infoFactory.addAttribute("root", URI.class, true); Modified: geronimo/branches/configid/modules/system/src/java/org/apache/geronimo/system/repository/Maven2Repository.java URL: http://svn.apache.org/viewcvs/geronimo/branches/configid/modules/system/src/java/org/apache/geronimo/system/repository/Maven2Repository.java?rev=380891&r1=380890&r2=380891&view=diff ============================================================================== --- geronimo/branches/configid/modules/system/src/java/org/apache/geronimo/system/repository/Maven2Repository.java (original) +++ geronimo/branches/configid/modules/system/src/java/org/apache/geronimo/system/repository/Maven2Repository.java Fri Feb 24 19:56:55 2006 @@ -26,13 +26,13 @@ import org.apache.geronimo.gbean.GBeanInfo; import org.apache.geronimo.gbean.GBeanInfoBuilder; import org.apache.geronimo.kernel.repository.Artifact; -import org.apache.geronimo.kernel.repository.ListableRepository; +import org.apache.geronimo.kernel.repository.WritableListableRepository; import org.apache.geronimo.system.serverinfo.ServerInfo; /** * @version $Rev$ $Date$ */ -public class Maven2Repository extends AbstractRepository implements ListableRepository { +public class Maven2Repository extends AbstractRepository implements WritableListableRepository { public Maven2Repository(URI root, ServerInfo serverInfo) { super(root, serverInfo); } @@ -139,7 +139,7 @@ public static final GBeanInfo GBEAN_INFO; static { - GBeanInfoBuilder infoFactory = GBeanInfoBuilder.createStatic(Maven2Repository.class, "GBean"); + GBeanInfoBuilder infoFactory = GBeanInfoBuilder.createStatic(Maven2Repository.class, "Repository"); infoFactory.addAttribute("root", URI.class, true); Added: geronimo/branches/configid/modules/system/src/java/org/apache/geronimo/system/repository/UnpackArtifactTypeHandler.java URL: http://svn.apache.org/viewcvs/geronimo/branches/configid/modules/system/src/java/org/apache/geronimo/system/repository/UnpackArtifactTypeHandler.java?rev=380891&view=auto ============================================================================== --- geronimo/branches/configid/modules/system/src/java/org/apache/geronimo/system/repository/UnpackArtifactTypeHandler.java (added) +++ geronimo/branches/configid/modules/system/src/java/org/apache/geronimo/system/repository/UnpackArtifactTypeHandler.java Fri Feb 24 19:56:55 2006 @@ -0,0 +1,95 @@ +/** + * + * Copyright 2005 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.repository; + +import java.io.InputStream; +import java.io.File; +import java.io.IOException; +import java.io.FileOutputStream; +import java.io.OutputStream; +import java.util.zip.ZipInputStream; +import java.util.zip.ZipEntry; + +import org.apache.geronimo.kernel.repository.ArtifactTypeHandler; +import org.apache.geronimo.kernel.repository.Artifact; +import org.apache.geronimo.kernel.repository.FileWriteMonitor; + +/** + * @version $Rev$ $Date$ + */ +public class UnpackArtifactTypeHandler implements ArtifactTypeHandler { + private final static int TRANSFER_NOTIFICATION_SIZE = 10240; // announce every this many bytes + private final static int TRANSFER_BUF_SIZE = 10240; // try this many bytes at a time + + public void install(InputStream source, Artifact artifact, FileWriteMonitor monitor, File target) throws IOException { + // assure that the target directory exists + File parent = target.getParentFile(); + if (!parent.exists() && !parent.mkdirs()) { + throw new RuntimeException("Unable to create directory " + parent.getAbsolutePath()); + } + + // copy it + if (monitor != null) { + monitor.writeStarted(artifact.toString()); + } + + int total = 0; + ZipInputStream in = new ZipInputStream(source); + try { + + int threshold = UnpackArtifactTypeHandler.TRANSFER_NOTIFICATION_SIZE; + byte[] buffer = new byte[TRANSFER_BUF_SIZE]; + + for (ZipEntry entry = in.getNextEntry(); entry != null; entry = in.getNextEntry()) { + File file = new File(target, entry.getName()); + if (entry.isDirectory()) { + file.mkdirs(); + } else { + if (!entry.getName().equals("META-INF/startup-jar")) { + file.getParentFile().mkdirs(); + OutputStream out = new FileOutputStream(file); + try { + int count; + while ((count = in.read(buffer)) > 0) { + out.write(buffer, 0, count); + if (monitor != null) { + total += count; + if (total > threshold) { + threshold += UnpackArtifactTypeHandler.TRANSFER_NOTIFICATION_SIZE; + monitor.writeProgress(total); + } + } + } + } finally { + IOUtil.flush(out); + out.close(); + } + in.closeEntry(); + } + } + } + } catch (IOException e) { + IOUtil.recursiveDelete(target); + throw e; + } finally { + in.close(); + if (monitor != null) { + monitor.writeComplete(total); + } + } + } +} Modified: geronimo/branches/configid/plugins/geronimo-assembly-plugin/plugin.jelly URL: http://svn.apache.org/viewcvs/geronimo/branches/configid/plugins/geronimo-assembly-plugin/plugin.jelly?rev=380891&r1=380890&r2=380891&view=diff ============================================================================== --- geronimo/branches/configid/plugins/geronimo-assembly-plugin/plugin.jelly (original) +++ geronimo/branches/configid/plugins/geronimo-assembly-plugin/plugin.jelly Fri Feb 24 19:56:55 2006 @@ -29,9 +29,7 @@ > - - @@ -202,7 +200,7 @@ - - - - - - - -