You are viewing a plain text version of this content. The canonical link for it is here.
Posted to scm@geronimo.apache.org by da...@apache.org on 2004/11/03 02:18:58 UTC
svn commit: rev 56449 - in geronimo/trunk: modules/axis modules/axis/src/java/org/apache/geronimo/axis modules/axis/src/test/org/apache/geronimo/axis modules/connector-builder/src/test/org/apache/geronimo/connector/deployment modules/deployment/src/java/org/apache/geronimo/deployment modules/kernel/src/java/org/apache/geronimo/kernel modules/kernel/src/java/org/apache/geronimo/kernel/config modules/system/src/java/org/apache/geronimo/system/main plugins/maven-geronimo-plugin/src/java/org/apache/geronimo/deployment/mavenplugin
Author: dain
Date: Tue Nov 2 17:18:58 2004
New Revision: 56449
Modified:
geronimo/trunk/modules/axis/project.xml
geronimo/trunk/modules/axis/src/java/org/apache/geronimo/axis/WSConfigBuilder.java
geronimo/trunk/modules/axis/src/test/org/apache/geronimo/axis/SimpleEJBWebServiceTest.java
geronimo/trunk/modules/axis/src/test/org/apache/geronimo/axis/WSConfigBuilderTest.java
geronimo/trunk/modules/connector-builder/src/test/org/apache/geronimo/connector/deployment/RAR_1_0ConfigBuilderTest.java
geronimo/trunk/modules/connector-builder/src/test/org/apache/geronimo/connector/deployment/RAR_1_5ConfigBuilderTest.java
geronimo/trunk/modules/deployment/src/java/org/apache/geronimo/deployment/DeploymentContext.java
geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/Kernel.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/Run.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/plugins/maven-geronimo-plugin/src/java/org/apache/geronimo/deployment/mavenplugin/StartServer.java
Log:
Cleaned up exception handling in kernel
Moved load code from Config to GBeanData
Modified: geronimo/trunk/modules/axis/project.xml
==============================================================================
--- geronimo/trunk/modules/axis/project.xml (original)
+++ geronimo/trunk/modules/axis/project.xml Tue Nov 2 17:18:58 2004
@@ -44,6 +44,14 @@
<!-- ============ -->
<dependencies>
<dependency>
+ <groupId>ews</groupId>
+ <artifactId>ews</artifactId>
+ <version>&ews-version;</version>
+ <properties>
+ <module>true</module>
+ </properties>
+ </dependency>
+ <dependency>
<groupId>geronimo</groupId>
<artifactId>geronimo-xmlbeans-plugin</artifactId>
<version>${pom.currentVersion}</version>
@@ -254,15 +262,7 @@
</dependency>
<!-- Module Dependencies -->
- <dependency>
- <groupId>ews</groupId>
- <artifactId>ews</artifactId>
- <version>&ews-version;</version>
- <properties>
- <module>true</module>
- </properties>
- </dependency>
- <dependency>
+ <dependency>
<groupId>xmlbeans</groupId>
<artifactId>xbean-apache-1.0</artifactId>
<version>DEV</version>
Modified: geronimo/trunk/modules/axis/src/java/org/apache/geronimo/axis/WSConfigBuilder.java
==============================================================================
--- geronimo/trunk/modules/axis/src/java/org/apache/geronimo/axis/WSConfigBuilder.java (original)
+++ geronimo/trunk/modules/axis/src/java/org/apache/geronimo/axis/WSConfigBuilder.java Tue Nov 2 17:18:58 2004
@@ -16,22 +16,6 @@
package org.apache.geronimo.axis;
-import org.apache.axis.utils.ClassUtils;
-import org.apache.geronimo.deployment.ConfigurationBuilder;
-import org.apache.geronimo.deployment.DeploymentException;
-import org.apache.geronimo.gbean.GBeanInfo;
-import org.apache.geronimo.gbean.GBeanInfoBuilder;
-import org.apache.geronimo.gbean.WaitingException;
-import org.apache.geronimo.gbean.jmx.GBeanMBean;
-import org.apache.geronimo.j2ee.deployment.EARConfigBuilder;
-import org.apache.geronimo.j2ee.deployment.ResourceReferenceBuilder;
-import org.apache.geronimo.kernel.Kernel;
-import org.apache.geronimo.kernel.config.Configuration;
-import org.apache.geronimo.kernel.config.ConfigurationStore;
-import org.apache.geronimo.kernel.repository.Repository;
-import org.openejb.deployment.OpenEJBModuleBuilder;
-
-import javax.management.ObjectName;
import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.File;
@@ -54,6 +38,23 @@
import java.util.jar.JarOutputStream;
import java.util.zip.ZipEntry;
import java.util.zip.ZipFile;
+import javax.management.ObjectName;
+
+import org.apache.axis.utils.ClassUtils;
+import org.apache.geronimo.deployment.ConfigurationBuilder;
+import org.apache.geronimo.deployment.DeploymentException;
+import org.apache.geronimo.gbean.GBeanData;
+import org.apache.geronimo.gbean.GBeanInfo;
+import org.apache.geronimo.gbean.GBeanInfoBuilder;
+import org.apache.geronimo.gbean.WaitingException;
+import org.apache.geronimo.gbean.jmx.GBeanMBean;
+import org.apache.geronimo.j2ee.deployment.EARConfigBuilder;
+import org.apache.geronimo.j2ee.deployment.ResourceReferenceBuilder;
+import org.apache.geronimo.kernel.Kernel;
+import org.apache.geronimo.kernel.config.Configuration;
+import org.apache.geronimo.kernel.config.ConfigurationStore;
+import org.apache.geronimo.kernel.repository.Repository;
+import org.openejb.deployment.OpenEJBModuleBuilder;
/**
* @author Srinath Perera(hemapani@opensource.lk)
@@ -119,12 +120,16 @@
break;
}
}
+
+ // TODO DSS: it is a bad idea to use the thread context classloader. Most of geronimo does not set
+ // the thread context classloader (because of speed) and it is likely to be null.
+ ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
GBeanMBean[] confBeans = null;
if (hasEJB) {
- File file = installEJBWebService(earFile, outfile, Thread.currentThread().getContextClassLoader());
- confBeans = loadEJBWebService(file, earFile);
+ File file = installEJBWebService(earFile, outfile, classLoader);
+ confBeans = loadEJBWebService(file, earFile, classLoader);
} else {
- File file = installPOJOWebService(earFile, outfile, Thread.currentThread().getContextClassLoader());
+ File file = installPOJOWebService(earFile, outfile, classLoader);
confBeans = loadPOJOWebService(file);
}
@@ -163,9 +168,9 @@
}
}
- public GBeanMBean[] loadtheWSConfigurations(File installedLocation, File module) throws Exception {
+ public GBeanMBean[] loadtheWSConfigurations(File installedLocation, File module, ClassLoader classLoader) throws Exception {
if (hasEJB) {
- return loadEJBWebService(installedLocation, module);
+ return loadEJBWebService(installedLocation, module, classLoader);
} else {
return loadPOJOWebService(installedLocation);
}
@@ -278,8 +283,8 @@
return new GBeanMBean[]{gbean};
}
- private GBeanMBean[] loadEJBWebService(File installLocation, File module) throws Exception {
- GBeanMBean config = loadConfig(installLocation);
+ private GBeanMBean[] loadEJBWebService(File installLocation, File module, ClassLoader classLoader) throws Exception {
+ GBeanMBean config = loadConfig(installLocation, classLoader);
config.setAttribute("baseURL", installLocation.toURL());
GBeanMBean gbean = new GBeanMBean(EJBWSGBean.getGBeanInfo());
ArrayList classList = AxisGeronimoUtils.getClassFileList(new ZipFile(module));
@@ -298,16 +303,13 @@
// throw new DeploymentException("can not found the ews module in " + installLocation);
}
- private static GBeanMBean loadConfig(File unpackedCar) throws Exception {
- InputStream in = new FileInputStream(new File(unpackedCar,
- "META-INF/config.ser"));
+ private GBeanMBean loadConfig(File unpackedCar, ClassLoader classLoader) throws Exception {
+ InputStream in = new FileInputStream(new File(unpackedCar, "META-INF/config.ser"));
try {
- ObjectInputStream ois =
- new ObjectInputStream(new BufferedInputStream(in));
- GBeanInfo gbeanInfo = Configuration.GBEAN_INFO;
- GBeanMBean config = new GBeanMBean(gbeanInfo);
- Configuration.loadGMBeanState(config, ois);
- return config;
+ ObjectInputStream ois = new ObjectInputStream(new BufferedInputStream(in));
+ GBeanData config = new GBeanData();
+ config.readExternal(ois);
+ return new GBeanMBean(config, classLoader);
} finally {
in.close();
}
Modified: geronimo/trunk/modules/axis/src/test/org/apache/geronimo/axis/SimpleEJBWebServiceTest.java
==============================================================================
--- geronimo/trunk/modules/axis/src/test/org/apache/geronimo/axis/SimpleEJBWebServiceTest.java (original)
+++ geronimo/trunk/modules/axis/src/test/org/apache/geronimo/axis/SimpleEJBWebServiceTest.java Tue Nov 2 17:18:58 2004
@@ -15,11 +15,6 @@
*/
package org.apache.geronimo.axis;
-import org.apache.geronimo.axis.testUtils.AxisGeronimoConstants;
-import org.apache.geronimo.gbean.WaitingException;
-import org.apache.geronimo.gbean.jmx.GBeanMBean;
-
-import javax.management.ObjectName;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileNotFoundException;
@@ -30,6 +25,11 @@
import java.net.URL;
import java.net.URLClassLoader;
import java.util.Arrays;
+import javax.management.ObjectName;
+
+import org.apache.geronimo.axis.testUtils.AxisGeronimoConstants;
+import org.apache.geronimo.gbean.WaitingException;
+import org.apache.geronimo.gbean.jmx.GBeanMBean;
public class SimpleEJBWebServiceTest extends AbstractWebServiceTest {
public SimpleEJBWebServiceTest(String testName) throws FileNotFoundException, WaitingException, IOException {
@@ -59,7 +59,7 @@
File out = new File("target/temp");
out.mkdirs();
File ws = wsconfBuilder.installWebService(jarfile, out, Thread.currentThread().getContextClassLoader());
- GBeanMBean[] gbeans = wsconfBuilder.loadtheWSConfigurations(ws, jarfile);
+ GBeanMBean[] gbeans = wsconfBuilder.loadtheWSConfigurations(ws, jarfile, cl);
ObjectName wsName = ObjectName.getInstance("test:configuration=" + "echo");
ObjectName wsEJBName = ObjectName.getInstance("test:configuration=" + "echoEJB");
AxisGeronimoUtils.startGBean(wsName, gbeans[0], kernel);
Modified: geronimo/trunk/modules/axis/src/test/org/apache/geronimo/axis/WSConfigBuilderTest.java
==============================================================================
--- geronimo/trunk/modules/axis/src/test/org/apache/geronimo/axis/WSConfigBuilderTest.java (original)
+++ geronimo/trunk/modules/axis/src/test/org/apache/geronimo/axis/WSConfigBuilderTest.java Tue Nov 2 17:18:58 2004
@@ -15,13 +15,13 @@
*/
package org.apache.geronimo.axis;
+import java.io.File;
+import javax.management.ObjectName;
+
import org.apache.geronimo.axis.testUtils.AxisGeronimoConstants;
import org.apache.geronimo.axis.testUtils.J2EEManager;
import org.apache.geronimo.gbean.jmx.GBeanMBean;
import org.apache.geronimo.kernel.Kernel;
-
-import javax.management.ObjectName;
-import java.io.File;
public class WSConfigBuilderTest extends AbstractTestCase {
private ObjectName configBuilderName;
Modified: geronimo/trunk/modules/connector-builder/src/test/org/apache/geronimo/connector/deployment/RAR_1_0ConfigBuilderTest.java
==============================================================================
--- geronimo/trunk/modules/connector-builder/src/test/org/apache/geronimo/connector/deployment/RAR_1_0ConfigBuilderTest.java (original)
+++ geronimo/trunk/modules/connector-builder/src/test/org/apache/geronimo/connector/deployment/RAR_1_0ConfigBuilderTest.java Tue Nov 2 17:18:58 2004
@@ -38,7 +38,7 @@
import junit.framework.TestCase;
import org.apache.geronimo.deployment.DeploymentException;
import org.apache.geronimo.deployment.util.DeploymentUtil;
-import org.apache.geronimo.gbean.GBeanInfo;
+import org.apache.geronimo.gbean.GBeanData;
import org.apache.geronimo.gbean.jmx.GBeanMBean;
import org.apache.geronimo.j2ee.deployment.EARConfigBuilder;
import org.apache.geronimo.j2ee.deployment.EARContext;
@@ -50,7 +50,6 @@
import org.apache.geronimo.j2ee.deployment.j2eeobjectnames.NameFactory;
import org.apache.geronimo.j2ee.management.impl.J2EEServerImpl;
import org.apache.geronimo.kernel.Kernel;
-import org.apache.geronimo.kernel.config.Configuration;
import org.apache.geronimo.kernel.management.State;
import org.apache.geronimo.system.serverinfo.ServerInfo;
import org.apache.geronimo.xbeans.geronimo.GerConnectorDocument;
@@ -257,7 +256,7 @@
DataSource ds = null;
Kernel kernel = null;
try {
- GBeanMBean config = loadConfig(unpackedDir);
+ GBeanMBean config = loadConfig(unpackedDir, cl);
kernel = new Kernel("blah");
kernel.boot();
@@ -399,14 +398,13 @@
assertEquals(State.RUNNING_INDEX, state);
}
- private GBeanMBean loadConfig(File unpackedCar) throws Exception {
+ private GBeanMBean loadConfig(File unpackedCar, ClassLoader classLoader) throws Exception {
InputStream in = new FileInputStream(new File(unpackedCar, "META-INF/config.ser"));
try {
ObjectInputStream ois = new ObjectInputStream(new BufferedInputStream(in));
- GBeanInfo gbeanInfo = Configuration.GBEAN_INFO;
- GBeanMBean config = new GBeanMBean(gbeanInfo);
- Configuration.loadGMBeanState(config, ois);
- return config;
+ GBeanData config = new GBeanData();
+ config.readExternal(ois);
+ return new GBeanMBean(config, classLoader);
} finally {
in.close();
}
Modified: geronimo/trunk/modules/connector-builder/src/test/org/apache/geronimo/connector/deployment/RAR_1_5ConfigBuilderTest.java
==============================================================================
--- geronimo/trunk/modules/connector-builder/src/test/org/apache/geronimo/connector/deployment/RAR_1_5ConfigBuilderTest.java (original)
+++ geronimo/trunk/modules/connector-builder/src/test/org/apache/geronimo/connector/deployment/RAR_1_5ConfigBuilderTest.java Tue Nov 2 17:18:58 2004
@@ -37,6 +37,7 @@
import junit.framework.TestCase;
import org.apache.geronimo.connector.ActivationSpecInfo;
import org.apache.geronimo.deployment.util.DeploymentUtil;
+import org.apache.geronimo.gbean.GBeanData;
import org.apache.geronimo.gbean.GBeanInfo;
import org.apache.geronimo.gbean.jmx.GBeanMBean;
import org.apache.geronimo.j2ee.deployment.EARContext;
@@ -48,7 +49,6 @@
import org.apache.geronimo.j2ee.deployment.j2eeobjectnames.NameFactory;
import org.apache.geronimo.j2ee.management.impl.J2EEServerImpl;
import org.apache.geronimo.kernel.Kernel;
-import org.apache.geronimo.kernel.config.Configuration;
import org.apache.geronimo.kernel.management.State;
import org.apache.geronimo.system.serverinfo.ServerInfo;
import org.apache.geronimo.xbeans.geronimo.GerConnectorDocument;
@@ -172,7 +172,7 @@
DataSource ds = null;
Kernel kernel = null;
try {
- GBeanMBean config = loadConfig(unpackedDir);
+ GBeanMBean config = loadConfig(unpackedDir, cl);
kernel = new Kernel("blah");
kernel.boot();
@@ -368,14 +368,13 @@
assertEquals(State.RUNNING_INDEX, state);
}
- private GBeanMBean loadConfig(File unpackedCar) throws Exception {
+ private GBeanMBean loadConfig(File unpackedCar, ClassLoader classLoader) throws Exception {
InputStream in = new FileInputStream(new File(unpackedCar, "META-INF/config.ser"));
try {
ObjectInputStream ois = new ObjectInputStream(new BufferedInputStream(in));
- GBeanInfo gbeanInfo = Configuration.GBEAN_INFO;
- GBeanMBean config = new GBeanMBean(gbeanInfo);
- Configuration.loadGMBeanState(config, ois);
- return config;
+ GBeanData config = new GBeanData();
+ config.readExternal(ois);
+ return new GBeanMBean(config, classLoader);
} finally {
in.close();
}
Modified: geronimo/trunk/modules/deployment/src/java/org/apache/geronimo/deployment/DeploymentContext.java
==============================================================================
--- 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 Tue Nov 2 17:18:58 2004
@@ -107,7 +107,7 @@
if (kernel != null && parentID != null) {
ConfigurationManager configurationManager = kernel.getConfigurationManager();
- ObjectName parentName = configurationManager.getConfigObjectName(parentID);
+ ObjectName parentName = Configuration.getConfigurationObjectName(parentID);
config.setReferencePatterns("Parent", Collections.singleton(parentName));
try {
ancestors = configurationManager.loadRecursive(parentID);
@@ -354,7 +354,9 @@
try {
out = new ObjectOutputStream(new FileOutputStream(configSer));
try {
- config.getGBeanData().writeExternal(out);
+ GBeanData gbeanData = config.getGBeanData();
+ gbeanData.setName(Configuration.getConfigurationObjectName(configID));
+ gbeanData.writeExternal(out);
} catch (IOException e) {
throw e;
} catch (Exception e) {
Modified: geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/Kernel.java
==============================================================================
--- geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/Kernel.java (original)
+++ geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/Kernel.java Tue Nov 2 17:18:58 2004
@@ -22,35 +22,34 @@
import java.lang.ref.WeakReference;
import java.net.URI;
import java.util.Collections;
+import java.util.Date;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Set;
-import java.util.Date;
import javax.management.Attribute;
import javax.management.InstanceAlreadyExistsException;
import javax.management.InstanceNotFoundException;
import javax.management.JMException;
import javax.management.JMRuntimeException;
-import javax.management.MBeanRegistrationException;
import javax.management.MBeanServer;
import javax.management.MBeanServerFactory;
import javax.management.MalformedObjectNameException;
-import javax.management.NotCompliantMBeanException;
import javax.management.NotificationBroadcasterSupport;
import javax.management.ObjectName;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.apache.geronimo.gbean.jmx.GBeanMBean;
-import org.apache.geronimo.gbean.GBeanInfo;
import org.apache.geronimo.gbean.GBeanData;
+import org.apache.geronimo.gbean.GBeanInfo;
+import org.apache.geronimo.gbean.jmx.GBeanMBean;
import org.apache.geronimo.kernel.config.ConfigurationManager;
import org.apache.geronimo.kernel.config.ConfigurationManagerImpl;
import org.apache.geronimo.kernel.config.InvalidConfigException;
import org.apache.geronimo.kernel.config.NoSuchConfigException;
import org.apache.geronimo.kernel.config.NoSuchStoreException;
+import org.apache.geronimo.kernel.config.Configuration;
import org.apache.geronimo.kernel.jmx.JMXUtil;
@@ -193,11 +192,8 @@
public Object getAttribute(ObjectName objectName, String attributeName) throws Exception {
try {
return mbServer.getAttribute(objectName, attributeName);
- } catch (JMException e) {
- Throwable cause = e;
- while ((cause instanceof JMException || cause instanceof JMRuntimeException) && cause.getCause() != null) {
- cause = cause.getCause();
- }
+ } catch (Exception e) {
+ Throwable cause = unwrapJMException(e);
if (cause instanceof Error) {
throw (Error) cause;
} else if (cause instanceof Exception) {
@@ -211,11 +207,8 @@
public void setAttribute(ObjectName objectName, String attributeName, Object attributeValue) throws Exception {
try {
mbServer.setAttribute(objectName, new Attribute(attributeName, attributeValue));
- } catch (JMException e) {
- Throwable cause = e;
- while ((cause instanceof JMException || cause instanceof JMRuntimeException) && cause.getCause() != null) {
- cause = cause.getCause();
- }
+ } catch (Exception e) {
+ Throwable cause = unwrapJMException(e);
if (cause instanceof Error) {
throw (Error) cause;
} else if (cause instanceof Exception) {
@@ -233,11 +226,8 @@
public Object invoke(ObjectName objectName, String methodName, Object[] args, String[] types) throws Exception {
try {
return mbServer.invoke(objectName, methodName, args, types);
- } catch (JMException e) {
- Throwable cause = e;
- while ((cause instanceof JMException || cause instanceof JMRuntimeException) && cause.getCause() != null) {
- cause = cause.getCause();
- }
+ } catch (Exception e) {
+ Throwable cause = unwrapJMException(e);
if (cause instanceof Error) {
throw (Error) cause;
} else if (cause instanceof Exception) {
@@ -248,6 +238,13 @@
}
}
+ private Throwable unwrapJMException(Throwable cause) {
+ while ((cause instanceof JMException || cause instanceof JMRuntimeException) && cause.getCause() != null) {
+ cause = cause.getCause();
+ }
+ return cause;
+ }
+
public boolean isLoaded(ObjectName name) {
return mbServer != null && mbServer.isRegistered(name);
@@ -286,34 +283,38 @@
try {
GBeanMBean gbean = new GBeanMBean(gbeanData, classLoader);
mbServer.registerMBean(gbean, gbeanData.getName());
- } catch (MBeanRegistrationException e) {
- throw new InvalidConfigException("Invalid GBean configuration for " + gbeanData.getName(), e);
- } catch (NotCompliantMBeanException e) {
- throw new InvalidConfigException("Invalid GBean configuration for " + gbeanData.getName(), e);
+ } catch (JMRuntimeException e) {
+ throw new InvalidConfigException("Invalid GBean configuration for " + gbeanData.getName(), unwrapJMException(e));
+ } catch (JMException e) {
+ throw new InvalidConfigException("Invalid GBean configuration for " + gbeanData.getName(), unwrapJMException(e));
}
}
public void loadGBean(ObjectName name, GBeanMBean gbean) throws InstanceAlreadyExistsException, InvalidConfigException {
try {
mbServer.registerMBean(gbean, name);
- } catch (MBeanRegistrationException e) {
- throw new InvalidConfigException("Invalid GBean configuration for " + name, e);
- } catch (NotCompliantMBeanException e) {
- throw new InvalidConfigException("Invalid GBean configuration for " + name, e);
+ } catch (InstanceAlreadyExistsException e) {
+ throw e;
+ } catch (Exception e) {
+ throw new InvalidConfigException("Invalid GBean configuration for " + name, unwrapJMException(e));
}
}
public void startGBean(ObjectName name) throws InstanceNotFoundException, InvalidConfigException {
try {
invoke(name, "start");
+ } catch (InstanceNotFoundException e) {
+ throw e;
} catch (Exception e) {
- throw new InvalidConfigException("Invalid GBean configuration for " + name, e);
+ throw new InvalidConfigException("Invalid GBean configuration for " + name, unwrapJMException(e));
}
}
public void startRecursiveGBean(ObjectName name) throws InstanceNotFoundException, InvalidConfigException {
try {
invoke(name, "startRecursive");
+ } catch (InstanceNotFoundException e) {
+ throw e;
} catch (Exception e) {
throw new InvalidConfigException("Invalid GBean configuration for " + name, e);
}
@@ -324,19 +325,19 @@
invoke(name, "stop");
} catch (InstanceNotFoundException e) {
throw e;
- } catch (InvalidConfigException e) {
- throw e;
} catch (Exception e) {
throw new InvalidConfigException("Invalid GBean configuration for " + name, e);
}
}
public void unloadGBean(ObjectName name) throws InstanceNotFoundException {
- try {
+ try {
mbServer.unregisterMBean(name);
- } catch (MBeanRegistrationException e) {
- throw (IllegalStateException) new IllegalStateException("Error unloading GBean " + name).initCause(e);
- }
+ } catch (InstanceNotFoundException e) {
+ throw e;
+ } catch (JMException e) {
+ throw (IllegalStateException) new IllegalStateException("Error unloading GBean " + name).initCause(unwrapJMException(e));
+ }
}
public Set listGBeans(ObjectName query) {
@@ -352,8 +353,7 @@
}
public ObjectName startConfiguration(URI configID) throws NoSuchConfigException, IOException, InvalidConfigException {
-
- ObjectName configName = getConfigurationManager().load(configID);
+ ObjectName configName = getConfigurationManager().load(configID);
try {
startRecursiveGBean(configName);
} catch (InstanceNotFoundException e) {
@@ -367,7 +367,7 @@
public void stopConfiguration(URI configID) throws NoSuchConfigException {
ConfigurationManager configurationManager = getConfigurationManager();
try {
- ObjectName configName = configurationManager.getConfigObjectName(configID);
+ ObjectName configName = Configuration.getConfigurationObjectName(configID);
stopGBean(configName);
} catch (MalformedObjectNameException e) {
throw new NoSuchConfigException(e);
@@ -382,7 +382,7 @@
public int getConfigurationState(URI configID) throws NoSuchConfigException {
ConfigurationManager configurationManager = getConfigurationManager();
try {
- ObjectName configName = configurationManager.getConfigObjectName(configID);
+ ObjectName configName = Configuration.getConfigurationObjectName(configID);
return ((Integer)getAttribute(configName, "state")).intValue();
} catch (MalformedObjectNameException e) {
throw new NoSuchConfigException(e);
Modified: geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/config/Configuration.java
==============================================================================
--- 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 Tue Nov 2 17:18:58 2004
@@ -40,6 +40,7 @@
import javax.management.JMRuntimeException;
import javax.management.ObjectName;
import javax.management.ReflectionException;
+import javax.management.MalformedObjectNameException;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -86,6 +87,10 @@
public class Configuration implements GBeanLifecycle {
private static final Log log = LogFactory.getLog(Configuration.class);
+ public static ObjectName getConfigurationObjectName(URI configID) throws MalformedObjectNameException {
+ return new ObjectName("geronimo.config:name=" + ObjectName.quote(configID.toString()));
+ }
+
private final Kernel kernel;
private final String objectNameString;
private final ObjectName objectName;
@@ -177,6 +182,8 @@
classLoader = new URLClassLoader(urls, parent.getClassLoader());
}
+ // DSS: why exactally are we doing this? I bet there is a reason, but
+ // we should state why here.
ClassLoader oldCl = Thread.currentThread().getContextClassLoader();
try {
Thread.currentThread().setContextClassLoader(classLoader);
@@ -368,12 +375,6 @@
} catch (Exception e) {
throw new InvalidConfigException("Unable to deserialize GBeanState", e);
}
- }
-
- public static void loadGMBeanState(GBeanMBean gbean, ObjectInputStream ois) throws IOException, AttributeNotFoundException, ReflectionException, ClassNotFoundException {
- GBeanData gbeanData = new GBeanData();
- gbeanData.readExternal(ois);
- gbean.setGBeanData(gbeanData);
}
/**
Modified: geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/config/ConfigurationManager.java
==============================================================================
--- 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 Tue Nov 2 17:18:58 2004
@@ -20,9 +20,9 @@
import java.net.URI;
import java.net.URL;
import java.util.List;
-import javax.management.MalformedObjectNameException;
import javax.management.ObjectName;
+import org.apache.geronimo.gbean.GBeanData;
import org.apache.geronimo.gbean.jmx.GBeanMBean;
/**
@@ -47,12 +47,12 @@
*/
List listConfigurations(ObjectName store) throws NoSuchStoreException;
- ObjectName getConfigObjectName(URI configID) throws MalformedObjectNameException;
-
ObjectName load(URI configID) throws NoSuchConfigException, IOException, InvalidConfigException;
ObjectName load(GBeanMBean config, URL rootURL) throws InvalidConfigException;
+ void load(GBeanData config, URL rootURL, ClassLoader classLoader) throws InvalidConfigException;
+
/**
* Load the supplied Configuration into the Kernel and override the default JMX name.
* This method should be used with discretion as it is possible to create
@@ -70,4 +70,5 @@
void unload(URI configID) throws NoSuchConfigException;
void unload(ObjectName configName) throws NoSuchConfigException;
+
}
Modified: geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/config/ConfigurationManagerImpl.java
==============================================================================
--- 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 Tue Nov 2 17:18:58 2004
@@ -36,6 +36,7 @@
import org.apache.geronimo.gbean.GBeanInfo;
import org.apache.geronimo.gbean.GBeanInfoBuilder;
import org.apache.geronimo.gbean.GBeanLifecycle;
+import org.apache.geronimo.gbean.GBeanData;
import org.apache.geronimo.gbean.jmx.GBeanMBean;
import org.apache.geronimo.kernel.Kernel;
import org.apache.geronimo.kernel.jmx.JMXUtil;
@@ -75,7 +76,7 @@
URI configID = (URI) ids.get(j);
ObjectName configName;
try {
- configName = getConfigObjectName(configID);
+ configName = Configuration.getConfigurationObjectName(configID);
} catch (MalformedObjectNameException e) {
throw new AssertionError("Store returned invalid configID: " + configID);
}
@@ -108,7 +109,7 @@
public boolean isLoaded(URI configID) {
try {
- ObjectName name = getConfigObjectName(configID);
+ ObjectName name = Configuration.getConfigurationObjectName(configID);
return kernel.isLoaded(name);
} catch (MalformedObjectNameException e) {
return false;
@@ -138,7 +139,7 @@
}
ObjectName configName;
try {
- configName = getConfigObjectName(configID);
+ configName = Configuration.getConfigurationObjectName(configID);
} catch (MalformedObjectNameException e) {
throw new InvalidConfigException("Cannot convert ID to ObjectName: ", e);
}
@@ -146,6 +147,11 @@
return configName;
}
+ public void load(GBeanData config, URL rootURL, ClassLoader classLoader) throws InvalidConfigException {
+ GBeanMBean mbean = new GBeanMBean(config, classLoader);
+ load(mbean, rootURL, config.getName());
+ }
+
public void load(GBeanMBean config, URL rootURL, ObjectName configName) throws InvalidConfigException {
try {
kernel.loadGBean(configName, config);
@@ -191,7 +197,7 @@
public void unload(URI configID) throws NoSuchConfigException {
ObjectName configName;
try {
- configName = getConfigObjectName(configID);
+ configName = Configuration.getConfigurationObjectName(configID);
} catch (MalformedObjectNameException e) {
throw new NoSuchConfigException("Cannot convert ID to ObjectName: ", e);
}
@@ -209,10 +215,6 @@
private List getStores() {
return new ArrayList(stores);
- }
-
- public ObjectName getConfigObjectName(URI configID) throws MalformedObjectNameException {
- return new ObjectName("geronimo.config:name=" + ObjectName.quote(configID.toString()));
}
public void doStart() {
Modified: geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/config/Run.java
==============================================================================
--- geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/config/Run.java (original)
+++ geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/config/Run.java Tue Nov 2 17:18:58 2004
@@ -24,6 +24,7 @@
import javax.management.ObjectName;
import org.apache.geronimo.gbean.jmx.GBeanMBean;
+import org.apache.geronimo.gbean.GBeanData;
import org.apache.geronimo.kernel.Kernel;
import org.apache.geronimo.kernel.log.GeronimoLogging;
@@ -61,10 +62,12 @@
try {
kernel.boot();
- GBeanMBean config = new GBeanMBean(Configuration.GBEAN_INFO, cl);
+ GBeanMBean config;
ObjectInputStream ois = new ObjectInputStream(cl.getResourceAsStream("META-INF/config.ser"));
try {
- Configuration.loadGMBeanState(config, ois);
+ GBeanData gbeanData = new GBeanData();
+ gbeanData.readExternal(ois);
+ config = new GBeanMBean(gbeanData, cl);
} finally {
ois.close();
}
Modified: geronimo/trunk/modules/system/src/java/org/apache/geronimo/system/main/CommandLine.java
==============================================================================
--- 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 Tue Nov 2 17:18:58 2004
@@ -17,20 +17,19 @@
package org.apache.geronimo.system.main;
-import java.util.List;
-import java.util.Iterator;
import java.io.ObjectInputStream;
import java.net.URI;
+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.kernel.log.GeronimoLogging;
+import org.apache.geronimo.gbean.GBeanData;
import org.apache.geronimo.kernel.Kernel;
import org.apache.geronimo.kernel.config.ConfigurationManager;
-import org.apache.geronimo.kernel.config.Configuration;
+import org.apache.geronimo.kernel.log.GeronimoLogging;
import org.apache.geronimo.system.url.GeronimoURLFactory;
-import org.apache.geronimo.gbean.jmx.GBeanMBean;
/**
@@ -79,16 +78,16 @@
// load and start the configuration in this jar
ConfigurationManager configurationManager = kernel.getConfigurationManager();
- GBeanMBean config = new GBeanMBean(Configuration.GBEAN_INFO);
+ GBeanData config = new GBeanData();
ClassLoader classLoader = CommandLine.class.getClassLoader();
ObjectInputStream ois = new ObjectInputStream(classLoader.getResourceAsStream("META-INF/config.ser"));
try {
- Configuration.loadGMBeanState(config, ois);
+ config.readExternal(ois);
} finally {
ois.close();
}
- ObjectName configName = configurationManager.load(config, classLoader.getResource("/"));
- kernel.startRecursiveGBean(configName);
+ configurationManager.load(config, classLoader.getResource("/"), classLoader);
+ kernel.startRecursiveGBean(config.getName());
// load and start the configurations
for (Iterator i = configurations.iterator(); i.hasNext();) {
@@ -112,7 +111,7 @@
log.info("Server shutdown begun");
// stop this configuration
- kernel.stopGBean(configName);
+ kernel.stopGBean(config.getName());
// shutdown the kernel
kernel.shutdown();
Modified: geronimo/trunk/modules/system/src/java/org/apache/geronimo/system/main/Daemon.java
==============================================================================
--- geronimo/trunk/modules/system/src/java/org/apache/geronimo/system/main/Daemon.java (original)
+++ geronimo/trunk/modules/system/src/java/org/apache/geronimo/system/main/Daemon.java Tue Nov 2 17:18:58 2004
@@ -28,9 +28,8 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.apache.geronimo.gbean.jmx.GBeanMBean;
+import org.apache.geronimo.gbean.GBeanData;
import org.apache.geronimo.kernel.Kernel;
-import org.apache.geronimo.kernel.config.Configuration;
import org.apache.geronimo.kernel.config.ConfigurationManager;
import org.apache.geronimo.kernel.config.PersistentConfigurationList;
import org.apache.geronimo.kernel.log.GeronimoLogging;
@@ -89,10 +88,10 @@
// load this configuration
ClassLoader classLoader = Daemon.class.getClassLoader();
- GBeanMBean configuration = new GBeanMBean(Configuration.GBEAN_INFO);
+ GBeanData configuration = new GBeanData();
ObjectInputStream ois = new ObjectInputStream(classLoader.getResourceAsStream("META-INF/config.ser"));
try {
- Configuration.loadGMBeanState(configuration, ois);
+ configuration.readExternal(ois);
} finally {
ois.close();
}
@@ -111,7 +110,7 @@
// add our shutdown hook
ConfigurationManager configurationManager = kernel.getConfigurationManager();
- final ObjectName configName = configurationManager.load(configuration, classLoader.getResource("/"));
+ configurationManager.load(configuration, classLoader.getResource("/"), classLoader);
Runtime.getRuntime().addShutdownHook(new Thread("Shutdown Thread") {
public void run() {
log.info("Server shutdown begun");
@@ -121,7 +120,7 @@
});
// start this configuration
- kernel.startRecursiveGBean(configName);
+ kernel.startRecursiveGBean(configuration.getName());
if (configs.isEmpty()) {
// nothing explicit, see what was running before
Modified: geronimo/trunk/plugins/maven-geronimo-plugin/src/java/org/apache/geronimo/deployment/mavenplugin/StartServer.java
==============================================================================
--- geronimo/trunk/plugins/maven-geronimo-plugin/src/java/org/apache/geronimo/deployment/mavenplugin/StartServer.java (original)
+++ geronimo/trunk/plugins/maven-geronimo-plugin/src/java/org/apache/geronimo/deployment/mavenplugin/StartServer.java Tue Nov 2 17:18:58 2004
@@ -19,19 +19,18 @@
import java.io.File;
import java.io.ObjectInputStream;
-import java.net.URL;
import java.net.URI;
+import java.net.URL;
+import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
-import java.util.ArrayList;
import java.util.StringTokenizer;
-
import javax.management.ObjectName;
+import org.apache.geronimo.gbean.GBeanData;
import org.apache.geronimo.gbean.jmx.GBeanMBean;
-import org.apache.geronimo.kernel.config.Configuration;
-import org.apache.geronimo.kernel.config.ConfigurationManager;
import org.apache.geronimo.kernel.Kernel;
+import org.apache.geronimo.kernel.config.ConfigurationManager;
import org.apache.geronimo.kernel.log.GeronimoLogging;
import org.apache.geronimo.system.url.GeronimoURLFactory;
@@ -98,10 +97,12 @@
URL systemURL = new File(root, "bin/server.jar").toURL();
// System.out.println("systemURL = " + systemURL);
URL configURL = new URL("jar:" + systemURL.toString() + "!/META-INF/config.ser");
- GBeanMBean configuration = new GBeanMBean(Configuration.GBEAN_INFO, this.getClass().getClassLoader());
+ GBeanMBean configuration;
ObjectInputStream ois = new ObjectInputStream(configURL.openStream());
try {
- Configuration.loadGMBeanState(configuration, ois);
+ GBeanData gbeanData = new GBeanData();
+ gbeanData.readExternal(ois);
+ configuration = new GBeanMBean(gbeanData, this.getClass().getClassLoader());
} finally {
ois.close();
}