From scm-return-10717-apmail-geronimo-scm-archive=geronimo.apache.org@geronimo.apache.org Sat Mar 04 07:59:50 2006 Return-Path: Delivered-To: apmail-geronimo-scm-archive@www.apache.org Received: (qmail 92050 invoked from network); 4 Mar 2006 07:59:50 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 4 Mar 2006 07:59:50 -0000 Received: (qmail 22135 invoked by uid 500); 4 Mar 2006 08:00:36 -0000 Delivered-To: apmail-geronimo-scm-archive@geronimo.apache.org Received: (qmail 22113 invoked by uid 500); 4 Mar 2006 08:00:36 -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 22101 invoked by uid 99); 4 Mar 2006 08:00:36 -0000 Received: from asf.osuosl.org (HELO asf.osuosl.org) (140.211.166.49) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 04 Mar 2006 00:00:36 -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; Sat, 04 Mar 2006 00:00:34 -0800 Received: (qmail 92002 invoked by uid 65534); 4 Mar 2006 07:59:26 -0000 Message-ID: <20060304075926.92001.qmail@minotaur.apache.org> Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r383067 - in /geronimo/branches/1.1: configs/j2ee-system/src/plan/ modules/deploy-tool/src/java/org/apache/geronimo/deployment/ modules/deployment/src/java/org/apache/geronimo/deployment/ modules/kernel/src/java/org/apache/geronimo/gbean/ru... Date: Sat, 04 Mar 2006 07:59:23 -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 Mar 3 23:59:20 2006 New Revision: 383067 URL: http://svn.apache.org/viewcvs?rev=383067&view=rev Log: More work to centeralize interation with Configurations. Changed ConfigurationManager to set declare dependencies on imports and references. Configuration now has a collection valued reference to parents which are initialized in ConfigurationManager to imports. ConfigurationManager sets ArtifactManager and ArtifactResolver as attributes now. Modified: geronimo/branches/1.1/configs/j2ee-system/src/plan/plan.xml geronimo/branches/1.1/modules/deploy-tool/src/java/org/apache/geronimo/deployment/PluginBootstrap.java geronimo/branches/1.1/modules/deployment/src/java/org/apache/geronimo/deployment/DeploymentContext.java geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/gbean/runtime/GBeanInstance.java geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/kernel/config/Configuration.java geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/kernel/config/ConfigurationManagerImpl.java geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/kernel/config/ConfigurationUtil.java geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/kernel/repository/DefaultArtifactManager.java geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/kernel/repository/DefaultArtifactResolver.java geronimo/branches/1.1/modules/kernel/src/test/org/apache/geronimo/kernel/ConfigTest.java geronimo/branches/1.1/modules/kernel/src/test/org/apache/geronimo/kernel/config/ConfigurationManagerTest.java geronimo/branches/1.1/modules/kernel/src/test/org/apache/geronimo/kernel/repository/ArtifactResolverTest.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/main/CommandLine.java geronimo/branches/1.1/modules/system/src/java/org/apache/geronimo/system/main/Daemon.java geronimo/branches/1.1/plugins/geronimo-deployment-plugin/src/java/org/apache/geronimo/deployment/mavenplugin/StartServer.java geronimo/branches/1.1/plugins/geronimo-packaging-plugin/src/java/org/apache/geronimo/plugin/packaging/PackageBuilder.java Modified: geronimo/branches/1.1/configs/j2ee-system/src/plan/plan.xml URL: http://svn.apache.org/viewcvs/geronimo/branches/1.1/configs/j2ee-system/src/plan/plan.xml?rev=383067&r1=383066&r2=383067&view=diff ============================================================================== --- geronimo/branches/1.1/configs/j2ee-system/src/plan/plan.xml (original) +++ geronimo/branches/1.1/configs/j2ee-system/src/plan/plan.xml Fri Mar 3 23:59:20 2006 @@ -28,73 +28,80 @@ --> - - - - org.apache.geronimo.name.javax.management.j2ee.BaseName - geronimo.server:J2EEServer=geronimo - - - - - - - - - - - *:j2eeType=ConfigurationStore,* - - - AttributeManager - - - AttributeStore - AttributeManager - - - - - - - ServerInfo - - var/config/config.xml - - - - - - Repository - - - - - - repository/ - - ServerInfo - - - - - - - - - ArtifactManager - - - *:name=Repository,* - - - - - - var/log/server-log4j.properties - 60 - - ServerInfo - - + + + + org.apache.geronimo.name.javax.management.j2ee.BaseName + geronimo.server:J2EEServer=geronimo + + + + + + + + + + repository/ + + ServerInfo + + + + + + + Repository + + + + + + + ServerInfo + + var/config/config.xml + + + + + + + + + ArtifactManager + + + *:name=Repository,* + + + + + + + *:j2eeType=ConfigurationStore,* + + + AttributeManager + + + AttributeStore + AttributeManager + + + ArtifactManager + + + ArtifactResolver + + + + + + var/log/server-log4j.properties + 60 + + ServerInfo + + 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=383067&r1=383066&r2=383067&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 Fri Mar 3 23:59:20 2006 @@ -16,27 +16,23 @@ */ package org.apache.geronimo.deployment; +import java.io.File; +import java.io.FileOutputStream; +import java.net.URI; +import java.net.URL; +import java.util.List; +import java.util.jar.JarOutputStream; + import org.apache.geronimo.deployment.service.ServiceConfigBuilder; import org.apache.geronimo.deployment.xbeans.ConfigurationDocument; import org.apache.geronimo.deployment.xbeans.ConfigurationType; import org.apache.geronimo.gbean.GBeanData; import org.apache.geronimo.kernel.config.ConfigurationData; 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.repository.Artifact; import org.apache.geronimo.system.configuration.ExecutableConfigurationUtil; import org.apache.geronimo.system.repository.Maven1Repository; -import java.io.File; -import java.io.FileOutputStream; -import java.io.IOException; -import java.net.MalformedURLException; -import java.net.URI; -import java.net.URL; -import java.util.List; -import java.util.jar.JarOutputStream; - /** * @version $Rev$ $Date$ */ @@ -63,19 +59,22 @@ } public void bootstrap() throws Exception { + System.out.println(); + System.out.println(" Packaging configuration " + plan); + System.out.println(); + ConfigurationType config = ConfigurationDocument.Factory.parse(plan).getConfiguration(); Maven1Repository repository = new Maven1Repository(localRepo); ServiceConfigBuilder builder = new ServiceConfigBuilder(null, repository); ConfigurationData configurationData = builder.buildConfiguration(config, null, new ConfigurationStore() { - - public void install(ConfigurationData configurationData) throws IOException, InvalidConfigException { + public void install(ConfigurationData configurationData) { } - public void uninstall(Artifact configID) throws NoSuchConfigException, IOException { + public void uninstall(Artifact configID) { } - public GBeanData loadConfiguration(Artifact configId) throws NoSuchConfigException, IOException, InvalidConfigException { + public GBeanData loadConfiguration(Artifact configId) { return null; } @@ -95,7 +94,7 @@ return buildDir; } - public URL resolve(Artifact configId, URI uri) throws NoSuchConfigException, MalformedURLException { + public URL resolve(Artifact configId, URI uri) { return null; } }); 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=383067&r1=383066&r2=383067&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 Fri Mar 3 23:59:20 2006 @@ -17,24 +17,6 @@ package org.apache.geronimo.deployment; -import org.apache.geronimo.common.DeploymentException; -import org.apache.geronimo.deployment.util.DeploymentUtil; -import org.apache.geronimo.gbean.GBeanData; -import org.apache.geronimo.kernel.GBeanNotFoundException; -import org.apache.geronimo.kernel.Kernel; -import org.apache.geronimo.kernel.config.Configuration; -import org.apache.geronimo.kernel.config.ConfigurationData; -import org.apache.geronimo.kernel.config.ConfigurationManager; -import org.apache.geronimo.kernel.config.ConfigurationModuleType; -import org.apache.geronimo.kernel.config.ConfigurationStore; -import org.apache.geronimo.kernel.config.ConfigurationUtil; -import org.apache.geronimo.kernel.config.InvalidConfigException; -import org.apache.geronimo.kernel.management.State; -import org.apache.geronimo.kernel.repository.Artifact; -import org.apache.geronimo.kernel.repository.Environment; -import org.apache.geronimo.kernel.repository.Repository; - -import javax.management.ObjectName; import java.io.ByteArrayInputStream; import java.io.File; import java.io.FileInputStream; @@ -63,6 +45,27 @@ import java.util.jar.Manifest; import java.util.zip.ZipEntry; import java.util.zip.ZipFile; +import javax.management.ObjectName; + +import org.apache.geronimo.common.DeploymentException; +import org.apache.geronimo.deployment.util.DeploymentUtil; +import org.apache.geronimo.gbean.GBeanData; +import org.apache.geronimo.kernel.GBeanNotFoundException; +import org.apache.geronimo.kernel.Kernel; +import org.apache.geronimo.kernel.config.Configuration; +import org.apache.geronimo.kernel.config.ConfigurationData; +import org.apache.geronimo.kernel.config.ConfigurationManager; +import org.apache.geronimo.kernel.config.ConfigurationModuleType; +import org.apache.geronimo.kernel.config.ConfigurationStore; +import org.apache.geronimo.kernel.config.ConfigurationUtil; +import org.apache.geronimo.kernel.config.InvalidConfigException; +import org.apache.geronimo.kernel.management.State; +import org.apache.geronimo.kernel.repository.Artifact; +import org.apache.geronimo.kernel.repository.ArtifactResolver; +import org.apache.geronimo.kernel.repository.DefaultArtifactResolver; +import org.apache.geronimo.kernel.repository.Environment; +import org.apache.geronimo.kernel.repository.MissingDependencyException; +import org.apache.geronimo.kernel.repository.Repository; /** * @version $Rev$ $Date$ @@ -510,17 +513,9 @@ public Configuration getConfiguration(Repository repository, Configuration knownParent) throws DeploymentException { Environment environmentCopy = new Environment(environment); - if (knownParent != null) { - LinkedHashSet allImports = environmentCopy.getImports(); - Artifact knownParentId = knownParent.getId(); - allImports.remove(knownParentId); - } Set repositories = Collections.singleton(repository); try { - ArrayList parents = Configuration.buildParents(environmentCopy, null, null, repositories, kernel); - if (knownParent != null) { - parents.add(knownParent); - } + List parents = createParentProxies(repositories, knownParent); Configuration configuration = new Configuration(parents, kernel, Configuration.getConfigurationObjectName(environmentCopy.getConfigId()).getCanonicalName(), @@ -567,6 +562,28 @@ } catch (Exception e) { throw new DeploymentException("Could not construct configuration classloader for deployment context", e); } + } + + private List createParentProxies(Set repositories, Configuration knownParent) throws MissingDependencyException, InvalidConfigException { + ArtifactResolver artifactResolver = new DefaultArtifactResolver(null, repositories); + LinkedHashSet imports = environment.getImports(); + imports = artifactResolver.resolve(imports); + environment.setImports(imports); + + // get proxies to my parent configurations (now that the imports have been resolved) + ArrayList parents = new ArrayList(); + for (Iterator iterator = imports.iterator(); iterator.hasNext();) { + Artifact artifact = (Artifact) iterator.next(); + Configuration parent; + if (knownParent != null && artifact.equals(knownParent.getId())) { + parent = knownParent; + } else { + ObjectName parentName = Configuration.getConfigurationObjectName(artifact); + parent = (Configuration) kernel.getProxyManager().createProxy(parentName, Configuration.class); + } + parents.add(parent); + } + return parents; } public void close() throws IOException, DeploymentException { Modified: geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/gbean/runtime/GBeanInstance.java URL: http://svn.apache.org/viewcvs/geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/gbean/runtime/GBeanInstance.java?rev=383067&r1=383066&r2=383067&view=diff ============================================================================== --- geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/gbean/runtime/GBeanInstance.java (original) +++ geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/gbean/runtime/GBeanInstance.java Fri Mar 3 23:59:20 2006 @@ -349,7 +349,7 @@ getReferenceByName(referenceName).setPatterns(referencePattern); } } catch (Exception e) { - throw new InvalidConfigurationException("GBeanData could not be loaded into the GBeanMBean", e); + throw new InvalidConfigurationException("Could not inject configuration data into the GBean " + objectName, e); } for (int i = 0; i < references.length; i++) { Modified: geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/kernel/config/Configuration.java URL: http://svn.apache.org/viewcvs/geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/kernel/config/Configuration.java?rev=383067&r1=383066&r2=383067&view=diff ============================================================================== --- geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/kernel/config/Configuration.java (original) +++ geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/kernel/config/Configuration.java Fri Mar 3 23:59:20 2006 @@ -189,49 +189,17 @@ } /** - * Constructor that can be used to create an offline Configuration, typically - * only used publically during the deployment process for initial configuration. - * + * Creates a configuration. + * @param parents parents of this configuation (not ordered) * @param moduleType the module type identifier * @param environment * @param classPath a List of locations that define the codebase for this Configuration * @param gbeanState a byte array contain the Java Serialized form of the GBeans in this Configuration * @param repositories a Collection of repositories used to resolve dependencies */ - public Configuration(Kernel kernel, - String objectName, - ConfigurationModuleType moduleType, - Environment environment, - List classPath, - byte[] gbeanState, - Collection repositories, - ConfigurationStore configurationStore, - ArtifactManager artifactManager, - ArtifactResolver artifactResolver) throws Exception { - - this(buildParents(environment, artifactResolver, artifactManager, repositories, kernel), kernel, objectName, moduleType, environment, classPath, gbeanState, repositories, configurationStore, artifactManager, artifactResolver); - } - - public static ArrayList buildParents(Environment environment, ArtifactResolver artifactResolver, ArtifactManager artifactManager, Collection repositories, Kernel kernel) throws MissingDependencyException, InvalidConfigException { - if (artifactResolver == null) { - artifactResolver = new DefaultArtifactResolver(artifactManager, repositories); - } - LinkedHashSet imports = environment.getImports(); - imports = artifactResolver.resolve(imports); - environment.setImports(imports); - - // get proxies to my parent configurations (now that the imports have been resolved) - ArrayList parents = new ArrayList(); - for (Iterator iterator = imports.iterator(); iterator.hasNext();) { - Artifact artifact = (Artifact) iterator.next(); - ObjectName parentName = getConfigurationObjectName(artifact); - parents.add(kernel.getProxyManager().createProxy(parentName, Configuration.class)); - } - return parents; - } - - public Configuration(ArrayList parents, Kernel kernel, String objectName, ConfigurationModuleType moduleType, Environment environment, List classPath, byte[] gbeanState, Collection repositories, ConfigurationStore configurationStore, ArtifactManager artifactManager, ArtifactResolver artifactResolver) throws MissingDependencyException, MalformedURLException, NoSuchConfigException, InvalidConfigException { - this.parents = parents; + public Configuration(Collection parents, Kernel kernel, String objectName, ConfigurationModuleType moduleType, Environment environment, List classPath, byte[] gbeanState, Collection repositories, ConfigurationStore configurationStore, ArtifactManager artifactManager, ArtifactResolver artifactResolver) throws MissingDependencyException, MalformedURLException, NoSuchConfigException, InvalidConfigException { + if (parents == null) parents = Collections.EMPTY_SET; + this.parents = orderParents(parents, environment); this.kernel = kernel; this.environment = environment; this.moduleType = moduleType; @@ -277,7 +245,7 @@ configurationClassLoader = new MultiParentClassLoader(environment.getConfigId(), urls, getClass().getClassLoader()); } else { ClassLoader[] parentClassLoaders = new ClassLoader[parents.size()]; - for (ListIterator iterator = parents.listIterator(); iterator.hasNext();) { + for (ListIterator iterator = this.parents.listIterator(); iterator.hasNext();) { Configuration configuration = (Configuration) iterator.next(); parentClassLoaders[iterator.previousIndex()] = configuration.getConfigurationClassLoader(); } @@ -319,6 +287,31 @@ } } + private List orderParents(Collection parents, Environment environment) { + Map parentsById = new HashMap(); + for (Iterator iterator = parents.iterator(); iterator.hasNext();) { + Configuration configuration = (Configuration) iterator.next(); + Artifact id = configuration.getId(); + parentsById.put(id, configuration); + } + LinkedHashSet imports = environment.getImports(); + if (!parentsById.keySet().equals(imports)) { + throw new IllegalArgumentException(environment.getConfigId() + " : Expected parents " + + imports + + ", but actual parents are " + + parentsById.keySet()); + } + + List orderedParents = new ArrayList(parents.size()); + for (Iterator iterator = imports.iterator(); iterator.hasNext();) { + Artifact id = (Artifact) iterator.next(); + Configuration configuration = (Configuration) parentsById.get(id); + if (configuration == null) throw new IllegalStateException("Could not find parent " + id + " in the parents collection"); + orderedParents.add(configuration); + } + return orderedParents; + } + private void determineInherited() { for (Iterator iterator = parents.iterator(); iterator.hasNext();) { Configuration parent = (Configuration) iterator.next(); @@ -601,16 +594,18 @@ infoFactory.addAttribute("configurationClassLoader", ClassLoader.class, false); //make id readable for convenience infoFactory.addAttribute("id", Artifact.class, false); - //NOTE THIS IS NOT A REFERENCE + //NOTE THESE IS NOT REFERENCES infoFactory.addAttribute("configurationStore", ConfigurationStore.class, true); + infoFactory.addAttribute("artifactManager", ArtifactManager.class, true); + infoFactory.addAttribute("artifactResolver", ArtifactResolver.class, true); + infoFactory.addReference("Parents", Configuration.class); infoFactory.addReference("Repositories", Repository.class, "Repository"); - infoFactory.addReference("ArtifactManager", ArtifactManager.class, "ArtifactManager"); - infoFactory.addReference("ArtifactResolver", ArtifactResolver.class, "ArtifactResolver"); infoFactory.addInterface(Configuration.class); infoFactory.setConstructor(new String[]{ + "Parents", "kernel", "objectName", "type", @@ -619,8 +614,8 @@ "gBeanState", "Repositories", "configurationStore", - "ArtifactManager", - "ArtifactResolver" + "artifactManager", + "artifactResolver" }); GBEAN_INFO = infoFactory.getBeanInfo(); Modified: geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/kernel/config/ConfigurationManagerImpl.java URL: http://svn.apache.org/viewcvs/geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/kernel/config/ConfigurationManagerImpl.java?rev=383067&r1=383066&r2=383067&view=diff ============================================================================== --- geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/kernel/config/ConfigurationManagerImpl.java (original) +++ geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/kernel/config/ConfigurationManagerImpl.java Fri Mar 3 23:59:20 2006 @@ -35,6 +35,8 @@ import org.apache.geronimo.kernel.repository.Environment; import org.apache.geronimo.kernel.repository.ArtifactResolver; import org.apache.geronimo.kernel.repository.ArtifactManager; +import org.apache.geronimo.kernel.repository.MissingDependencyException; +import org.apache.geronimo.kernel.repository.DefaultArtifactResolver; import javax.management.MalformedObjectNameException; import javax.management.ObjectName; @@ -87,10 +89,15 @@ ArtifactManager artifactManager, ArtifactResolver artifactResolver, ClassLoader classLoader) { + + if (kernel == null) throw new NullPointerException("kernel is null"); + if (classLoader == null) throw new NullPointerException("classLoader is null"); + this.kernel = kernel; this.stores = stores; this.attributeStore = attributeStore; this.configurationList = configurationList; + if (artifactResolver == null) artifactResolver = new DefaultArtifactResolver(artifactManager, Collections.EMPTY_SET); this.artifactManager = artifactManager; this.artifactResolver = artifactResolver; this.classLoader = classLoader; @@ -155,22 +162,8 @@ public Configuration loadConfiguration(ConfigurationData configurationData, ConfigurationStore configurationStore) throws NoSuchConfigException, IOException, InvalidConfigException { Artifact id = configurationData.getId(); - ObjectName objectName = Configuration.getConfigurationObjectName(id); try { - GBeanData gbeanData = new GBeanData(objectName, Configuration.GBEAN_INFO); - gbeanData.setAttribute("type", configurationData.getModuleType()); - Environment environment = configurationData.getEnvironment(); - gbeanData.setAttribute("environment", environment); - gbeanData.setAttribute("gBeanState", Configuration.storeGBeans(configurationData.getGBeans())); - gbeanData.setAttribute("classPath", configurationData.getClassPath()); - gbeanData.setAttribute("configurationStore", configurationStore); - gbeanData.setReferencePattern("Repositories", new ObjectName("*:j2eeType=Repository,*")); - if (artifactManager != null) { - gbeanData.setReferencePattern("ArtifactManager", kernel.getProxyManager().getProxyTarget(artifactManager)); - } - if (artifactResolver != null) { - gbeanData.setReferencePattern("ArtifactResolver", kernel.getProxyManager().getProxyTarget(artifactResolver)); - } + GBeanData gbeanData = ConfigurationUtil.toConfigurationGBeanData(configurationData, configurationStore); loadConfiguration(id, gbeanData); Configuration configuration = getConfiguration(id); @@ -233,6 +226,8 @@ return; } + preprocess(gbeanData); + try { kernel.loadGBean(gbeanData, classLoader); } catch (Exception e) { @@ -246,19 +241,6 @@ ancestors.addFirst(configId); Environment environment = (Environment) kernel.getAttribute(name, "environment"); - LinkedHashSet imports = environment.getImports(); - for (Iterator iterator = imports.iterator(); iterator.hasNext();) { - Artifact artifact = (Artifact) iterator.next(); - if (!artifact.isResolved()) { - if (artifactResolver == null) { - throw new IllegalStateException("Parent artifact is not resolved, and no artifact resolver is available: " + artifact); - } - imports = artifactResolver.resolve(imports); - environment.setImports(imports); - break; - } - } - for (Iterator iterator = environment.getImports().iterator(); iterator.hasNext();) { Artifact parent = (Artifact) iterator.next(); if (!isLoaded(parent)) { @@ -293,6 +275,48 @@ } } throw new NoSuchConfigException("No configuration with id: " + configId); + } + + private void preprocess(GBeanData gbeanData) throws MissingDependencyException, InvalidConfigException { + if (artifactManager != null) { + gbeanData.setAttribute("artifactManager", artifactManager); + } + if (artifactResolver != null) { + gbeanData.setAttribute("artifactResolver", artifactResolver); + } + + Environment environment = (Environment) gbeanData.getAttribute("environment"); + + // resolve the parents + LinkedHashSet imports = environment.getImports(); + imports = artifactResolver.resolve(imports); + environment.setImports(imports); + + // resolve the references + LinkedHashSet references = environment.getReferences(); + references = artifactResolver.resolve(references); + environment.setReferences(references); + + // convert the parents and reference artifactIds to objectNames + LinkedHashSet importNames = new LinkedHashSet(); + for (Iterator iterator = imports.iterator(); iterator.hasNext();) { + Artifact artifact = (Artifact) iterator.next(); + ObjectName importName = Configuration.getConfigurationObjectName(artifact); + importNames.add(importName); + } + LinkedHashSet referenceNames = new LinkedHashSet(); + for (Iterator iterator = references.iterator(); iterator.hasNext();) { + Artifact artifact = (Artifact) iterator.next(); + ObjectName referenceName = Configuration.getConfigurationObjectName(artifact); + referenceNames.add(referenceName); + } + + // add dependencies on the imports and references + gbeanData.getDependencies().addAll(importNames); + gbeanData.getDependencies().addAll(referenceNames); + + // imports become the parents + gbeanData.setReferencePatterns("Parents", importNames); } private void registerGBeans(Configuration configuration) throws InvalidConfigException, NoSuchConfigException, MalformedURLException { Modified: geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/kernel/config/ConfigurationUtil.java URL: http://svn.apache.org/viewcvs/geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/kernel/config/ConfigurationUtil.java?rev=383067&r1=383066&r2=383067&view=diff ============================================================================== --- geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/kernel/config/ConfigurationUtil.java (original) +++ geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/kernel/config/ConfigurationUtil.java Fri Mar 3 23:59:20 2006 @@ -18,11 +18,15 @@ import java.io.InputStream; import java.io.ObjectInputStream; +import java.io.OutputStream; +import java.io.ObjectOutputStream; +import java.io.IOException; import java.util.Collections; import java.util.Iterator; import java.util.Map; import java.util.Set; import javax.management.ObjectName; +import javax.management.MalformedObjectNameException; import org.apache.geronimo.gbean.GBeanData; import org.apache.geronimo.gbean.GBeanQuery; @@ -39,7 +43,7 @@ private ConfigurationUtil() { } - public static ObjectName startBootstrapConfiguration(Kernel kernel, InputStream in, ClassLoader classLoader) throws Exception { + public static ObjectName loadBootstrapConfiguration(Kernel kernel, InputStream in, ClassLoader classLoader) throws Exception { // load and start the configuration in this jar GBeanData configuration = new GBeanData(); ObjectInputStream ois = new ObjectInputStream(in); @@ -55,8 +59,8 @@ configuration.setName(configurationName); // for a bootstrap we should have an empty kernel, so clear the references and dependencies - configuration.setReferencePattern("ArtifactManager", null); - configuration.setReferencePattern("ArtifactResolver", null); + configuration.setAttribute("artifactManager", null); + configuration.setAttribute("artifactResolver", null); environment.setDependencies(Collections.EMPTY_LIST); // load and start the gbean @@ -84,6 +88,46 @@ return configurationName; } + public static void storeBootstrapConfiguration(ConfigurationData configurationData, OutputStream out) throws InvalidConfigException, IOException { + ObjectOutputStream objectOutputStream = null; + try { + GBeanData configurationGBeanData = toConfigurationGBeanData(configurationData, null); + objectOutputStream = new ObjectOutputStream(out); + configurationGBeanData.writeExternal(objectOutputStream); + } catch (MalformedObjectNameException e) { + throw new InvalidConfigException(e); + } catch (IOException e) { + throw e; + } catch (Exception e) { + throw new InvalidConfigException("Unable to save configuration state", e); + } finally { + if (objectOutputStream != null) { + try { + objectOutputStream.flush(); + } catch (IOException ignored) { + } + } + } + + } + + // This method is package protected in an attempt to hide how we turn ConfigurationData into a GBeanData + // user should be using ConfigurationManager to do this work + static GBeanData toConfigurationGBeanData(ConfigurationData configurationData, ConfigurationStore configurationStore) throws InvalidConfigException, MalformedObjectNameException { + Artifact id = configurationData.getId(); + ObjectName objectName = Configuration.getConfigurationObjectName(id); + GBeanData gbeanData = new GBeanData(objectName, Configuration.GBEAN_INFO); + gbeanData.setAttribute("type", configurationData.getModuleType()); + Environment environment = configurationData.getEnvironment(); + gbeanData.setAttribute("environment", environment); + gbeanData.setAttribute("gBeanState", Configuration.storeGBeans(configurationData.getGBeans())); + gbeanData.setAttribute("classPath", configurationData.getClassPath()); + if (configurationStore != null) { + gbeanData.setAttribute("configurationStore", configurationStore); + } + gbeanData.setReferencePattern("Repositories", new ObjectName("*:j2eeType=Repository,*")); + return gbeanData; + } /** * Gets a reference or proxy to the ConfigurationManager running in the specified kernel. @@ -148,5 +192,4 @@ public static void releaseConfigurationManager(Kernel kernel, ConfigurationManager configurationManager) { kernel.getProxyManager().destroyProxy(configurationManager); } - } Modified: geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/kernel/repository/DefaultArtifactManager.java URL: http://svn.apache.org/viewcvs/geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/kernel/repository/DefaultArtifactManager.java?rev=383067&r1=383066&r2=383067&view=diff ============================================================================== --- geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/kernel/repository/DefaultArtifactManager.java (original) +++ geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/kernel/repository/DefaultArtifactManager.java Fri Mar 3 23:59:20 2006 @@ -104,7 +104,7 @@ public static final GBeanInfo GBEAN_INFO; static { - GBeanInfoBuilder infoFactory = GBeanInfoBuilder.createStatic(DefaultArtifactManager.class, "GBean"); + GBeanInfoBuilder infoFactory = GBeanInfoBuilder.createStatic(DefaultArtifactManager.class, "ArtifactManager"); infoFactory.addInterface(ArtifactManager.class); GBEAN_INFO = infoFactory.getBeanInfo(); } Modified: geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/kernel/repository/DefaultArtifactResolver.java URL: http://svn.apache.org/viewcvs/geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/kernel/repository/DefaultArtifactResolver.java?rev=383067&r1=383066&r2=383067&view=diff ============================================================================== --- geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/kernel/repository/DefaultArtifactResolver.java (original) +++ geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/kernel/repository/DefaultArtifactResolver.java Fri Mar 3 23:59:20 2006 @@ -181,8 +181,8 @@ static { GBeanInfoBuilder infoFactory = GBeanInfoBuilder.createStatic(DefaultArtifactResolver.class, "ArtifactResolver"); - infoFactory.addReference("ArtifactManager", ArtifactManager.class, "GBean"); - infoFactory.addReference("Repositories", Repository.class, "GBean"); + infoFactory.addReference("ArtifactManager", ArtifactManager.class, "ArtifactManager"); + infoFactory.addReference("Repositories", Repository.class, "Repository"); infoFactory.addInterface(ArtifactResolver.class); infoFactory.setConstructor(new String[]{ Modified: geronimo/branches/1.1/modules/kernel/src/test/org/apache/geronimo/kernel/ConfigTest.java URL: http://svn.apache.org/viewcvs/geronimo/branches/1.1/modules/kernel/src/test/org/apache/geronimo/kernel/ConfigTest.java?rev=383067&r1=383066&r2=383067&view=diff ============================================================================== --- geronimo/branches/1.1/modules/kernel/src/test/org/apache/geronimo/kernel/ConfigTest.java (original) +++ geronimo/branches/1.1/modules/kernel/src/test/org/apache/geronimo/kernel/ConfigTest.java Fri Mar 3 23:59:20 2006 @@ -46,6 +46,7 @@ import org.apache.geronimo.kernel.repository.Artifact; import org.apache.geronimo.kernel.repository.DefaultArtifactManager; import org.apache.geronimo.kernel.repository.Environment; +import org.apache.geronimo.kernel.repository.DefaultArtifactResolver; /** * @version $Rev$ $Date$ @@ -201,9 +202,17 @@ kernel.startGBean(artifactManagerName); assertEquals(State.RUNNING_INDEX, kernel.getGBeanState(artifactManagerName)); + ObjectName artifactResolverName = new ObjectName(":j2eeType=ArtifactResolver"); + GBeanData artifactResolverData = new GBeanData(artifactResolverName, DefaultArtifactResolver.GBEAN_INFO); + artifactResolverData.setReferencePattern("ArtifactManager", artifactManagerName); + kernel.loadGBean(artifactResolverData, getClass().getClassLoader()); + kernel.startGBean(artifactResolverName); + assertEquals(State.RUNNING_INDEX, kernel.getGBeanState(artifactResolverName)); + ObjectName configurationManagerName = new ObjectName(":j2eeType=ConfigurationManager,name=Basic"); GBeanData configurationManagerData = new GBeanData(configurationManagerName, ConfigurationManagerImpl.GBEAN_INFO); configurationManagerData.setReferencePattern("ArtifactManager", artifactManagerName); + configurationManagerData.setReferencePattern("ArtifactResolver", artifactResolverName); kernel.loadGBean(configurationManagerData, getClass().getClassLoader()); kernel.startGBean(configurationManagerName); configurationManager = ConfigurationUtil.getConfigurationManager(kernel); Modified: geronimo/branches/1.1/modules/kernel/src/test/org/apache/geronimo/kernel/config/ConfigurationManagerTest.java URL: http://svn.apache.org/viewcvs/geronimo/branches/1.1/modules/kernel/src/test/org/apache/geronimo/kernel/config/ConfigurationManagerTest.java?rev=383067&r1=383066&r2=383067&view=diff ============================================================================== --- geronimo/branches/1.1/modules/kernel/src/test/org/apache/geronimo/kernel/config/ConfigurationManagerTest.java (original) +++ geronimo/branches/1.1/modules/kernel/src/test/org/apache/geronimo/kernel/config/ConfigurationManagerTest.java Fri Mar 3 23:59:20 2006 @@ -89,7 +89,6 @@ e1.setConfigId(artifact1); GBeanData gbeanData1 = new GBeanData(Configuration.getConfigurationObjectName(artifact1), Configuration.GBEAN_INFO); gbeanData1.setAttribute("environment", e1); - gbeanData1.setReferencePattern("ArtifactManager", artifactManagerName); configurations.put(artifact1, gbeanData1); Environment e2 = new Environment(); @@ -97,7 +96,6 @@ e2.addImport(new Artifact("test", "1", (Version) null, "bar")); GBeanData gbeanData2 = new GBeanData(Configuration.getConfigurationObjectName(artifact2), Configuration.GBEAN_INFO); gbeanData2.setAttribute("environment", e2); - gbeanData2.setReferencePattern("ArtifactManager", artifactManagerName); configurations.put(artifact2, gbeanData2); Environment e3 = new Environment(); @@ -105,7 +103,6 @@ e3.addImport(new Artifact("test", "2", (Version) null, "bar")); GBeanData gbeanData3 = new GBeanData(Configuration.getConfigurationObjectName(artifact3), Configuration.GBEAN_INFO); gbeanData3.setAttribute("environment", e3); - gbeanData3.setReferencePattern("ArtifactManager", artifactManagerName); configurations.put(artifact3, gbeanData3); TestRepository testRepository = new TestRepository(); Modified: geronimo/branches/1.1/modules/kernel/src/test/org/apache/geronimo/kernel/repository/ArtifactResolverTest.java URL: http://svn.apache.org/viewcvs/geronimo/branches/1.1/modules/kernel/src/test/org/apache/geronimo/kernel/repository/ArtifactResolverTest.java?rev=383067&r1=383066&r2=383067&view=diff ============================================================================== --- geronimo/branches/1.1/modules/kernel/src/test/org/apache/geronimo/kernel/repository/ArtifactResolverTest.java (original) +++ geronimo/branches/1.1/modules/kernel/src/test/org/apache/geronimo/kernel/repository/ArtifactResolverTest.java Fri Mar 3 23:59:20 2006 @@ -91,6 +91,7 @@ environment.setConfigId(loader); environment.addDependency(version1); Configuration parent = new Configuration(null, + null, Configuration.getConfigurationObjectName(loader).getCanonicalName(), ConfigurationModuleType.SERVICE, environment, 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=383067&r1=383066&r2=383067&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 Fri Mar 3 23:59:20 2006 @@ -21,7 +21,6 @@ import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; -import java.io.ObjectOutputStream; import java.io.OutputStream; import java.net.URI; import java.util.Collection; @@ -31,15 +30,10 @@ import java.util.jar.JarOutputStream; import java.util.jar.Manifest; import java.util.zip.ZipEntry; -import javax.management.MalformedObjectNameException; -import javax.management.ObjectName; -import org.apache.geronimo.gbean.GBeanData; -import org.apache.geronimo.kernel.config.Configuration; import org.apache.geronimo.kernel.config.ConfigurationData; +import org.apache.geronimo.kernel.config.ConfigurationUtil; import org.apache.geronimo.kernel.config.InvalidConfigException; -import org.apache.geronimo.kernel.repository.Artifact; -import org.apache.geronimo.kernel.repository.Environment; /** * @version $Rev$ $Date$ @@ -93,49 +87,24 @@ } public static void writeConfiguration(ConfigurationData configurationData, JarOutputStream out) throws IOException, InvalidConfigException { - - // convert the configuration data to a gbeandata object - GBeanData configurationGBeanData = ExecutableConfigurationUtil.getConfigurationGBeanData(configurationData); - // save the persisted form in the source directory out.putNextEntry(new ZipEntry("META-INF/config.ser")); - ObjectOutputStream objectOutputStream = null; try { - objectOutputStream = new ObjectOutputStream(out); - configurationGBeanData.writeExternal(objectOutputStream); - } catch (IOException e) { - throw e; - } catch (Exception e) { - throw new InvalidConfigException("Unable to save configuration state", e); + ConfigurationUtil.storeBootstrapConfiguration(configurationData, out); } finally { - if (objectOutputStream != null) { - try { - objectOutputStream.flush(); - } catch (IOException ignored) { - } - } out.closeEntry(); } } public static void writeConfiguration(ConfigurationData configurationData, File source) throws InvalidConfigException, IOException { - // convert the configuration data to a gbeandata object - GBeanData configurationGBeanData = getConfigurationGBeanData(configurationData); - // save the persisted form in the source directory File metaInf = new File(source, "META-INF"); metaInf.mkdirs(); File configSer = new File(metaInf, "config.ser"); - ObjectOutputStream out = null; + + OutputStream out = new FileOutputStream(configSer); try { - out = new ObjectOutputStream(new FileOutputStream(configSer)); - try { - configurationGBeanData.writeExternal(out); - } catch (IOException e) { - throw e; - } catch (Exception e) { - throw new InvalidConfigException("Unable to save configuration state", e); - } + ConfigurationUtil.storeBootstrapConfiguration(configurationData, out); } finally { if (out != null) { try { @@ -147,25 +116,6 @@ } catch (Exception ignored) { } } - } - } - - public static GBeanData getConfigurationGBeanData(ConfigurationData configurationData) throws InvalidConfigException { - try { - Artifact id = configurationData.getId(); - GBeanData config = new GBeanData(Configuration.getConfigurationObjectName(id), Configuration.GBEAN_INFO); - config.setAttribute("type", configurationData.getModuleType()); - Environment environment = configurationData.getEnvironment(); - config.setAttribute("environment", environment); - config.setAttribute("gBeanState", Configuration.storeGBeans(configurationData.getGBeans())); - config.setAttribute("classPath", configurationData.getClassPath()); - config.setReferencePattern("Repositories", new ObjectName("*:name=Repository,*")); - config.setReferencePattern("ArtifactManager", new ObjectName("*:name=ArtifactManager,*")); - config.setReferencePattern("ArtifactResolver", new ObjectName("*:name=ArtifactResolver,*")); - - return config; - } catch (MalformedObjectNameException e) { - throw new InvalidConfigException(e); } } Modified: geronimo/branches/1.1/modules/system/src/java/org/apache/geronimo/system/main/CommandLine.java URL: http://svn.apache.org/viewcvs/geronimo/branches/1.1/modules/system/src/java/org/apache/geronimo/system/main/CommandLine.java?rev=383067&r1=383066&r2=383067&view=diff ============================================================================== --- geronimo/branches/1.1/modules/system/src/java/org/apache/geronimo/system/main/CommandLine.java (original) +++ geronimo/branches/1.1/modules/system/src/java/org/apache/geronimo/system/main/CommandLine.java Fri Mar 3 23:59:20 2006 @@ -103,7 +103,7 @@ kernel.boot(); // load the configuration - configurationName = ConfigurationUtil.startBootstrapConfiguration(kernel, in, classLoader); + configurationName = ConfigurationUtil.loadBootstrapConfiguration(kernel, in, classLoader); // load and start the configurations ConfigurationManager configurationManager = ConfigurationUtil.getConfigurationManager(kernel); Modified: geronimo/branches/1.1/modules/system/src/java/org/apache/geronimo/system/main/Daemon.java URL: http://svn.apache.org/viewcvs/geronimo/branches/1.1/modules/system/src/java/org/apache/geronimo/system/main/Daemon.java?rev=383067&r1=383066&r2=383067&view=diff ============================================================================== --- geronimo/branches/1.1/modules/system/src/java/org/apache/geronimo/system/main/Daemon.java (original) +++ geronimo/branches/1.1/modules/system/src/java/org/apache/geronimo/system/main/Daemon.java Fri Mar 3 23:59:20 2006 @@ -264,7 +264,7 @@ // load this configuration InputStream in = classLoader.getResourceAsStream("META-INF/config.ser"); - ConfigurationUtil.startBootstrapConfiguration(kernel, in, classLoader); + ConfigurationUtil.loadBootstrapConfiguration(kernel, in, classLoader); monitor.systemStarted(kernel); Modified: geronimo/branches/1.1/plugins/geronimo-deployment-plugin/src/java/org/apache/geronimo/deployment/mavenplugin/StartServer.java URL: http://svn.apache.org/viewcvs/geronimo/branches/1.1/plugins/geronimo-deployment-plugin/src/java/org/apache/geronimo/deployment/mavenplugin/StartServer.java?rev=383067&r1=383066&r2=383067&view=diff ============================================================================== --- geronimo/branches/1.1/plugins/geronimo-deployment-plugin/src/java/org/apache/geronimo/deployment/mavenplugin/StartServer.java (original) +++ geronimo/branches/1.1/plugins/geronimo-deployment-plugin/src/java/org/apache/geronimo/deployment/mavenplugin/StartServer.java Fri Mar 3 23:59:20 2006 @@ -98,7 +98,7 @@ Kernel kernel = KernelFactory.newInstance().createKernel(getKernelName()); kernel.boot(); - ConfigurationUtil.startBootstrapConfiguration(kernel, in, this.getClass().getClassLoader()); + ConfigurationUtil.loadBootstrapConfiguration(kernel, in, this.getClass().getClassLoader()); // load the rest of the configuration listed on the command line ConfigurationManager configurationManager = ConfigurationUtil.getConfigurationManager(kernel); Modified: geronimo/branches/1.1/plugins/geronimo-packaging-plugin/src/java/org/apache/geronimo/plugin/packaging/PackageBuilder.java URL: http://svn.apache.org/viewcvs/geronimo/branches/1.1/plugins/geronimo-packaging-plugin/src/java/org/apache/geronimo/plugin/packaging/PackageBuilder.java?rev=383067&r1=383066&r2=383067&view=diff ============================================================================== --- geronimo/branches/1.1/plugins/geronimo-packaging-plugin/src/java/org/apache/geronimo/plugin/packaging/PackageBuilder.java (original) +++ geronimo/branches/1.1/plugins/geronimo-packaging-plugin/src/java/org/apache/geronimo/plugin/packaging/PackageBuilder.java Fri Mar 3 23:59:20 2006 @@ -261,6 +261,9 @@ } public void execute() throws Exception { + System.out.println(); + System.out.println(" Packaging configuration " + planFile); + System.out.println(); try { Kernel kernel = createKernel(repository, repositoryClass, configurationStoreClass);