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=384686&r1=384685&r2=384686&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 9 18:57:07 2006
@@ -17,32 +17,6 @@
package org.apache.geronimo.kernel.config;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.geronimo.gbean.GBeanData;
-import org.apache.geronimo.gbean.GBeanInfo;
-import org.apache.geronimo.gbean.GBeanInfoBuilder;
-import org.apache.geronimo.gbean.GBeanLifecycle;
-import org.apache.geronimo.gbean.AbstractName;
-import org.apache.geronimo.gbean.AbstractNameQuery;
-import org.apache.geronimo.gbean.ReferencePatterns;
-import org.apache.geronimo.kernel.DependencyManager;
-import org.apache.geronimo.kernel.GBeanAlreadyExistsException;
-import org.apache.geronimo.kernel.GBeanNotFoundException;
-import org.apache.geronimo.kernel.Kernel;
-import org.apache.geronimo.kernel.ObjectInputStreamExt;
-import org.apache.geronimo.kernel.jmx.JMXUtil;
-import org.apache.geronimo.kernel.management.State;
-import org.apache.geronimo.kernel.repository.Artifact;
-import org.apache.geronimo.kernel.repository.ArtifactManager;
-import org.apache.geronimo.kernel.repository.ArtifactResolver;
-import org.apache.geronimo.kernel.repository.DefaultArtifactResolver;
-import org.apache.geronimo.kernel.repository.Environment;
-import org.apache.geronimo.kernel.repository.MissingDependencyException;
-import org.apache.geronimo.kernel.repository.Repository;
-
-import javax.management.MalformedObjectNameException;
-import javax.management.ObjectName;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.EOFException;
@@ -58,13 +32,35 @@
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
-import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.ListIterator;
import java.util.Map;
import java.util.Set;
+import javax.management.MalformedObjectNameException;
+import javax.management.ObjectName;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.geronimo.gbean.AbstractName;
+import org.apache.geronimo.gbean.GBeanData;
+import org.apache.geronimo.gbean.GBeanInfo;
+import org.apache.geronimo.gbean.GBeanInfoBuilder;
+import org.apache.geronimo.gbean.GBeanLifecycle;
+import org.apache.geronimo.kernel.GBeanAlreadyExistsException;
+import org.apache.geronimo.kernel.GBeanNotFoundException;
+import org.apache.geronimo.kernel.ObjectInputStreamExt;
+import org.apache.geronimo.kernel.jmx.JMXUtil;
+import org.apache.geronimo.kernel.repository.Artifact;
+import org.apache.geronimo.kernel.repository.ArtifactManager;
+import org.apache.geronimo.kernel.repository.ArtifactResolver;
+import org.apache.geronimo.kernel.repository.DefaultArtifactResolver;
+import org.apache.geronimo.kernel.repository.Dependency;
+import org.apache.geronimo.kernel.repository.Environment;
+import org.apache.geronimo.kernel.repository.ImportType;
+import org.apache.geronimo.kernel.repository.MissingDependencyException;
+import org.apache.geronimo.kernel.repository.Repository;
/**
* A Configuration represents a collection of runnable services that can be
@@ -131,11 +127,6 @@
}
}
- /**
- * The kernel in which this configuration is registered.
- */
- private final Kernel kernel;
-
private final ConfigurationStore configurationStore;
/**
@@ -159,9 +150,19 @@
private final ConfigurationModuleType moduleType;
/**
- * List of the parent configurations
+ * Parent configurations used for class loader.
+ */
+ private final List classParents = new ArrayList();
+
+ /**
+ * Parent configuations used for service resolution.
+ */
+ private final List serviceParents = new ArrayList();
+
+ /**
+ * Artifacts added to the class loader (non-configuation artifacts).
*/
- private final List parents;
+ private final LinkedHashSet dependencies;
/**
* The GBeanData objects by ObjectName
@@ -188,13 +189,12 @@
*/
public Configuration() {
environment = null;
- kernel = null;
configurationStore = null;
id = null;
objectName = null;
abstractName = null;
moduleType = null;
- parents = null;
+ dependencies = null;
configurationClassLoader = null;
repositories = null;
artifactManager = null;
@@ -209,13 +209,12 @@
* @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
*/
- public Configuration(Collection parents, Kernel kernel, String objectName, ConfigurationModuleType moduleType, Environment environment, List classPath, byte[] gbeanState, Collection repositories, ConfigurationStore configurationStore, ArtifactManager artifactManager, ArtifactResolver artifactResolver) throws MissingDependencyException, MalformedURLException, NoSuchConfigException, InvalidConfigException {
- if (parents == null) parents = Collections.EMPTY_SET;
- this.parents = orderParents(parents, environment);
- this.kernel = kernel;
+ public Configuration(Collection parents, String objectName, ConfigurationModuleType moduleType, Environment environment, List classPath, byte[] gbeanState, Collection repositories, ConfigurationStore configurationStore, ArtifactManager artifactManager, ArtifactResolver artifactResolver) throws MissingDependencyException, MalformedURLException, NoSuchConfigException, InvalidConfigException {
this.environment = environment;
this.moduleType = moduleType;
this.repositories = repositories;
+ this.configurationStore = configurationStore;
+ this.artifactManager = artifactManager;
this.id = environment.getConfigId();
this.objectName = objectName == null ? null : JMXUtil.getObjectName(objectName);
@@ -227,38 +226,73 @@
}
abstractName = getConfigurationAbstractName(id);
- this.configurationStore = configurationStore;
-
- this.artifactManager = artifactManager;
-
+ //
+ // Resolve all artifacts in the environment
+ //
if (artifactResolver == null) {
artifactResolver = new DefaultArtifactResolver(artifactManager, repositories);
}
+ environment.setDependencies(resolveDependencies(artifactResolver, parents, environment.getDependencies()));
+
+ //
+ // Process environment splitting it into classParents, serviceParents and artifactDependencies
+ //
+ if (parents == null) parents = Collections.EMPTY_SET;
+ Map parentsById = new HashMap();
+ for (Iterator iterator = parents.iterator(); iterator.hasNext();) {
+ Configuration configuration = (Configuration) iterator.next();
+ Artifact id = configuration.getId();
+ parentsById.put(id, configuration);
+ }
- //propagate non overridable classes etc from parents.
- determineInherited();
+ LinkedHashSet dependencies = new LinkedHashSet();
+ for (Iterator iterator = environment.getDependencies().iterator(); iterator.hasNext();) {
+ Dependency dependency = (Dependency) iterator.next();
+ Artifact artifact = dependency.getArtifact();
+ if (parentsById.containsKey(artifact)) {
+ Configuration parent = (Configuration) parentsById.get(artifact);
+ if (dependency.getImportType() == ImportType.CLASSES || dependency.getImportType() == ImportType.ALL) {
+ classParents.add(parent);
+ }
+ if (dependency.getImportType() == ImportType.SERVICES || dependency.getImportType() == ImportType.ALL) {
+ serviceParents.add(parent);
+ }
+ } else if (dependency.getImportType() == ImportType.SERVICES) {
+ throw new IllegalStateException("Could not find parent " + artifact + " in the parents collection");
+ } else {
+ dependencies.add(artifact);
+ }
+ }
+
+ //
+ // recursively resolve the artifact dependencies
+ //
+ this.dependencies = recursiveResolve(parents, artifactResolver, dependencies);
- // resolve dependencies
- LinkedHashSet dependencies = environment.getDependencies();
- dependencies = recursiveResolve(artifactResolver, dependencies);
- environment.setDependencies(dependencies);
-
- // resolve references
- LinkedHashSet references = environment.getReferences();
- references = artifactResolver.resolve(parents, references);
- environment.setReferences(references);
+ //
+ // Propagate non-overridable classes from class parents
+ //
+ for (Iterator iterator = classParents.iterator(); iterator.hasNext();) {
+ Configuration parent = (Configuration) iterator.next();
+
+ Environment parentEnvironment = parent.getEnvironment();
+ Set nonOverridableClasses = parentEnvironment.getNonOverrideableClasses();
+ environment.addNonOverrideableClasses(nonOverridableClasses);
+ }
- // build configurationClassLoader
- URL[] urls = buildClassPath(configurationStore, classPath);
+ //
+ // Build the configuration class loader
+ //
+ URL[] urls = buildClassPath(classPath);
log.debug("ClassPath for " + id + " resolved to " + Arrays.asList(urls));
- if (parents.size() == 0) {
+ if (parents.size() == 0 && classParents.size() == 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 MultiParentClassLoader(environment.getConfigId(), urls, getClass().getClassLoader());
} else {
- ClassLoader[] parentClassLoaders = new ClassLoader[parents.size()];
- for (ListIterator iterator = this.parents.listIterator(); iterator.hasNext();) {
+ ClassLoader[] parentClassLoaders = new ClassLoader[classParents.size()];
+ for (ListIterator iterator = classParents.listIterator(); iterator.hasNext();) {
Configuration configuration = (Configuration) iterator.next();
parentClassLoaders[iterator.previousIndex()] = configuration.getConfigurationClassLoader();
}
@@ -276,7 +310,6 @@
ObjectInputStream ois = new ObjectInputStreamExt(new ByteArrayInputStream(gbeanState), configurationClassLoader);
try {
- ObjectName baseName = getBaseName();
while (true) {
GBeanData gbeanData = new GBeanData();
gbeanData.readExternal(ois);
@@ -295,42 +328,18 @@
}
}
- private List orderParents(Collection parents, Environment environment) {
- Map parentsById = new HashMap();
- for (Iterator iterator = parents.iterator(); iterator.hasNext();) {
- Configuration configuration = (Configuration) iterator.next();
- Artifact id = configuration.getId();
- parentsById.put(id, configuration);
- }
- LinkedHashSet imports = environment.getImports();
- if (!parentsById.keySet().equals(imports)) {
- throw new IllegalArgumentException(environment.getConfigId() + " : Expected parents " +
- imports +
- ", but actual parents are " +
- parentsById.keySet());
- }
-
- List orderedParents = new ArrayList(parents.size());
- for (Iterator iterator = imports.iterator(); iterator.hasNext();) {
- Artifact id = (Artifact) iterator.next();
- Configuration configuration = (Configuration) parentsById.get(id);
- if (configuration == null) throw new IllegalStateException("Could not find parent " + id + " in the parents collection");
- orderedParents.add(configuration);
- }
- return orderedParents;
- }
-
- private void determineInherited() {
- for (Iterator iterator = parents.iterator(); iterator.hasNext();) {
- Configuration parent = (Configuration) iterator.next();
-
- Environment parentEnvironment = parent.getEnvironment();
- Set nonOverridableClasses = parentEnvironment.getNonOverrideableClasses();
- environment.addNonOverrideableClasses(nonOverridableClasses);
+ private List resolveDependencies(ArtifactResolver artifactResolver, Collection parents, List dependencies) throws MissingDependencyException {
+ List resolvedDependencies = new ArrayList();
+ for (Iterator iterator = dependencies.iterator(); iterator.hasNext();) {
+ Dependency dependency = (Dependency) iterator.next();
+ Artifact artifact = dependency.getArtifact();
+ artifact = artifactResolver.resolve(parents, artifact);
+ resolvedDependencies.add(new Dependency(artifact, dependency.getImportType()));
}
+ return resolvedDependencies;
}
- private LinkedHashSet recursiveResolve(ArtifactResolver artifactResolver, LinkedHashSet dependencies) throws MissingDependencyException {
+ private LinkedHashSet recursiveResolve(Collection parents, ArtifactResolver artifactResolver, LinkedHashSet dependencies) throws MissingDependencyException {
dependencies = artifactResolver.resolve(parents, dependencies);
for (Iterator iterator = new ArrayList(dependencies).iterator(); iterator.hasNext();) {
Artifact dependency = (Artifact) iterator.next();
@@ -338,16 +347,17 @@
Repository repository = (Repository) iterator1.next();
if (repository.contains(dependency)) {
LinkedHashSet subDependencies = repository.getDependencies(dependency);
- subDependencies = recursiveResolve(artifactResolver, subDependencies);
- dependencies.addAll(subDependencies);
+ if (!subDependencies.isEmpty()) {
+ subDependencies = recursiveResolve(parents, artifactResolver, subDependencies);
+ dependencies.addAll(subDependencies);
+ }
}
}
}
return dependencies;
}
- private URL[] buildClassPath(ConfigurationStore configurationStore, List classPath) throws MalformedURLException, MissingDependencyException, NoSuchConfigException {
- LinkedHashSet dependencies = environment.getDependencies();
+ private URL[] buildClassPath(List classPath) throws MalformedURLException, MissingDependencyException, NoSuchConfigException {
List urls = new ArrayList();
for (Iterator i = dependencies.iterator(); i.hasNext();) {
Artifact artifact = (Artifact) i.next();
@@ -399,11 +409,27 @@
}
/**
- * Gets the parent configurations of this configuration.
- * @return the parents of this configuration
+ * Gets the parent configurations used for class loading.
+ * @return the parents of this configuration used for class loading
*/
- public List getParents() {
- return parents;
+ public List getClassParents() {
+ return classParents;
+ }
+
+ /**
+ * Gets the parent configurations used for service resolution.
+ * @return the parents of this configuration used for service resolution
+ */
+ public List getServiceParents() {
+ return serviceParents;
+ }
+
+ /**
+ * Gets the artifact dependencies of this configuration.
+ * @return the artifact dependencies of this configuration
+ */
+ public LinkedHashSet getDependencies() {
+ return dependencies;
}
/**
@@ -442,55 +468,35 @@
return Collections.unmodifiableMap(gbeans);
}
- //TODO this is pretty much broken, it assumes everything is pre-resolved
- public synchronized void addGBean(GBeanData beanData, boolean start) throws InvalidConfigException, GBeanAlreadyExistsException {
- ClassLoader oldCl = Thread.currentThread().getContextClassLoader();
- try {
- Thread.currentThread().setContextClassLoader(configurationClassLoader);
-
- log.trace("Registering GBean " + beanData.getName());
-
- // add a dependency on this configuration
- beanData.addDependency(abstractName);
-
- // register the bean with the kernel
- kernel.loadGBean(beanData, configurationClassLoader);
+ /**
+ * Determines of this configuration constains the specified GBean.
+ * @param gbean the name of the GBean
+ * @return true if this configuration contains the specified GBean; false otherwise
+ */
+ public synchronized boolean containsGBean(AbstractName gbean) {
+ return gbeans.containsKey(gbean);
+ }
- // start the configuration
- if (start) {
- try {
- kernel.startRecursiveGBean(beanData.getName());
- } catch (GBeanNotFoundException e) {
- throw new IllegalStateException("How could we not find a GBean that we just loaded ('" + beanData.getName() + "')?");
- }
- }
- } finally {
- Thread.currentThread().setContextClassLoader(oldCl);
+ public synchronized void addGBean(GBeanData gbean) throws InvalidConfigException, GBeanAlreadyExistsException {
+ if (gbeans.containsKey(gbean.getName())) {
+ throw new GBeanAlreadyExistsException(gbean.getName().getCanonicalName());
}
-
- gbeans.put(beanData.getAbstractName(), beanData);
+ gbeans.put(gbean.getAbstractName(), gbean);
}
+ public synchronized void removeGBean(AbstractName name) throws GBeanNotFoundException {
+ if (!gbeans.containsKey(name)) {
+ throw new GBeanNotFoundException(name);
+ }
+ gbeans.remove(name);
+ }
public void doStart() throws Exception {
assert objectName != null;
- // declare dependencies on parents
- Set parentNames = new HashSet();
- for (Iterator iterator = parents.iterator(); iterator.hasNext();) {
- Configuration configuration = (Configuration) iterator.next();
- AbstractName parentName = getConfigurationAbstractName(configuration.getId());
- parentNames.add(parentName);
- }
- DependencyManager dependencyManager = this.kernel.getDependencyManager();
- dependencyManager.addDependencies(abstractName, parentNames);
-
// declare the artifacts as loaded
- LinkedHashSet artifacts = new LinkedHashSet();
- artifacts.addAll(environment.getDependencies());
- artifacts.addAll(environment.getReferences());
if (artifactManager != null) {
- artifactManager.loadArtifacts(id, artifacts);
+ artifactManager.loadArtifacts(id, dependencies);
}
log.debug("Started configuration " + id);
@@ -508,18 +514,7 @@
}
private void shutdown() {
- // unregister all GBeans
- for (Iterator i = gbeans.keySet().iterator(); i.hasNext();) {
- AbstractName name = (AbstractName) i.next();
- try {
- if (kernel.isLoaded(name)) {
- log.trace("Unregistering GBean " + name);
- kernel.unloadGBean(name);
- }
- } catch (Exception e) {
- log.warn("Could not unregister child " + name, e);
- }
- }
+ // clear references to GBeanDatas
gbeans.clear();
// destroy the class loader
@@ -579,7 +574,6 @@
static {
GBeanInfoBuilder infoFactory = GBeanInfoBuilder.createStatic(Configuration.class);//does not use jsr-77 naming
- infoFactory.addAttribute("kernel", Kernel.class, false);
infoFactory.addAttribute("objectName", String.class, false);
infoFactory.addAttribute("environment", Environment.class, true, false);
infoFactory.addAttribute("type", ConfigurationModuleType.class, true, false);
@@ -600,7 +594,6 @@
infoFactory.setConstructor(new String[]{
"Parents",
- "kernel",
"objectName",
"type",
"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=384686&r1=384685&r2=384686&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 9 18:57:07 2006
@@ -50,6 +50,20 @@
List listConfigurations(ObjectName store) throws NoSuchStoreException;
/**
+ * Is the specified artifact a configurations?
+ * @param artifact the artifact to check
+ * @return true if the artifact is a configuration
+ */
+ boolean isConfiguration(Artifact artifact);
+
+ /**
+ * Gets the loaded Configuration.
+ * @param configId the configuration to get
+ * @return the specified configuration or null if the configuration has not been loaded
+ */
+ Configuration getConfiguration(Artifact configId);
+
+ /**
* Load the specified configuration and all parent configurations into the kernel. This does not
* start any configuration gbeans or load any gbeans from the configurations loaded. It does
* not hurt to call this even if some or all of the GBeans are already loaded -- though only
@@ -76,6 +90,8 @@
*/
void unloadConfiguration(Artifact configID) throws NoSuchConfigException;
+ void unloadConfiguration(Configuration configuration) throws NoSuchConfigException;
+
/**
* Start the gbeans in this configuration.
*
@@ -84,6 +100,8 @@
*/
void startConfiguration(Artifact configID) throws InvalidConfigException;
+ void startConfiguration(Configuration configuration) throws InvalidConfigException;
+
/**
* Stop the gbeans in this configuration, but do not stop the configuration gbean.
*
@@ -92,11 +110,6 @@
*/
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=384686&r1=384685&r2=384686&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 9 18:57:07 2006
@@ -39,6 +39,8 @@
import org.apache.geronimo.kernel.repository.ArtifactManager;
import org.apache.geronimo.kernel.repository.ArtifactResolver;
import org.apache.geronimo.kernel.repository.DefaultArtifactResolver;
+import org.apache.geronimo.kernel.repository.Dependency;
+import org.apache.geronimo.kernel.repository.ImportType;
import org.apache.geronimo.kernel.repository.Environment;
import org.apache.geronimo.kernel.repository.MissingDependencyException;
@@ -55,8 +57,9 @@
import java.util.LinkedHashMap;
import java.util.LinkedHashSet;
import java.util.LinkedList;
-import java.util.List;
+import java.util.ListIterator;
import java.util.Map;
+import java.util.List;
import java.util.Set;
import java.util.HashSet;
@@ -69,7 +72,7 @@
* @see EditableConfigurationManager
*/
public class ConfigurationManagerImpl implements ConfigurationManager, GBeanLifecycle {
- private static final Log log = LogFactory.getLog(ConfigurationManagerImpl.class);
+ protected static final Log log = LogFactory.getLog(ConfigurationManagerImpl.class);
protected final Kernel kernel;
private final Collection stores;
@@ -125,6 +128,17 @@
throw new NoSuchStoreException("No such store: " + storeName);
}
+ public boolean isConfiguration(Artifact artifact) {
+ List storeSnapshot = getStores();
+ for (int i = 0; i < storeSnapshot.size(); i++) {
+ ConfigurationStore store = (ConfigurationStore) storeSnapshot.get(i);
+ if (store.containsConfiguration(artifact)) {
+ return true;
+ }
+ }
+ return false;
+ }
+
public Configuration getConfiguration(Artifact configurationId) {
ConfigurationStatus configurationStatus = (ConfigurationStatus) configurations.get(configurationId);
return configurationStatus.getConfiguration();
@@ -143,7 +157,7 @@
} else if (kernel.isLoaded(Configuration.getConfigurationObjectName(configurationId))) {
// hack
Configuration configuration = (Configuration) kernel.getProxyManager().createProxy(Configuration.getConfigurationObjectName(configurationId), Configuration.class);
- configurationStatus = new ConfigurationStatus(configuration, getParentStatuses(configuration));
+ configurationStatus = createConfigurationStatus(configuration);
configurationStatus.load();
configurations.put(configurationId, configurationStatus);
return configurationStatus.getConfiguration();
@@ -204,19 +218,21 @@
try {
kernel.startGBean(configurationName);
if (State.RUNNING_INDEX != kernel.getGBeanState(configurationName)) {
- throw new InvalidConfigurationException("Configuration " + configurationId + " failed to start");
+ throw new InvalidConfigurationException("Configuration gbean failed to start " + configurationId);
}
// create a proxy to the configuration
configuration = (Configuration) kernel.getProxyManager().createProxy(configurationName, Configuration.class);
loadedConfigurations.put(configurationId, configuration);
log.debug("Loaded Configuration " + configurationName);
+ } catch (InvalidConfigurationException e) {
+ throw e;
} catch (Exception e) {
safeConfigurationUnload(configurationId);
if (e instanceof InvalidConfigException) {
throw (InvalidConfigException) e;
}
- throw new InvalidConfigException("Unable to start configuration gbean " + configurationId, e);
+ throw new InvalidConfigException("Error starting configuration gbean " + configurationId, e);
}
// todo move this to startConfiguration when deployment code has been update to not search kernel
@@ -236,9 +252,7 @@
// update the status of the loaded configurations
for (Iterator iterator = loadedConfigurations.values().iterator(); iterator.hasNext();) {
Configuration configuration = (Configuration) iterator.next();
-
- List parentStatuses = getParentStatuses(configuration);
- ConfigurationStatus configurationStatus = new ConfigurationStatus(configuration, parentStatuses);
+ ConfigurationStatus configurationStatus = createConfigurationStatus(configuration);
configurations.put(getConfigurationId(configuration), configurationStatus);
}
@@ -247,11 +261,22 @@
return configurationStatus.getConfiguration();
}
- private List getParentStatuses(Configuration configuration) {
- List parents = configuration.getParents();
+ private ConfigurationStatus createConfigurationStatus(Configuration configuration) {
+ // start parents are just the service parents of the configuration... we want the services to be running so we can use them
+ List startParents = getParentStatuses(configuration.getServiceParents());
+
+ // load parents are both the class parents and the service parents
+ LinkedHashSet loadParents = new LinkedHashSet(startParents);
+ loadParents.addAll(getParentStatuses(configuration.getClassParents()));
+
+ ConfigurationStatus configurationStatus = new ConfigurationStatus(configuration, new ArrayList(loadParents), startParents);
+ return configurationStatus;
+ }
+
+ private List getParentStatuses(List parents) {
List parentStatuses = new ArrayList(parents.size());
- for (Iterator iterator1 = parents.iterator(); iterator1.hasNext();) {
- Configuration parent = (Configuration) iterator1.next();
+ for (Iterator iterator = parents.iterator(); iterator.hasNext();) {
+ Configuration parent = (Configuration) iterator.next();
Artifact parentId = getConfigurationId(parent);
ConfigurationStatus parentStatus = (ConfigurationStatus) configurations.get(parentId);
if (parentStatus == null) {
@@ -276,16 +301,17 @@
preprocess(gbeanData);
Environment environment = (Environment) gbeanData.getAttribute("environment");
- for (Iterator iterator = environment.getImports().iterator(); iterator.hasNext();) {
- Artifact parentId = (Artifact) iterator.next();
- if (!configurations.containsKey(parentId)) {
+ for (Iterator iterator = environment.getDependencies().iterator(); iterator.hasNext();) {
+ Dependency dependency = (Dependency) iterator.next();
+ Artifact parentId = dependency.getArtifact();
+ if (!configurations.containsKey(parentId) && isConfiguration(parentId)) {
GBeanData parentGBeanData = loadConfigurationGBeanData(parentId);
loadDepthFirst(parentGBeanData, unloadedConfigurations);
}
}
}
- // depth first - all unloaded parents have been added, not add this configuration
+ // depth first - all unloaded parents have been added, now add this configuration
unloadedConfigurations.put(configurationId, gbeanData);
} catch (NoSuchConfigException e) {
throw e;
@@ -324,38 +350,35 @@
Environment environment = (Environment) gbeanData.getAttribute("environment");
- // resolve the parents
- LinkedHashSet imports = environment.getImports();
- imports = artifactResolver.resolve(imports);
- environment.setImports(imports);
-
- // resolve the references
- LinkedHashSet references = environment.getReferences();
- references = artifactResolver.resolve(references);
- environment.setReferences(references);
-
- // convert the parents and reference artifactIds to objectNames
- LinkedHashSet importNames = new LinkedHashSet();
- for (Iterator iterator = imports.iterator(); iterator.hasNext();) {
- Artifact artifact = (Artifact) iterator.next();
- AbstractName importName = Configuration.getConfigurationAbstractName(artifact);
- gbeanData.addDependency(importName);
- importNames.add(new AbstractNameQuery(importName));
- }
- for (Iterator iterator = references.iterator(); iterator.hasNext();) {
- Artifact artifact = (Artifact) iterator.next();
- AbstractName referenceName = Configuration.getConfigurationAbstractName(artifact);
- gbeanData.addDependency(referenceName);
- }
-
- // imports become the parents
- gbeanData.setReferencePatterns("Parents", importNames);
+ LinkedHashSet parentNames = new LinkedHashSet();
+ List dependencies = new ArrayList(environment.getDependencies());
+ for (ListIterator iterator = dependencies.listIterator(); iterator.hasNext();) {
+ Dependency dependency = (Dependency) iterator.next();
+ Artifact resolvedArtifact = artifactResolver.resolve(dependency.getArtifact());
+ if (isConfiguration(resolvedArtifact)) {
+ AbstractName parentName = Configuration.getConfigurationAbstractName(resolvedArtifact);
+ parentNames.add(parentName);
+
+ // update the dependency list to contain the resolved artifact
+ dependency = new Dependency(resolvedArtifact, dependency.getImportType());
+ iterator.set(dependency);
+ } else if (dependency.getImportType() == ImportType.SERVICES) {
+ // Service depdendencies require that the depdencency be a configuration
+ throw new InvalidConfigException("Dependency does not have services: " + resolvedArtifact);
+ }
+ }
+ environment.setDependencies(dependencies);
+
+
+ // add parents to the parents reference collection
+ gbeanData.addDependencies(parentNames);
+ gbeanData.setReferencePatterns("Parents", parentNames);
}
private void safeConfigurationUnload(Artifact configurationId) {
- ObjectName configurationName;
+ AbstractName configurationName;
try {
- configurationName = Configuration.getConfigurationObjectName(configurationId);
+ configurationName = Configuration.getConfigurationAbstractName(configurationId);
} catch (InvalidConfigException e) {
throw new AssertionError(e);
}
@@ -490,7 +513,7 @@
private void resolveAncestors(Configuration configuration, List ancestors) {
ancestors.add(configuration);
- for (Iterator parents = configuration.getParents().iterator(); parents.hasNext();) {
+ for (Iterator parents = configuration.getServiceParents().iterator(); parents.hasNext();) {
Configuration parent = (Configuration) parents.next();
resolveAncestors(parent, ancestors);
}
@@ -508,11 +531,10 @@
// todo recursion disabled
List startList = configurationStatus.start();
- start(configurationStatus.getConfiguration());
-// for (Iterator iterator = startList.iterator(); iterator.hasNext();) {
-// Configuration configuration = (Configuration) iterator.next();
-// start(configuration);
-// }
+ for (Iterator iterator = startList.iterator(); iterator.hasNext();) {
+ Configuration configuration = (Configuration) iterator.next();
+ start(configuration);
+ }
// // todo clean up after failure
}
@@ -522,8 +544,8 @@
try {
// start the gbeans
- Collection gbeans = configuration.getGBeans().values();
- for (Iterator iterator = gbeans.iterator(); iterator.hasNext();) {
+ Map gbeans = configuration.getGBeans();
+ for (Iterator iterator = gbeans.values().iterator(); iterator.hasNext();) {
GBeanData gbeanData = (GBeanData) iterator.next();
AbstractName gbeanName = gbeanData.getAbstractName();
if (kernel.isGBeanEnabled(gbeanName)) {
@@ -532,13 +554,12 @@
}
// assure all of the gbeans are started
-// for (Iterator iterator = gbeans.values().iterator(); iterator.hasNext();) {
-// GBeanData gbeanData = (GBeanData) iterator.next();
-// AbstractName gbeanName = gbeanData.getAbstractName();
-// if (State.RUNNING_INDEX != kernel.getGBeanState(gbeanName)) {
-// throw new InvalidConfigurationException("Configuration " + configuration.getId() + " failed to start because gbean " + gbeanName + " did not start");
-// }
-// }
+ for (Iterator iterator = gbeans.keySet().iterator(); iterator.hasNext();) {
+ AbstractName gbeanName = (AbstractName) iterator.next();
+ if (State.RUNNING_INDEX != kernel.getGBeanState(gbeanName)) {
+ throw new InvalidConfigurationException("Configuration " + getConfigurationId(configuration) + " failed to start because gbean " + gbeanName + " did not start");
+ }
+ }
} catch (GBeanNotFoundException e) {
throw new InvalidConfigException(e);
}
@@ -709,13 +730,16 @@
private static class ConfigurationStatus {
private final Configuration configuration;
- private final List parents;
+ private final List loadParents;
+ private final List startParents;
private int loadCount = 0;
private int startCount = 0;
- public ConfigurationStatus(Configuration configuration, List parents) {
+ public ConfigurationStatus(Configuration configuration, List loadParents, List startParents) {
+ if (!loadParents.containsAll(startParents)) throw new IllegalArgumentException("loadParents must contain all startParents");
this.configuration = configuration;
- this.parents = parents;
+ this.loadParents = loadParents;
+ this.startParents = startParents;
}
public Configuration getConfiguration() {
@@ -727,7 +751,7 @@
}
public void load() {
- for (Iterator iterator = parents.iterator(); iterator.hasNext();) {
+ for (Iterator iterator = loadParents.iterator(); iterator.hasNext();) {
ConfigurationStatus parent = (ConfigurationStatus) iterator.next();
parent.load();
}
@@ -735,15 +759,15 @@
}
public List unload() {
- List unloadList = new LinkedList();
- for (Iterator iterator = parents.iterator(); iterator.hasNext();) {
+ LinkedList unloadList = new LinkedList();
+ for (Iterator iterator = loadParents.iterator(); iterator.hasNext();) {
ConfigurationStatus parent = (ConfigurationStatus) iterator.next();
unloadList.addAll(parent.unload());
}
loadCount--;
if (loadCount == 0) {
assert(startCount == 0);
- unloadList.add(configuration);
+ unloadList.addFirst(configuration);
}
return unloadList;
}
@@ -754,7 +778,7 @@
public List start() {
List startList = new LinkedList();
- for (Iterator iterator = parents.iterator(); iterator.hasNext();) {
+ for (Iterator iterator = startParents.iterator(); iterator.hasNext();) {
ConfigurationStatus parent = (ConfigurationStatus) iterator.next();
startList.addAll(parent.start());
}
@@ -766,14 +790,14 @@
}
public List stop() {
- List stopList = new LinkedList();
- for (Iterator iterator = parents.iterator(); iterator.hasNext();) {
+ LinkedList stopList = new LinkedList();
+ for (Iterator iterator = startParents.iterator(); iterator.hasNext();) {
ConfigurationStatus parent = (ConfigurationStatus) iterator.next();
stopList.addAll(parent.stop());
}
startCount--;
if (startCount == 0) {
- stopList.add(configuration);
+ stopList.addFirst(configuration);
}
return stopList;
}
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=384686&r1=384685&r2=384686&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 9 18:57:07 2006
@@ -17,7 +17,7 @@
package org.apache.geronimo.kernel.config;
import java.util.Collection;
-import javax.management.ObjectName;
+
import org.apache.geronimo.kernel.Kernel;
import org.apache.geronimo.kernel.GBeanNotFoundException;
import org.apache.geronimo.kernel.repository.Artifact;
@@ -36,52 +36,76 @@
*/
public class EditableConfigurationManagerImpl extends ConfigurationManagerImpl implements EditableConfigurationManager {
public EditableConfigurationManagerImpl(Kernel kernel,
- Collection stores,
- ManageableAttributeStore attributeStore,
- PersistentConfigurationList configurationList,
- ArtifactManager artifactManager,
- ArtifactResolver artifactResolver,
- ClassLoader classLoader) {
+ 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 {
+ public void addGBeanToConfiguration(Artifact configurationId, GBeanData gbean, boolean start) throws InvalidConfigException {
+ Configuration configuration = getConfiguration(configurationId);
+ ClassLoader configurationClassLoader = configuration.getConfigurationClassLoader();
+
+ ClassLoader oldCl = Thread.currentThread().getContextClassLoader();
try {
- ObjectName name = Configuration.getConfigurationObjectName(configID);
- kernel.invoke(name, "addGBean", new Object[]{gbean, start ? Boolean.TRUE : Boolean.FALSE}, new String[]{GBeanData.class.getName(), boolean.class.getName()});
- } catch (Exception e) {
- throw new InvalidConfigException("Unable to add GBean to configuration", e);
- }
+ Thread.currentThread().setContextClassLoader(configurationClassLoader);
- attributeStore.addGBean(configID.toString(), gbean);
- }
+ log.trace("Registering GBean " + gbean.getName());
- public void removeGBeanFromConfiguration(Artifact configID, AbstractName gbean) throws GBeanNotFoundException, InvalidConfigException {
- // Make sure the specified configuration has the specified GBean
- try {
- ObjectName name = Configuration.getConfigurationObjectName(configID);
- Boolean result = (Boolean) kernel.invoke(name, "containsGBean", new Object[]{gbean}, new String[]{ObjectName.class.getName()});
- if(!result.booleanValue()) {
- throw new GBeanNotFoundException(gbean);
+ // add a dependency on the configuration
+ gbean.addDependency(configuration.getAbstractName());
+
+ // register the bean with the kernel
+ kernel.loadGBean(gbean, configurationClassLoader);
+
+ // start the configuration
+ if (start) {
+ try {
+ kernel.startRecursiveGBean(gbean.getName());
+ } catch (GBeanNotFoundException e) {
+ throw new InvalidConfigException("How could we not find a GBean that we just loaded ('" + gbean.getName() + "')?");
+ }
}
- } catch(GBeanNotFoundException e) {
+
+ configuration.addGBean(gbean);
+ } catch(InvalidConfigException e) {
throw e;
- } catch (Exception e) {
- throw new InvalidConfigException("Unable to add GBean to configuration", e);
+ } catch(Exception e) {
+ throw new InvalidConfigException("Cound not add GBean " + gbean.getName() + " to configuration " + configurationId, e);
+ } finally {
+ Thread.currentThread().setContextClassLoader(oldCl);
}
- // Stop and unload the GBean if necessary
+ if (attributeStore != null) {
+ attributeStore.addGBean(configurationId.toString(), gbean);
+ }
+ }
+
+ public void removeGBeanFromConfiguration(Artifact configurationId, AbstractName gbeanName) throws GBeanNotFoundException, InvalidConfigException {
+ Configuration configuration = getConfiguration(configurationId);
+ if (!configuration.containsGBean(gbeanName)) {
+ throw new GBeanNotFoundException(gbeanName);
+ }
+ configuration.removeGBean(gbeanName);
+
try {
- if (kernel.getGBeanState(gbean) == State.RUNNING_INDEX) {
- kernel.stopGBean(gbean);
+ if (kernel.getGBeanState(gbeanName) == State.RUNNING_INDEX) {
+ kernel.stopGBean(gbeanName);
}
- kernel.unloadGBean(gbean);
+ kernel.unloadGBean(gbeanName);
} catch (GBeanNotFoundException e) {
// Bean is no longer loaded
}
+ configuration.removeGBean(gbeanName);
+
// Make sure it's not loaded next time the configuration is loaded
- attributeStore.setShouldLoad(configID.toString(), gbean, false);
+ if (attributeStore != null) {
+ attributeStore.setShouldLoad(configurationId.toString(), gbeanName, false);
+ }
}
public static final GBeanInfo GBEAN_INFO;
Modified: geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/kernel/repository/ArtifactResolver.java
URL: http://svn.apache.org/viewcvs/geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/kernel/repository/ArtifactResolver.java?rev=384686&r1=384685&r2=384686&view=diff
==============================================================================
--- geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/kernel/repository/ArtifactResolver.java (original)
+++ geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/kernel/repository/ArtifactResolver.java Thu Mar 9 18:57:07 2006
@@ -23,9 +23,9 @@
* @version $Rev$ $Date$
*/
public interface ArtifactResolver {
- LinkedHashSet resolve(LinkedHashSet artifacts) throws MissingDependencyException;
+ LinkedHashSet resolve(Collection artifacts) throws MissingDependencyException;
- LinkedHashSet resolve(Collection parentConfigurations, LinkedHashSet artifacts) throws MissingDependencyException;
+ LinkedHashSet resolve(Collection parentConfigurations, Collection artifacts) throws MissingDependencyException;
Artifact resolve(Artifact artifact) throws MissingDependencyException;
Modified: geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/kernel/repository/DefaultArtifactResolver.java
URL: http://svn.apache.org/viewcvs/geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/kernel/repository/DefaultArtifactResolver.java?rev=384686&r1=384685&r2=384686&view=diff
==============================================================================
--- geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/kernel/repository/DefaultArtifactResolver.java (original)
+++ geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/kernel/repository/DefaultArtifactResolver.java Thu Mar 9 18:57:07 2006
@@ -44,11 +44,11 @@
this.repositories = repositories;
}
- public LinkedHashSet resolve(LinkedHashSet artifacts) throws MissingDependencyException {
+ public LinkedHashSet resolve(Collection artifacts) throws MissingDependencyException {
return this.resolve(Collections.EMPTY_SET, artifacts);
}
- public LinkedHashSet resolve(Collection parentConfigurations, LinkedHashSet artifacts) throws MissingDependencyException {
+ public LinkedHashSet resolve(Collection parentConfigurations, Collection artifacts) throws MissingDependencyException {
LinkedHashSet resolvedArtifacts = new LinkedHashSet();
for (Iterator iterator = artifacts.iterator(); iterator.hasNext();) {
Artifact artifact = (Artifact) iterator.next();
@@ -135,28 +135,26 @@
Environment environment = configuration.getEnvironment();
if (environment.isInverseClassLoading()) {
// Search dependencies of the configuration before searching the parents
- LinkedHashSet dependencies = environment.getDependencies();
- Version version = getArtifactVersion(dependencies, groupId, artifactId, type);
+ Version version = getArtifactVersion(configuration.getDependencies(), groupId, artifactId, type);
if (version != null) {
return version;
}
- // wasn't declared in the dependencies, so searcht the parents of the configuration
- version = searchParents(configuration.getParents(), groupId, artifactId, type);
+ // wasn't declared in the dependencies, so search the parents of the configuration
+ version = searchParents(configuration.getClassParents(), groupId, artifactId, type);
if (version != null) {
return version;
}
} else {
// Search the parents before the dependencies of the configuration
- Version version = searchParents(configuration.getParents(), groupId, artifactId, type);
+ Version version = searchParents(configuration.getClassParents(), groupId, artifactId, type);
if (version != null) {
return version;
}
// wasn't declared in a parent check the dependencies of the configuration
- LinkedHashSet dependencies = environment.getDependencies();
- version = getArtifactVersion(dependencies, groupId, artifactId, type);
+ version = getArtifactVersion(configuration.getDependencies(), groupId, artifactId, type);
if (version != null) {
return version;
}
@@ -165,7 +163,7 @@
return null;
}
- private Version getArtifactVersion(LinkedHashSet artifacts, String groupId, String artifactId, String type) {
+ private Version getArtifactVersion(Collection artifacts, String groupId, String artifactId, String type) {
for (Iterator iterator = artifacts.iterator(); iterator.hasNext();) {
Artifact artifact = (Artifact) iterator.next();
if (groupId.equals(artifact.getGroupId()) &&
Added: geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/kernel/repository/Dependency.java
URL: http://svn.apache.org/viewcvs/geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/kernel/repository/Dependency.java?rev=384686&view=auto
==============================================================================
--- geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/kernel/repository/Dependency.java (added)
+++ geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/kernel/repository/Dependency.java Thu Mar 9 18:57:07 2006
@@ -0,0 +1,60 @@
+/**
+ *
+ * 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.kernel.repository;
+
+import java.io.Serializable;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class Dependency implements Serializable {
+ private static final long serialVersionUID = -1940822102064150145L;
+ private final Artifact artifact;
+ private final ImportType importType;
+
+ public Dependency(Artifact artifact, ImportType importType) {
+ this.artifact = artifact;
+ this.importType = importType;
+ }
+
+ public Artifact getArtifact() {
+ return artifact;
+ }
+
+ public ImportType getImportType() {
+ return importType;
+ }
+
+ public boolean equals(Object o) {
+ if (this == o) return true;
+ if (o == null || getClass() != o.getClass()) return false;
+
+ final Dependency that = (Dependency) o;
+
+ if (artifact != null ? !artifact.equals(that.artifact) : that.artifact != null) return false;
+
+ return true;
+ }
+
+ public int hashCode() {
+ return (artifact != null ? artifact.hashCode() : 0);
+ }
+
+ public String toString() {
+ return "[" + importType + ": " + artifact + "]";
+ }
+}
Modified: geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/kernel/repository/Environment.java
URL: http://svn.apache.org/viewcvs/geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/kernel/repository/Environment.java?rev=384686&r1=384685&r2=384686&view=diff
==============================================================================
--- geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/kernel/repository/Environment.java (original)
+++ geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/kernel/repository/Environment.java Thu Mar 9 18:57:07 2006
@@ -24,6 +24,10 @@
import java.util.LinkedHashSet;
import java.util.Map;
import java.util.Set;
+import java.util.List;
+import java.util.Collections;
+import java.util.ArrayList;
+import java.util.Iterator;
/**
* holds the data from the EnvironmentType xml while it is being resolved, transitively closed, etc.
@@ -31,15 +35,13 @@
* @version $Rev:$ $Date:$
*/
public class Environment implements Serializable {
+ private static final long serialVersionUID = 7075760873629376317L;
private Artifact configId;
private final Map properties = new HashMap();
- private final LinkedHashSet imports = new LinkedHashSet();
- private final LinkedHashSet references = new LinkedHashSet();
private final LinkedHashSet dependencies = new LinkedHashSet();
- private final LinkedHashSet includes = new LinkedHashSet();
private final Set hiddenClasses = new HashSet();
private final Set nonOverrideableClasses = new HashSet();
@@ -52,10 +54,7 @@
public Environment(Environment environment) {
this.configId = environment.getConfigId();
- this.imports.addAll(environment.getImports());
- this.references.addAll(environment.getReferences());
- this.dependencies.addAll(environment.getDependencies());
- this.includes.addAll(environment.getIncludes());
+ this.dependencies.addAll(environment.dependencies);
this.hiddenClasses.addAll(environment.getHiddenClasses());
this.nonOverrideableClasses.addAll(environment.getNonOverrideableClasses());
this.inverseClassLoading = environment.isInverseClassLoading();
@@ -83,50 +82,24 @@
addProperties(properties);
}
- public LinkedHashSet getImports() {
- return imports;
+ public List getDependencies() {
+ return Collections.unmodifiableList(new ArrayList(dependencies));
}
- public void addImport(Artifact importArtifact) {
- this.imports.add(importArtifact);
+ public void addDependency(Artifact artifact, ImportType importType) {
+ this.dependencies.add(new Dependency(artifact, importType));
}
- public void addImports(Collection imports) {
- this.imports.addAll(imports);
- }
-
- public void setImports(Collection imports) {
- this.imports.clear();
- addImports(imports);
- }
-
- public LinkedHashSet getReferences() {
- return references;
- }
-
- public void addReference(Artifact reference) {
- this.references.add(reference);
- }
-
- public void addReferences(Collection references) {
- this.references.addAll(references);
- }
-
- public void setReferences(Collection references) {
- this.references.clear();
- addReferences(references);
- }
-
- public LinkedHashSet getDependencies() {
- return dependencies;
- }
-
- public void addDependency(Artifact dependency) {
+ public void addDependency(Dependency dependency) {
this.dependencies.add(dependency);
}
public void addDependencies(Collection dependencies) {
- this.dependencies.addAll(dependencies);
+ for (Iterator iterator = dependencies.iterator(); iterator.hasNext();) {
+ // make sure they are all dependency objects... generics would be sooooo nice
+ Dependency dependency = (Dependency) iterator.next();
+ addDependency(dependency);
+ }
}
public void setDependencies(Collection dependencies) {
@@ -134,23 +107,6 @@
addDependencies(dependencies);
}
- public LinkedHashSet getIncludes() {
- return includes;
- }
-
- public void addInclude(Artifact include) {
- this.includes.add(include);
- }
-
- public void addIncludes(Collection includes) {
- this.includes.addAll(includes);
- }
-
- public void setIncludes(Collection includes) {
- this.includes.clear();
- addIncludes(includes);
- }
-
public Set getHiddenClasses() {
return hiddenClasses;
}
@@ -192,4 +148,5 @@
public void setSuppressDefaultEnvironment(boolean suppressDefaultEnvironment) {
this.suppressDefaultEnvironment = suppressDefaultEnvironment;
}
+
}
Added: geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/kernel/repository/ImportType.java
URL: http://svn.apache.org/viewcvs/geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/kernel/repository/ImportType.java?rev=384686&view=auto
==============================================================================
--- geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/kernel/repository/ImportType.java (added)
+++ geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/kernel/repository/ImportType.java Thu Mar 9 18:57:07 2006
@@ -0,0 +1,56 @@
+/**
+ *
+ * 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.kernel.repository;
+
+import java.io.Serializable;
+import java.util.Map;
+import java.util.HashMap;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class ImportType implements Serializable {
+ private static final long serialVersionUID = 9084371394522950958L;
+
+ private static final Map typesByName = new HashMap();
+
+ // todo this class imples that there are only classes and services... is that true?
+ public static final ImportType ALL = new ImportType("ALL");
+ public static final ImportType CLASSES = new ImportType("CLASSES");
+ public static final ImportType SERVICES = new ImportType("SERVICES");
+
+ private final String name;
+
+ private ImportType(String name) {
+ this.name = name;
+ typesByName.put(name, this);
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public String toString() {
+ return name;
+ }
+
+ protected Object readResolve() {
+ ImportType type = (ImportType) typesByName.get(name);
+ if (type == null) throw new IllegalStateException("Unknown import type: " + name);
+ return type;
+ }
+}
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=384686&r1=384685&r2=384686&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 9 18:57:07 2006
@@ -17,6 +17,21 @@
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.HashMap;
+import java.util.Hashtable;
+import java.util.List;
+import java.util.Map;
+import javax.management.MalformedObjectNameException;
+import javax.management.ObjectName;
+
import junit.framework.TestCase;
import org.apache.geronimo.gbean.AbstractName;
import org.apache.geronimo.gbean.AbstractNameQuery;
@@ -25,34 +40,19 @@
import org.apache.geronimo.gbean.GBeanInfoBuilder;
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.ConfigurationManagerImpl;
import org.apache.geronimo.kernel.config.ConfigurationModuleType;
import org.apache.geronimo.kernel.config.ConfigurationStore;
import org.apache.geronimo.kernel.config.ConfigurationUtil;
+import org.apache.geronimo.kernel.config.EditableConfigurationManager;
import org.apache.geronimo.kernel.config.InvalidConfigException;
import org.apache.geronimo.kernel.config.NoSuchConfigException;
+import org.apache.geronimo.kernel.config.EditableConfigurationManagerImpl;
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.DefaultArtifactResolver;
import org.apache.geronimo.kernel.repository.Environment;
-import javax.management.MalformedObjectNameException;
-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.ArrayList;
-import java.util.HashMap;
-import java.util.Hashtable;
-import java.util.List;
-import java.util.Map;
-
/**
* @version $Rev$ $Date$
*/
@@ -61,7 +61,7 @@
private AbstractName gbeanName1;
private AbstractName gbeanName2;
private ConfigurationData configurationData;
- private ConfigurationManager configurationManager;
+ private EditableConfigurationManager configurationManager;
private final String BASE_NAME = "test:J2EEServer=geronimo";
public void testConfigLifecycle() throws Exception {
@@ -188,7 +188,7 @@
mockBean3.setAttribute("value", "1234");
mockBean3.setAttribute("name", "child");
mockBean3.setAttribute("finalInt", new Integer(1));
- configuration.addGBean(mockBean3, true);
+ configurationManager.addGBeanToConfiguration(configuration.getId(), mockBean3, true);
assertEquals(State.RUNNING_INDEX, kernel.getGBeanState(mockBean3.getAbstractName()));
assertEquals(new Integer(1), kernel.getAttribute(mockBean3.getAbstractName(), "finalInt"));
@@ -213,13 +213,13 @@
kernel.startGBean(artifactResolverData.getAbstractName());
assertEquals(State.RUNNING_INDEX, kernel.getGBeanState(artifactResolverData.getAbstractName()));
- GBeanData configurationManagerData = buildGBeanData(baseArtifact, new String[] {"module", "name"}, new String[] {"base", "BasicConfigurationManager"}, ConfigurationManagerImpl.GBEAN_INFO);
+ GBeanData configurationManagerData = buildGBeanData(baseArtifact, new String[] {"module", "name"}, new String[] {"base", "BasicConfigurationManager"}, EditableConfigurationManagerImpl.GBEAN_INFO);
configurationManagerData.setReferencePattern("ArtifactManager", artifactManagerData.getAbstractName());
configurationManagerData.setReferencePattern("ArtifactResolver", artifactResolverData.getAbstractName());
kernel.loadGBean(configurationManagerData, getClass().getClassLoader());
kernel.startGBean(configurationManagerData.getAbstractName());
- configurationManager = ConfigurationUtil.getConfigurationManager(kernel);
+ configurationManager = ConfigurationUtil.getEditableConfigurationManager(kernel);
Environment environment = new Environment();
environment.setConfigId(new Artifact("geronimo", "test", "1", "car"));
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=384686&r1=384685&r2=384686&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 9 18:57:07 2006
@@ -40,6 +40,7 @@
import org.apache.geronimo.kernel.repository.ArtifactManager;
import org.apache.geronimo.kernel.repository.Version;
import org.apache.geronimo.kernel.repository.ListableRepository;
+import org.apache.geronimo.kernel.repository.ImportType;
import org.apache.geronimo.kernel.KernelFactory;
import org.apache.geronimo.kernel.Kernel;
import org.apache.geronimo.kernel.management.State;
@@ -96,14 +97,14 @@
Environment e2 = new Environment();
e2.setConfigId(artifact2);
- e2.addImport(new Artifact("test", "1", (Version) null, "bar"));
+ e2.addDependency(new Artifact("test", "1", (Version) null, "bar"), ImportType.ALL);
GBeanData gbeanData2 = new GBeanData(Configuration.getConfigurationAbstractName(artifact2), Configuration.GBEAN_INFO);
gbeanData2.setAttribute("environment", e2);
configurations.put(artifact2, gbeanData2);
Environment e3 = new Environment();
e3.setConfigId(artifact3);
- e3.addImport(new Artifact("test", "2", (Version) null, "bar"));
+ e3.addDependency(new Artifact("test", "2", (Version) null, "bar"), ImportType.ALL);
GBeanData gbeanData3 = new GBeanData(Configuration.getConfigurationAbstractName(artifact3), Configuration.GBEAN_INFO);
gbeanData3.setAttribute("environment", e3);
configurations.put(artifact3, gbeanData3);
Modified: geronimo/branches/1.1/modules/kernel/src/test/org/apache/geronimo/kernel/repository/ArtifactResolverTest.java
URL: http://svn.apache.org/viewcvs/geronimo/branches/1.1/modules/kernel/src/test/org/apache/geronimo/kernel/repository/ArtifactResolverTest.java?rev=384686&r1=384685&r2=384686&view=diff
==============================================================================
--- geronimo/branches/1.1/modules/kernel/src/test/org/apache/geronimo/kernel/repository/ArtifactResolverTest.java (original)
+++ geronimo/branches/1.1/modules/kernel/src/test/org/apache/geronimo/kernel/repository/ArtifactResolverTest.java Thu Mar 9 18:57:07 2006
@@ -89,9 +89,8 @@
// create parent which uses version1 explicitly
Environment environment = new Environment();
environment.setConfigId(loader);
- environment.addDependency(version1);
+ environment.addDependency(version1, ImportType.CLASSES);
Configuration parent = new Configuration(null,
- null,
Configuration.getConfigurationObjectName(loader).getCanonicalName(),
ConfigurationModuleType.SERVICE,
environment,
Modified: geronimo/branches/1.1/modules/service-builder/src/java/org/apache/geronimo/deployment/service/EnvironmentBuilder.java
URL: http://svn.apache.org/viewcvs/geronimo/branches/1.1/modules/service-builder/src/java/org/apache/geronimo/deployment/service/EnvironmentBuilder.java?rev=384686&r1=384685&r2=384686&view=diff
==============================================================================
--- geronimo/branches/1.1/modules/service-builder/src/java/org/apache/geronimo/deployment/service/EnvironmentBuilder.java (original)
+++ geronimo/branches/1.1/modules/service-builder/src/java/org/apache/geronimo/deployment/service/EnvironmentBuilder.java Thu Mar 9 18:57:07 2006
@@ -28,6 +28,7 @@
import org.apache.geronimo.deployment.xbeans.PropertyType;
import org.apache.geronimo.kernel.repository.Artifact;
import org.apache.geronimo.kernel.repository.Environment;
+import org.apache.geronimo.kernel.repository.Dependency;
import org.apache.xmlbeans.XmlException;
import org.apache.xmlbeans.XmlObject;
import org.apache.xmlbeans.XmlOptions;
@@ -70,29 +71,8 @@
if (environmentType.isSetDependencies()) {
ArtifactType[] dependencyArray = environmentType.getDependencies().getDependencyArray();
- Collection dependencies = new LinkedHashSet();
- Collection imports = new LinkedHashSet();
- Collection references = new LinkedHashSet();
- for (int i = 0; i < dependencyArray.length; i++) {
- ArtifactType artifactType = dependencyArray[i];
- Artifact artifact = toArtifact(artifactType);
- String type = artifact.getType();
- if (type.equals("jar")) {
- dependencies.add(artifact);
- } else if (type.equals("car")) {
- if ("classes".equals(artifactType.getImport())) {
- throw new IllegalArgumentException("classes-only dependency on car files not yet supported");
- } else if ("services".equals(artifactType.getImport())) {
- references.add(artifact);
- } else {
- imports.add(artifact);
- }
- }
- }
- environment.setImports(imports);
+ LinkedHashSet dependencies = toDependencies(dependencyArray);
environment.setDependencies(dependencies);
- environment.setReferences(references);
-
}
environment.setInverseClassLoading(environmentType.isSetInverseClassloading());
environment.setSuppressDefaultEnvironment(environmentType.isSetSuppressDefaultEnvironment());
@@ -109,15 +89,12 @@
if (environment.getConfigId() == null){
environment.setConfigId(additionalEnvironment.getConfigId());
}
- environment.addProperties(additionalEnvironment.getProperties());
- environment.addImports(additionalEnvironment.getImports());
environment.addDependencies(additionalEnvironment.getDependencies());
- environment.addIncludes(additionalEnvironment.getIncludes());
+ environment.addProperties(additionalEnvironment.getProperties());
environment.setInverseClassLoading(environment.isInverseClassLoading() || additionalEnvironment.isInverseClassLoading());
environment.setSuppressDefaultEnvironment(environment.isSuppressDefaultEnvironment() || additionalEnvironment.isSuppressDefaultEnvironment());
environment.addHiddenClasses(additionalEnvironment.getHiddenClasses());
environment.addNonOverrideableClasses(additionalEnvironment.getNonOverrideableClasses());
- environment.addReferences(additionalEnvironment.getReferences());
}
}
@@ -129,7 +106,7 @@
public static EnvironmentType buildEnvironmentType(Environment environment) {
EnvironmentType environmentType = EnvironmentType.Factory.newInstance();
- ArtifactType configId = toArtifactType(environment.getConfigId(), null);
+ ArtifactType configId = toArtifactType(environment.getConfigId());
environmentType.setConfigId(configId);
if (environment.getProperties().size() >0) {
@@ -143,11 +120,7 @@
propertyType.setValue(value);
}
}
- List dependencies = new ArrayList();
- toArtifactTypes(environment.getImports(), null, dependencies);
-// toArtifactTypes(environment.getIncludes(), null, dependencies));
- toArtifactTypes(environment.getDependencies(), null, dependencies);
- toArtifactTypes(environment.getReferences(), ImportType.SERVICES, dependencies);
+ List dependencies = toArtifactTypes(environment.getDependencies());
ArtifactType[] artifactTypes = (ArtifactType[]) dependencies.toArray(new ArtifactType[dependencies.size()]);
DependenciesType dependenciesType = environmentType.addNewDependencies();
dependenciesType.setDependencyArray(artifactTypes);
@@ -169,15 +142,17 @@
return classFilter;
}
- private static void toArtifactTypes(Collection artifacts, ImportType.Enum importType, List dependencies) {
+ private static List toArtifactTypes(Collection artifacts) {
+ List dependencies = new ArrayList();
for (Iterator iterator = artifacts.iterator(); iterator.hasNext();) {
- Artifact artifact = (Artifact) iterator.next();
- ArtifactType artifactType = toArtifactType(artifact, importType);
+ Dependency dependency = (Dependency) iterator.next();
+ ArtifactType artifactType = toArtifactType(dependency);
dependencies.add(artifactType);
}
+ return dependencies;
}
- private static ArtifactType toArtifactType(Artifact artifact, ImportType.Enum importType) {
+ private static ArtifactType toArtifactType(Artifact artifact) {
ArtifactType artifactType = ArtifactType.Factory.newInstance();
if (artifact.getGroupId() != null) {
artifactType.setGroupId(artifact.getGroupId());
@@ -191,9 +166,19 @@
if (artifact.getType() != null) {
artifactType.setType(artifact.getType());
}
- if (importType != null) {
- artifactType.setImport(importType);
+ return artifactType;
+ }
+
+ private static ArtifactType toArtifactType(Dependency dependency) {
+ ArtifactType artifactType = toArtifactType(dependency.getArtifact());
+
+ org.apache.geronimo.kernel.repository.ImportType importType = dependency.getImportType();
+ if (importType == org.apache.geronimo.kernel.repository.ImportType.CLASSES) {
+ artifactType.setImport(ImportType.CLASSES);
+ } else if (importType == org.apache.geronimo.kernel.repository.ImportType.SERVICES) {
+ artifactType.setImport(ImportType.SERVICES);
}
+
return artifactType;
}
@@ -220,6 +205,29 @@
return artifacts;
}
+ private static LinkedHashSet toDependencies(ArtifactType[] dependencyArray) {
+ LinkedHashSet dependencies = new LinkedHashSet();
+ for (int i = 0; i < dependencyArray.length; i++) {
+ ArtifactType artifactType = dependencyArray[i];
+ Dependency dependency = toDependency(artifactType);
+ dependencies.add(dependency);
+ }
+ return dependencies;
+ }
+
+ private static Dependency toDependency(ArtifactType artifactType) {
+ Artifact artifact = toArtifact(artifactType);
+ if (ImportType.CLASSES.equals(artifactType.getImport())) {
+ return new Dependency(artifact, org.apache.geronimo.kernel.repository.ImportType.CLASSES);
+ } else if (ImportType.SERVICES.equals(artifactType.getImport())) {
+ return new Dependency(artifact, org.apache.geronimo.kernel.repository.ImportType.SERVICES);
+ } else if (artifactType.getImport() == null) {
+ return new Dependency(artifact, org.apache.geronimo.kernel.repository.ImportType.ALL);
+ } else {
+ throw new IllegalArgumentException("Unknown import type: " + artifactType.getImport());
+ }
+ }
+
//TODO make private
static Artifact toArtifact(ArtifactType artifactType) {
String groupId = artifactType.isSetGroupId() ? artifactType.getGroupId().trim() : null;
Modified: geronimo/branches/1.1/modules/service-builder/src/java/org/apache/geronimo/deployment/service/ServiceConfigBuilder.java
URL: http://svn.apache.org/viewcvs/geronimo/branches/1.1/modules/service-builder/src/java/org/apache/geronimo/deployment/service/ServiceConfigBuilder.java?rev=384686&r1=384685&r2=384686&view=diff
==============================================================================
--- geronimo/branches/1.1/modules/service-builder/src/java/org/apache/geronimo/deployment/service/ServiceConfigBuilder.java (original)
+++ geronimo/branches/1.1/modules/service-builder/src/java/org/apache/geronimo/deployment/service/ServiceConfigBuilder.java Thu Mar 9 18:57:07 2006
@@ -56,6 +56,7 @@
import java.util.Collection;
import java.util.HashMap;
import java.util.Map;
+import java.util.Collections;
import java.util.jar.JarFile;
/**
@@ -163,8 +164,8 @@
} catch (ConfigurationAlreadyExistsException e) {
throw new DeploymentException(e);
}
- DeploymentContext context = new DeploymentContext(outfile, environment, ConfigurationModuleType.SERVICE, kernel);
- ClassLoader cl = context.getClassLoader(repository);
+ DeploymentContext context = new DeploymentContext(outfile, environment, ConfigurationModuleType.SERVICE, Collections.singleton(repository), kernel);
+ ClassLoader cl = context.getClassLoader();
AbstractName moduleName;
Modified: geronimo/branches/1.1/modules/service-builder/src/test/org/apache/geronimo/deployment/service/ServiceConfigBuilderTest.java
URL: http://svn.apache.org/viewcvs/geronimo/branches/1.1/modules/service-builder/src/test/org/apache/geronimo/deployment/service/ServiceConfigBuilderTest.java?rev=384686&r1=384685&r2=384686&view=diff
==============================================================================
--- geronimo/branches/1.1/modules/service-builder/src/test/org/apache/geronimo/deployment/service/ServiceConfigBuilderTest.java (original)
+++ geronimo/branches/1.1/modules/service-builder/src/test/org/apache/geronimo/deployment/service/ServiceConfigBuilderTest.java Thu Mar 9 18:57:07 2006
@@ -61,7 +61,7 @@
try {
Environment environment = EnvironmentBuilder.buildEnvironment(plan.getEnvironment());
- DeploymentContext context = new DeploymentContext(outFile, environment, ConfigurationModuleType.SERVICE, null);
+ DeploymentContext context = new DeploymentContext(outFile, environment, ConfigurationModuleType.SERVICE, null, null);
AbstractName j2eeContext = NameFactory.buildModuleName(environment.getProperties(), environment.getConfigId(), ConfigurationModuleType.SERVICE, null);
// new J2eeContextImpl("domain", "server", "null", "test", "configtest", "foo", NameFactory.J2EE_MODULE);
GbeanType[] gbeans = plan.getGbeanArray();
Modified: geronimo/branches/1.1/modules/system/src/java/org/apache/geronimo/system/configuration/RepositoryConfigurationStore.java
URL: http://svn.apache.org/viewcvs/geronimo/branches/1.1/modules/system/src/java/org/apache/geronimo/system/configuration/RepositoryConfigurationStore.java?rev=384686&r1=384685&r2=384686&view=diff
==============================================================================
--- geronimo/branches/1.1/modules/system/src/java/org/apache/geronimo/system/configuration/RepositoryConfigurationStore.java (original)
+++ geronimo/branches/1.1/modules/system/src/java/org/apache/geronimo/system/configuration/RepositoryConfigurationStore.java Thu Mar 9 18:57:07 2006
@@ -61,7 +61,7 @@
public class RepositoryConfigurationStore implements ConfigurationStore {
private final Kernel kernel;
private final ObjectName objectName;
- private final WritableListableRepository repository;
+ protected final WritableListableRepository repository;
public RepositoryConfigurationStore(WritableListableRepository repository) {
this(null, null, repository);
@@ -105,9 +105,10 @@
}
} else {
JarFile jarFile = new JarFile(location);
- ZipEntry entry = jarFile.getEntry("META-INF/config.ser");
- InputStream in = jarFile.getInputStream(entry);
+ InputStream in = null;
try {
+ ZipEntry entry = jarFile.getEntry("META-INF/config.ser");
+ in = jarFile.getInputStream(entry);
ObjectInputStream ois = new ObjectInputStream(in);
config.readExternal(ois);
} finally {
@@ -125,10 +126,22 @@
public boolean containsConfiguration(Artifact configId) {
File location = repository.getLocation(configId);
- location = new File(location, "META-INF");
- location = new File(location, "config.ser");
-
- return location.isFile() && location.canRead();
+ if (location.isDirectory()) {
+ location = new File(location, "META-INF");
+ location = new File(location, "config.ser");
+ return location.isFile() && location.canRead();
+ } else {
+ JarFile jarFile = null;
+ try {
+ jarFile = new JarFile(location);
+ ZipEntry entry = jarFile.getEntry("META-INF/config.ser");
+ return entry != null && !entry.isDirectory();
+ } catch (IOException e) {
+ return false;
+ } finally {
+ IOUtil.close(jarFile);
+ }
+ }
}
public File createNewConfigurationDir(Artifact configId) throws ConfigurationAlreadyExistsException {
@@ -145,9 +158,14 @@
public URL resolve(Artifact configId, URI uri) throws NoSuchConfigException, MalformedURLException {
File location = repository.getLocation(configId);
- URL locationUrl = location.toURL();
- URL resolvedUrl = new URL(locationUrl, uri.toString());
- return resolvedUrl;
+ if (location.isDirectory()) {
+ URL locationUrl = location.toURL();
+ URL resolvedUrl = new URL(locationUrl, uri.toString());
+ return resolvedUrl;
+ } else {
+ URL baseURL = new URL("jar:" + repository.getLocation(configId).toURL().toString() + "!/");
+ return new URL(baseURL, uri.toString());
+ }
}
public void install(InputStream in, Artifact configId, FileWriteMonitor fileWriteMonitor) throws IOException {
Modified: geronimo/branches/1.1/modules/tomcat-builder/src/java/org/apache/geronimo/tomcat/deployment/TomcatModuleBuilder.java
URL: http://svn.apache.org/viewcvs/geronimo/branches/1.1/modules/tomcat-builder/src/java/org/apache/geronimo/tomcat/deployment/TomcatModuleBuilder.java?rev=384686&r1=384685&r2=384686&view=diff
==============================================================================
--- geronimo/branches/1.1/modules/tomcat-builder/src/java/org/apache/geronimo/tomcat/deployment/TomcatModuleBuilder.java (original)
+++ geronimo/branches/1.1/modules/tomcat-builder/src/java/org/apache/geronimo/tomcat/deployment/TomcatModuleBuilder.java Thu Mar 9 18:57:07 2006
@@ -267,9 +267,9 @@
EARContext moduleContext = module.getEarContext();
Configuration knownParent = null;
if (!module.isStandAlone()) {
- knownParent = earContext.getConfiguration(repository, null);
+ knownParent = earContext.getConfiguration(null);
}
- ClassLoader moduleClassLoader = moduleContext.getClassLoader(repository, knownParent);
+ ClassLoader moduleClassLoader = moduleContext.getClassLoader(knownParent);
J2eeContext earJ2eeContext = moduleContext.getModuleName();
J2eeContext moduleJ2eeContext = J2eeContextImpl.newModuleContextFromApplication(earJ2eeContext, NameFactory.WEB_MODULE, module.getName());
WebModule webModule = (WebModule) module;
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=384686&r1=384685&r2=384686&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 9 18:57:07 2006
@@ -190,7 +190,7 @@
ObjectName serverName = earContext.getServerObjectName();
GBeanData server = new GBeanData(serverName, J2EEServerImpl.GBEAN_INFO);
start(server);
- builder.installModule(jarFile, earContext, module, new MockConfigStore());
+ builder.installModule(jarFile, earContext, module, new MockConfigStore(), null);
builder.initContext(earContext, module, cl);
builder.addGBeans(earContext, module, cl, null);
earContext.close();
@@ -222,12 +222,20 @@
configurationManager.unloadConfiguration(configuration);
}
- private EARContext createEARContext(File outputPath, Environment environment)
- throws MalformedObjectNameException, DeploymentException {
- EARContext earContext = new EARContext(outputPath, environment,
- ConfigurationModuleType.WAR, kernel, moduleContext
- .getJ2eeApplicationName(), tcmName, ctcName, null,
- null, null, new RefContext(new EJBReferenceBuilder() {
+ private EARContext createEARContext(File outputPath, Environment environment) throws MalformedObjectNameException, DeploymentException {
+ EARContext earContext = new EARContext(
+ outputPath,
+ environment,
+ ConfigurationModuleType.WAR,
+ null,
+ kernel,
+ moduleContext.getJ2eeApplicationName(),
+ tcmName,
+ ctcName,
+ null,
+ null,
+ null,
+ new RefContext(new EJBReferenceBuilder() {
public Reference createEJBLocalReference(String objectName,
GBeanData gbeanData, boolean isSession, String localHome, String local)
|