Author: djencks
Date: Tue Aug 30 18:32:17 2005
New Revision: 264914
URL: http://svn.apache.org/viewcvs?rev=264914&view=rev
Log:
GERONIMO-947 step 2b and 3. Use the MultiParentClassLoader and provide xml elements for parents.
Not well tested but doesn't appear to break single parent usage
Added:
geronimo/trunk/modules/connector-builder/src/schema/geronimo-connector.xsd
- copied, changed from r264675, geronimo/trunk/modules/connector-builder/src/schema/geronimo-connector_1_5.xsd
geronimo/trunk/modules/service-builder/src/test/org/apache/geronimo/deployment/service/ParentIDTest.java
Removed:
geronimo/trunk/modules/connector-builder/src/schema/geronimo-connector_1_5.xsd
Modified:
geronimo/trunk/modules/client-builder/src/java/org/apache/geronimo/client/builder/AppClientModuleBuilder.java
geronimo/trunk/modules/client-builder/src/schema/geronimo-application-client.xsd
geronimo/trunk/modules/connector-builder/maven.xml
geronimo/trunk/modules/connector-builder/src/java/org/apache/geronimo/connector/deployment/ConnectorModuleBuilder.java
geronimo/trunk/modules/deployment/src/java/org/apache/geronimo/deployment/DeploymentContext.java
geronimo/trunk/modules/j2ee-builder/src/java/org/apache/geronimo/j2ee/deployment/EARConfigBuilder.java
geronimo/trunk/modules/j2ee-builder/src/schema/geronimo-application.xsd
geronimo/trunk/modules/jetty-builder/src/java/org/apache/geronimo/jetty/deployment/JettyModuleBuilder.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/MultiParentClassLoader.java
geronimo/trunk/modules/kernel/src/test/org/apache/geronimo/kernel/ConfigTest.java
geronimo/trunk/modules/kernel/src/test/org/apache/geronimo/kernel/config/MultiParentClassLoaderTest.java
geronimo/trunk/modules/service-builder/src/java/org/apache/geronimo/deployment/service/ServiceConfigBuilder.java
geronimo/trunk/modules/service-builder/src/schema/geronimo-config.xsd
geronimo/trunk/modules/system/src/java/org/apache/geronimo/system/configuration/ExecutableConfigurationUtil.java
geronimo/trunk/modules/tomcat-builder/src/java/org/apache/geronimo/tomcat/deployment/TomcatModuleBuilder.java
geronimo/trunk/modules/web-builder/src/schema/geronimo-web.xsd
Modified: geronimo/trunk/modules/client-builder/src/java/org/apache/geronimo/client/builder/AppClientModuleBuilder.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/client-builder/src/java/org/apache/geronimo/client/builder/AppClientModuleBuilder.java?rev=264914&r1=264913&r2=264914&view=diff
==============================================================================
--- geronimo/trunk/modules/client-builder/src/java/org/apache/geronimo/client/builder/AppClientModuleBuilder.java
(original)
+++ geronimo/trunk/modules/client-builder/src/java/org/apache/geronimo/client/builder/AppClientModuleBuilder.java
Tue Aug 30 18:32:17 2005
@@ -176,7 +176,12 @@
URI[] parentId = null;
if (gerAppClient.isSetParentId()) {
- parentId = getParentIds(gerAppClient.getParentId());
+ String parentIdString = gerAppClient.getParentId();
+ try {
+ parentId = new URI[] {new URI(parentIdString)};
+ } catch (URISyntaxException e) {
+ throw new DeploymentException("Could not create parentId uri from " + parentIdString,
e);
+ }
} else {
parentId = defaultServerParentId;
}
@@ -336,10 +341,8 @@
try {
URI clientConfigId = URI.create(geronimoAppClient.getClientConfigId());
- URI[] clientParentId;
- if (geronimoAppClient.isSetClientParentId()) {
- clientParentId = getParentIds(geronimoAppClient.getClientParentId());
- } else {
+ URI[] clientParentId = ServiceConfigBuilder.getParentID(geronimoAppClient.getClientParentId(),
geronimoAppClient.getImportArray());
+ if (clientParentId == null) {
clientParentId = defaultClientParentId;
}
appClientDeploymentContext = new EARContext(appClientDir,
Modified: geronimo/trunk/modules/client-builder/src/schema/geronimo-application-client.xsd
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/client-builder/src/schema/geronimo-application-client.xsd?rev=264914&r1=264913&r2=264914&view=diff
==============================================================================
--- geronimo/trunk/modules/client-builder/src/schema/geronimo-application-client.xsd (original)
+++ geronimo/trunk/modules/client-builder/src/schema/geronimo-application-client.xsd Tue Aug
30 18:32:17 2005
@@ -37,6 +37,7 @@
<xs:complexType name="application-clientType">
<xs:sequence>
+ <xs:element ref="sys:import" minOccurs="0" maxOccurs="unbounded"/>
<xs:element name="include" type="sys:dependencyType" minOccurs="0" maxOccurs="unbounded"/>
<xs:element ref="sys:dependency" minOccurs="0" maxOccurs="unbounded"/>
Modified: geronimo/trunk/modules/connector-builder/maven.xml
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/connector-builder/maven.xml?rev=264914&r1=264913&r2=264914&view=diff
==============================================================================
--- geronimo/trunk/modules/connector-builder/maven.xml (original)
+++ geronimo/trunk/modules/connector-builder/maven.xml Tue Aug 30 18:32:17 2005
@@ -28,7 +28,7 @@
<preGoal name="java:compile">
<xmlbeans:schema2java
- maven.xmlbeans2.sourceschema="schema/geronimo-connector_1_5.xsd"/>
+ maven.xmlbeans2.sourceschema="schema/geronimo-connector.xsd"/>
<mkdir dir="${basedir}/target/xmlbeans-classes"/>
<mkdir dir="${basedir}/target/xmlbeans-classes/schemaorg_apache_xmlbeans"/>
<copy todir="${basedir}/target/xmlbeans-classes/schemaorg_apache_xmlbeans">
Modified: geronimo/trunk/modules/connector-builder/src/java/org/apache/geronimo/connector/deployment/ConnectorModuleBuilder.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/connector-builder/src/java/org/apache/geronimo/connector/deployment/ConnectorModuleBuilder.java?rev=264914&r1=264913&r2=264914&view=diff
==============================================================================
--- geronimo/trunk/modules/connector-builder/src/java/org/apache/geronimo/connector/deployment/ConnectorModuleBuilder.java
(original)
+++ geronimo/trunk/modules/connector-builder/src/java/org/apache/geronimo/connector/deployment/ConnectorModuleBuilder.java
Tue Aug 30 18:32:17 2005
@@ -219,21 +219,8 @@
throw new DeploymentException("Invalid configId " + gerConnector.getConfigId(),
e);
}
- URI[] parentId = null;
- if (gerConnector.isSetParentId()) {
- String parentIdString = gerConnector.getParentId();
- try {
- String[] parentIdStrings = parentIdString.split(",");
- parentId = new URI[parentIdStrings.length];
- for (int i = 0; i < parentIdStrings.length; i++) {
- String idString = parentIdStrings[i];
- URI parent = new URI(idString);
- parentId[i] = parent;
- }
- } catch (URISyntaxException e) {
- throw new DeploymentException("Invalid parentId " + gerConnector.getParentId(),
e);
- }
- } else {
+ URI[] parentId = ServiceConfigBuilder.getParentID(gerConnector.getParentId(), gerConnector.getImportArray());
+ if (parentId == null) {
parentId = defaultParentId;
}
assert parentId != null;
Copied: geronimo/trunk/modules/connector-builder/src/schema/geronimo-connector.xsd (from r264675,
geronimo/trunk/modules/connector-builder/src/schema/geronimo-connector_1_5.xsd)
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/connector-builder/src/schema/geronimo-connector.xsd?p2=geronimo/trunk/modules/connector-builder/src/schema/geronimo-connector.xsd&p1=geronimo/trunk/modules/connector-builder/src/schema/geronimo-connector_1_5.xsd&r1=264675&r2=264914&rev=264914&view=diff
==============================================================================
--- geronimo/trunk/modules/connector-builder/src/schema/geronimo-connector_1_5.xsd (original)
+++ geronimo/trunk/modules/connector-builder/src/schema/geronimo-connector.xsd Tue Aug 30
18:32:17 2005
@@ -297,8 +297,8 @@
</xs:annotation>
<xs:sequence>
+ <xs:element ref="sys:import" minOccurs="0" maxOccurs="unbounded"/>
<xs:element ref="sys:dependency" minOccurs="0" maxOccurs="unbounded"/>
-<!-- <xs:element name="dependency" type="sys:dependencyType" minOccurs="0"
maxOccurs="unbounded"/>-->
<xs:element name="resourceadapter" type="ger:resourceadapterType" maxOccurs="unbounded"/>
Modified: geronimo/trunk/modules/deployment/src/java/org/apache/geronimo/deployment/DeploymentContext.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/deployment/src/java/org/apache/geronimo/deployment/DeploymentContext.java?rev=264914&r1=264913&r2=264914&view=diff
==============================================================================
--- geronimo/trunk/modules/deployment/src/java/org/apache/geronimo/deployment/DeploymentContext.java
(original)
+++ geronimo/trunk/modules/deployment/src/java/org/apache/geronimo/deployment/DeploymentContext.java
Tue Aug 30 18:32:17 2005
@@ -29,15 +29,14 @@
import java.net.URISyntaxException;
import java.net.URL;
import java.net.URLClassLoader;
+import java.util.ArrayList;
+import java.util.Arrays;
import java.util.Collections;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import java.util.Set;
import java.util.StringTokenizer;
-import java.util.Arrays;
-import java.util.HashSet;
-import java.util.ArrayList;
import java.util.jar.Attributes;
import java.util.jar.JarFile;
import java.util.jar.Manifest;
@@ -52,11 +51,11 @@
import org.apache.geronimo.kernel.GBeanNotFoundException;
import org.apache.geronimo.kernel.Kernel;
import org.apache.geronimo.kernel.config.Configuration;
+import org.apache.geronimo.kernel.config.ConfigurationData;
import org.apache.geronimo.kernel.config.ConfigurationManager;
import org.apache.geronimo.kernel.config.ConfigurationModuleType;
-import org.apache.geronimo.kernel.config.ConfigurationData;
-import org.apache.geronimo.kernel.config.InvalidConfigException;
import org.apache.geronimo.kernel.config.ConfigurationUtil;
+import org.apache.geronimo.kernel.config.InvalidConfigException;
import org.apache.geronimo.kernel.management.State;
import org.apache.geronimo.kernel.repository.Repository;
@@ -123,16 +122,19 @@
try {
startedAncestors = new LinkedList();
- ObjectName ancestorName = parentName;
- findToStart(ancestorName, kernel);
- //we've found what we need to start, now start them.
- for (Iterator iterator = startedAncestors.iterator(); iterator.hasNext();)
{
- ObjectName objectName = (ObjectName) iterator.next();
- kernel.startGBean(objectName);
- if (!isRunning(kernel, objectName)) {
- throw new DeploymentException("Failed to start parent configuration:
" + objectName);
- }
+ for (int i = 0; i < parentId.length; i++) {
+ URI uri = parentId[i];
+ ObjectName ancestorName = Configuration.getConfigurationObjectName(uri);
+ findToStart(ancestorName, kernel);
+ //we've found what we need to start, now start them.
+ for (Iterator iterator = startedAncestors.iterator(); iterator.hasNext();)
{
+ ObjectName objectName = (ObjectName) iterator.next();
+ kernel.startGBean(objectName);
+ if (!isRunning(kernel, objectName)) {
+ throw new DeploymentException("Failed to start parent configuration:
" + objectName);
+ }
+ }
}
} catch (DeploymentException e) {
throw e;
@@ -509,13 +511,6 @@
URI[] parentId = configurationData.getParentId();
if (parentId != null) {
config.setAttribute("parentId", parentId);
- Set parentNames = new HashSet();
- for (int i = 0; i < parentId.length; i++) {
- URI uri = parentId[i];
- ObjectName parentName = Configuration.getConfigurationObjectName(uri);
- parentNames.add(parentName);
- }
- config.setReferencePatterns("Parent", parentNames);
}
config.setAttribute("gBeanState", Configuration.storeGBeans(gbeans.getGBeans()));
Modified: geronimo/trunk/modules/j2ee-builder/src/java/org/apache/geronimo/j2ee/deployment/EARConfigBuilder.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/j2ee-builder/src/java/org/apache/geronimo/j2ee/deployment/EARConfigBuilder.java?rev=264914&r1=264913&r2=264914&view=diff
==============================================================================
--- geronimo/trunk/modules/j2ee-builder/src/java/org/apache/geronimo/j2ee/deployment/EARConfigBuilder.java
(original)
+++ geronimo/trunk/modules/j2ee-builder/src/java/org/apache/geronimo/j2ee/deployment/EARConfigBuilder.java
Tue Aug 30 18:32:17 2005
@@ -221,23 +221,10 @@
throw new DeploymentException("Invalid configId " + gerApplication.getConfigId(),
e);
}
- URI[] parentId = null;
- if (gerApplication.isSetParentId()) {
- String parentIdString = gerApplication.getParentId();
- try {
- String[] parentIdStrings = parentIdString.split(",");
- parentId = new URI[parentIdStrings.length];
- for (int i = 0; i < parentIdStrings.length; i++) {
- String idString = parentIdStrings[i];
- URI parent = new URI(idString);
- parentId[i] = parent;
- }
- } catch (URISyntaxException e) {
- throw new DeploymentException("Invalid parentId " + gerApplication.getParentId(),
e);
- }
- } else {
- parentId = defaultParentId;
- }
+ URI[] parentId = ServiceConfigBuilder.getParentID(gerApplication.getParentId(), gerApplication.getImportArray());
+ if (parentId == null) {
+ parentId = defaultParentId;
+ }
// get the modules either the application plan or for a stand alone module from the
specific deployer
// todo change module so you can extract the real module path back out.. then we
can eliminate
Modified: geronimo/trunk/modules/j2ee-builder/src/schema/geronimo-application.xsd
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/j2ee-builder/src/schema/geronimo-application.xsd?rev=264914&r1=264913&r2=264914&view=diff
==============================================================================
--- geronimo/trunk/modules/j2ee-builder/src/schema/geronimo-application.xsd (original)
+++ geronimo/trunk/modules/j2ee-builder/src/schema/geronimo-application.xsd Tue Aug 30 18:32:17
2005
@@ -33,6 +33,7 @@
<xs:complexType name="applicationType">
<xs:sequence>
+ <xs:element ref="sys:import" minOccurs="0" maxOccurs="unbounded"/>
<xs:element ref="sys:dependency" minOccurs="0" maxOccurs="unbounded"/>
<xs:element name="module" type="geronimo:moduleType" minOccurs="0" maxOccurs="unbounded"/>
<xs:element name="ext-module" type="geronimo:ext-moduleType" minOccurs="0"
maxOccurs="unbounded"/>
Modified: geronimo/trunk/modules/jetty-builder/src/java/org/apache/geronimo/jetty/deployment/JettyModuleBuilder.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/jetty-builder/src/java/org/apache/geronimo/jetty/deployment/JettyModuleBuilder.java?rev=264914&r1=264913&r2=264914&view=diff
==============================================================================
--- geronimo/trunk/modules/jetty-builder/src/java/org/apache/geronimo/jetty/deployment/JettyModuleBuilder.java
(original)
+++ geronimo/trunk/modules/jetty-builder/src/java/org/apache/geronimo/jetty/deployment/JettyModuleBuilder.java
Tue Aug 30 18:32:17 2005
@@ -255,21 +255,8 @@
throw new DeploymentException("Invalid configId " + jettyWebApp.getConfigId(),
e);
}
- URI[] parentId = null;
- if (jettyWebApp.isSetParentId()) {
- String parentIdString = jettyWebApp.getParentId();
- try {
- String[] parentIdStrings = parentIdString.split(",");
- parentId = new URI[parentIdStrings.length];
- for (int i = 0; i < parentIdStrings.length; i++) {
- String idString = parentIdStrings[i];
- URI parent = new URI(idString);
- parentId[i] = parent;
- }
- } catch (URISyntaxException e) {
- throw new DeploymentException("Invalid parentId " + parentIdString, e);
- }
- } else {
+ URI[] parentId = ServiceConfigBuilder.getParentID(jettyWebApp.getParentId(), jettyWebApp.getImportArray());
+ if (parentId == null) {
parentId = defaultParentId;
}
Modified: geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/config/Configuration.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/config/Configuration.java?rev=264914&r1=264913&r2=264914&view=diff
==============================================================================
--- geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/config/Configuration.java
(original)
+++ geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/config/Configuration.java
Tue Aug 30 18:32:17 2005
@@ -49,6 +49,7 @@
import org.apache.geronimo.kernel.GBeanNotFoundException;
import org.apache.geronimo.kernel.Kernel;
import org.apache.geronimo.kernel.ObjectInputStreamExt;
+import org.apache.geronimo.kernel.DependencyManager;
import org.apache.geronimo.kernel.jmx.JMXUtil;
import org.apache.geronimo.kernel.management.State;
import org.apache.geronimo.kernel.repository.MissingDependencyException;
@@ -83,7 +84,7 @@
*
* @version $Rev$ $Date$
*/
-public class Configuration implements GBeanLifecycle {
+public class Configuration implements GBeanLifecycle, ConfigurationParent {
private static final Log log = LogFactory.getLog(Configuration.class);
public static ObjectName getConfigurationObjectName(URI configId) throws MalformedObjectNameException
{
@@ -145,7 +146,7 @@
/**
* The classloader used to load the child GBeans contained in this configuration.
*/
- private ConfigurationClassLoader configurationClassLoader;
+ private MultiParentClassLoader configurationClassLoader;
/**
* The GBeanData for the GBeans contained in this configuration. These must be persisted
as a ByteArray, becuase
@@ -160,11 +161,6 @@
private final URL baseURL;
/**
- * Parent of this configuration
- */
- private final ConfigurationParent parent;
-
- /**
* The repositories used dependencies.
*/
private final Collection repositories;
@@ -187,7 +183,6 @@
dependencies = null;
classPath = null;
baseURL = null;
- parent = null;
repositories = null;
manageableStore = null;
}
@@ -198,7 +193,6 @@
*
* @param id the unique id of this Configuration
* @param moduleType the module type identifier
- * @param parent the parent Configuration; may be null
* @param classPath a List<URI> of locations that define the codebase for this
Configuration
* @param gbeanState a byte array contain the Java Serialized form of the GBeans in
this Configuration
* @param repositories a Collection<Repository> of repositories used to resolve
dependencies
@@ -210,7 +204,6 @@
ConfigurationModuleType moduleType,
URL baseURL,
URI[] parentId,
- ConfigurationParent parent,
String domain,
String server,
List classPath,
@@ -227,7 +220,6 @@
this.moduleType = moduleType;
this.baseURL = baseURL;
this.parentId = parentId;
- this.parent = parent;
this.gbeanState = gbeanState;
this.repositories = repositories;
if (classPath != null) {
@@ -246,6 +238,7 @@
this.domain = domain;
this.server = server;
+ addParentDependencies(kernel, id, parentId);
}
public String getObjectName() {
@@ -265,13 +258,13 @@
URL[] urls = resolveClassPath(classPath, baseURL, dependencies, repositories);
log.debug("ClassPath for " + id + " resolved to " + Arrays.asList(urls));
- if (parent == null) {
+ if (parentId == null || parentId.length == 0) {
// no explicit parent set, so use the class loader of this class as
// the parent... this class should be in the root geronimo classloader,
// which is normally the system class loader but not always, so be safe
- configurationClassLoader = new ConfigurationClassLoader(id, urls, getClass().getClassLoader());
+ configurationClassLoader = new MultiParentClassLoader(id, urls, getClass().getClassLoader());
} else {
- configurationClassLoader = new ConfigurationClassLoader(id, urls, parent.getConfigurationClassLoader());
+ configurationClassLoader = new MultiParentClassLoader(id, urls, getClassLoaders(parentId));
}
// DSS: why exactally are we doing this? I bet there is a reason, but
@@ -298,6 +291,30 @@
log.info("Started configuration " + id);
}
+ private void addParentDependencies(Kernel kernel, URI id, URI[] parentId) throws MalformedObjectNameException
{
+ if (parentId != null && parentId.length > 0) {
+ ObjectName name = getConfigurationObjectName(id);
+ Set parentNames = new HashSet();
+ for (int i = 0; i < parentId.length; i++) {
+ URI uri = parentId[i];
+ ObjectName parentName = getConfigurationObjectName(uri);
+ parentNames.add(parentName);
+ }
+ DependencyManager dependencyManager = kernel.getDependencyManager();
+ dependencyManager.addDependencies(name, parentNames);
+ }
+ }
+
+ private ClassLoader[] getClassLoaders(URI[] parentId) throws Exception {
+ ClassLoader[] classLoaders = new ClassLoader[parentId.length];
+ for (int i = 0; i < parentId.length; i++) {
+ URI uri = parentId[i];
+ ObjectName parentName = getConfigurationObjectName(uri);
+ classLoaders[i] = (ClassLoader) kernel.getAttribute(parentName, "configurationClassLoader");
+ }
+ return classLoaders;
+ }
+
private static URL[] resolveClassPath(List classPath, URL baseURL, List dependencies,
Collection repositories) throws MalformedURLException, MissingDependencyException {
if (classPath == null) {
classPath = Collections.EMPTY_LIST;
@@ -603,7 +620,6 @@
infoFactory.addAttribute("baseURL", URL.class, true);
infoFactory.addAttribute("configurationClassLoader", ClassLoader.class, false);
- infoFactory.addReference("Parent", ConfigurationParent.class);
infoFactory.addReference("Repositories", Repository.class, "GBean");
infoFactory.addReference("ConfigurationStore", ConfigurationStore.class);
infoFactory.addReference("AttributeStore", ManageableAttributeStore.class);
@@ -618,7 +634,6 @@
"type",
"baseURL",
"parentId",
- "Parent",
"domain",
"server",
"classPath",
Modified: geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/config/MultiParentClassLoader.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/config/MultiParentClassLoader.java?rev=264914&r1=264913&r2=264914&view=diff
==============================================================================
--- geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/config/MultiParentClassLoader.java
(original)
+++ geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/config/MultiParentClassLoader.java
Tue Aug 30 18:32:17 2005
@@ -19,80 +19,88 @@
import java.net.URLClassLoader;
import java.net.URL;
import java.net.URLStreamHandlerFactory;
+import java.net.URI;
import java.util.Enumeration;
import java.util.List;
import java.util.ArrayList;
import java.util.Collections;
+import java.util.Map;
import java.io.IOException;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+import java.io.ObjectStreamClass;
+import java.lang.reflect.Field;
+
+import org.apache.commons.logging.LogFactory;
/**
* A MultiParentClassLoader is a simple extension of the URLClassLoader that simply changes
the single parent class
* loader model to support a list of parent class loaders. Each operation that accesses
a parent, has been replaced
* with a operation that checks each parent in order. This getParent method of this class
will always return null,
- * which may be interperated by the calling code to mean that this class loader is a direct
child of the system class
+ * which may be interpreted by the calling code to mean that this class loader is a direct
child of the system class
* loader.
* @version $Rev$ $Date$
*/
public class MultiParentClassLoader extends URLClassLoader {
- private final String name;
+ private final URI id;
private final ClassLoader[] parents;
/**
* Creates a named class loader with no parents.
- * @param name the name of this class loader
+ * @param id the id of this class loader
* @param urls the urls from which this class loader will classes and resources
*/
- public MultiParentClassLoader(String name, URL[] urls) {
+ public MultiParentClassLoader(URI id, URL[] urls) {
super(urls);
- this.name = name;
+ this.id = id;
parents = new ClassLoader[0];
}
/**
* Creates a named class loader as a child of the specified parent.
- * @param name the name of this class loader
+ * @param id the id of this class loader
* @param urls the urls from which this class loader will classes and resources
* @param parent the parent of this class loader
*/
- public MultiParentClassLoader(String name, URL[] urls, ClassLoader parent) {
- this(name, urls, new ClassLoader[] {parent});
+ public MultiParentClassLoader(URI id, URL[] urls, ClassLoader parent) {
+ this(id, urls, new ClassLoader[] {parent});
}
/**
* Creates a named class loader as a child of the specified parent and using the specified
URLStreamHandlerFactory
* for accessing the urls..
- * @param name the name of this class loader
+ * @param id the id of this class loader
* @param urls the urls from which this class loader will classes and resources
* @param parent the parent of this class loader
* @param factory the URLStreamHandlerFactory used to access the urls
*/
- public MultiParentClassLoader(String name, URL[] urls, ClassLoader parent, URLStreamHandlerFactory
factory) {
- this(name, urls, new ClassLoader[] {parent}, factory);
+ public MultiParentClassLoader(URI id, URL[] urls, ClassLoader parent, URLStreamHandlerFactory
factory) {
+ this(id, urls, new ClassLoader[] {parent}, factory);
}
/**
* Creates a named class loader as a child of the specified parents.
- * @param name the name of this class loader
+ * @param id the id of this class loader
* @param urls the urls from which this class loader will classes and resources
* @param parents the parents of this class loader
*/
- public MultiParentClassLoader(String name, URL[] urls, ClassLoader[] parents) {
+ public MultiParentClassLoader(URI id, URL[] urls, ClassLoader[] parents) {
super(urls);
- this.name = name;
+ this.id = id;
this.parents = copyParents(parents);
}
/**
* Creates a named class loader as a child of the specified parents and using the specified
URLStreamHandlerFactory
* for accessing the urls..
- * @param name the name of this class loader
+ * @param id the id of this class loader
* @param urls the urls from which this class loader will classes and resources
* @param parents the parents of this class loader
* @param factory the URLStreamHandlerFactory used to access the urls
*/
- public MultiParentClassLoader(String name, URL[] urls, ClassLoader[] parents, URLStreamHandlerFactory
factory) {
+ public MultiParentClassLoader(URI id, URL[] urls, ClassLoader[] parents, URLStreamHandlerFactory
factory) {
super(urls, null, factory);
- this.name = name;
+ this.id = id;
this.parents = copyParents(parents);
}
@@ -109,11 +117,11 @@
}
/**
- * Gets the name of this class loader.
- * @return the name of this class loader
+ * Gets the id of this class loader.
+ * @return the id of this class loader
*/
- public String getName() {
- return name;
+ public URI getId() {
+ return id;
}
/**
@@ -181,6 +189,39 @@
}
public String toString() {
- return "[" + getClass().getName() + " name=" + name + "]";
+ return "[" + getClass().getName() + " id=" + id + "]";
+ }
+
+ public void destroy() {
+ LogFactory.release(this);
+ clearSoftCache(ObjectInputStream.class, "subclassAudits");
+ clearSoftCache(ObjectOutputStream.class, "subclassAudits");
+ clearSoftCache(ObjectStreamClass.class, "localDescs");
+ clearSoftCache(ObjectStreamClass.class, "reflectors");
+ }
+
+ private static Object lock = new Object();
+ private static boolean clearSoftCacheFailed = false;
+ private static void clearSoftCache(Class clazz, String fieldName) {
+ Map cache = null;
+ try {
+ Field f = clazz.getDeclaredField(fieldName);
+ f.setAccessible(true);
+ cache = (Map) f.get(null);
+ } catch (Throwable e) {
+ synchronized (lock) {
+ if (!clearSoftCacheFailed) {
+ clearSoftCacheFailed = true;
+ LogFactory.getLog(ConfigurationClassLoader.class).error("Unable to clear
SoftCache field " + fieldName + " in class " + clazz);
+ }
+ }
+ }
+
+ if (cache != null) {
+ synchronized (cache) {
+ cache.clear();
+ }
+ }
}
+
}
Modified: geronimo/trunk/modules/kernel/src/test/org/apache/geronimo/kernel/ConfigTest.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/kernel/src/test/org/apache/geronimo/kernel/ConfigTest.java?rev=264914&r1=264913&r2=264914&view=diff
==============================================================================
--- geronimo/trunk/modules/kernel/src/test/org/apache/geronimo/kernel/ConfigTest.java (original)
+++ geronimo/trunk/modules/kernel/src/test/org/apache/geronimo/kernel/ConfigTest.java Tue
Aug 30 18:32:17 2005
@@ -43,7 +43,6 @@
// create the config gbean data
GBeanData config = new GBeanData(Configuration.getConfigurationObjectName(id), Configuration.GBEAN_INFO);
config.setAttribute("id", id);
- config.setReferencePatterns("Parent", null);
config.setAttribute("classPath", Collections.EMPTY_LIST);
config.setAttribute("gBeanState", state);
config.setAttribute("dependencies", Collections.EMPTY_LIST);
@@ -98,7 +97,6 @@
// create the config gbean data
GBeanData config = new GBeanData(Configuration.getConfigurationObjectName(id), Configuration.GBEAN_INFO);
config.setAttribute("id", id);
- config.setReferencePatterns("Parent", null);
config.setAttribute("classPath", Collections.EMPTY_LIST);
config.setAttribute("gBeanState", state);
config.setAttribute("dependencies", Collections.EMPTY_LIST);
@@ -128,7 +126,7 @@
assertEquals("1234", kernel.getAttribute(gbeanName3, "value"));
assertEquals("child", kernel.getAttribute(gbeanName3, "name"));
-
+
}
protected void setUp() throws Exception {
Modified: geronimo/trunk/modules/kernel/src/test/org/apache/geronimo/kernel/config/MultiParentClassLoaderTest.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/kernel/src/test/org/apache/geronimo/kernel/config/MultiParentClassLoaderTest.java?rev=264914&r1=264913&r2=264914&view=diff
==============================================================================
--- geronimo/trunk/modules/kernel/src/test/org/apache/geronimo/kernel/config/MultiParentClassLoaderTest.java
(original)
+++ geronimo/trunk/modules/kernel/src/test/org/apache/geronimo/kernel/config/MultiParentClassLoaderTest.java
Tue Aug 30 18:32:17 2005
@@ -23,6 +23,7 @@
import java.io.FileOutputStream;
import java.net.URLClassLoader;
import java.net.URL;
+import java.net.URI;
import java.util.jar.JarFile;
import java.util.jar.JarOutputStream;
import java.util.jar.JarEntry;
@@ -48,7 +49,7 @@
private URLClassLoader[] parents;
private File myFile;
private MultiParentClassLoader classLoader;
- private static final String NAME = "my test class loader";
+ private static final URI NAME = URI.create("myTestClassLoader");
/**
* Verify that the test jars are valid
@@ -88,7 +89,7 @@
* Verify the get name method returns the name provided to the constructor.
*/
public void testGetName() {
- assertEquals(NAME, classLoader.getName());
+ assertEquals(NAME, classLoader.getId());
}
/**
Modified: geronimo/trunk/modules/service-builder/src/java/org/apache/geronimo/deployment/service/ServiceConfigBuilder.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/service-builder/src/java/org/apache/geronimo/deployment/service/ServiceConfigBuilder.java?rev=264914&r1=264913&r2=264914&view=diff
==============================================================================
--- geronimo/trunk/modules/service-builder/src/java/org/apache/geronimo/deployment/service/ServiceConfigBuilder.java
(original)
+++ geronimo/trunk/modules/service-builder/src/java/org/apache/geronimo/deployment/service/ServiceConfigBuilder.java
Tue Aug 30 18:32:17 2005
@@ -29,6 +29,7 @@
import java.util.Collection;
import java.util.HashMap;
import java.util.Map;
+import java.util.List;
import java.util.jar.JarFile;
import javax.management.MalformedObjectNameException;
import javax.management.ObjectName;
@@ -162,21 +163,8 @@
}
public ConfigurationData buildConfiguration(ConfigurationType configType, String domain,
String server, File outfile) throws DeploymentException, IOException {
- URI[] parentID = null;
- if (configType.isSetParentId()) {
- try {
- String parentIdString = configType.getParentId();
- String[] parentIdStrings = parentIdString.split(",");
- parentID = new URI[parentIdStrings.length];
- for (int i = 0; i < parentIdStrings.length; i++) {
- String idString = parentIdStrings[i];
- URI parent = new URI(idString);
- parentID[i] = parent;
- }
- } catch (URISyntaxException e) {
- throw new DeploymentException("Invalid parentId " + configType.getParentId(),
e);
- }
- } else {
+ URI[] parentID = getParentID(configType.getParentId(), configType.getImportArray());
+ if (parentID == null) {
if (configType.isSetDomain()) {
if (!configType.isSetServer()) {
throw new DeploymentException("You must set both domain and server");
@@ -220,6 +208,26 @@
return context.getConfigurationData();
}
+ public static URI[] getParentID(String parentIDString, DependencyType[] imports) throws
DeploymentException {
+ List uris = new ArrayList();
+ if (parentIDString != null) {
+ try {
+ uris.add(new URI(parentIDString));
+ } catch (URISyntaxException e) {
+ throw new DeploymentException("Invalid parentId " + parentIDString, e);
+ }
+ } else if (imports.length == 0) {
+ return null;
+ }
+ for (int i = 0; i < imports.length; i++) {
+ DependencyType anImport = imports[i];
+ URI parentURI = getDependencyURI(anImport);
+ uris.add(parentURI);
+ }
+ URI[] parentID = (URI[])uris.toArray(new URI[uris.size()]);
+ return parentID;
+ }
+
public static void addIncludes(DeploymentContext context, DependencyType[] includes,
Repository repository) throws DeploymentException {
for (int i = 0; i < includes.length; i++) {
DependencyType include = includes[i];
@@ -358,6 +366,14 @@
}
private static URI getDependencyURI(DependencyType dep, Repository repository) throws
DeploymentException {
+ URI uri = getDependencyURI(dep);
+ if (!repository.hasURI(uri)) {
+ throw new DeploymentException(new MissingDependencyException("uri " + uri + "
not found in repository"));
+ }
+ return uri;
+ }
+
+ private static URI getDependencyURI(DependencyType dep) throws DeploymentException {
URI uri;
if (dep.isSetUri()) {
try {
@@ -376,9 +392,6 @@
} catch (URISyntaxException e) {
throw new DeploymentException("Unable to construct URI for groupId=" + dep.getGroupId()
+ ", artifactId=" + dep.getArtifactId() + ", version=" + dep.getVersion(), e);
}
- }
- if (!repository.hasURI(uri)) {
- throw new DeploymentException(new MissingDependencyException("uri " + uri + "
not found in repository"));
}
return uri;
}
Modified: geronimo/trunk/modules/service-builder/src/schema/geronimo-config.xsd
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/service-builder/src/schema/geronimo-config.xsd?rev=264914&r1=264913&r2=264914&view=diff
==============================================================================
--- geronimo/trunk/modules/service-builder/src/schema/geronimo-config.xsd (original)
+++ geronimo/trunk/modules/service-builder/src/schema/geronimo-config.xsd Tue Aug 30 18:32:17
2005
@@ -36,6 +36,7 @@
<xs:complexType name="configurationType">
<xs:sequence>
+ <xs:element ref="sys:import" minOccurs="0" maxOccurs="unbounded"/>
<xs:element name="include" type="sys:dependencyType" minOccurs="0" maxOccurs="unbounded"/>
<xs:element ref="sys:dependency" minOccurs="0" maxOccurs="unbounded"/>
<xs:element ref="sys:gbean" minOccurs="0" maxOccurs="unbounded"/>
@@ -53,6 +54,7 @@
<xs:attribute name="server" type="xs:string" use="optional"/>
</xs:complexType>
+ <xs:element name="import" type="sys:dependencyType"/>
<xs:element name="dependency" type="sys:dependencyType"/>
<xs:element name="gbean" type="sys:gbeanType"/>
Added: geronimo/trunk/modules/service-builder/src/test/org/apache/geronimo/deployment/service/ParentIDTest.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/service-builder/src/test/org/apache/geronimo/deployment/service/ParentIDTest.java?rev=264914&view=auto
==============================================================================
--- geronimo/trunk/modules/service-builder/src/test/org/apache/geronimo/deployment/service/ParentIDTest.java
(added)
+++ geronimo/trunk/modules/service-builder/src/test/org/apache/geronimo/deployment/service/ParentIDTest.java
Tue Aug 30 18:32:17 2005
@@ -0,0 +1,71 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.geronimo.deployment.service;
+
+import java.net.URI;
+
+import junit.framework.TestCase;
+import org.apache.geronimo.deployment.xbeans.DependencyType;
+
+/**
+ * @version $Rev: $ $Date: $
+ */
+public class ParentIDTest extends TestCase {
+
+ public void testNoParents() throws Exception {
+ URI[] parentId = ServiceConfigBuilder.getParentID(null, new DependencyType[] {});
+ assertNull(parentId);
+ }
+
+ public void testAttributeParent() throws Exception {
+ URI[] parentId = ServiceConfigBuilder.getParentID("attribute", new DependencyType[]
{});
+ assertEquals(1, parentId.length);
+ }
+
+ public void testImportParent1() throws Exception {
+ DependencyType anImport = DependencyType.Factory.newInstance();
+ anImport.setUri("import");
+ URI[] parentId = ServiceConfigBuilder.getParentID(null, new DependencyType[] {anImport});
+ assertEquals(1, parentId.length);
+ assertEquals("import", parentId[0].getPath());
+ }
+
+ public void testImportParent2() throws Exception {
+ DependencyType anImport = DependencyType.Factory.newInstance();
+ anImport.setGroupId("groupId");
+ anImport.setType("type");
+ anImport.setArtifactId("artifactId");
+ anImport.setVersion("version");
+ URI[] parentId = ServiceConfigBuilder.getParentID(null, new DependencyType[] {anImport});
+ assertEquals(1, parentId.length);
+ assertEquals("groupId/types/artifactId-version.type", parentId[0].getPath());
+ }
+
+ public void testBothParent() throws Exception {
+ DependencyType import1 = DependencyType.Factory.newInstance();
+ import1.setUri("import1");
+ DependencyType import2 = DependencyType.Factory.newInstance();
+ import2.setUri("import2");
+ URI[] parentId = ServiceConfigBuilder.getParentID("attribute", new DependencyType[]
{import1, import2});
+ assertEquals(3, parentId.length);
+ assertEquals("attribute", parentId[0].getPath());
+ assertEquals("import1", parentId[1].getPath());
+ assertEquals("import2", parentId[2].getPath());
+ }
+
+
+}
Modified: geronimo/trunk/modules/system/src/java/org/apache/geronimo/system/configuration/ExecutableConfigurationUtil.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/system/src/java/org/apache/geronimo/system/configuration/ExecutableConfigurationUtil.java?rev=264914&r1=264913&r2=264914&view=diff
==============================================================================
--- geronimo/trunk/modules/system/src/java/org/apache/geronimo/system/configuration/ExecutableConfigurationUtil.java
(original)
+++ geronimo/trunk/modules/system/src/java/org/apache/geronimo/system/configuration/ExecutableConfigurationUtil.java
Tue Aug 30 18:32:17 2005
@@ -161,13 +161,6 @@
URI[] parentId = configurationData.getParentId();
if (parentId != null) {
config.setAttribute("parentId", parentId);
- Set parentNames = new HashSet();
- for (int i = 0; i < parentId.length; i++) {
- URI uri = parentId[i];
- ObjectName parentName = Configuration.getConfigurationObjectName(uri);
- parentNames.add(parentName);
- }
- config.setReferencePatterns("Parent", parentNames);
}
config.setAttribute("gBeanState", Configuration.storeGBeans(configurationData.getGBeans()));
Modified: geronimo/trunk/modules/tomcat-builder/src/java/org/apache/geronimo/tomcat/deployment/TomcatModuleBuilder.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/tomcat-builder/src/java/org/apache/geronimo/tomcat/deployment/TomcatModuleBuilder.java?rev=264914&r1=264913&r2=264914&view=diff
==============================================================================
--- geronimo/trunk/modules/tomcat-builder/src/java/org/apache/geronimo/tomcat/deployment/TomcatModuleBuilder.java
(original)
+++ geronimo/trunk/modules/tomcat-builder/src/java/org/apache/geronimo/tomcat/deployment/TomcatModuleBuilder.java
Tue Aug 30 18:32:17 2005
@@ -177,23 +177,11 @@
throw new DeploymentException("Invalid configId " + tomcatWebApp.getConfigId(),
e);
}
- URI[] parentId = null;
- if (tomcatWebApp.isSetParentId()) {
- String parentIdString = tomcatWebApp.getParentId();
- try {
- String[] parentIdStrings = parentIdString.split(",");
- parentId = new URI[parentIdStrings.length];
- for (int i = 0; i < parentIdStrings.length; i++) {
- String idString = parentIdStrings[i];
- URI parent = new URI(idString);
- parentId[i] = parent;
- }
- } catch (URISyntaxException e) {
- throw new DeploymentException("Invalid parentId " + parentIdString, e);
- }
- } else {
+ URI[] parentId = ServiceConfigBuilder.getParentID(tomcatWebApp.getParentId(), tomcatWebApp.getImportArray());
+ if (parentId == null) {
parentId = defaultParentId;
}
+
if (contextRoot == null) {
contextRoot = tomcatWebApp.getContextRoot();
}
Modified: geronimo/trunk/modules/web-builder/src/schema/geronimo-web.xsd
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/web-builder/src/schema/geronimo-web.xsd?rev=264914&r1=264913&r2=264914&view=diff
==============================================================================
--- geronimo/trunk/modules/web-builder/src/schema/geronimo-web.xsd (original)
+++ geronimo/trunk/modules/web-builder/src/schema/geronimo-web.xsd Tue Aug 30 18:32:17 2005
@@ -36,6 +36,7 @@
<xs:complexType name="web-appType">
<xs:sequence>
+ <xs:element ref="sys:import" minOccurs="0" maxOccurs="unbounded"/>
<xs:element ref="sys:dependency" minOccurs="0" maxOccurs="unbounded"/>
<xs:element name="context-root" type="xs:string" minOccurs="0"/>
|