Author: dain
Date: Thu Mar 2 20:01:03 2006
New Revision: 382645
URL: http://svn.apache.org/viewcvs?rev=382645&view=rev
Log:
All configuration lifecycle is now controlled via the ConfigurationManager
Bootstrat configuration is now loaded with ConfigurationUtil
Modified:
geronimo/branches/1.1/modules/connector-builder/src/test/org/apache/geronimo/connector/deployment/ConnectorModuleBuilderTest.java
geronimo/branches/1.1/modules/jetty-builder/src/test/org/apache/geronimo/jetty/deployment/JettyModuleBuilderTest.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/ConfigurationData.java
geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/kernel/config/ConfigurationManager.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/config/EditableConfigurationManagerImpl.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/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/modules/tomcat-builder/src/test/org/apache/geronimo/tomcat/deployment/TomcatModuleBuilderTest.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/modules/connector-builder/src/test/org/apache/geronimo/connector/deployment/ConnectorModuleBuilderTest.java
URL: http://svn.apache.org/viewcvs/geronimo/branches/1.1/modules/connector-builder/src/test/org/apache/geronimo/connector/deployment/ConnectorModuleBuilderTest.java?rev=382645&r1=382644&r2=382645&view=diff
==============================================================================
--- geronimo/branches/1.1/modules/connector-builder/src/test/org/apache/geronimo/connector/deployment/ConnectorModuleBuilderTest.java (original)
+++ geronimo/branches/1.1/modules/connector-builder/src/test/org/apache/geronimo/connector/deployment/ConnectorModuleBuilderTest.java Thu Mar 2 20:01:03 2006
@@ -46,7 +46,6 @@
import org.apache.geronimo.kernel.config.ConfigurationManagerImpl;
import org.apache.geronimo.kernel.config.ConfigurationStore;
import org.apache.geronimo.kernel.config.InvalidConfigException;
-import org.apache.geronimo.kernel.config.ManageableAttributeStore;
import org.apache.geronimo.kernel.config.NoSuchConfigException;
import org.apache.geronimo.kernel.jmx.JMXUtil;
import org.apache.geronimo.kernel.management.State;
@@ -55,7 +54,6 @@
import org.apache.geronimo.kernel.repository.DefaultArtifactResolver;
import org.apache.geronimo.kernel.repository.Environment;
import org.apache.geronimo.kernel.repository.Repository;
-import org.apache.geronimo.system.configuration.ExecutableConfigurationUtil;
import org.apache.geronimo.system.serverinfo.BasicServerInfo;
import org.tranql.sql.jdbc.JDBCUtil;
@@ -385,10 +383,6 @@
DataSource ds = null;
Kernel kernel = null;
try {
- GBeanData config = ExecutableConfigurationUtil.getConfigurationGBeanData(configurationData);
- ObjectName configName = ObjectName.getInstance("test:configuration=test-ejb-jar");
- config.setName(configName);
-
kernel = KernelFactory.newInstance().createKernel("bar");
kernel.boot();
@@ -396,18 +390,19 @@
kernel.loadGBean(store, this.getClass().getClassLoader());
kernel.startGBean(store.getName());
- GBeanData manager = new GBeanData(JMXUtil.getObjectName("foo:name=ArtifactManager"), DefaultArtifactManager.GBEAN_INFO);
- kernel.loadGBean(manager, this.getClass().getClassLoader());
- kernel.startGBean(manager.getName());
-
- GBeanData resolver = new GBeanData(JMXUtil.getObjectName("foo:name=ArtifactResolver"), DefaultArtifactResolver.GBEAN_INFO);
- resolver.setReferencePattern("ArtifactManager", manager.getName());
-// resolver.setReferencePattern("Repositories", repository.getName());
- kernel.loadGBean(resolver, this.getClass().getClassLoader());
- kernel.startGBean(resolver.getName());
+ GBeanData artifactManager = new GBeanData(JMXUtil.getObjectName("foo:name=ArtifactManager"), DefaultArtifactManager.GBEAN_INFO);
+ kernel.loadGBean(artifactManager, this.getClass().getClassLoader());
+ kernel.startGBean(artifactManager.getName());
+
+ GBeanData artifactResolver = new GBeanData(JMXUtil.getObjectName("foo:name=ArtifactResolver"), DefaultArtifactResolver.GBEAN_INFO);
+ artifactResolver.setReferencePattern("ArtifactManager", artifactManager.getName());
+ kernel.loadGBean(artifactResolver, this.getClass().getClassLoader());
+ kernel.startGBean(artifactResolver.getName());
GBeanData configurationManagerData = new GBeanData(configurationManagerName, ConfigurationManagerImpl.GBEAN_INFO);
- configurationManagerData.setReferencePatterns("Stores", Collections.singleton(store.getName()));
+ configurationManagerData.setReferencePattern("Stores", store.getName());
+ configurationManagerData.setReferencePattern("ArtifactManager", artifactManager.getName());
+ configurationManagerData.setReferencePattern("ArtifactResolver", artifactResolver.getName());
kernel.loadGBean(configurationManagerData, getClass().getClassLoader());
kernel.startGBean(configurationManagerName);
ConfigurationManager configurationManager = (ConfigurationManager) kernel.getProxyManager().createProxy(configurationManagerName, ConfigurationManager.class);
@@ -431,10 +426,8 @@
assertRunning(kernel, j2eeServerObjectName);
// load the configuration
- kernel.loadGBean(config, cl);
- kernel.startGBean(configName);
- kernel.invoke(configName, "loadGBeans", new Object[]{null}, new String[]{ManageableAttributeStore.class.getName()});
- kernel.invoke(configName, "startRecursiveGBeans");
+ Configuration configuration = configurationManager.loadConfiguration(configurationData);
+ configurationManager.startConfiguration(configuration);
Set gb = kernel.listGBeans(JMXUtil.getObjectName("test:*"));
for (Iterator iterator = gb.iterator(); iterator.hasNext();) {
ObjectName name = (ObjectName) iterator.next();
@@ -442,7 +435,6 @@
System.out.println("Not running: " + name);
}
}
- assertRunning(kernel, configName);
ObjectName applicationObjectName = NameFactory.getApplicationName(null, null, null, j2eeContext);
if (!j2eeContext.getJ2eeApplicationName().equals("null")) {
@@ -542,7 +534,8 @@
}
- kernel.stopGBean(configName);
+ configurationManager.stopConfiguration(configuration);
+ configurationManager.unloadConfiguration(configuration);
} finally {
if (ds != null) {
Connection connection = null;
Modified: geronimo/branches/1.1/modules/jetty-builder/src/test/org/apache/geronimo/jetty/deployment/JettyModuleBuilderTest.java
URL: http://svn.apache.org/viewcvs/geronimo/branches/1.1/modules/jetty-builder/src/test/org/apache/geronimo/jetty/deployment/JettyModuleBuilderTest.java?rev=382645&r1=382644&r2=382645&view=diff
==============================================================================
--- geronimo/branches/1.1/modules/jetty-builder/src/test/org/apache/geronimo/jetty/deployment/JettyModuleBuilderTest.java (original)
+++ geronimo/branches/1.1/modules/jetty-builder/src/test/org/apache/geronimo/jetty/deployment/JettyModuleBuilderTest.java Thu Mar 2 20:01:03 2006
@@ -16,6 +16,26 @@
*/
package org.apache.geronimo.jetty.deployment;
+import java.io.ByteArrayOutputStream;
+import java.io.File;
+import java.io.IOException;
+import java.io.ObjectOutputStream;
+import java.net.MalformedURLException;
+import java.net.URI;
+import java.net.URL;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import javax.management.MalformedObjectNameException;
+import javax.management.ObjectName;
+import javax.naming.Reference;
+import javax.xml.namespace.QName;
+
import junit.framework.TestCase;
import org.apache.geronimo.common.DeploymentException;
import org.apache.geronimo.connector.outbound.connectiontracking.ConnectionTrackingCoordinatorGBean;
@@ -48,7 +68,6 @@
import org.apache.geronimo.kernel.config.ConfigurationModuleType;
import org.apache.geronimo.kernel.config.ConfigurationStore;
import org.apache.geronimo.kernel.config.InvalidConfigException;
-import org.apache.geronimo.kernel.config.ManageableAttributeStore;
import org.apache.geronimo.kernel.config.NoSuchConfigException;
import org.apache.geronimo.kernel.jmx.JMXUtil;
import org.apache.geronimo.kernel.management.State;
@@ -57,31 +76,10 @@
import org.apache.geronimo.kernel.repository.DefaultArtifactResolver;
import org.apache.geronimo.kernel.repository.Environment;
import org.apache.geronimo.security.SecurityServiceImpl;
-import org.apache.geronimo.system.configuration.ExecutableConfigurationUtil;
import org.apache.geronimo.system.serverinfo.BasicServerInfo;
import org.apache.geronimo.transaction.context.TransactionContextManagerGBean;
import org.apache.geronimo.transaction.manager.TransactionManagerImplGBean;
-import javax.management.MalformedObjectNameException;
-import javax.management.ObjectName;
-import javax.naming.Reference;
-import javax.xml.namespace.QName;
-import java.io.ByteArrayOutputStream;
-import java.io.File;
-import java.io.IOException;
-import java.io.ObjectOutputStream;
-import java.net.MalformedURLException;
-import java.net.URI;
-import java.net.URL;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
/**
* @version $Rev$ $Date$
*/
@@ -113,6 +111,7 @@
private String ARTIFACT_ID = "foo/bar/1/car";
private List parentId = Arrays.asList(new Artifact[] {Artifact.create(PARENT_ARTIFACT_ID)});
private Environment defaultEnvironment = new Environment();
+ private ConfigurationManager configurationManager;
public void testDeployWar4() throws Exception {
File outputPath = new File(basedir, "target/test-resources/deployables/war4");
@@ -132,16 +131,10 @@
earContext.close();
module.close();
- GBeanData configData = ExecutableConfigurationUtil.getConfigurationGBeanData(earContext.getConfigurationData());
- ObjectName configName = configData.getName();
- configData.setAttribute("configurationStore", new MockConfigStore(outputPath.toURL()));
- kernel.loadGBean(configData, cl);
- kernel.startGBean(configName);
- kernel.invoke(configName, "loadGBeans", new Object[] {null}, new String[] {ManageableAttributeStore.class.getName()});
- kernel.invoke(configName, "startRecursiveGBeans");
- if (kernel.getGBeanState(configData.getName()) != State.RUNNING_INDEX) {
- fail("gbean not started: " + configData.getName());
- }
+ ConfigurationStore configurationStore = new MockConfigStore(outputPath.toURL());
+ Configuration configuration = configurationManager.loadConfiguration(earContext.getConfigurationData(), configurationStore);
+ configurationManager.startConfiguration(configuration);
+
assertEquals(State.RUNNING_INDEX, kernel.getGBeanState(ObjectName.getInstance(BASE_NAME + ",J2EEApplication=null,j2eeType=WebModule,name=" + ARTIFACT_ID)));
Set names = kernel.listGBeans(ObjectName.getInstance(DOMAIN_NAME + ":J2EEApplication=null,WebModule=" + ARTIFACT_ID + ",*"));
System.out.println("Object names: " + names);
@@ -151,17 +144,14 @@
}
GBeanData filterMapping2Data = kernel.getGBeanData(ObjectName.getInstance(BASE_NAME + ",J2EEApplication=null,Servlet=Servlet1,WebFilter=Filter2,WebModule=" + ARTIFACT_ID + ",j2eeType=WebFilterMapping"));
- kernel.stopGBean(configName);
- kernel.unloadGBean(configName);
+ configurationManager.stopConfiguration(configuration);
+ configurationManager.unloadConfiguration(configuration);
//what is this testing?
- kernel.loadGBean(configData, cl);
- kernel.startGBean(configName);
- kernel.invoke(configName, "loadGBeans", new Object[] {null}, new String[] {ManageableAttributeStore.class.getName()});
- kernel.invoke(configName, "startRecursiveGBeans");
- kernel.stopGBean(configName);
- kernel.unloadGBean(configName);
+ configuration = configurationManager.loadConfiguration(earContext.getConfigurationData(), configurationStore);
+ configurationManager.stopConfiguration(configuration);
+ configurationManager.unloadConfiguration(configuration);
}
private EARContext createEARContext(File outputPath, Environment environment) throws MalformedObjectNameException, DeploymentException {
@@ -270,22 +260,23 @@
kernel.loadGBean(store, this.getClass().getClassLoader());
kernel.startGBean(store.getName());
- GBeanData manager = new GBeanData(JMXUtil.getObjectName("foo:name=ArtifactManager"), DefaultArtifactManager.GBEAN_INFO);
- kernel.loadGBean(manager, this.getClass().getClassLoader());
- kernel.startGBean(manager.getName());
-
- GBeanData resolver = new GBeanData(JMXUtil.getObjectName("foo:name=ArtifactResolver"), DefaultArtifactResolver.GBEAN_INFO);
- resolver.setReferencePattern("ArtifactManager", manager.getName());
-// resolver.setReferencePattern("Repositories", repository.getName());
- kernel.loadGBean(resolver, this.getClass().getClassLoader());
- kernel.startGBean(resolver.getName());
+ GBeanData artifactManager = new GBeanData(JMXUtil.getObjectName("foo:name=ArtifactManager"), DefaultArtifactManager.GBEAN_INFO);
+ kernel.loadGBean(artifactManager, this.getClass().getClassLoader());
+ kernel.startGBean(artifactManager.getName());
+
+ GBeanData artifactResolver = new GBeanData(JMXUtil.getObjectName("foo:name=ArtifactResolver"), DefaultArtifactResolver.GBEAN_INFO);
+ artifactResolver.setReferencePattern("ArtifactManager", artifactManager.getName());
+ kernel.loadGBean(artifactResolver, this.getClass().getClassLoader());
+ kernel.startGBean(artifactResolver.getName());
ObjectName configurationManagerName = new ObjectName(":j2eeType=ConfigurationManager,name=Basic");
GBeanData configurationManagerData = new GBeanData(configurationManagerName, ConfigurationManagerImpl.GBEAN_INFO);
- configurationManagerData.setReferencePatterns("Stores", Collections.singleton(store.getName()));
+ configurationManagerData.setReferencePattern("Stores", store.getName());
+ configurationManagerData.setReferencePattern("ArtifactManager", artifactManager.getName());
+ configurationManagerData.setReferencePattern("ArtifactResolver", artifactResolver.getName());
kernel.loadGBean(configurationManagerData, getClass().getClassLoader());
kernel.startGBean(configurationManagerName);
- ConfigurationManager configurationManager = (ConfigurationManager) kernel.getProxyManager().createProxy(configurationManagerName, ConfigurationManager.class);
+ configurationManager = (ConfigurationManager) kernel.getProxyManager().createProxy(configurationManagerName, ConfigurationManager.class);
configurationManager.loadConfiguration((Artifact) parentId.get(0));
configurationManager.startConfiguration((Artifact) parentId.get(0));
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=382645&r1=382644&r2=382645&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 Thu Mar 2 20:01:03 2006
@@ -19,7 +19,6 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.apache.geronimo.gbean.GAttributeInfo;
import org.apache.geronimo.gbean.GBeanData;
import org.apache.geronimo.gbean.GBeanInfo;
import org.apache.geronimo.gbean.GBeanInfoBuilder;
@@ -154,11 +153,6 @@
private final List parents;
/**
- * The paths within the this configuration artifact that should be added to the class loader.
- */
- private final List classPath;
-
- /**
* The GBeanData objects by ObjectName
*/
private final Map gbeans = new HashMap();
@@ -190,7 +184,6 @@
moduleType = null;
parents = null;
configurationClassLoader = null;
- classPath = null;
repositories = null;
artifactManager = null;
}
@@ -253,11 +246,6 @@
"<" + this.objectName.getCanonicalName() + ">");
}
- if (classPath != null) {
- this.classPath = classPath;
- } else {
- this.classPath = Collections.EMPTY_LIST;
- }
this.configurationStore = configurationStore;
this.artifactManager = artifactManager;
@@ -280,7 +268,7 @@
environment.setReferences(references);
// build configurationClassLoader
- URL[] urls = buildClassPath(configurationStore);
+ URL[] urls = buildClassPath(configurationStore, classPath);
log.debug("ClassPath for " + id + " resolved to " + Arrays.asList(urls));
if (parents.size() == 0) {
// no explicit parent set, so use the class loader of this class as
@@ -357,9 +345,9 @@
return dependencies;
}
- private URL[] buildClassPath(ConfigurationStore configurationStore) throws MalformedURLException, MissingDependencyException, NoSuchConfigException {
+ private URL[] buildClassPath(ConfigurationStore configurationStore, List classPath) throws MalformedURLException, MissingDependencyException, NoSuchConfigException {
LinkedHashSet dependencies = environment.getDependencies();
- List urls = new ArrayList(dependencies.size() + classPath.size());
+ List urls = new ArrayList();
for (Iterator i = dependencies.iterator(); i.hasNext();) {
Artifact artifact = (Artifact) i.next();
File file = null;
@@ -375,9 +363,11 @@
}
urls.add(file.toURL());
}
- for (Iterator i = classPath.iterator(); i.hasNext();) {
- URI uri = (URI) i.next();
- urls.add(configurationStore.resolve(id, uri));
+ if (classPath != null) {
+ for (Iterator i = classPath.iterator(); i.hasNext();) {
+ URI uri = (URI) i.next();
+ urls.add(configurationStore.resolve(id, uri));
+ }
}
return (URL[]) urls.toArray(new URL[urls.size()]);
}
@@ -455,18 +445,28 @@
ClassLoader oldCl = Thread.currentThread().getContextClassLoader();
try {
Thread.currentThread().setContextClassLoader(configurationClassLoader);
- ObjectName name = loadGBean(beanData);
+
+ log.trace("Registering GBean " + beanData.getName());
+
+ // add a dependency on this configuration
+ beanData.getDependencies().add(objectName);
+
+ // register the bean with the kernel
+ kernel.loadGBean(beanData, configurationClassLoader);
+
+ // start the configuration
if (start) {
try {
- kernel.startRecursiveGBean(name);
+ kernel.startRecursiveGBean(beanData.getName());
} 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 ('" + beanData.getName() + "')?");
}
}
- gbeans.put(name, beanData);
} finally {
Thread.currentThread().setContextClassLoader(oldCl);
}
+
+ gbeans.put(beanData.getName(), beanData);
}
public synchronized void removeGBean(ObjectName name) throws GBeanNotFoundException {
@@ -481,71 +481,8 @@
} catch (GBeanNotFoundException e) {
// Bean is no longer loaded
}
- gbeans.remove(name);
- }
-
- public void loadGBeans(ManageableAttributeStore attributeStore) throws InvalidConfigException, GBeanAlreadyExistsException {
- try {
- // create and initialize GBeans
- Collection gbeans = this.gbeans.values();
- if (attributeStore != null) {
- gbeans = attributeStore.setAttributes(id, gbeans, configurationClassLoader);
- }
-
- // register all the GBeans
- for (Iterator i = gbeans.iterator(); i.hasNext();) {
- GBeanData gbeanData = (GBeanData) i.next();
-
- // If the GBean has a configurationBaseUrl attribute, set it
- // todo remove this when web app cl are config. cl.
- GAttributeInfo attribute = gbeanData.getGBeanInfo().getAttribute("configurationBaseUrl");
- if (attribute != null && attribute.getType().equals("java.net.URL")) {
- URL baseURL = configurationStore.resolve(id, URI.create(""));
- gbeanData.setAttribute("configurationBaseUrl", baseURL);
- }
-
- loadGBean(gbeanData);
- }
- } catch (MalformedURLException e) {
- throw new InvalidConfigException(e);
- } catch (NoSuchConfigException e) {
- throw new InvalidConfigException(e);
- }
- }
-
- private ObjectName loadGBean(GBeanData beanData) throws GBeanAlreadyExistsException {
- ObjectName name = beanData.getName();
-
- log.trace("Registering GBean " + name);
- kernel.loadGBean(beanData, configurationClassLoader);
-
- beanData.getDependencies().add(objectName);
- return name;
- }
-
- public void startRecursiveGBeans() throws GBeanNotFoundException {
- for (Iterator iterator = gbeans.keySet().iterator(); iterator.hasNext();) {
- ObjectName gbeanName = (ObjectName) iterator.next();
- if (kernel.isGBeanEnabled(gbeanName)) {
- kernel.startRecursiveGBean(gbeanName);
- }
- }
- }
-
- public void stopGBeans() throws GBeanNotFoundException {
- for (Iterator iterator = gbeans.keySet().iterator(); iterator.hasNext();) {
- ObjectName gbeanName = (ObjectName) iterator.next();
- kernel.stopGBean(gbeanName);
- }
- }
-
- public void unloadGBeans() throws GBeanNotFoundException {
- for (Iterator iterator = gbeans.keySet().iterator(); iterator.hasNext();) {
- ObjectName gbeanName = (ObjectName) iterator.next();
- kernel.getDependencyManager().removeDependency(gbeanName, objectName);
- kernel.unloadGBean(gbeanName);
- }
+ gbeans.remove(name);
}
public void doStart() throws Exception {
@@ -667,8 +604,8 @@
//NOTE THIS IS NOT A REFERENCE
infoFactory.addAttribute("configurationStore", ConfigurationStore.class, true);
- infoFactory.addReference("Repositories", Repository.class, "GBean");
- infoFactory.addReference("ArtifactManager", ArtifactManager.class);
+ infoFactory.addReference("Repositories", Repository.class, "Repository");
+ infoFactory.addReference("ArtifactManager", ArtifactManager.class, "ArtifactManager");
infoFactory.addReference("ArtifactResolver", ArtifactResolver.class, "ArtifactResolver");
infoFactory.addInterface(Configuration.class);
Modified: geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/kernel/config/ConfigurationData.java
URL: http://svn.apache.org/viewcvs/geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/kernel/config/ConfigurationData.java?rev=382645&r1=382644&r2=382645&view=diff
==============================================================================
--- geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/kernel/config/ConfigurationData.java (original)
+++ geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/kernel/config/ConfigurationData.java Thu Mar 2 20:01:03 2006
@@ -58,7 +58,11 @@
public ConfigurationData(ConfigurationModuleType moduleType, LinkedHashSet classPath, List gbeans, List childConfigurations, Environment environment, File configurationDir) {
this.moduleType = moduleType;
- this.classPath = classPath;
+ if (classPath != null) {
+ this.classPath = classPath;
+ } else {
+ this.classPath = new LinkedHashSet();
+ }
this.gbeans = gbeans;
this.childConfigurations = childConfigurations;
this.environment = environment;
Modified: geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/kernel/config/ConfigurationManager.java
URL: http://svn.apache.org/viewcvs/geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/kernel/config/ConfigurationManager.java?rev=382645&r1=382644&r2=382645&view=diff
==============================================================================
--- geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/kernel/config/ConfigurationManager.java (original)
+++ geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/kernel/config/ConfigurationManager.java Thu Mar 2 20:01:03 2006
@@ -20,7 +20,6 @@
import javax.management.ObjectName;
import java.io.IOException;
-import java.net.URI;
import java.util.List;
/**
@@ -64,6 +63,10 @@
*/
List loadConfiguration(Artifact configID) throws NoSuchConfigException, IOException, InvalidConfigException;
+ Configuration loadConfiguration(ConfigurationData configurationData) throws NoSuchConfigException, IOException, InvalidConfigException;
+
+ Configuration loadConfiguration(ConfigurationData configurationData, ConfigurationStore configurationStore) throws NoSuchConfigException, IOException, InvalidConfigException;
+
/**
* Unloads the gbeans of the specified configuration, stops the configuration gbean, and unloads the
* configuration gbean from the kernel. Stop should always be called first.
@@ -74,7 +77,7 @@
void unloadConfiguration(Artifact configID) throws NoSuchConfigException;
/**
- * Start the gbeans in this configuration. You must have called loadGBeans before calling this method.
+ * Start the gbeans in this configuration.
*
* @param configID
* @throws InvalidConfigException
@@ -88,4 +91,12 @@
* @throws InvalidConfigException
*/
void stopConfiguration(Artifact configID) throws InvalidConfigException;
+
+ Configuration getConfiguration(Artifact configId);
+
+ void startConfiguration(Configuration configuration) throws InvalidConfigException;
+
+ void stopConfiguration(Configuration configuration) throws InvalidConfigException;
+
+ void unloadConfiguration(Configuration configuration) throws NoSuchConfigException;
}
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=382645&r1=382644&r2=382645&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 Thu Mar 2 20:01:03 2006
@@ -34,6 +34,7 @@
import org.apache.geronimo.kernel.repository.Artifact;
import org.apache.geronimo.kernel.repository.Environment;
import org.apache.geronimo.kernel.repository.ArtifactResolver;
+import org.apache.geronimo.kernel.repository.ArtifactManager;
import javax.management.MalformedObjectNameException;
import javax.management.ObjectName;
@@ -46,6 +47,7 @@
import java.util.Set;
import java.util.LinkedHashSet;
import java.util.Map;
+import java.util.Collections;
import java.net.URL;
import java.net.URI;
import java.net.MalformedURLException;
@@ -65,7 +67,9 @@
protected final ManageableAttributeStore attributeStore;
protected final PersistentConfigurationList configurationList;
private final ShutdownHook shutdownHook;
+ private final ArtifactManager artifactManager;
private final ArtifactResolver artifactResolver;
+ private final ClassLoader classLoader;
private static final ObjectName CONFIGURATION_NAME_QUERY;
static {
@@ -76,12 +80,20 @@
}
}
- public ConfigurationManagerImpl(Kernel kernel, Collection stores, ManageableAttributeStore attributeStore, PersistentConfigurationList configurationList, ArtifactResolver artifactResolver) {
+ public ConfigurationManagerImpl(Kernel kernel,
+ Collection stores,
+ ManageableAttributeStore attributeStore,
+ PersistentConfigurationList configurationList,
+ ArtifactManager artifactManager,
+ ArtifactResolver artifactResolver,
+ ClassLoader classLoader) {
this.kernel = kernel;
this.stores = stores;
this.attributeStore = attributeStore;
this.configurationList = configurationList;
+ this.artifactManager = artifactManager;
this.artifactResolver = artifactResolver;
+ this.classLoader = classLoader;
shutdownHook = new ShutdownHook(kernel);
}
@@ -126,6 +138,49 @@
}
public List loadConfiguration(Artifact configID) throws NoSuchConfigException, IOException, InvalidConfigException {
+ if (isLoaded(configID)) {
+ return Collections.EMPTY_LIST;
+ }
+
+ // load the GBeanData for the new configuration
+ GBeanData gbeanData = loadConfigurationGBeanData(configID);
+
+ // load the configuration
+ return loadConfiguration(configID, gbeanData);
+ }
+
+ public Configuration loadConfiguration(ConfigurationData configurationData) throws NoSuchConfigException, IOException, InvalidConfigException {
+ return loadConfiguration(configurationData, null);
+ }
+
+ 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));
+ }
+
+ loadConfiguration(id, gbeanData);
+ Configuration configuration = getConfiguration(id);
+ return configuration;
+ } catch (MalformedObjectNameException e) {
+ throw new InvalidConfigException(e);
+ }
+ }
+
+ private List loadConfiguration(Artifact configID, GBeanData gbeanData) throws NoSuchConfigException, IOException, InvalidConfigException {
Set preloaded = kernel.listGBeans(CONFIGURATION_NAME_QUERY);
for (Iterator it = preloaded.iterator(); it.hasNext();) {
ObjectName name = (ObjectName) it.next();
@@ -140,7 +195,7 @@
// load configurations from the new child to the parents
LinkedList ancestors = new LinkedList();
- loadRecursive(configID, ancestors, preloaded);
+ loadRecursive(configID, gbeanData, ancestors, preloaded);
// start the unloaded configurations from the prents to the chidren
List parentToChild = new LinkedList(ancestors);
@@ -171,23 +226,21 @@
return ancestors;
}
- private void loadRecursive(Artifact configId, LinkedList ancestors, Set preloaded) throws NoSuchConfigException, IOException, InvalidConfigException {
+ private void loadRecursive(Artifact configId, GBeanData gbeanData, LinkedList ancestors, Set preloaded) throws NoSuchConfigException, IOException, InvalidConfigException {
try {
ObjectName name = Configuration.getConfigurationObjectName(configId);
if (preloaded.contains(name)) {
return;
}
- if (!isLoaded(configId)) {
- GBeanData gbeanData = loadConfigurationGBeanData(configId);
- try {
- kernel.loadGBean(gbeanData, Configuration.class.getClassLoader());
- } catch (Exception e) {
- throw new InvalidConfigException("Unable to register configuration", e);
- }
- log.debug("Loaded Configuration " + configId);
+ try {
+ kernel.loadGBean(gbeanData, classLoader);
+ } catch (Exception e) {
+ throw new InvalidConfigException("Unable to register configuration", e);
}
+ log.debug("Loaded Configuration " + configId);
+
//put the earliest ancestors first, even if we have already started them.
ancestors.remove(configId);
ancestors.addFirst(configId);
@@ -208,7 +261,10 @@
for (Iterator iterator = environment.getImports().iterator(); iterator.hasNext();) {
Artifact parent = (Artifact) iterator.next();
- loadRecursive(parent, ancestors, preloaded);
+ if (!isLoaded(parent)) {
+ GBeanData parentGBeanData = loadConfigurationGBeanData(parent);
+ loadRecursive(parent, parentGBeanData, ancestors, preloaded);
+ }
}
} catch (NoSuchConfigException e) {
throw e;
@@ -281,6 +337,13 @@
}
Configuration configuration = getConfiguration(configId);
+ startConfiguration(configuration);
+ }
+
+ public void startConfiguration(Configuration configuration) throws InvalidConfigException {
+ if (!isLoaded(configuration.getId())) {
+ throw new InvalidConfigurationException("Configuration " + configuration.getId() + " failed to start");
+ }
// todo move this from loadConfiguration when deployment code has been update to not search kernel
// registerGBeans(configuration);
@@ -308,35 +371,37 @@
// todo clean up after failure
if (configurationList != null) {
- configurationList.addConfiguration(configId.toString());
+ configurationList.addConfiguration(configuration.getId().toString());
}
}
public void stopConfiguration(Artifact configId) throws InvalidConfigException {
+ Configuration configuration = getConfiguration(configId);
+
+ stopConfiguration(configuration);
+ }
+
+ public void stopConfiguration(Configuration configuration) throws InvalidConfigException {
try {
- Configuration configuration = getConfiguration(configId);
- Collection gbeans = configuration.getGBeans().values();
+ Collection gbeans = configuration.getGBeans().keySet();
// stop the gbeans
for (Iterator iterator = gbeans.iterator(); iterator.hasNext();) {
ObjectName gbeanName = (ObjectName) iterator.next();
kernel.stopGBean(gbeanName);
}
-
- // unload the gbeans
- // todo this is very weird to have here since registration happens in load
- for (Iterator iterator = gbeans.iterator(); iterator.hasNext();) {
- ObjectName gbeanName = (ObjectName) iterator.next();
- kernel.unloadGBean(gbeanName);
- }
} catch (Exception e) {
throw new InvalidConfigException("Could not stop gbeans in configuration", e);
}
if (configurationList != null) {
- configurationList.removeConfiguration(configId.toString());
+ configurationList.removeConfiguration(configuration.getId().toString());
}
}
+ public void unloadConfiguration(Configuration configuration) throws NoSuchConfigException {
+ unloadConfiguration(configuration.getId());
+ }
+
public void unloadConfiguration(Artifact configId) throws NoSuchConfigException {
ObjectName configName;
try {
@@ -346,6 +411,18 @@
}
try {
if (State.RUNNING_INDEX == kernel.getGBeanState(configName)) {
+ try {
+ Map gbeans = (Map) kernel.getAttribute(configName, "GBeans");
+
+ // unload the gbeans
+ // todo move this to stopConfiguration
+ for (Iterator iterator = gbeans.keySet().iterator(); iterator.hasNext();) {
+ ObjectName gbeanName = (ObjectName) iterator.next();
+ kernel.unloadGBean(gbeanName);
+ }
+ } catch (Exception e) {
+ throw new InvalidConfigException("Could not stop gbeans in configuration", e);
+ }
kernel.stopGBean(configName);
}
kernel.unloadGBean(configName);
@@ -382,9 +459,11 @@
infoFactory.addReference("Stores", ConfigurationStore.class, "ConfigurationStore");
infoFactory.addReference("AttributeStore", ManageableAttributeStore.class, ManageableAttributeStore.ATTRIBUTE_STORE);
infoFactory.addReference("PersistentConfigurationList", PersistentConfigurationList.class, PersistentConfigurationList.PERSISTENT_CONFIGURATION_LIST);
+ infoFactory.addReference("ArtifactManager", ArtifactManager.class, "ArtifactManager");
infoFactory.addReference("ArtifactResolver", ArtifactResolver.class, "ArtifactResolver");
+ infoFactory.addAttribute("classLoader", ClassLoader.class, false);
infoFactory.addInterface(ConfigurationManager.class);
- infoFactory.setConstructor(new String[]{"kernel", "Stores", "AttributeStore", "PersistentConfigurationList", "ArtifactResolver"});
+ infoFactory.setConstructor(new String[]{"kernel", "Stores", "AttributeStore", "PersistentConfigurationList", "ArtifactManager", "ArtifactResolver", "classLoader"});
GBEAN_INFO = infoFactory.getBeanInfo();
}
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=382645&r1=382644&r2=382645&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 Thu Mar 2 20:01:03 2006
@@ -16,15 +16,21 @@
*/
package org.apache.geronimo.kernel.config;
-import java.util.Set;
+import java.io.InputStream;
+import java.io.ObjectInputStream;
+import java.util.Collections;
import java.util.Iterator;
+import java.util.Map;
+import java.util.Set;
import javax.management.ObjectName;
-import org.apache.geronimo.kernel.jmx.JMXUtil;
-import org.apache.geronimo.kernel.Kernel;
+import org.apache.geronimo.gbean.GBeanData;
+import org.apache.geronimo.gbean.GBeanQuery;
import org.apache.geronimo.kernel.GBeanNotFoundException;
+import org.apache.geronimo.kernel.Kernel;
import org.apache.geronimo.kernel.management.State;
-import org.apache.geronimo.gbean.GBeanQuery;
+import org.apache.geronimo.kernel.repository.Environment;
+import org.apache.geronimo.kernel.repository.Artifact;
/**
* @version $Rev$ $Date$
@@ -32,6 +38,52 @@
public final class ConfigurationUtil {
private ConfigurationUtil() {
}
+
+ public static ObjectName startBootstrapConfiguration(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);
+ try {
+ configuration.readExternal(ois);
+ } finally {
+ ois.close();
+ }
+
+ Environment environment = (Environment) configuration.getAttribute("environment");
+ Artifact configId = environment.getConfigId();
+ ObjectName configurationName = Configuration.getConfigurationObjectName(configId);
+ 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);
+ environment.setDependencies(Collections.EMPTY_LIST);
+
+ // load and start the gbean
+ kernel.loadGBean(configuration, classLoader);
+ kernel.startGBean(configurationName);
+
+ // get the gbeans and classloader
+ Map gbeans = (Map) kernel.getAttribute(configurationName, "GBeans");
+ ClassLoader configurationClassLoader = (ClassLoader) kernel.getAttribute(configurationName, "configurationClassLoader");
+
+ // register all the GBeans
+ for (Iterator i = gbeans.values().iterator(); i.hasNext();) {
+ GBeanData gbeanData = (GBeanData) i.next();
+ gbeanData.getDependencies().add(configurationName);
+
+ // load the gbean into the kernel
+ kernel.loadGBean(gbeanData, configurationClassLoader);
+
+ // start the gbean
+ if (kernel.isGBeanEnabled(gbeanData.getName())) {
+ kernel.startRecursiveGBean(gbeanData.getName());
+ }
+ }
+
+ return configurationName;
+ }
+
/**
* Gets a reference or proxy to the ConfigurationManager running in the specified kernel.
Modified: geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/kernel/config/EditableConfigurationManagerImpl.java
URL: http://svn.apache.org/viewcvs/geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/kernel/config/EditableConfigurationManagerImpl.java?rev=382645&r1=382644&r2=382645&view=diff
==============================================================================
--- geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/kernel/config/EditableConfigurationManagerImpl.java (original)
+++ geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/kernel/config/EditableConfigurationManagerImpl.java Thu Mar 2 20:01:03 2006
@@ -22,6 +22,7 @@
import org.apache.geronimo.kernel.GBeanNotFoundException;
import org.apache.geronimo.kernel.repository.Artifact;
import org.apache.geronimo.kernel.repository.ArtifactResolver;
+import org.apache.geronimo.kernel.repository.ArtifactManager;
import org.apache.geronimo.kernel.management.State;
import org.apache.geronimo.gbean.GBeanData;
import org.apache.geronimo.gbean.GBeanInfo;
@@ -33,9 +34,14 @@
* @version $Rev$ $Date$
*/
public class EditableConfigurationManagerImpl extends ConfigurationManagerImpl implements EditableConfigurationManager {
- public EditableConfigurationManagerImpl(Kernel kernel, Collection stores, ManageableAttributeStore attributeStore,
- PersistentConfigurationList configurationList, ArtifactResolver artifactResolver) {
- super(kernel, stores, attributeStore, configurationList, artifactResolver);
+ public EditableConfigurationManagerImpl(Kernel kernel,
+ Collection stores,
+ ManageableAttributeStore attributeStore,
+ PersistentConfigurationList configurationList,
+ ArtifactManager artifactManager,
+ ArtifactResolver artifactResolver,
+ ClassLoader classLoader) {
+ super(kernel, stores, attributeStore, configurationList, artifactManager, artifactResolver, classLoader);
}
public void addGBeanToConfiguration(Artifact configID, GBeanData gbean, boolean start) throws InvalidConfigException {
@@ -82,7 +88,7 @@
static {
GBeanInfoBuilder infoFactory = GBeanInfoBuilder.createStatic(EditableConfigurationManagerImpl.class, ConfigurationManagerImpl.GBEAN_INFO, "ConfigurationManager");
infoFactory.addInterface(EditableConfigurationManager.class);
- infoFactory.setConstructor(new String[]{"kernel", "Stores", "AttributeStore", "PersistentConfigurationList", "ArtifactResolver"});
+ infoFactory.setConstructor(new String[]{"kernel", "Stores", "AttributeStore", "PersistentConfigurationList", "ArtifactManager", "ArtifactResolver", "classLoader"});
GBEAN_INFO = infoFactory.getBeanInfo();
}
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=382645&r1=382644&r2=382645&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 Thu Mar 2 20:01:03 2006
@@ -17,6 +17,18 @@
package org.apache.geronimo.kernel;
+import java.io.ByteArrayOutputStream;
+import java.io.File;
+import java.io.IOException;
+import java.io.ObjectOutputStream;
+import java.net.MalformedURLException;
+import java.net.URI;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+import javax.management.ObjectName;
+
import junit.framework.TestCase;
import org.apache.geronimo.gbean.GBeanData;
import org.apache.geronimo.gbean.GBeanInfo;
@@ -24,51 +36,48 @@
import org.apache.geronimo.kernel.config.Configuration;
import org.apache.geronimo.kernel.config.ConfigurationData;
import org.apache.geronimo.kernel.config.ConfigurationManagerImpl;
+import org.apache.geronimo.kernel.config.ConfigurationModuleType;
import org.apache.geronimo.kernel.config.ConfigurationStore;
import org.apache.geronimo.kernel.config.InvalidConfigException;
-import org.apache.geronimo.kernel.config.ManageableAttributeStore;
import org.apache.geronimo.kernel.config.NoSuchConfigException;
+import org.apache.geronimo.kernel.config.ConfigurationUtil;
+import org.apache.geronimo.kernel.config.ConfigurationManager;
import org.apache.geronimo.kernel.management.State;
import org.apache.geronimo.kernel.repository.Artifact;
import org.apache.geronimo.kernel.repository.DefaultArtifactManager;
import org.apache.geronimo.kernel.repository.Environment;
-import javax.management.ObjectName;
-import java.io.ByteArrayOutputStream;
-import java.io.File;
-import java.io.IOException;
-import java.io.ObjectOutputStream;
-import java.net.MalformedURLException;
-import java.net.URI;
-import java.net.URL;
-import java.util.Collections;
-import java.util.List;
-
/**
* @version $Rev$ $Date$
*/
public class ConfigTest extends TestCase {
- private ObjectName gbeanName1;
private Kernel kernel;
+ private ObjectName gbeanName1;
private ObjectName gbeanName2;
- private GBeanData config;
+ private ConfigurationData configurationData;
+ private ConfigurationManager configurationManager;
- public void testOnlineConfig() throws Exception {
+ public void testConfigLifecycle() throws Exception {
- // load and start the config
- kernel.loadGBean(config, this.getClass().getClassLoader());
- kernel.startGBean(config.getName());
- assertEquals(State.RUNNING_INDEX, kernel.getGBeanState(config.getName()));
+ // load -- config should be running and gbean registered but not started
+ Configuration configuration = configurationManager.loadConfiguration(configurationData);
+ ObjectName configurationName = new ObjectName(configuration.getObjectName());
+
+ assertEquals(State.RUNNING_INDEX, kernel.getGBeanState(configurationName));
+ assertNotNull(configuration.getConfigurationClassLoader());
+
+ assertTrue(kernel.isLoaded(gbeanName1));
+ assertTrue(kernel.isLoaded(gbeanName2));
- kernel.invoke(config.getName(), "loadGBeans", new Object[] {null}, new String[] {ManageableAttributeStore.class.getName()});
- kernel.invoke(config.getName(), "startRecursiveGBeans");
+ assertEquals(State.STOPPED_INDEX, kernel.getGBeanState(gbeanName1));
+ assertEquals(State.STOPPED_INDEX, kernel.getGBeanState(gbeanName2));
- assertEquals(State.RUNNING_INDEX, kernel.getGBeanState(config.getName()));
- assertNotNull(kernel.getAttribute(config.getName(), "configurationClassLoader"));
+ // start -- gbeans should now be started
+ configurationManager.startConfiguration(configuration);
assertEquals(State.RUNNING_INDEX, kernel.getGBeanState(gbeanName1));
- int state = kernel.getGBeanState(gbeanName2);
- assertEquals(State.RUNNING_INDEX, state);
+ assertEquals(State.RUNNING_INDEX, kernel.getGBeanState(gbeanName2));
+
assertEquals(new Integer(1), kernel.getAttribute(gbeanName1, "finalInt"));
assertEquals("1234", kernel.getAttribute(gbeanName1, "value"));
assertEquals(new Integer(3), kernel.getAttribute(gbeanName2, "finalInt"));
@@ -89,30 +98,79 @@
assertEquals(new Integer(99), kernel.getAttribute(gbeanName2, "endpointMutableInt"));
assertEquals(new Integer(99), kernel.getAttribute(gbeanName1, "mutableInt"));
- kernel.stopGBean(config.getName());
- try {
- kernel.getAttribute(gbeanName1, "value");
- fail();
- } catch (GBeanNotFoundException e) {
- // ok
- }
- assertEquals(State.STOPPED_INDEX, kernel.getGBeanState(config.getName()));
- kernel.unloadGBean(config.getName());
- assertFalse(kernel.isLoaded(config.getName()));
+
+ // stop -- gbeans should now be started, but still registered
+ configurationManager.stopConfiguration(configuration);
+
+ assertTrue(kernel.isLoaded(gbeanName1));
+ assertTrue(kernel.isLoaded(gbeanName2));
+
+ assertEquals(State.STOPPED_INDEX, kernel.getGBeanState(gbeanName1));
+ assertEquals(State.STOPPED_INDEX, kernel.getGBeanState(gbeanName2));
+
+
+ // unload -- configuration and gbeans should be unloaded
+ configurationManager.unloadConfiguration(configuration);
+
+ assertFalse(kernel.isLoaded(configurationName));
+ assertFalse(kernel.isLoaded(gbeanName1));
+ assertFalse(kernel.isLoaded(gbeanName2));
+
}
- public void testAddToConfig() throws Exception {
+ public void testConfigStartStopRestart() throws Exception {
+ // load -- config should be running and gbean registered but not started
+ Configuration configuration = configurationManager.loadConfiguration(configurationData);
+ ObjectName configurationName = new ObjectName(configuration.getObjectName());
- // load and start the config
- kernel.loadGBean(config, this.getClass().getClassLoader());
- kernel.startGBean(config.getName());
- assertEquals(State.RUNNING_INDEX, kernel.getGBeanState(config.getName()));
+ assertEquals(State.RUNNING_INDEX, kernel.getGBeanState(configurationName));
+ assertNotNull(configuration.getConfigurationClassLoader());
+
+ assertTrue(kernel.isLoaded(gbeanName1));
+ assertTrue(kernel.isLoaded(gbeanName2));
+ assertEquals(State.STOPPED_INDEX, kernel.getGBeanState(gbeanName1));
+ assertEquals(State.STOPPED_INDEX, kernel.getGBeanState(gbeanName2));
+
+
+ // start -- gbeans should now be started
+ configurationManager.startConfiguration(configuration);
+
+ assertTrue(kernel.isLoaded(gbeanName1));
+ assertTrue(kernel.isLoaded(gbeanName2));
+ assertEquals(State.RUNNING_INDEX, kernel.getGBeanState(gbeanName1));
+ assertEquals(State.RUNNING_INDEX, kernel.getGBeanState(gbeanName2));
+
+
+ // stop -- gbeans should now be started, but still registered
+ configurationManager.stopConfiguration(configuration);
+
+ assertTrue(kernel.isLoaded(gbeanName1));
+ assertTrue(kernel.isLoaded(gbeanName2));
+ assertEquals(State.STOPPED_INDEX, kernel.getGBeanState(gbeanName1));
+ assertEquals(State.STOPPED_INDEX, kernel.getGBeanState(gbeanName2));
- kernel.invoke(config.getName(), "loadGBeans", new Object[] {null}, new String[] {ManageableAttributeStore.class.getName()});
- kernel.invoke(config.getName(), "startRecursiveGBeans");
- assertEquals(State.RUNNING_INDEX, kernel.getGBeanState(config.getName()));
- assertNotNull(kernel.getAttribute(config.getName(), "configurationClassLoader"));
+ // restart -- gbeans should now be started
+ configurationManager.startConfiguration(configuration);
+
+ assertTrue(kernel.isLoaded(gbeanName1));
+ assertTrue(kernel.isLoaded(gbeanName2));
+ assertEquals(State.RUNNING_INDEX, kernel.getGBeanState(gbeanName1));
+ assertEquals(State.RUNNING_INDEX, kernel.getGBeanState(gbeanName2));
+
+ // unload -- configuration and gbeans should be unloaded
+ configurationManager.unloadConfiguration(configuration);
+
+ assertFalse(kernel.isLoaded(configurationName));
+ assertFalse(kernel.isLoaded(gbeanName1));
+ assertFalse(kernel.isLoaded(gbeanName2));
+
+ }
+
+ public void testAddToConfig() throws Exception {
+ // load and start the config
+ Configuration configuration = configurationManager.loadConfiguration(configurationData);
+ assertNotNull(configuration.getConfigurationClassLoader());
ObjectName gbeanName3 = new ObjectName("geronimo.test:name=MyMockGMBean3");
try {
@@ -124,14 +182,12 @@
mockBean3.setAttribute("value", "1234");
mockBean3.setAttribute("name", "child");
mockBean3.setAttribute("finalInt", new Integer(1));
- kernel.invoke(config.getName(), "addGBean", new Object[]{mockBean3,Boolean.TRUE}, new String[]{GBeanData.class.getName(), boolean.class.getName()});
+ configuration.addGBean(mockBean3, true);
assertEquals(State.RUNNING_INDEX, kernel.getGBeanState(gbeanName3));
assertEquals(new Integer(1), kernel.getAttribute(gbeanName3, "finalInt"));
assertEquals("1234", kernel.getAttribute(gbeanName3, "value"));
assertEquals("child", kernel.getAttribute(gbeanName3, "name"));
-
-
}
protected void setUp() throws Exception {
@@ -139,27 +195,28 @@
kernel = KernelFactory.newInstance().createKernel("test");
kernel.boot();
- ObjectName configurationManagerName = new ObjectName(":j2eeType=ConfigurationManager,name=Basic");
- GBeanData configurationManagerData = new GBeanData(configurationManagerName, ConfigurationManagerImpl.GBEAN_INFO);
- kernel.loadGBean(configurationManagerData, getClass().getClassLoader());
- kernel.startGBean(configurationManagerName);
-
-// ObjectName configurationStoreName = new ObjectName(":j2eeType=ConfigurationStore,name=foo");
-// GBeanData configurationStoreData = new GBeanData(configurationStoreName, MockConfigStore.GBEAN_INFO);
-// kernel.loadGBean(configurationStoreData, getClass().getClassLoader());
-// kernel.startGBean(configurationStoreName);
-//
ObjectName artifactManagerName = new ObjectName(":j2eeType=ArtifactManager");
GBeanData artifactManagerData = new GBeanData(artifactManagerName, DefaultArtifactManager.GBEAN_INFO);
kernel.loadGBean(artifactManagerData, getClass().getClassLoader());
kernel.startGBean(artifactManagerName);
assertEquals(State.RUNNING_INDEX, kernel.getGBeanState(artifactManagerName));
+ ObjectName configurationManagerName = new ObjectName(":j2eeType=ConfigurationManager,name=Basic");
+ GBeanData configurationManagerData = new GBeanData(configurationManagerName, ConfigurationManagerImpl.GBEAN_INFO);
+ configurationManagerData.setReferencePattern("ArtifactManager", artifactManagerName);
+ kernel.loadGBean(configurationManagerData, getClass().getClassLoader());
+ kernel.startGBean(configurationManagerName);
+ configurationManager = ConfigurationUtil.getConfigurationManager(kernel);
+
+
+ ArrayList gbeans = new ArrayList();
+
gbeanName1 = new ObjectName("geronimo.test:name=MyMockGMBean1");
GBeanData mockBean1 = new GBeanData(gbeanName1, MockGBean.getGBeanInfo());
mockBean1.setAttribute("value", "1234");
mockBean1.setAttribute("name", "child");
mockBean1.setAttribute("finalInt", new Integer(1));
+ gbeans.add(mockBean1);
gbeanName2 = new ObjectName("geronimo.test:name=MyMockGMBean2");
GBeanData mockBean2 = new GBeanData(gbeanName2, MockGBean.getGBeanInfo());
@@ -168,21 +225,12 @@
mockBean2.setAttribute("finalInt", new Integer(3));
mockBean2.setReferencePatterns("MockEndpoint", Collections.singleton(gbeanName1));
mockBean2.setReferencePatterns("EndpointCollection", Collections.singleton(gbeanName1));
+ gbeans.add(mockBean2);
- byte[] state = Configuration.storeGBeans(new GBeanData[]{mockBean1, mockBean2});
-
- Artifact id = new Artifact("geronimo", "test", "1", "car");
- ObjectName configName = Configuration.getConfigurationObjectName(id);
-
- // create the config gbean data
- config = new GBeanData(Configuration.getConfigurationObjectName(id), Configuration.GBEAN_INFO);
Environment environment = new Environment();
- environment.setConfigId(id);
- config.setAttribute("environment", environment);
- config.setAttribute("gBeanState", state);
- config.setName(configName);
- config.setReferencePattern("ArtifactManager", artifactManagerName);
- config.setAttribute("configurationStore", new MockConfigStore(new File("foo").toURL()));
+ environment.setConfigId(new Artifact("geronimo", "test", "1", "car"));
+
+ configurationData = new ConfigurationData(ConfigurationModuleType.CAR, null, gbeans, null, environment, null);
}
protected void tearDown() throws Exception {
@@ -246,7 +294,6 @@
static {
GBeanInfoBuilder infoBuilder = GBeanInfoBuilder.createStatic(MockConfigStore.class, "ConfigurationStore");
infoBuilder.addInterface(ConfigurationStore.class);
-// infoBuilder.setConstructor(new String[] {"kernel"});
GBEAN_INFO = infoBuilder.getBeanInfo();
ByteArrayOutputStream baos = new ByteArrayOutputStream();
@@ -259,5 +306,4 @@
}
}
}
-
}
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=382645&r1=382644&r2=382645&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 Thu Mar 2 20:01:03 2006
@@ -98,8 +98,6 @@
GBeanData gbeanData2 = new GBeanData(Configuration.getConfigurationObjectName(artifact2), Configuration.GBEAN_INFO);
gbeanData2.setAttribute("environment", e2);
gbeanData2.setReferencePattern("ArtifactManager", artifactManagerName);
-// gbeanData2.setAttribute("gBeanState", state);
-// e2.setAttribute("configurationStore", new MockConfigStore(new File("foo").toURL()));
configurations.put(artifact2, gbeanData2);
Environment e3 = new Environment();
@@ -115,7 +113,9 @@
Collections.singleton(new TestConfigStore()),
null,
null,
- new DefaultArtifactResolver(artifactManager, testRepository));
+ artifactManager,
+ new DefaultArtifactResolver(artifactManager, testRepository),
+ ConfigurationManagerImpl.class.getClassLoader());
}
private class TestConfigStore implements ConfigurationStore {
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=382645&r1=382644&r2=382645&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 Thu Mar 2 20:01:03 2006
@@ -17,28 +17,22 @@
package org.apache.geronimo.system.main;
+import java.io.InputStream;
+import java.util.Iterator;
+import java.util.List;
+import javax.management.ObjectName;
+
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.geronimo.common.GeronimoEnvironment;
-import org.apache.geronimo.gbean.GBeanData;
import org.apache.geronimo.kernel.GBeanNotFoundException;
import org.apache.geronimo.kernel.InternalKernelException;
import org.apache.geronimo.kernel.Kernel;
import org.apache.geronimo.kernel.KernelFactory;
-import org.apache.geronimo.kernel.config.Configuration;
import org.apache.geronimo.kernel.config.ConfigurationManager;
import org.apache.geronimo.kernel.config.ConfigurationUtil;
-import org.apache.geronimo.kernel.config.ManageableAttributeStore;
import org.apache.geronimo.kernel.log.GeronimoLogging;
import org.apache.geronimo.kernel.repository.Artifact;
-import org.apache.geronimo.kernel.repository.Environment;
-
-import javax.management.ObjectName;
-import java.io.ObjectInputStream;
-import java.net.URI;
-import java.util.Collections;
-import java.util.Iterator;
-import java.util.List;
/**
@@ -81,7 +75,7 @@
}
private Kernel kernel;
- private GBeanData configuration;
+ private ObjectName configurationName;
public void invokeMainGBean(List configurations, ObjectName mainGBean, String mainMethod, String[] args) throws Exception {
startKernel(configurations);
@@ -101,32 +95,15 @@
}
protected void startKernel(List configurations) throws Exception {
- // load and start the configuration in this jar
- configuration = new GBeanData();
ClassLoader classLoader = CommandLine.class.getClassLoader();
- ObjectInputStream ois = new ObjectInputStream(classLoader.getResourceAsStream("META-INF/config.ser"));
- try {
- configuration.readExternal(ois);
- } finally {
- ois.close();
- }
- URI configurationId = (URI) configuration.getAttribute("id");
- ObjectName configName = Configuration.getConfigurationObjectName(configurationId);
- configuration.setName(configName);
- // todo: JNB for now we clear out the dependency list but we really need a way to resolve them
- Environment environment = (Environment) configuration.getAttribute("environment");
- environment.setDependencies(Collections.EMPTY_LIST);
-// configuration.setAttribute("baseURL", classLoader.getResource("/"));
+ InputStream in = classLoader.getResourceAsStream("META-INF/config.ser");
// boot the kernel
kernel = KernelFactory.newInstance().createKernel("geronimo");
kernel.boot();
- // load this configuration into the kernel
- kernel.loadGBean(configuration, classLoader);
- kernel.startGBean(configName);
- kernel.invoke(configName, "loadGBeans", new Object[] {null}, new String[] {ManageableAttributeStore.class.getName()});
- kernel.invoke(configName, "startRecursiveGBeans");
+ // load the configuration
+ configurationName = ConfigurationUtil.startBootstrapConfiguration(kernel, in, classLoader);
// load and start the configurations
ConfigurationManager configurationManager = ConfigurationUtil.getConfigurationManager(kernel);
@@ -150,7 +127,7 @@
protected void stopKernel() throws GBeanNotFoundException, InternalKernelException {
// stop this configuration
- kernel.stopGBean(configuration.getName());
+ kernel.stopGBean(configurationName);
// shutdown the kernel
kernel.shutdown();
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=382645&r1=382644&r2=382645&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 Thu Mar 2 20:01:03 2006
@@ -17,6 +17,18 @@
package org.apache.geronimo.system.main;
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.PrintStream;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Set;
+import javax.management.MBeanServer;
+import javax.management.MBeanServerFactory;
+import javax.management.ObjectName;
+
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.geronimo.common.GeronimoEnvironment;
@@ -24,30 +36,14 @@
import org.apache.geronimo.gbean.GBeanQuery;
import org.apache.geronimo.kernel.Kernel;
import org.apache.geronimo.kernel.KernelFactory;
-import org.apache.geronimo.kernel.config.Configuration;
import org.apache.geronimo.kernel.config.ConfigurationManager;
import org.apache.geronimo.kernel.config.ConfigurationUtil;
-import org.apache.geronimo.kernel.config.ManageableAttributeStore;
import org.apache.geronimo.kernel.config.PersistentConfigurationList;
import org.apache.geronimo.kernel.log.GeronimoLogging;
import org.apache.geronimo.kernel.repository.Artifact;
-import org.apache.geronimo.kernel.repository.Environment;
import org.apache.geronimo.system.jmx.MBeanServerKernelBridge;
import org.apache.geronimo.system.serverinfo.DirectoryUtils;
-import javax.management.MBeanServer;
-import javax.management.MBeanServerFactory;
-import javax.management.ObjectName;
-import java.io.File;
-import java.io.IOException;
-import java.io.ObjectInputStream;
-import java.io.PrintStream;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Set;
-
/**
* @version $Rev$ $Date$
*/
@@ -232,26 +228,7 @@
List extensionDirsFromManifest = manifestEntries.getExtensionDirs();
AddToSystemProperty(extensionDirs, extensionDirsFromManifest, geronimoInstallDirectory);
-
- // load this configuration
ClassLoader classLoader = Daemon.class.getClassLoader();
- GBeanData configuration = new GBeanData();
- ObjectInputStream ois = new ObjectInputStream(classLoader.getResourceAsStream("META-INF/config.ser"));
- try {
- configuration.readExternal(ois);
- } finally {
- ois.close();
- }
- Environment environment = (Environment) configuration.getAttribute("environment");
- Artifact configurationId = environment.getConfigId();
- ObjectName configName = Configuration.getConfigurationObjectName(configurationId);
- configuration.setName(configName);
- configuration.setReferencePattern("ArtifactManager", null);
- configuration.setReferencePattern("ArtifactResolver", null);
-
- // todo: JNB for now we clear out the dependency list but we really need a way to resolve them
- environment.setDependencies(Collections.EMPTY_LIST);
-// configuration.setAttribute("baseURL", classLoader.getResource("/"));
// create a mbean server
MBeanServer mbeanServer = MBeanServerFactory.createMBeanServer("geronimo");
@@ -269,10 +246,6 @@
throw new AssertionError();
}
- // load this configuration into the kernel
- kernel.loadGBean(configuration, classLoader);
- kernel.startGBean(configName);
-
// add our shutdown hook
Runtime.getRuntime().addShutdownHook(new Thread("Geronimo shutdown thread") {
public void run() {
@@ -289,9 +262,10 @@
kernel.loadGBean(mbeanServerKernelBridge, classLoader);
kernel.startGBean(mbeanServerKernelBridgeName);
- // start this configuration
- kernel.invoke(configName, "loadGBeans", new Object[]{null}, new String[]{ManageableAttributeStore.class.getName()});
- kernel.invoke(configName, "startRecursiveGBeans");
+ // load this configuration
+ InputStream in = classLoader.getResourceAsStream("META-INF/config.ser");
+ ConfigurationUtil.startBootstrapConfiguration(kernel, in, classLoader);
+
monitor.systemStarted(kernel);
GBeanQuery query = new GBeanQuery(null, PersistentConfigurationList.class.getName());
Modified: geronimo/branches/1.1/modules/tomcat-builder/src/test/org/apache/geronimo/tomcat/deployment/TomcatModuleBuilderTest.java
URL: http://svn.apache.org/viewcvs/geronimo/branches/1.1/modules/tomcat-builder/src/test/org/apache/geronimo/tomcat/deployment/TomcatModuleBuilderTest.java?rev=382645&r1=382644&r2=382645&view=diff
==============================================================================
--- geronimo/branches/1.1/modules/tomcat-builder/src/test/org/apache/geronimo/tomcat/deployment/TomcatModuleBuilderTest.java (original)
+++ geronimo/branches/1.1/modules/tomcat-builder/src/test/org/apache/geronimo/tomcat/deployment/TomcatModuleBuilderTest.java Thu Mar 2 20:01:03 2006
@@ -16,6 +16,29 @@
*/
package org.apache.geronimo.tomcat.deployment;
+import java.io.ByteArrayOutputStream;
+import java.io.File;
+import java.io.IOException;
+import java.io.ObjectOutputStream;
+import java.net.MalformedURLException;
+import java.net.URI;
+import java.net.URL;
+import java.security.PermissionCollection;
+import java.security.Permissions;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import javax.management.MalformedObjectNameException;
+import javax.management.ObjectName;
+import javax.naming.Reference;
+import javax.xml.namespace.QName;
+
import junit.framework.TestCase;
import org.apache.commons.io.FileUtils;
import org.apache.geronimo.axis.builder.AxisBuilder;
@@ -47,7 +70,6 @@
import org.apache.geronimo.kernel.config.ConfigurationModuleType;
import org.apache.geronimo.kernel.config.ConfigurationStore;
import org.apache.geronimo.kernel.config.InvalidConfigException;
-import org.apache.geronimo.kernel.config.ManageableAttributeStore;
import org.apache.geronimo.kernel.config.NoSuchConfigException;
import org.apache.geronimo.kernel.jmx.JMXUtil;
import org.apache.geronimo.kernel.management.State;
@@ -58,7 +80,6 @@
import org.apache.geronimo.security.SecurityServiceImpl;
import org.apache.geronimo.security.jacc.ApplicationPolicyConfigurationManager;
import org.apache.geronimo.security.jacc.ComponentPermissions;
-import org.apache.geronimo.system.configuration.ExecutableConfigurationUtil;
import org.apache.geronimo.system.serverinfo.BasicServerInfo;
import org.apache.geronimo.tomcat.ConnectorGBean;
import org.apache.geronimo.tomcat.EngineGBean;
@@ -68,29 +89,6 @@
import org.apache.geronimo.transaction.context.TransactionContextManagerGBean;
import org.apache.geronimo.transaction.manager.TransactionManagerImplGBean;
-import javax.management.MalformedObjectNameException;
-import javax.management.ObjectName;
-import javax.naming.Reference;
-import javax.xml.namespace.QName;
-import java.io.ByteArrayOutputStream;
-import java.io.File;
-import java.io.IOException;
-import java.io.ObjectOutputStream;
-import java.net.MalformedURLException;
-import java.net.URI;
-import java.net.URL;
-import java.security.PermissionCollection;
-import java.security.Permissions;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
/**
* @version $Rev$ $Date$
*/
@@ -152,6 +150,7 @@
private List parentId = Arrays.asList(new Artifact[] {Artifact.create("geronimo/Foo/1/car")});
private Environment defaultEnvironment = new Environment();
+ private ConfigurationManager configurationManager;
public void testDeployWar4() throws Exception {
deployWar("war4", "foo/bar/1/car");
@@ -196,16 +195,10 @@
builder.addGBeans(earContext, module, cl, null);
earContext.close();
module.close();
- GBeanData configData = ExecutableConfigurationUtil.getConfigurationGBeanData(earContext.getConfigurationData());
- configData.setAttribute("configurationStore", new MockConfigStore());
- kernel.loadGBean(configData, cl);
- ObjectName configName = configData.getName();
- kernel.startGBean(configName);
- kernel.invoke(configName, "loadGBeans", new Object[] {null}, new String[] {ManageableAttributeStore.class.getName()});
- kernel.invoke(configName, "startRecursiveGBeans");
- if (kernel.getGBeanState(configName) != State.RUNNING_INDEX) {
- fail("gbean not started: " + configName);
- }
+
+ ConfigurationStore configurationStore = new MockConfigStore();
+ Configuration configuration = configurationManager.loadConfiguration(earContext.getConfigurationData(), configurationStore);
+ configurationManager.startConfiguration(configuration);
assertEquals(State.RUNNING_INDEX, kernel.getGBeanState(ObjectName.getInstance(BASE_NAME + ",J2EEApplication=null,j2eeType=WebModule,name=" + name)));
Set names = kernel.listGBeans(ObjectName.getInstance(DOMAIN_NAME + ":J2EEApplication=null,WebModule=" + name + ",*"));
@@ -218,15 +211,14 @@
//If we got here with no errors, then Tomcat deployed the war and loaded the classes
- kernel.stopGBean(configName);
- kernel.unloadGBean(configName);
+ configurationManager.stopConfiguration(configuration);
+ configurationManager.unloadConfiguration(configuration);
- kernel.loadGBean(configData, cl);
- kernel.startGBean(configName);
- kernel.invoke(configName, "loadGBeans", new Object[] {null}, new String[] {ManageableAttributeStore.class.getName()});
- kernel.invoke(configName, "startRecursiveGBeans");
- kernel.stopGBean(configName);
- kernel.unloadGBean(configName);
+
+ //what is this testing?
+ configuration = configurationManager.loadConfiguration(earContext.getConfigurationData(), configurationStore);
+ configurationManager.stopConfiguration(configuration);
+ configurationManager.unloadConfiguration(configuration);
}
private EARContext createEARContext(File outputPath, Environment environment)
@@ -376,23 +368,24 @@
kernel.loadGBean(store, this.getClass().getClassLoader());
kernel.startGBean(store.getName());
+ GBeanData artifactManager = new GBeanData(JMXUtil.getObjectName("foo:name=ArtifactManager"), DefaultArtifactManager.GBEAN_INFO);
+ kernel.loadGBean(artifactManager, this.getClass().getClassLoader());
+ kernel.startGBean(artifactManager.getName());
+
+ GBeanData artifactResolver = new GBeanData(JMXUtil.getObjectName("foo:name=ArtifactResolver"), DefaultArtifactResolver.GBEAN_INFO);
+ artifactResolver.setReferencePattern("ArtifactManager", artifactManager.getName());
+ kernel.loadGBean(artifactResolver, this.getClass().getClassLoader());
+ kernel.startGBean(artifactResolver.getName());
+
ObjectName configurationManagerName = new ObjectName(":j2eeType=ConfigurationManager,name=Basic");
GBeanData configurationManagerData = new GBeanData(configurationManagerName, ConfigurationManagerImpl.GBEAN_INFO);
configurationManagerData.setReferencePatterns("Stores", Collections.singleton(store.getName()));
+ configurationManagerData.setReferencePattern("ArtifactManager", artifactManager.getName());
+ configurationManagerData.setReferencePattern("ArtifactResolver", artifactResolver.getName());
kernel.loadGBean(configurationManagerData, getClass().getClassLoader());
kernel.startGBean(configurationManagerName);
- GBeanData manager = new GBeanData(JMXUtil.getObjectName("foo:name=ArtifactManager"), DefaultArtifactManager.GBEAN_INFO);
- kernel.loadGBean(manager, this.getClass().getClassLoader());
- kernel.startGBean(manager.getName());
-
- GBeanData resolver = new GBeanData(JMXUtil.getObjectName("foo:name=ArtifactResolver"), DefaultArtifactResolver.GBEAN_INFO);
- resolver.setReferencePattern("ArtifactManager", manager.getName());
-// resolver.setReferencePattern("Repositories", repository.getName());
- kernel.loadGBean(resolver, this.getClass().getClassLoader());
- kernel.startGBean(resolver.getName());
-
- ConfigurationManager configurationManager = (ConfigurationManager) kernel.getProxyManager().createProxy(configurationManagerName, ConfigurationManager.class);
+ configurationManager = (ConfigurationManager) kernel.getProxyManager().createProxy(configurationManagerName, ConfigurationManager.class);
configurationManager.loadConfiguration((Artifact) parentId.get(0));
configurationManager.startConfiguration((Artifact) parentId.get(0));
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=382645&r1=382644&r2=382645&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 Thu Mar 2 20:01:03 2006
@@ -18,24 +18,20 @@
package org.apache.geronimo.deployment.mavenplugin;
import java.io.File;
-import java.io.ObjectInputStream;
+import java.io.InputStream;
import java.net.URI;
import java.net.URL;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.StringTokenizer;
-import javax.management.ObjectName;
-import org.apache.geronimo.gbean.GBeanData;
import org.apache.geronimo.kernel.Kernel;
import org.apache.geronimo.kernel.KernelFactory;
-import org.apache.geronimo.kernel.repository.Artifact;
-import org.apache.geronimo.kernel.config.Configuration;
import org.apache.geronimo.kernel.config.ConfigurationManager;
import org.apache.geronimo.kernel.config.ConfigurationUtil;
-import org.apache.geronimo.kernel.config.ManageableAttributeStore;
import org.apache.geronimo.kernel.log.GeronimoLogging;
+import org.apache.geronimo.kernel.repository.Artifact;
/**
*
@@ -96,26 +92,13 @@
File root = new File(getGeronimoHome());
URL systemURL = new File(root, "bin/server.jar").toURL();
URL configURL = new URL("jar:" + systemURL.toString() + "!/META-INF/config.ser");
- GBeanData configuration = new GBeanData();
- ObjectInputStream ois = new ObjectInputStream(configURL.openStream());
- try {
- configuration.readExternal(ois);
- } finally {
- ois.close();
- }
- URI configurationId = (URI) configuration.getAttribute("id");
- ObjectName configName = Configuration.getConfigurationObjectName(configurationId);
- configuration.setName(configName);
- configuration.setAttribute("baseURL", systemURL);
+ InputStream in = configURL.openStream();
// build a basic kernel without a configuration-store, our configuration store is
Kernel kernel = KernelFactory.newInstance().createKernel(getKernelName());
kernel.boot();
- kernel.loadGBean(configuration, this.getClass().getClassLoader());
- kernel.startGBean(configName);
- kernel.invoke(configName, "loadGBeans", new Object[] {null}, new String[] {ManageableAttributeStore.class.getName()});
- kernel.invoke(configName, "startRecursiveGBeans");
+ ConfigurationUtil.startBootstrapConfiguration(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=382645&r1=382644&r2=382645&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 Thu Mar 2 20:01:03 2006
@@ -91,7 +91,7 @@
static {
try {
- REPOSITORY_NAME = new ObjectName(KERNEL_NAME + ":name=Repository");
+ REPOSITORY_NAME = new ObjectName(KERNEL_NAME + ":name=Repository,j2eeType=Repository");
ARTIFACT_MANAGER_NAME = new ObjectName(KERNEL_NAME + ":name=ArtifactManager");
ARTIFACT_RESOLVER_NAME = new ObjectName(KERNEL_NAME + ":name=ArtifactResolver");
CONFIGSTORE_NAME = new ObjectName(KERNEL_NAME + ":name=MavenConfigStore,j2eeType=ConfigurationStore");
@@ -353,6 +353,8 @@
GBeanData configManagerGBean = new GBeanData(CONFIGMANAGER_NAME, ConfigurationManagerImpl.GBEAN_INFO);
configManagerGBean.setReferencePattern("Stores", CONFIGSTORE_NAME);
configManagerGBean.setReferencePattern("AttributeStore", ATTRIBUTESTORE_NAME);
+ configManagerGBean.setReferencePattern("ArtifactManager", ARTIFACT_MANAGER_NAME);
+ configManagerGBean.setReferencePattern("ArtifactResolver", ARTIFACT_RESOLVER_NAME);
kernel.loadGBean(configManagerGBean, cl);
kernel.startGBean(CONFIGMANAGER_NAME);
|