Return-Path: Delivered-To: apmail-geronimo-scm-archive@www.apache.org Received: (qmail 22855 invoked from network); 18 Oct 2005 01:38:42 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 18 Oct 2005 01:38:42 -0000 Received: (qmail 21013 invoked by uid 500); 18 Oct 2005 01:38:41 -0000 Delivered-To: apmail-geronimo-scm-archive@geronimo.apache.org Received: (qmail 20990 invoked by uid 500); 18 Oct 2005 01:38:41 -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 20979 invoked by uid 99); 18 Oct 2005 01:38:41 -0000 Received: from asf.osuosl.org (HELO asf.osuosl.org) (140.211.166.49) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 17 Oct 2005 18:38:40 -0700 X-ASF-Spam-Status: No, hits=-8.6 required=10.0 tests=ALL_TRUSTED,INFO_TLD,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; Mon, 17 Oct 2005 18:38:39 -0700 Received: (qmail 22545 invoked by uid 65534); 18 Oct 2005 01:38:17 -0000 Message-ID: <20051018013817.22544.qmail@minotaur.apache.org> Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r326008 [1/2] - in /geronimo/trunk: applications/console-standard/src/java/org/apache/geronimo/console/configmanager/ applications/console-standard/src/java/org/apache/geronimo/console/databasemanager/ applications/console-standard/src/java... Date: Tue, 18 Oct 2005 01:38:10 -0000 To: scm@geronimo.apache.org From: djencks@apache.org X-Mailer: svnmailer-1.0.5 X-Virus-Checked: Checked by ClamAV on apache.org X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N Author: djencks Date: Mon Oct 17 18:37:46 2005 New Revision: 326008 URL: http://svn.apache.org/viewcvs?rev=326008&view=rev Log: GERONIMO-1060 step 2,3. load tags for configurations and gbeans. config.xml is the persistent config list Added: geronimo/trunk/modules/assembly/src/var/config/config.offline.xml Modified: geronimo/trunk/applications/console-standard/src/java/org/apache/geronimo/console/configmanager/ConfigManagerPortlet.java geronimo/trunk/applications/console-standard/src/java/org/apache/geronimo/console/configmanager/DeploymentPortlet.java geronimo/trunk/applications/console-standard/src/java/org/apache/geronimo/console/databasemanager/DatabaseManagerHelper.java geronimo/trunk/applications/console-standard/src/java/org/apache/geronimo/console/jmsmanager/activemqCF/ActiveMQConnectorHelper.java geronimo/trunk/applications/console-standard/src/java/org/apache/geronimo/console/jmsmanager/handlers/CreateDestinationHandler.java geronimo/trunk/modules/assembly/maven.xml geronimo/trunk/modules/assembly/src/plan/client-system-plan.xml geronimo/trunk/modules/assembly/src/plan/deployer-system-plan.xml geronimo/trunk/modules/assembly/src/plan/system-plan.xml geronimo/trunk/modules/assembly/src/var/config/config.xml geronimo/trunk/modules/connector-builder/src/test/org/apache/geronimo/connector/deployment/ConnectorModuleBuilderTest.java geronimo/trunk/modules/deploy-jsr88/src/java/org/apache/geronimo/deployment/plugin/local/RedeployCommand.java geronimo/trunk/modules/deploy-jsr88/src/java/org/apache/geronimo/deployment/plugin/local/StartCommand.java geronimo/trunk/modules/deploy-jsr88/src/java/org/apache/geronimo/deployment/plugin/local/StopCommand.java geronimo/trunk/modules/deployment/src/java/org/apache/geronimo/deployment/DeploymentContext.java geronimo/trunk/modules/jetty-builder/src/test/org/apache/geronimo/jetty/deployment/JettyModuleBuilderTest.java geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/config/Configuration.java geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/config/ConfigurationManager.java geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/config/ConfigurationManagerImpl.java geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/config/ManageableAttributeStore.java geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/config/PersistentConfigurationList.java geronimo/trunk/modules/system/src/java/org/apache/geronimo/system/configuration/FileConfigurationList.java geronimo/trunk/modules/system/src/java/org/apache/geronimo/system/configuration/LocalAttributeManager.java geronimo/trunk/modules/system/src/java/org/apache/geronimo/system/configuration/LocalConfigStore.java geronimo/trunk/modules/system/src/java/org/apache/geronimo/system/main/CommandLine.java geronimo/trunk/modules/system/src/java/org/apache/geronimo/system/main/Daemon.java geronimo/trunk/modules/system/src/schema/local-attribute.xsd geronimo/trunk/modules/system/src/test/org/apache/geronimo/system/configuration/LocalConfigStoreTest.java geronimo/trunk/modules/tomcat-builder/src/test/org/apache/geronimo/tomcat/deployment/TomcatModuleBuilderTest.java geronimo/trunk/plugins/geronimo-deployment-plugin/src/java/org/apache/geronimo/deployment/mavenplugin/StartServer.java geronimo/trunk/plugins/geronimo-packaging-plugin/src/java/org/apache/geronimo/plugin/packaging/PackageBuilder.java Modified: geronimo/trunk/applications/console-standard/src/java/org/apache/geronimo/console/configmanager/ConfigManagerPortlet.java URL: http://svn.apache.org/viewcvs/geronimo/trunk/applications/console-standard/src/java/org/apache/geronimo/console/configmanager/ConfigManagerPortlet.java?rev=326008&r1=326007&r2=326008&view=diff ============================================================================== --- geronimo/trunk/applications/console-standard/src/java/org/apache/geronimo/console/configmanager/ConfigManagerPortlet.java (original) +++ geronimo/trunk/applications/console-standard/src/java/org/apache/geronimo/console/configmanager/ConfigManagerPortlet.java Mon Oct 17 18:37:46 2005 @@ -99,22 +99,18 @@ try { ConfigurationManager configurationManager = ConfigurationUtil .getConfigurationManager(kernel); - ObjectName configName = null; String config = getConfigID(actionRequest); URI configID = URI.create(config); - if (configurationManager.isLoaded(configID)) { - configName = Configuration.getConfigurationObjectName(configID); - } else { - configName = configurationManager.load(configID); - } if (START_ACTION.equals(action)) { - configurationManager.start(configName); - //kernel.startConfiguration(getConfigID(actionRequest)); + if (!configurationManager.isLoaded(configID)) { + configurationManager.load(configID); + } + configurationManager.start(configID); messageStatus = "Started application

"; } else if (STOP_ACTION.equals(action)) { - kernel.stopGBean(configName); - //kernel.stopConfiguration(getConfigID(actionRequest)); + configurationManager.stop(configID); + configurationManager.unload(configID); messageStatus = "Stopped application

"; } else if (UNINSTALL_ACTION.equals(action)) { uninstallConfig(actionRequest); Modified: geronimo/trunk/applications/console-standard/src/java/org/apache/geronimo/console/configmanager/DeploymentPortlet.java URL: http://svn.apache.org/viewcvs/geronimo/trunk/applications/console-standard/src/java/org/apache/geronimo/console/configmanager/DeploymentPortlet.java?rev=326008&r1=326007&r2=326008&view=diff ============================================================================== --- geronimo/trunk/applications/console-standard/src/java/org/apache/geronimo/console/configmanager/DeploymentPortlet.java (original) +++ geronimo/trunk/applications/console-standard/src/java/org/apache/geronimo/console/configmanager/DeploymentPortlet.java Mon Oct 17 18:37:46 2005 @@ -125,14 +125,11 @@ ConfigurationManager configurationManager = ConfigurationUtil .getConfigurationManager(kernel); for (Iterator iterator = list.iterator(); iterator.hasNext();) { - URI config = URI.create((String)iterator.next()); - ObjectName configName; - if (configurationManager.isLoaded(config)) { - configName = Configuration.getConfigurationObjectName(config); - } else { - configName = configurationManager.load(config); + URI configID = URI.create((String)iterator.next()); + if (!configurationManager.isLoaded(configID)) { + configurationManager.load(configID); } - configurationManager.start(configName); + configurationManager.start(configID); } } } catch (DeploymentException e) { Modified: geronimo/trunk/applications/console-standard/src/java/org/apache/geronimo/console/databasemanager/DatabaseManagerHelper.java URL: http://svn.apache.org/viewcvs/geronimo/trunk/applications/console-standard/src/java/org/apache/geronimo/console/databasemanager/DatabaseManagerHelper.java?rev=326008&r1=326007&r2=326008&view=diff ============================================================================== --- geronimo/trunk/applications/console-standard/src/java/org/apache/geronimo/console/databasemanager/DatabaseManagerHelper.java (original) +++ geronimo/trunk/applications/console-standard/src/java/org/apache/geronimo/console/databasemanager/DatabaseManagerHelper.java Mon Oct 17 18:37:46 2005 @@ -182,14 +182,11 @@ .getConfigurationManager(kernel); // start installed app/s for (Iterator iterator = list.iterator(); iterator.hasNext();) { - URI configId = URI.create((String)iterator.next()); - ObjectName configName = null; - if (configurationManager.isLoaded(configId)) { - configName = Configuration.getConfigurationObjectName(configId); - } else { - configName = configurationManager.load(configId); + URI configID = URI.create((String)iterator.next()); + if (!configurationManager.isLoaded(configID)) { + configurationManager.load(configID); } - configurationManager.start(configName); + configurationManager.start(configID); } } catch (DeploymentException e) { StringBuffer buf = new StringBuffer(256); Modified: geronimo/trunk/applications/console-standard/src/java/org/apache/geronimo/console/jmsmanager/activemqCF/ActiveMQConnectorHelper.java URL: http://svn.apache.org/viewcvs/geronimo/trunk/applications/console-standard/src/java/org/apache/geronimo/console/jmsmanager/activemqCF/ActiveMQConnectorHelper.java?rev=326008&r1=326007&r2=326008&view=diff ============================================================================== --- geronimo/trunk/applications/console-standard/src/java/org/apache/geronimo/console/jmsmanager/activemqCF/ActiveMQConnectorHelper.java (original) +++ geronimo/trunk/applications/console-standard/src/java/org/apache/geronimo/console/jmsmanager/activemqCF/ActiveMQConnectorHelper.java Mon Oct 17 18:37:46 2005 @@ -189,15 +189,12 @@ ConfigurationManager configurationManager = ConfigurationUtil .getConfigurationManager(kernel); for (Iterator iterator = list.iterator(); iterator.hasNext();) { - URI configId = URI.create((String)iterator.next()); - ObjectName configName = null; - if (configurationManager.isLoaded(configId)) { - configName = Configuration.getConfigurationObjectName(configId); - } else { - configName = configurationManager.load(configId); + URI configID = URI.create((String)iterator.next()); + if (!configurationManager.isLoaded(configID)) { + configurationManager.load(configID); } - configurationManager.start(configName); + configurationManager.start(configID); } } catch (DeploymentException e) { StringBuffer buf = new StringBuffer(256); Modified: geronimo/trunk/applications/console-standard/src/java/org/apache/geronimo/console/jmsmanager/handlers/CreateDestinationHandler.java URL: http://svn.apache.org/viewcvs/geronimo/trunk/applications/console-standard/src/java/org/apache/geronimo/console/jmsmanager/handlers/CreateDestinationHandler.java?rev=326008&r1=326007&r2=326008&view=diff ============================================================================== --- geronimo/trunk/applications/console-standard/src/java/org/apache/geronimo/console/jmsmanager/handlers/CreateDestinationHandler.java (original) +++ geronimo/trunk/applications/console-standard/src/java/org/apache/geronimo/console/jmsmanager/handlers/CreateDestinationHandler.java Mon Oct 17 18:37:46 2005 @@ -155,8 +155,8 @@ installDir}, new String[] { ConfigurationData.class.getName(), File.class.getName() }); - ObjectName configName = configurationManager.load(configId); - configurationManager.start(configName); + configurationManager.load(configId); + configurationManager.start(configId); } catch (Exception e) { log.info("problem", e); Modified: geronimo/trunk/modules/assembly/maven.xml URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/assembly/maven.xml?rev=326008&r1=326007&r2=326008&view=diff ============================================================================== --- geronimo/trunk/modules/assembly/maven.xml (original) +++ geronimo/trunk/modules/assembly/maven.xml Mon Oct 17 18:37:46 2005 @@ -754,6 +754,7 @@ + Modified: geronimo/trunk/modules/assembly/src/plan/client-system-plan.xml URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/assembly/src/plan/client-system-plan.xml?rev=326008&r1=326007&r2=326008&view=diff ============================================================================== --- geronimo/trunk/modules/assembly/src/plan/client-system-plan.xml (original) +++ geronimo/trunk/modules/assembly/src/plan/client-system-plan.xml Mon Oct 17 18:37:46 2005 @@ -38,13 +38,23 @@ - *:j2eeType=ConfigurationStore,* - AttributeManager + + *:j2eeType=ConfigurationStore,* + + + AttributeManager + + + AttributeStore + AttributeManager + - ServerInfo + + ServerInfo + var/config/config.xml true @@ -53,14 +63,20 @@ config-store - ServerInfo - AttributeManager + + ServerInfo + + + AttributeManager + repository/ - ServerInfo + + ServerInfo + @@ -86,6 +102,8 @@ var/log/client-log4j.properties 60 - ServerInfo + + ServerInfo + Modified: geronimo/trunk/modules/assembly/src/plan/deployer-system-plan.xml URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/assembly/src/plan/deployer-system-plan.xml?rev=326008&r1=326007&r2=326008&view=diff ============================================================================== --- geronimo/trunk/modules/assembly/src/plan/deployer-system-plan.xml (original) +++ geronimo/trunk/modules/assembly/src/plan/deployer-system-plan.xml Mon Oct 17 18:37:46 2005 @@ -34,14 +34,24 @@ - *:j2eeType=ConfigurationStore,* - AttributeManager + + *:j2eeType=ConfigurationStore,* + + + AttributeManager + + + + + - ServerInfo - var/config/config.xml + + ServerInfo + + var/config/config.offline.xml true @@ -49,20 +59,28 @@ config-store - ServerInfo - AttributeManager + + ServerInfo + + + AttributeManager + repository/ - ServerInfo + + ServerInfo + var/log/deployer-log4j.properties 60 - ServerInfo + + ServerInfo + Modified: geronimo/trunk/modules/assembly/src/plan/system-plan.xml URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/assembly/src/plan/system-plan.xml?rev=326008&r1=326007&r2=326008&view=diff ============================================================================== --- geronimo/trunk/modules/assembly/src/plan/system-plan.xml (original) +++ geronimo/trunk/modules/assembly/src/plan/system-plan.xml Mon Oct 17 18:37:46 2005 @@ -38,40 +38,59 @@ - *:j2eeType=ConfigurationStore,* - AttributeManager + + *:j2eeType=ConfigurationStore,* + + + AttributeManager + + + AttributeStore + AttributeManager + - ServerInfo + + ServerInfo + var/config/config.xml config-store - ServerInfo - AttributeManager + + ServerInfo + + + AttributeManager + - - ServerInfo - ConfigurationManager - var/config/config.list - + + + + + + repository/ - ServerInfo + + ServerInfo + var/log/server-log4j.properties 60 - ServerInfo + + ServerInfo + Added: geronimo/trunk/modules/assembly/src/var/config/config.offline.xml URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/assembly/src/var/config/config.offline.xml?rev=326008&view=auto ============================================================================== --- geronimo/trunk/modules/assembly/src/var/config/config.offline.xml (added) +++ geronimo/trunk/modules/assembly/src/var/config/config.offline.xml Mon Oct 17 18:37:46 2005 @@ -0,0 +1,12 @@ + + + + + + ${PlanWebBuilderDefaultNamespace} + + + geronimo.server:J2EEApplication=null,J2EEModule=org/apache/geronimo/${PlanWebServerName},J2EEServer=geronimo,j2eeType=GBean,name=${PlanWebServerName}WebContainer + + + Modified: geronimo/trunk/modules/assembly/src/var/config/config.xml URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/assembly/src/var/config/config.xml?rev=326008&r1=326007&r2=326008&view=diff ============================================================================== --- geronimo/trunk/modules/assembly/src/var/config/config.xml (original) +++ geronimo/trunk/modules/assembly/src/var/config/config.xml Mon Oct 17 18:37:46 2005 @@ -10,14 +10,6 @@ rmi://${PlanServerHostname}:${PlanNamingPort} - - - ${PlanWebBuilderDefaultNamespace} - - - geronimo.server:J2EEApplication=null,J2EEModule=org/apache/geronimo/${PlanWebServerName},J2EEServer=geronimo,j2eeType=GBean,name=${PlanWebServerName}WebContainer - - ${PlanWebBuilderDefaultNamespace} @@ -68,7 +60,7 @@ service:jmx:rmi://${PlanServerHostname}/jndi/rmi:/JMXConnector - + var/cosnaming.db ${PlanCOSNamingPort} @@ -86,6 +78,7 @@ ${PlanActiveMQPort} + ${PlanServerHostname} @@ -98,4 +91,8 @@ ${PlanLdapPort} + + + + Modified: geronimo/trunk/modules/connector-builder/src/test/org/apache/geronimo/connector/deployment/ConnectorModuleBuilderTest.java URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/connector-builder/src/test/org/apache/geronimo/connector/deployment/ConnectorModuleBuilderTest.java?rev=326008&r1=326007&r2=326008&view=diff ============================================================================== --- geronimo/trunk/modules/connector-builder/src/test/org/apache/geronimo/connector/deployment/ConnectorModuleBuilderTest.java (original) +++ geronimo/trunk/modules/connector-builder/src/test/org/apache/geronimo/connector/deployment/ConnectorModuleBuilderTest.java Mon Oct 17 18:37:46 2005 @@ -394,8 +394,8 @@ kernel.startGBean(configurationManagerName); ConfigurationManager configurationManager = (ConfigurationManager) kernel.getProxyManager().createProxy(configurationManagerName, ConfigurationManager.class); - ObjectName baseConfigName = configurationManager.load(defaultParentId[0]); - kernel.startGBean(baseConfigName); + configurationManager.load(defaultParentId[0]); + configurationManager.start(defaultParentId[0]); ObjectName serverInfoObjectName = ObjectName.getInstance(j2eeContext.getJ2eeDomainName() + ":name=ServerInfo"); GBeanData serverInfoGBean = new GBeanData(serverInfoObjectName, BasicServerInfo.GBEAN_INFO); Modified: geronimo/trunk/modules/deploy-jsr88/src/java/org/apache/geronimo/deployment/plugin/local/RedeployCommand.java URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/deploy-jsr88/src/java/org/apache/geronimo/deployment/plugin/local/RedeployCommand.java?rev=326008&r1=326007&r2=326008&view=diff ============================================================================== --- geronimo/trunk/modules/deploy-jsr88/src/java/org/apache/geronimo/deployment/plugin/local/RedeployCommand.java (original) +++ geronimo/trunk/modules/deploy-jsr88/src/java/org/apache/geronimo/deployment/plugin/local/RedeployCommand.java Mon Oct 17 18:37:46 2005 @@ -109,9 +109,9 @@ List list = configurationManager.loadRecursive(configID); for (int j = 0; j < list.size(); j++) { - ObjectName name = (ObjectName) list.get(j); + URI name = (URI) list.get(j); configurationManager.start(name); - updateStatus("Started "+clean(name.getKeyProperty("name"))); + updateStatus("Started " + name); } } } finally { Modified: geronimo/trunk/modules/deploy-jsr88/src/java/org/apache/geronimo/deployment/plugin/local/StartCommand.java URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/deploy-jsr88/src/java/org/apache/geronimo/deployment/plugin/local/StartCommand.java?rev=326008&r1=326007&r2=326008&view=diff ============================================================================== --- geronimo/trunk/modules/deploy-jsr88/src/java/org/apache/geronimo/deployment/plugin/local/StartCommand.java (original) +++ geronimo/trunk/modules/deploy-jsr88/src/java/org/apache/geronimo/deployment/plugin/local/StartCommand.java Mon Oct 17 18:37:46 2005 @@ -74,9 +74,9 @@ // Load and start the module List list = configurationManager.loadRecursive(moduleID); for (int j = 0; j < list.size(); j++) { - ObjectName name = (ObjectName) list.get(j); + URI name = (URI) list.get(j); configurationManager.start(name); - String configName = ObjectName.unquote(name.getKeyProperty("name")); + String configName = name.toString(); List kids = loadChildren(kernel, configName); TargetModuleIDImpl id = new TargetModuleIDImpl(modules[i].getTarget(), configName, (String[]) kids.toArray(new String[kids.size()])); Modified: geronimo/trunk/modules/deploy-jsr88/src/java/org/apache/geronimo/deployment/plugin/local/StopCommand.java URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/deploy-jsr88/src/java/org/apache/geronimo/deployment/plugin/local/StopCommand.java?rev=326008&r1=326007&r2=326008&view=diff ============================================================================== --- geronimo/trunk/modules/deploy-jsr88/src/java/org/apache/geronimo/deployment/plugin/local/StopCommand.java (original) +++ geronimo/trunk/modules/deploy-jsr88/src/java/org/apache/geronimo/deployment/plugin/local/StopCommand.java Mon Oct 17 18:37:46 2005 @@ -31,6 +31,7 @@ import org.apache.geronimo.kernel.config.ConfigurationManager; import org.apache.geronimo.kernel.config.Configuration; import org.apache.geronimo.kernel.config.ConfigurationUtil; +import org.apache.geronimo.kernel.config.InvalidConfigException; /** * @version $Rev$ $Date$ @@ -53,17 +54,19 @@ TargetModuleID module = modules[i]; URI moduleID = URI.create(module.getModuleID()); - ObjectName configName = Configuration.getConfigurationObjectName(moduleID); +// ObjectName configName = Configuration.getConfigurationObjectName(moduleID); try { - kernel.stopGBean(configName); - } catch (GBeanNotFoundException e) { - if(clean(e.getGBeanName().getKeyProperty("name")).equals(moduleID.toString())) { +// kernel.stopGBean(configName); + configurationManager.stop(moduleID); +// } catch (GBeanNotFoundException e) { + } catch (InvalidConfigException e) { +// if(clean(e.getGBeanName().getKeyProperty("name")).equals(moduleID.toString())) { updateStatus("Module "+moduleID+" is not running."); continue; - } else { - System.out.println("Unmatched name '"+clean(e.getGBeanName().getKeyProperty("name"))+"'"); - throw e; - } +// } else { +// System.out.println("Unmatched name '"+clean(e.getGBeanName().getKeyProperty("name"))+"'"); +// throw e; +// } } configurationManager.unload(moduleID); addModule(module); Modified: geronimo/trunk/modules/deployment/src/java/org/apache/geronimo/deployment/DeploymentContext.java URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/deployment/src/java/org/apache/geronimo/deployment/DeploymentContext.java?rev=326008&r1=326007&r2=326008&view=diff ============================================================================== --- geronimo/trunk/modules/deployment/src/java/org/apache/geronimo/deployment/DeploymentContext.java (original) +++ geronimo/trunk/modules/deployment/src/java/org/apache/geronimo/deployment/DeploymentContext.java Mon Oct 17 18:37:46 2005 @@ -59,8 +59,11 @@ import org.apache.geronimo.kernel.config.ConfigurationUtil; import org.apache.geronimo.kernel.config.InvalidConfigException; import org.apache.geronimo.kernel.config.MultiParentClassLoader; +import org.apache.geronimo.kernel.config.NoSuchConfigException; import org.apache.geronimo.kernel.management.State; import org.apache.geronimo.kernel.repository.Repository; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; /** * @version $Rev$ $Date$ @@ -104,6 +107,7 @@ configurationData.setParentId(parentId); configurationData.setDomain(domain); configurationData.setServer(server); + determineNaming(); determineInherited(); } @@ -133,7 +137,7 @@ throw new DeploymentException("Unable to copy domain and server from parent configuration", e); } finally { if (loaded) { - //we need to unload again so the loadedAncestors list will be in the correct order to start configs. +// we need to unload again so the loadedAncestors list will be in the correct order to start configs. configurationManager.unload(parent); } } @@ -520,6 +524,7 @@ } + private static final Log log = LogFactory.getLog(DeploymentContext.class); private ClassLoader[] determineParents() throws DeploymentException { ClassLoader[] parentCL; List parentId = configurationData.getParentId(); @@ -534,9 +539,8 @@ try { for (Iterator iterator = parentId.iterator(); iterator.hasNext();) { URI uri = (URI) iterator.next(); - ObjectName ancestorName = Configuration.getConfigurationObjectName(uri); List started = new ArrayList(); - startAncestors(ancestorName, kernel, started, configurationManager); + startAncestors(uri, kernel, started, configurationManager); startedAncestors.addAll(started); } } catch (DeploymentException e) { @@ -574,7 +578,8 @@ try { for (Iterator iterator = parentId.iterator(); iterator.hasNext();) { URI uri = (URI) iterator.next(); - loadedAncestors.addAll(configurationManager.loadRecursive(uri)); + List newAncestors = configurationManager.loadRecursive(uri); + loadedAncestors.addAll(newAncestors); } } catch (Exception e) { throw new DeploymentException("Unable to load parents", e); @@ -582,18 +587,20 @@ } } - private void startAncestors(ObjectName name, Kernel kernel, List started, ConfigurationManager configurationManager) throws Exception { - if (name != null && !isRunning(kernel, name)) { - URI[] patterns = (URI[]) kernel.getGBeanData(name).getAttribute("parentId"); - if (patterns != null) { - for (int i = 0; i < patterns.length; i++) { - URI pattern = patterns[i]; - ObjectName ancestorName = Configuration.getConfigurationObjectName(pattern); - startAncestors(ancestorName, kernel, started, configurationManager); + private void startAncestors(URI configID, Kernel kernel, List started, ConfigurationManager configurationManager) throws Exception { + if (configID != null) { + ObjectName configName = Configuration.getConfigurationObjectName(configID); + if (!isRunning(kernel, configName)) { + URI[] patterns = (URI[]) kernel.getGBeanData(configName).getAttribute("parentId"); + if (patterns != null) { + for (int i = 0; i < patterns.length; i++) { + URI pattern = patterns[i]; + startAncestors(pattern, kernel, started, configurationManager); + } } + configurationManager.loadGBeans(configID); + started.add(configID); } - configurationManager.loadGBeans(name); - started.add(name); } } @@ -602,7 +609,6 @@ } public ClassLoader getClassLoader(Repository repository) throws DeploymentException { - ClassLoader[] parentCL = determineParents(); // shouldn't user classpath come before dependencies? List dependencies = configurationData.getDependencies(); List classPath = configurationData.getClassPath(); @@ -621,6 +627,7 @@ } catch (MalformedURLException e) { throw new DeploymentException(e); } + ClassLoader[] parentCL = determineParents(); boolean inverseClassloading = configurationData.isInverseClassloading(); Set filter = configurationData.getHiddenClasses(); @@ -633,32 +640,21 @@ public void close() throws IOException, DeploymentException { if (kernel != null) { - if (startedAncestors != null) { - //stopping one stops all it's children. - //doesn't work though. - Collections.reverse(startedAncestors); - for (Iterator iterator = startedAncestors.iterator(); iterator.hasNext();) { - ObjectName objectName = (ObjectName) iterator.next(); - - try { - kernel.stopGBean(objectName); - } catch (GBeanNotFoundException e) { - throw new DeploymentException("Could not find a configuration we previously started! " + objectName, e); - } - } + ConfigurationManager configurationManager = ConfigurationUtil.getConfigurationManager(kernel); + try { startedAncestors.clear(); - } - if (loadedAncestors != null) { Collections.reverse(loadedAncestors); for (Iterator iterator = loadedAncestors.iterator(); iterator.hasNext();) { - ObjectName objectName = (ObjectName) iterator.next(); + URI configID = (URI) iterator.next(); try { - kernel.unloadGBean(objectName); - } catch (GBeanNotFoundException e) { - throw new DeploymentException("Could not find a configuration we previously loaded! " + objectName, e); + configurationManager.unload(configID); + } catch (NoSuchConfigException e) { + throw new DeploymentException("Could not find a configuration we previously loaded! " + configID, e); } } loadedAncestors.clear(); + } finally { + ConfigurationUtil.releaseConfigurationManager(kernel, configurationManager); } } } Modified: geronimo/trunk/modules/jetty-builder/src/test/org/apache/geronimo/jetty/deployment/JettyModuleBuilderTest.java URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/jetty-builder/src/test/org/apache/geronimo/jetty/deployment/JettyModuleBuilderTest.java?rev=326008&r1=326007&r2=326008&view=diff ============================================================================== --- geronimo/trunk/modules/jetty-builder/src/test/org/apache/geronimo/jetty/deployment/JettyModuleBuilderTest.java (original) +++ geronimo/trunk/modules/jetty-builder/src/test/org/apache/geronimo/jetty/deployment/JettyModuleBuilderTest.java Mon Oct 17 18:37:46 2005 @@ -264,8 +264,8 @@ kernel.startGBean(configurationManagerName); ConfigurationManager configurationManager = (ConfigurationManager) kernel.getProxyManager().createProxy(configurationManagerName, ConfigurationManager.class); - ObjectName baseConfigName = configurationManager.load((URI) parentId.get(0)); - kernel.startGBean(baseConfigName); + configurationManager.load((URI) parentId.get(0)); + configurationManager.start((URI) parentId.get(0)); Collection defaultServlets = new HashSet(); Collection defaultFilters = new HashSet(); Modified: geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/config/Configuration.java URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/config/Configuration.java?rev=326008&r1=326007&r2=326008&view=diff ============================================================================== --- geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/config/Configuration.java (original) +++ geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/config/Configuration.java Mon Oct 17 18:37:46 2005 @@ -25,8 +25,8 @@ import java.io.ObjectOutputStream; import java.net.MalformedURLException; import java.net.URI; +import java.net.URISyntaxException; import java.net.URL; -import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; import java.util.Collections; @@ -46,11 +46,11 @@ import org.apache.geronimo.gbean.GBeanInfo; import org.apache.geronimo.gbean.GBeanInfoBuilder; import org.apache.geronimo.gbean.GBeanLifecycle; +import org.apache.geronimo.kernel.DependencyManager; import org.apache.geronimo.kernel.GBeanAlreadyExistsException; import org.apache.geronimo.kernel.GBeanNotFoundException; import org.apache.geronimo.kernel.Kernel; import org.apache.geronimo.kernel.ObjectInputStreamExt; -import org.apache.geronimo.kernel.DependencyManager; import org.apache.geronimo.kernel.jmx.JMXUtil; import org.apache.geronimo.kernel.management.State; import org.apache.geronimo.kernel.repository.MissingDependencyException; @@ -96,6 +96,16 @@ return name.getDomain().equals("geronimo.config") && name.getKeyPropertyList().size() == 1 && name.getKeyProperty("name") != null; } + public static URI getConfigurationID(ObjectName objectName) throws URISyntaxException { + if (isConfigurationObjectName(objectName)) { + String name = ObjectName.unquote(objectName.getKeyProperty("name")); + URI uri = new URI(name); + return uri; + } else { + throw new IllegalArgumentException("ObjectName " + objectName + " is not a Configuration name"); + } + } + /** * The kernel in which this configuration is registered */ @@ -280,8 +290,6 @@ configurationClassLoader = new MultiParentClassLoader(id, urls, getClassLoaders(parentId), inverseClassLoading, hiddenClasses, nonOverridableClasses); } -// loadGBeans(); - log.info("Started configuration " + id); } @@ -320,6 +328,21 @@ } } + public void stopGBeans() throws GBeanNotFoundException { + for (Iterator iterator = objectNames.iterator(); iterator.hasNext();) { + ObjectName gbeanName = (ObjectName) iterator.next(); + kernel.stopGBean(gbeanName); + } + } + + public void unloadGBeans() throws GBeanNotFoundException { + for (Iterator iterator = objectNames.iterator(); iterator.hasNext();) { + ObjectName gbeanName = (ObjectName) iterator.next(); + kernel.getDependencyManager().removeDependency(gbeanName, objectName); + kernel.unloadGBean(gbeanName); + } + } + private void addParentDependencies(Kernel kernel, URI id, URI[] parentId) throws MalformedObjectNameException { if (parentId != null && parentId.length > 0) { ObjectName name = getConfigurationObjectName(id); @@ -391,8 +414,6 @@ public synchronized void doStop() throws Exception { log.info("Stopping configuration " + id); - - // shutdown the configuration and unload all beans shutdown(); @@ -406,7 +427,9 @@ kernel.getDependencyManager().removeDependency(name, objectName); try { log.trace("Unregistering GBean " + name); - kernel.unloadGBean(name); + if (kernel.isLoaded(name)) { + kernel.unloadGBean(name); + } } catch (Exception e) { // ignore log.warn("Could not unregister child " + name, e); @@ -495,11 +518,11 @@ try { Thread.currentThread().setContextClassLoader(configurationClassLoader); ObjectName name = loadGBean(beanData, objectNames); - if(start) { + if (start) { try { kernel.startRecursiveGBean(name); } catch (GBeanNotFoundException e) { - throw new IllegalStateException("How could we not find a GBean that we just loaded ('"+name+"')?"); + throw new IllegalStateException("How could we not find a GBean that we just loaded ('" + name + "')?"); } } } finally { @@ -509,12 +532,12 @@ } public synchronized void removeGBean(ObjectName name) throws GBeanNotFoundException { - if(!objectNames.contains(name)) { + if (!objectNames.contains(name)) { throw new GBeanNotFoundException(name); } kernel.getDependencyManager().removeDependency(name, this.objectName); try { - if(kernel.getGBeanState(name) == State.RUNNING_INDEX) { + if (kernel.getGBeanState(name) == State.RUNNING_INDEX) { kernel.stopGBean(name); } kernel.unloadGBean(name); @@ -536,22 +559,6 @@ return name; } -/* - private void setManageableAttributes(GBeanData data) { - if(manageableStore == null) { - log.debug("Configuration cannot load manageable attributes; no manageable store present"); - return; - } - List list = data.getGBeanInfo().getManageableAttributes(); - for (int i = 0; i < list.size(); i++) { - GAttributeInfo info = (GAttributeInfo) list.get(i); - Object value = manageableStore.getValue(id.toString(), data.getName(), info); - if(value != null) { - data.setAttribute(info.getName(), value); - } - } - } -*/ /** * Load GBeans from the supplied byte array using the supplied ClassLoader @@ -586,7 +593,8 @@ * Return a byte array containing the persisted form of the supplied GBeans * * @return the persisted GBeans - * @throws org.apache.geronimo.kernel.config.InvalidConfigException if there is a problem serializing the state + * @throws org.apache.geronimo.kernel.config.InvalidConfigException + * if there is a problem serializing the state */ public synchronized GBeanData[] storeCurrentGBeans() throws InvalidConfigException { // get the gbean data for all gbeans @@ -615,7 +623,8 @@ * * @param gbeans the gbean data to persist * @return the persisted GBeans - * @throws org.apache.geronimo.kernel.config.InvalidConfigException if there is a problem serializing the state + * @throws org.apache.geronimo.kernel.config.InvalidConfigException + * if there is a problem serializing the state */ public static byte[] storeGBeans(GBeanData[] gbeans) throws InvalidConfigException { return storeGBeans(Arrays.asList(gbeans)); @@ -672,8 +681,10 @@ infoFactory.addOperation("addGBean", new Class[]{GBeanData.class, boolean.class}); infoFactory.addOperation("removeGBean", new Class[]{ObjectName.class}); infoFactory.addOperation("saveState"); - infoFactory.addOperation("loadGBeans", new Class[] {ManageableAttributeStore.class}); + infoFactory.addOperation("loadGBeans", new Class[]{ManageableAttributeStore.class}); infoFactory.addOperation("startRecursiveGBeans"); + infoFactory.addOperation("stopGBeans"); + infoFactory.addOperation("unloadGBeans"); infoFactory.setConstructor(new String[]{ "kernel", Modified: geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/config/ConfigurationManager.java URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/config/ConfigurationManager.java?rev=326008&r1=326007&r2=326008&view=diff ============================================================================== --- geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/config/ConfigurationManager.java (original) +++ geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/config/ConfigurationManager.java Mon Oct 17 18:37:46 2005 @@ -74,7 +74,9 @@ */ void unload(URI configID) throws NoSuchConfigException; - void start(ObjectName configName) throws InvalidConfigException; + void start(URI configID) throws InvalidConfigException; - void loadGBeans(ObjectName configName) throws InvalidConfigException; + void loadGBeans(URI configID) throws InvalidConfigException; + + void stop(URI configID) throws InvalidConfigException; } Modified: geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/config/ConfigurationManagerImpl.java URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/config/ConfigurationManagerImpl.java?rev=326008&r1=326007&r2=326008&view=diff ============================================================================== --- geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/config/ConfigurationManagerImpl.java (original) +++ geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/config/ConfigurationManagerImpl.java Mon Oct 17 18:37:46 2005 @@ -36,6 +36,8 @@ import org.apache.geronimo.kernel.GBeanNotFoundException; import org.apache.geronimo.kernel.InternalKernelException; import org.apache.geronimo.kernel.Kernel; +import org.apache.geronimo.kernel.NoSuchOperationException; +import org.apache.geronimo.kernel.management.State; import org.apache.geronimo.kernel.jmx.JMXUtil; /** @@ -46,6 +48,7 @@ private final Kernel kernel; private final Collection stores; private final ManageableAttributeStore attributeStore; + private final PersistentConfigurationList configurationList; private final ShutdownHook shutdownHook; private static final ObjectName CONFIGURATION_NAME_QUERY; @@ -57,10 +60,11 @@ } } - public ConfigurationManagerImpl(Kernel kernel, Collection stores, ManageableAttributeStore attributeStore) { + public ConfigurationManagerImpl(Kernel kernel, Collection stores, ManageableAttributeStore attributeStore, PersistentConfigurationList configurationList) { this.kernel = kernel; this.stores = stores; this.attributeStore = attributeStore; + this.configurationList = configurationList; shutdownHook = new ShutdownHook(kernel); } @@ -107,7 +111,13 @@ throw new NoSuchConfigException("No configuration with id: " + configID); } - public void loadGBeans(ObjectName configName) throws InvalidConfigException { + public void loadGBeans(URI configID) throws InvalidConfigException { + ObjectName configName; + try { + configName = Configuration.getConfigurationObjectName(configID); + } catch (MalformedObjectNameException e) { + throw new InvalidConfigException("Cannot convert ID to ObjectName: ", e); + } try { kernel.startGBean(configName); kernel.invoke(configName, "loadGBeans", new Object[] {attributeStore}, new String[] {ManageableAttributeStore.class.getName()}); @@ -116,12 +126,38 @@ } } - public void start(ObjectName configName) throws InvalidConfigException { - loadGBeans(configName); + public void start(URI configID) throws InvalidConfigException { + loadGBeans(configID); + ObjectName configName; + try { + configName = Configuration.getConfigurationObjectName(configID); + } catch (MalformedObjectNameException e) { + throw new InvalidConfigException("Cannot convert ID to ObjectName: ", e); + } try { kernel.invoke(configName, "startRecursiveGBeans"); } catch (Exception e) { - throw new InvalidConfigException("Could not extract gbean data from configuration", e); + throw new InvalidConfigException("Could not start gbeans in configuration", e); + } + if (configurationList != null) { + configurationList.addConfiguration(configID.toString()); + } + } + + public void stop(URI configID) throws InvalidConfigException { + ObjectName configName; + try { + configName = Configuration.getConfigurationObjectName(configID); + } catch (MalformedObjectNameException e) { + throw new InvalidConfigException("Cannot convert ID to ObjectName: ", e); + } + try { + kernel.invoke(configName, "stopGBeans"); + } catch (Exception e) { + throw new InvalidConfigException("Could not stop gbeans in configuration", e); + } + if (configurationList != null) { + configurationList.removeConfiguration(configID.toString()); } } @@ -142,8 +178,8 @@ load(configID); } //put the earliest ancestors first, even if we have already started them. - ancestors.remove(name); - ancestors.addFirst(name); + ancestors.remove(configID); + ancestors.addFirst(configID); URI[] parents = (URI[]) kernel.getAttribute(name, "parentId"); if (parents != null) { for (int i = 0; i < parents.length; i++) { @@ -170,11 +206,16 @@ throw new NoSuchConfigException("Cannot convert ID to ObjectName: ", e); } try { + if (State.RUNNING_INDEX == kernel.getGBeanState(configName)) { + kernel.invoke(configName, "unloadGBeans"); + kernel.stopGBean(configName); + } kernel.unloadGBean(configName); } catch (GBeanNotFoundException e) { throw new NoSuchConfigException("No config registered: " + configName, e); + } catch (Exception e) { + throw new NoSuchConfigException("Problem unloading config: " + configName, e); } - log.info("Unloaded Configuration " + configName); } private List getStores() { @@ -202,8 +243,9 @@ infoFactory.addAttribute("kernel", Kernel.class, false); infoFactory.addReference("Stores", ConfigurationStore.class, "ConfigurationStore"); infoFactory.addReference("AttributeStore", ManageableAttributeStore.class, ManageableAttributeStore.ATTRIBUTE_STORE); + infoFactory.addReference("PersistentConfigurationList", PersistentConfigurationList.class, PersistentConfigurationList.PERSISTENT_CONFIGURATION_LIST); infoFactory.addInterface(ConfigurationManager.class); - infoFactory.setConstructor(new String[]{"kernel", "Stores", "AttributeStore"}); + infoFactory.setConstructor(new String[]{"kernel", "Stores", "AttributeStore", "PersistentConfigurationList"}); GBEAN_INFO = infoFactory.getBeanInfo(); } Modified: geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/config/ManageableAttributeStore.java URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/config/ManageableAttributeStore.java?rev=326008&r1=326007&r2=326008&view=diff ============================================================================== --- geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/config/ManageableAttributeStore.java (original) +++ geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/config/ManageableAttributeStore.java Mon Oct 17 18:37:46 2005 @@ -40,7 +40,7 @@ * Return the object name of this store * @return the object name of this store */ - public String getObjectName(); +// public String getObjectName(); /** * Gets a stored value (if any) for a particular attribute. The attribute @@ -57,7 +57,7 @@ * question, or null if this store has no value saved for the * specified attribute. */ - public Object getValue(String configurationName, ObjectName gbean, GAttributeInfo attribute); +// public Object getValue(String configurationName, ObjectName gbean, GAttributeInfo attribute); /** * Sets the stored value for a particular attribute. The attribute is Modified: geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/config/PersistentConfigurationList.java URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/config/PersistentConfigurationList.java?rev=326008&r1=326007&r2=326008&view=diff ============================================================================== --- geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/config/PersistentConfigurationList.java (original) +++ geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/config/PersistentConfigurationList.java Mon Oct 17 18:37:46 2005 @@ -26,6 +26,9 @@ * @version $Rev$ $Date$ */ public interface PersistentConfigurationList { + + static final String PERSISTENT_CONFIGURATION_LIST = "PersistentConfigurationList"; + boolean isKernelFullyStarted(); void setKernelFullyStarted(boolean kernelFullyStarted); @@ -33,4 +36,8 @@ void save() throws IOException; List restore() throws IOException; + + void addConfiguration(String configName); + + void removeConfiguration(String configName); } Modified: geronimo/trunk/modules/system/src/java/org/apache/geronimo/system/configuration/FileConfigurationList.java URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/system/src/java/org/apache/geronimo/system/configuration/FileConfigurationList.java?rev=326008&r1=326007&r2=326008&view=diff ============================================================================== --- geronimo/trunk/modules/system/src/java/org/apache/geronimo/system/configuration/FileConfigurationList.java (original) +++ geronimo/trunk/modules/system/src/java/org/apache/geronimo/system/configuration/FileConfigurationList.java Mon Oct 17 18:37:46 2005 @@ -211,6 +211,22 @@ } } + public void addConfiguration(String configName) { + try { + save(); + } catch (IOException e) { + log.info("Couldn't save while adding " + configName, e); + } + } + + public void removeConfiguration(String configName) { + try { + save(); + } catch (IOException e) { + log.info("Couldnt save while removing " + configName, e); + } + } + public static final GBeanInfo GBEAN_INFO; static { Modified: geronimo/trunk/modules/system/src/java/org/apache/geronimo/system/configuration/LocalAttributeManager.java URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/system/src/java/org/apache/geronimo/system/configuration/LocalAttributeManager.java?rev=326008&r1=326007&r2=326008&view=diff ============================================================================== --- geronimo/trunk/modules/system/src/java/org/apache/geronimo/system/configuration/LocalAttributeManager.java (original) +++ geronimo/trunk/modules/system/src/java/org/apache/geronimo/system/configuration/LocalAttributeManager.java Mon Oct 17 18:37:46 2005 @@ -23,11 +23,17 @@ import java.io.IOException; import java.io.PrintWriter; import java.net.URI; +import java.net.URISyntaxException; +import java.util.ArrayList; import java.util.Collection; +import java.util.Collections; import java.util.HashMap; import java.util.Iterator; import java.util.LinkedHashMap; +import java.util.List; import java.util.Map; +import java.util.Timer; +import java.util.TimerTask; import javax.management.MalformedObjectNameException; import javax.management.ObjectName; import javax.xml.parsers.DocumentBuilderFactory; @@ -41,8 +47,9 @@ import org.apache.geronimo.gbean.GBeanInfo; import org.apache.geronimo.gbean.GBeanInfoBuilder; import org.apache.geronimo.gbean.GBeanLifecycle; -import org.apache.geronimo.kernel.config.ManageableAttributeStore; import org.apache.geronimo.kernel.config.InvalidConfigException; +import org.apache.geronimo.kernel.config.ManageableAttributeStore; +import org.apache.geronimo.kernel.config.PersistentConfigurationList; import org.apache.geronimo.system.serverinfo.ServerInfo; import org.w3c.dom.Document; import org.w3c.dom.Element; @@ -56,7 +63,7 @@ * * @version $Rev: 106387 $ $Date: 2004-11-23 22:16:54 -0800 (Tue, 23 Nov 2004) $ */ -public class LocalAttributeManager implements ManageableAttributeStore, GBeanLifecycle { +public class LocalAttributeManager implements ManageableAttributeStore, PersistentConfigurationList, GBeanLifecycle { private final static Log log = LogFactory.getLog(LocalAttributeManager.class); private final static String BACKUP_EXTENSION = ".bak"; private final static String TEMP_EXTENSION = ".working"; @@ -64,50 +71,67 @@ private final ServerInfo serverInfo; private final String configFile; - private boolean readOnly = false; - private String objectName; + private final boolean readOnly; private File attributeFile; private File backupFile; private File tempFile; private final Map configurations = new LinkedHashMap(); - private UpdateThread updater; - public LocalAttributeManager(ServerInfo serverInfo, String configFile, String objectName) { - this.serverInfo = serverInfo; + private Timer timer; + private TimerTask currentTask; + + private boolean kernelFullyStarted; + + public LocalAttributeManager(String configFile, boolean readOnly, ServerInfo serverInfo) { this.configFile = configFile; - this.objectName = objectName; + this.readOnly = readOnly; + this.serverInfo = serverInfo; } public boolean isReadOnly() { return readOnly; } - public void setReadOnly(boolean readOnly) { - this.readOnly = readOnly; - } - public Collection setAttributes(URI configurationName, Collection datas) throws InvalidConfigException { String configName = configurationName.toString(); - Map configInfo = (Map) configurations.get(configName); + ConfigInfo configInfo = (ConfigInfo) configurations.get(configName); if (configInfo != null) { - for (Iterator iterator = datas.iterator(); iterator.hasNext();) { - GBeanData data = (GBeanData) iterator.next(); - setAttributes(data, configInfo, configName); + if (configInfo.isLoad()) { + for (Iterator iterator = datas.iterator(); iterator.hasNext();) { + GBeanData data = (GBeanData) iterator.next(); + boolean load = setAttributes(data, configInfo, configName); + if (!load) { + iterator.remove(); + } + } + } else { + return Collections.EMPTY_LIST; } } return datas; } - private void setAttributes(GBeanData data, Map configInfo, String configName) throws InvalidConfigException { + /** + * Set the attributes from the attribute store on a single gbean, and return whether or not to load the gbean. + * + * @param data + * @param configInfo + * @param configName + * @return true if the gbean should be loaded, false otherwise. + * @throws InvalidConfigException + */ + private boolean setAttributes(GBeanData data, ConfigInfo configInfo, String configName) throws InvalidConfigException { ObjectName gbeanName = data.getName(); GBeanInfo gBeanInfo = data.getGBeanInfo(); - Map attributeMap = (Map) configInfo.get(gbeanName); + GBeanAttrsInfo attributeMap = configInfo.getGBean(gbeanName); if (attributeMap == null) { - attributeMap = (Map) configInfo.get(gbeanName.getKeyProperty("name")); - if (attributeMap != null) { - for (Iterator iterator = attributeMap.entrySet().iterator(); iterator.hasNext();) { - Map.Entry entry = (Map.Entry) iterator.next(); + attributeMap = configInfo.getGBean(gbeanName.getKeyProperty("name")); + } + if (attributeMap != null) { + if (attributeMap.isLoad()) { + for (Iterator iterator = attributeMap.getAttributes().entrySet().iterator(); iterator.hasNext();) { + Map.Entry entry = (Map.Entry) iterator.next(); String attributeName = (String) entry.getKey(); GAttributeInfo attributeInfo = gBeanInfo.getAttribute(attributeName); if (attributeInfo == null) { @@ -117,34 +141,20 @@ Object value = getValue(attributeInfo, valueString, configName, gbeanName); data.setAttribute(attributeName, value); } + return true; + } else { + return false; } } + //no attr info, load by default + return true; } - public String getObjectName() { - return objectName; - } - public Object getValue(String configurationName, ObjectName gbean, GAttributeInfo attribute) { - Map config = (Map) configurations.get(configurationName); - if (config == null) { - return null; // nothing specified for this configuration - } - Map atts = (Map) config.get(gbean); - if (atts == null) { - atts = (Map) config.get(gbean.getKeyProperty("name")); - } - if (atts == null) { - return null; // nothing specified for this GBean - } - String value = (String) atts.get(attribute.getName()); + private Object getValue(GAttributeInfo attribute, String value, String configurationName, ObjectName gbeanName) { if (value == null) { - return null; // nothing specified for this attribute + return null; } - return getValue(attribute, value, configurationName, gbean); - } - - private Object getValue(GAttributeInfo attribute, String value, String configurationName, ObjectName gbeanName) { try { PropertyEditor editor = PropertyEditors.findEditor(attribute.getType(), getClass().getClassLoader()); if (editor == null) { @@ -165,17 +175,17 @@ if (readOnly) { return; } - Map config = (Map) configurations.get(configurationName); + ConfigInfo config = (ConfigInfo) configurations.get(configurationName); if (config == null) { - config = new HashMap(); + config = new ConfigInfo(true); configurations.put(configurationName, config); } - Map atts = (Map) config.get(gbean); + GBeanAttrsInfo atts = config.getGBean(gbean); if (atts == null) { - atts = (Map) config.get(gbean.getKeyProperty("name")); + atts = config.getGBean(gbean.getKeyProperty("name")); if (atts == null) { - atts = new HashMap(); - config.put(gbean, atts); + atts = new GBeanAttrsInfo(true); + config.addGBean(gbean, atts); } } try { @@ -189,12 +199,9 @@ editor.setValue(value); string = editor.getAsText(); } - if (string == null) { - atts.remove(attribute.getName()); - } else { - atts.put(attribute.getName(), string); - } - updater.attributeChanged(); + Map attrMap = atts.getAttributes(); + attrMap.put(attribute.getName(), string); + attributeChanged(); } catch (ClassNotFoundException e) { //todo: use the Configuration's ClassLoader to load the attribute, if this ever becomes an issue log.error("Unable to store attribute type " + attribute.getType()); @@ -217,18 +224,22 @@ for (int c = 0; c < configs.getLength(); c++) { Element config = (Element) configs.item(c); String configName = config.getAttribute("name"); - Map configMap = new LinkedHashMap(); - results.put(configName, configMap); + String loadConfigString = config.getAttribute("load"); + boolean loadConfig = !"false".equals(loadConfigString); + ConfigInfo configInfo = new ConfigInfo(loadConfig); + results.put(configName, configInfo); NodeList gbeans = config.getElementsByTagName("gbean"); for (int g = 0; g < gbeans.getLength(); g++) { Element gbean = (Element) gbeans.item(g); String gbeanName = gbean.getAttribute("name"); - Map gbeanMap = new LinkedHashMap(); + String loadGBeanString = gbean.getAttribute("load"); + boolean loadGBean = !"false".equals(loadGBeanString); + GBeanAttrsInfo gbeanAttrs = new GBeanAttrsInfo(loadGBean); if (gbeanName.indexOf(':') > -1) { ObjectName name = ObjectName.getInstance(gbeanName); - configMap.put(name, gbeanMap); + configInfo.addGBean(name, gbeanAttrs); } else { - configMap.put(gbeanName, gbeanMap); + configInfo.addGBean(gbeanName, gbeanAttrs); } NodeList attributes = gbean.getElementsByTagName("attribute"); for (int a = 0; a < attributes.getLength(); a++) { @@ -242,7 +253,7 @@ value += n.getNodeValue(); } } - gbeanMap.put(attName, value.trim()); + gbeanAttrs.setAttribute(attName, value.trim()); } } } @@ -256,7 +267,7 @@ } } - public synchronized void save() throws IOException { + public synchronized void save() throws IOException { if (readOnly) { return; } @@ -273,14 +284,16 @@ out.println(""); for (Iterator it = configurations.entrySet().iterator(); it.hasNext();) { Map.Entry entry = (Map.Entry) it.next(); - out.println(" "); - Map map = (Map) entry.getValue(); - for (Iterator gb = map.entrySet().iterator(); gb.hasNext();) { + ConfigInfo configInfo = (ConfigInfo) entry.getValue(); + boolean configLoaded = configInfo.isLoad(); + out.println(" " : "\" load=\"false\">")); + for (Iterator gb = configInfo.getGBeans().entrySet().iterator(); gb.hasNext();) { Map.Entry gbean = (Map.Entry) gb.next(); String gbeanName = gbean.getKey() instanceof String ? (String) gbean.getKey() : ((ObjectName) gbean.getKey()).getCanonicalName(); - out.println(" "); - Map atts = (Map) gbean.getValue(); - for (Iterator att = atts.entrySet().iterator(); att.hasNext();) { + GBeanAttrsInfo atts = (GBeanAttrsInfo) gbean.getValue(); + boolean gbeanLoaded = atts.isLoad(); + out.println(" " : "\" load=\"false\">")); + for (Iterator att = atts.getAttributes().entrySet().iterator(); att.hasNext();) { Map.Entry attribute = (Map.Entry) att.next(); out.print(" "); out.print((String) attribute.getValue()); @@ -307,31 +320,92 @@ } } + //PersistentConfigurationList + public boolean isKernelFullyStarted() { + return kernelFullyStarted; + } + + public void setKernelFullyStarted(boolean kernelFullyStarted) { + this.kernelFullyStarted = kernelFullyStarted; + } + + public List restore() throws IOException { + List configs = new ArrayList(); + for (Iterator iterator = configurations.entrySet().iterator(); iterator.hasNext();) { + Map.Entry entry = (Map.Entry) iterator.next(); + ConfigInfo configInfo = (ConfigInfo) entry.getValue(); + if (configInfo.isLoad()) { + String configName = (String) entry.getKey(); + try { + URI configID = new URI(configName); + configs.add(configID); + } catch (URISyntaxException e) { + throw new IOException("Could not construct URI configID for " + configName); + } + } + } + return configs; + } + + public synchronized void addConfiguration(String configName) { + ConfigInfo configInfo = (ConfigInfo) configurations.get(configName); + if (configInfo == null) { + configInfo = new ConfigInfo(true); + configurations.put(configName, configInfo); + } else { + configInfo.setLoad(true); + } + } + + public synchronized void removeConfiguration(String configName) { + ConfigInfo configInfo = (ConfigInfo) configurations.get(configName); + if (configInfo == null) { + log.error("Trying to stop unknown configuration: " + configName); + } else { + Map gbeans = configInfo.getGBeans(); + if (gbeans.isEmpty()) { + configurations.remove(configName); + } else { + configInfo.setLoad(false); + } + } + } + + //GBeanLifeCycle public void doStart() throws Exception { load(); if (!readOnly) { - updater = new UpdateThread(); - updater.start(); + timer = new Timer(); } log.info("Started LocalAttributeManager with data on " + configurations.size() + " configurations"); } public void doStop() throws Exception { - if (updater != null) { - updater.shutdown(); - if (updater.isPending()) { - save(); + boolean doSave = false; + synchronized (this) { + if (timer != null) { + timer.cancel(); + if (currentTask != null) { + currentTask.cancel(); + doSave = true; + } } - updater = null; + } + if (doSave) { + save(); } log.info("Stopped LocalAttributeManager with data on " + configurations.size() + " configurations"); configurations.clear(); } public void doFail() { - if (updater != null) { - updater.shutdown(); - updater = null; + synchronized (this) { + if (timer != null) { + timer.cancel(); + if (currentTask != null) { + currentTask.cancel(); + } + } } configurations.clear(); } @@ -354,10 +428,29 @@ } + private synchronized void attributeChanged() { + if (currentTask != null) { + currentTask.cancel(); + } + currentTask = new TimerTask() { + + public void run() { + try { + LocalAttributeManager.this.save(); + } catch (IOException e) { + log.error("Error saving attributes", e); + } + } + }; + timer.schedule(currentTask, SAVE_BUFFER_MS); + } + + /** * A thread that's notified on every attribute update. 5 seconds after * being notified, it will save the changes to a file. */ +/* // todo: This code is not pleasing -- it uses lots of synchronization and still doesn't guarantee a timely shutdown. private class UpdateThread extends Thread { private boolean done = false; @@ -433,18 +526,85 @@ } } } +*/ + + private static class ConfigInfo { + private boolean load; + private final Map gbeans = new HashMap(); + + public ConfigInfo(boolean load) { + this.load = load; + } + + public boolean isLoad() { + return load; + } + + public void setLoad(boolean load) { + this.load = load; + } + + public GBeanAttrsInfo getGBean(String gbeanName) { + return (GBeanAttrsInfo) gbeans.get(gbeanName); + } + + public void addGBean(String gbeanName, GBeanAttrsInfo gbean) { + gbeans.put(gbeanName, gbean); + } + + public Map getGBeans() { + return gbeans; + } + + public GBeanAttrsInfo getGBean(ObjectName gbeanName) { + return (GBeanAttrsInfo) gbeans.get(gbeanName); + } + + public void addGBean(ObjectName gbeanName, GBeanAttrsInfo gbean) { + gbeans.put(gbeanName, gbean); + } + } + + private static class GBeanAttrsInfo { + private boolean load; + private final Map attributes = new HashMap(); + + public GBeanAttrsInfo(boolean load) { + this.load = load; + } + + public boolean isLoad() { + return load; + } + + public void setLoad(boolean load) { + this.load = load; + } + + public Map getAttributes() { + return attributes; + } + + public String getAttribute(String attributeName) { + return (String) attributes.get(attributeName); + } + + public void setAttribute(String attributeName, String attributeValue) { + attributes.put(attributeName, attributeValue); + } + } public static final GBeanInfo GBEAN_INFO; static { - GBeanInfoBuilder infoFactory = new GBeanInfoBuilder(LocalAttributeManager.class, "AttributeStore");//does not use jsr-77 naming + GBeanInfoBuilder infoFactory = new GBeanInfoBuilder(LocalAttributeManager.class, "AttributeStore"); infoFactory.addReference("ServerInfo", ServerInfo.class, "GBean"); infoFactory.addAttribute("configFile", String.class, true); infoFactory.addAttribute("readOnly", boolean.class, true); - infoFactory.addAttribute("objectName", String.class, false); infoFactory.addInterface(ManageableAttributeStore.class); + infoFactory.addInterface(PersistentConfigurationList.class); - infoFactory.setConstructor(new String[]{"ServerInfo", "configFile", "objectName"}); + infoFactory.setConstructor(new String[]{"configFile", "readOnly", "ServerInfo"}); GBEAN_INFO = infoFactory.getBeanInfo(); } Modified: geronimo/trunk/modules/system/src/java/org/apache/geronimo/system/configuration/LocalConfigStore.java URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/system/src/java/org/apache/geronimo/system/configuration/LocalConfigStore.java?rev=326008&r1=326007&r2=326008&view=diff ============================================================================== --- geronimo/trunk/modules/system/src/java/org/apache/geronimo/system/configuration/LocalConfigStore.java (original) +++ geronimo/trunk/modules/system/src/java/org/apache/geronimo/system/configuration/LocalConfigStore.java Mon Oct 17 18:37:46 2005 @@ -202,7 +202,7 @@ saveIndex(); } - log.info("Installed configuration " + configId + " in location " + configurationDir.getName()); + log.info("Installed configuration (URL) " + configId + " in location " + configurationDir.getName()); return configId; } @@ -222,7 +222,7 @@ saveIndex(); } - log.info("Installed configuration " + configurationData.getId() + " in location " + source.getName()); + log.info("Installed configuration (file) " + configurationData.getId() + " in location " + source.getName()); } public void uninstall(URI configID) throws NoSuchConfigException, IOException { Modified: geronimo/trunk/modules/system/src/java/org/apache/geronimo/system/main/CommandLine.java URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/system/src/java/org/apache/geronimo/system/main/CommandLine.java?rev=326008&r1=326007&r2=326008&view=diff ============================================================================== --- geronimo/trunk/modules/system/src/java/org/apache/geronimo/system/main/CommandLine.java (original) +++ geronimo/trunk/modules/system/src/java/org/apache/geronimo/system/main/CommandLine.java Mon Oct 17 18:37:46 2005 @@ -125,7 +125,7 @@ URI configID = (URI) i.next(); List list = configurationManager.loadRecursive(configID); for (Iterator iterator = list.iterator(); iterator.hasNext();) { - ObjectName name = (ObjectName) iterator.next(); + URI name = (URI) iterator.next(); configurationManager.start(name); } }