You are viewing a plain text version of this content. The canonical link for it is here.
Posted to scm@geronimo.apache.org by da...@apache.org on 2006/03/12 02:34:07 UTC
svn commit: r385232 [2/2] - in /geronimo/branches/1.1/modules:
axis-builder/src/test/org/apache/geronimo/axis/builder/
client-builder/src/java/org/apache/geronimo/client/builder/
connector-builder/src/test/org/apache/geronimo/connector/deployment/ depl...
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=385232&r1=385231&r2=385232&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 Sat Mar 11 17:34:04 2006
@@ -29,7 +29,9 @@
import java.util.ListIterator;
import java.util.Map;
import java.util.Set;
-import javax.management.MalformedObjectNameException;
+import java.util.HashSet;
+import java.net.URL;
+import java.net.URI;
import javax.management.ObjectName;
import org.apache.commons.logging.Log;
@@ -40,6 +42,9 @@
import org.apache.geronimo.gbean.GBeanInfoBuilder;
import org.apache.geronimo.gbean.GBeanLifecycle;
import org.apache.geronimo.gbean.InvalidConfigurationException;
+import org.apache.geronimo.gbean.GReferenceInfo;
+import org.apache.geronimo.gbean.ReferencePatterns;
+import org.apache.geronimo.gbean.GAttributeInfo;
import org.apache.geronimo.kernel.GBeanAlreadyExistsException;
import org.apache.geronimo.kernel.GBeanNotFoundException;
import org.apache.geronimo.kernel.InternalKernelException;
@@ -54,13 +59,14 @@
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;
/**
* The standard non-editable ConfigurationManager implementation. That is,
* you can save a lost configurations and stuff, but not change the set of
* GBeans included in a configuration.
*
- * @version $Rev$ $Date$
+ * @version $Rev: 384999 $ $Date$
* @see EditableConfigurationManager
*/
public class ConfigurationManagerImpl implements ConfigurationManager, GBeanLifecycle {
@@ -75,26 +81,30 @@
private final ArtifactResolver artifactResolver;
private final ClassLoader classLoader;
private final Map configurations = new LinkedHashMap();
+ private final Collection repositories;
public ConfigurationManagerImpl(Kernel kernel,
- Collection stores,
- ManageableAttributeStore attributeStore,
- PersistentConfigurationList configurationList,
- ArtifactManager artifactManager,
- ArtifactResolver artifactResolver,
- ClassLoader classLoader) {
+ Collection stores,
+ ManageableAttributeStore attributeStore,
+ PersistentConfigurationList configurationList,
+ ArtifactManager artifactManager,
+ ArtifactResolver artifactResolver,
+ Collection repositories,
+ ClassLoader classLoader) {
if (kernel == null) throw new NullPointerException("kernel is null");
+ if (stores == null) stores = Collections.EMPTY_SET;
if (classLoader == null) throw new NullPointerException("classLoader is null");
+ if (artifactResolver == null) artifactResolver = new DefaultArtifactResolver(artifactManager, repositories);
+ if (repositories == null) repositories = Collections.EMPTY_SET;
this.kernel = kernel;
this.stores = stores;
this.attributeStore = attributeStore;
this.configurationList = configurationList;
- if (artifactResolver == null)
- artifactResolver = new DefaultArtifactResolver(artifactManager, Collections.EMPTY_SET);
this.artifactManager = artifactManager;
this.artifactResolver = artifactResolver;
+ this.repositories = repositories;
this.classLoader = classLoader;
shutdownHook = new ShutdownHook(kernel);
}
@@ -147,7 +157,7 @@
configurationStatus.load();
return configurationStatus.getConfiguration();
} else if (kernel.isLoaded(Configuration.getConfigurationObjectName(configurationId))) {
- // hack
+ // todo hack for bootstrap deploy
Configuration configuration = (Configuration) kernel.getProxyManager().createProxy(Configuration.getConfigurationObjectName(configurationId), Configuration.class);
configurationStatus = createConfigurationStatus(configuration);
configurationStatus.load();
@@ -167,13 +177,8 @@
}
public Configuration loadConfiguration(ConfigurationData configurationData, ConfigurationStore configurationStore) throws NoSuchConfigException, IOException, InvalidConfigException {
- try {
- GBeanData gbeanData = ConfigurationUtil.toConfigurationGBeanData(configurationData, configurationStore);
-
- return loadConfiguration(gbeanData);
- } catch (MalformedObjectNameException e) {
- throw new InvalidConfigException(e);
- }
+ GBeanData gbeanData = ConfigurationUtil.toConfigurationGBeanData(configurationData, configurationStore, repositories, artifactResolver);
+ return loadConfiguration(gbeanData);
}
private Configuration loadConfiguration(GBeanData gbeanData) throws NoSuchConfigException, IOException, InvalidConfigException {
@@ -216,6 +221,12 @@
// create a proxy to the configuration
configuration = (Configuration) kernel.getProxyManager().createProxy(configurationName, Configuration.class);
loadedConfigurations.put(configurationId, configuration);
+
+ // declare the dependencies as loaded
+ if (artifactManager != null) {
+ artifactManager.loadArtifacts(configurationId, configuration.getDependencies());
+ }
+
log.debug("Loaded Configuration " + configurationName);
} catch (InvalidConfigurationException e) {
throw e;
@@ -227,8 +238,8 @@
throw new InvalidConfigException("Error starting configuration gbean " + configurationId, e);
}
- // todo move this to startConfiguration when deployment code has been update to not search kernel
- registerGBeans(configuration);
+// // todo move this to startConfiguration when deployment code has been update to not search kernel
+// registerGBeans(configuration);
}
} catch (Exception e) {
for (Iterator iterator = loadedConfigurations.keySet().iterator(); iterator.hasNext();) {
@@ -323,10 +334,12 @@
ConfigurationStore store = (ConfigurationStore) storeSnapshot.get(i);
if (store.containsConfiguration(configId)) {
GBeanData configurationGBean = store.loadConfiguration(configId);
-
AbstractName configurationName = Configuration.getConfigurationAbstractName(configId);
configurationGBean.setAbstractName(configurationName);
- configurationGBean.setAttribute("configurationStore", store);
+
+ Environment environment = (Environment) configurationGBean.getAttribute("environment");
+ ConfigurationResolver configurationResolver = new ConfigurationResolver(environment.getConfigId(), store, repositories, artifactResolver);
+ configurationGBean.setAttribute("configurationResolver", configurationResolver);
return configurationGBean;
}
@@ -335,11 +348,6 @@
}
private void preprocessConfiguration(GBeanData gbeanData) throws MissingDependencyException, InvalidConfigException {
- if (artifactManager != null) {
- gbeanData.setAttribute("artifactManager", artifactManager);
- }
- gbeanData.setAttribute("artifactResolver", artifactResolver);
-
Environment environment = (Environment) gbeanData.getAttribute("environment");
LinkedHashSet parentNames = new LinkedHashSet();
@@ -401,51 +409,15 @@
gbeans = attributeStore.applyOverrides(getConfigurationId(configuration), gbeans, configuration.getConfigurationClassLoader());
}
-// List ancestors = new ArrayList();
-// resolveAncestors(configuration, ancestors);
-
// register all the GBeans
-// AbstractName configurationName = Configuration.getConfigurationAbstractName(configuration.getId());
-// ConfigurationStore configurationStore = configuration.getConfigurationStore();
for (Iterator iterator = gbeans.iterator(); iterator.hasNext();) {
GBeanData gbeanData = (GBeanData) iterator.next();
-// // copy the gbeanData object as not to mutate the original
-// gbeanData = new GBeanData(gbeanData);
-//
-// for (Iterator references = gbeanData.getReferencesNames().iterator(); references.hasNext();) {
-// String referenceName = (String) references.next();
-// GReferenceInfo referenceInfo = gbeanData.getGBeanInfo().getReference(referenceName);
-// if (referenceInfo == null) {
-// throw new InvalidConfigException("No reference named " + referenceName + " in gbean " + gbeanData.getAbstractName());
-// }
-// boolean isSingleValued = !referenceInfo.getProxyType().equals(Collection.class.getName());
-// if (isSingleValued) {
-// ReferencePatterns referencePatterns = gbeanData.getReferencePatterns(referenceName);
-// ReferencePatterns resolvedPatterns = resolveReferencePatterns(referencePatterns, ancestors);
-// gbeanData.setReferencePatterns(referenceName, resolvedPatterns);
-// }
-// }
-//
-// Set newDependencies = new HashSet();
-// for (Iterator dependencies = gbeanData.getDependencies().iterator(); dependencies.hasNext();) {
-// ReferencePatterns referencePatterns = (ReferencePatterns) dependencies.next();
-// ReferencePatterns resolvedPatterns = resolveReferencePatterns(referencePatterns, ancestors);
-// newDependencies.add(resolvedPatterns);
-// }
-// gbeanData.setDependencies(newDependencies);
-//
-// // If the GBean has a configurationBaseUrl attribute, set it
-// // todo remove this when web app cl are config. cl.
-// GAttributeInfo attribute = gbeanData.getGBeanInfo().getAttribute("configurationBaseUrl");
-// if (attribute != null && attribute.getType().equals("java.net.URL")) {
-// URL baseURL = configurationStore.resolve(getConfigurationId(configuration), URI.create(""));
-// gbeanData.setAttribute("configurationBaseUrl", baseURL);
-// }
-//
-// // add a dependency from the gbean to the configuration
-// gbeanData.addDependency(configurationName);
+ // copy the gbeanData object as not to mutate the original
+ gbeanData = new GBeanData(gbeanData);
+ // preprocess the gbeanData (resolve references, set base url, declare dependency, etc.)
+ preprocessGBeanData(configuration, gbeanData);
log.trace("Registering GBean " + gbeanData.getName());
try {
@@ -456,60 +428,54 @@
}
}
-// private ReferencePatterns resolveReferencePatterns(ReferencePatterns referencePatterns, List ancestors) throws InvalidConfigException {
-// ReferencePatterns result = null;
-// boolean first = true;
-// for (Iterator iterator = ancestors.iterator(); iterator.hasNext();) {
-// Configuration configuration = (Configuration) iterator.next();
-// ReferencePatterns match = resolve(referencePatterns, configuration);
-// if (first && match != null) {
-// return match;
-// }
-// first = false;
-// if (result != null) {
-// throw new InvalidConfigException("More than one match for referencePatterns " + referencePatterns);
-// }
-// result = match;
-// }
-// if (result == null) {
-// throw new InvalidConfigException("No matches for referencePatterns: " + referencePatterns);
-// }
-// return result;
-// }
-//
-// private ReferencePatterns resolve(ReferencePatterns referencePatterns, Configuration configuration) throws InvalidConfigException {
-// if (referencePatterns.getAbstractName() != null) {
-// //this should not occur, but it means no further resolution is needed
-// return referencePatterns;
-// }
-// ReferencePatterns result = null;
-// Set gbeanNames = configuration.getGBeans().keySet();
-// for (Iterator abstractNameQueries = referencePatterns.getPatterns().iterator(); abstractNameQueries.hasNext();) {
-// AbstractNameQuery abstractNameQuery = (AbstractNameQuery) abstractNameQueries.next();
-// Artifact queryArtifact = abstractNameQuery.getArtifact();
-// //skip this configuration if we know it can't match.
-// if (queryArtifact == null || queryArtifact.matches(configuration.getId())) {
-// for (Iterator iterator = gbeanNames.iterator(); iterator.hasNext();) {
-// AbstractName abstractName = (AbstractName) iterator.next();
-// if (abstractNameQuery.matches(abstractName)) {
-// if (result != null ) {
-// throw new InvalidConfigException("More than one match to referencePatterns " + referencePatterns + " in configuration " + configuration.getId());
-// }
-// result = new ReferencePatterns(abstractName);
-// }
-// }
-// }
-// }
-// return result;
-// }
-//
-// private void resolveAncestors(Configuration configuration, List ancestors) {
-// ancestors.add(configuration);
-// for (Iterator parents = configuration.getServiceParents().iterator(); parents.hasNext();) {
-// Configuration parent = (Configuration) parents.next();
-// resolveAncestors(parent, ancestors);
-// }
-// }
+ protected static void preprocessGBeanData(Configuration configuration, GBeanData gbeanData) throws InvalidConfigException {
+ for (Iterator references = gbeanData.getReferencesNames().iterator(); references.hasNext();) {
+ String referenceName = (String) references.next();
+ GReferenceInfo referenceInfo = gbeanData.getGBeanInfo().getReference(referenceName);
+ if (referenceInfo == null) {
+ throw new InvalidConfigException("No reference named " + referenceName + " in gbean " + gbeanData.getAbstractName());
+ }
+ boolean isSingleValued = !referenceInfo.getProxyType().equals(Collection.class.getName());
+ if (isSingleValued) {
+ ReferencePatterns referencePatterns = gbeanData.getReferencePatterns(referenceName);
+ AbstractName abstractName = null;
+ try {
+ abstractName = configuration.findGBean(referencePatterns);
+ } catch (GBeanNotFoundException e) {
+ throw new InvalidConfigException("Unable to resolve reference named " + referenceName + " in gbean " + gbeanData.getAbstractName(), e);
+ }
+ gbeanData.setReferencePatterns(referenceName, new ReferencePatterns(abstractName));
+ }
+ }
+
+ Set newDependencies = new HashSet();
+ for (Iterator dependencyIterator = gbeanData.getDependencies().iterator(); dependencyIterator.hasNext();) {
+ ReferencePatterns referencePatterns = (ReferencePatterns) dependencyIterator.next();
+ AbstractName abstractName = null;
+ try {
+ abstractName = configuration.findGBean(referencePatterns);
+ } catch (GBeanNotFoundException e) {
+ throw new InvalidConfigException("Unable to resolve dependency in gbean " + gbeanData.getAbstractName(), e);
+ }
+ newDependencies.add(new ReferencePatterns(abstractName));
+ }
+ gbeanData.setDependencies(newDependencies);
+
+ // If the GBean has a configurationBaseUrl attribute, set it
+ // todo remove this when web app cl are config. cl.
+ GAttributeInfo attribute = gbeanData.getGBeanInfo().getAttribute("configurationBaseUrl");
+ if (attribute != null && attribute.getType().equals("java.net.URL")) {
+ try {
+ URL baseURL = configuration.getConfigurationResolver().resolve(URI.create(""));
+ gbeanData.setAttribute("configurationBaseUrl", baseURL);
+ } catch (Exception e) {
+ throw new InvalidConfigException("Unable to set attribute named " + "configurationBaseUrl" + " in gbean " + gbeanData.getAbstractName(), e);
+ }
+ }
+
+ // add a dependency from the gbean to the configuration
+ gbeanData.addDependency(configuration.getAbstractName());
+ }
public void startConfiguration(Configuration configuration) throws InvalidConfigException {
startConfiguration(getConfigurationId(configuration));
@@ -527,12 +493,12 @@
Configuration configuration = (Configuration) iterator.next();
start(configuration);
}
-// // todo clean up after failure
+ // todo clean up after failure
}
public void start(Configuration configuration) throws InvalidConfigException {
// todo move this from loadConfiguration when deployment code has been update to not search kernel
- // registerGBeans(configuration);
+ registerGBeans(configuration);
try {
// start the gbeans
@@ -589,6 +555,12 @@
AbstractName gbeanName = gbeanData.getAbstractName();
kernel.stopGBean(gbeanName);
}
+
+ for (Iterator iterator = gbeans.iterator(); iterator.hasNext();) {
+ GBeanData gbeanData = (GBeanData) iterator.next();
+ AbstractName gbeanName = gbeanData.getAbstractName();
+ kernel.unloadGBean(gbeanName);
+ }
} catch (Exception e) {
throw new InvalidConfigException("Could not stop gbeans in configuration", e);
}
@@ -625,22 +597,27 @@
}
try {
if (State.RUNNING_INDEX == kernel.getGBeanState(configName)) {
- try {
- Map gbeans = (Map) kernel.getAttribute(configName, "GBeans");
-
- // unload the gbeans
- // todo move this to stopConfiguration
- for (Iterator iterator = gbeans.values().iterator(); iterator.hasNext();) {
- GBeanData gbeanData = (GBeanData) iterator.next();
- AbstractName gbeanName = gbeanData.getAbstractName();
- kernel.unloadGBean(gbeanName);
- }
- } catch (Exception e) {
- throw new InvalidConfigException("Could not stop gbeans in configuration", e);
- }
+// try {
+// Map gbeans = (Map) kernel.getAttribute(configName, "GBeans");
+//
+// // unload the gbeans
+// // todo move this to stopConfiguration
+// for (Iterator iterator = gbeans.values().iterator(); iterator.hasNext();) {
+// GBeanData gbeanData = (GBeanData) iterator.next();
+// AbstractName gbeanName = gbeanData.getAbstractName();
+// kernel.unloadGBean(gbeanName);
+// }
+// } catch (Exception e) {
+// throw new InvalidConfigException("Could not stop gbeans in configuration", e);
+// }
kernel.stopGBean(configName);
}
kernel.unloadGBean(configName);
+
+ // declare all artifacts as unloaded
+ if (artifactManager != null) {
+ artifactManager.unloadAllArtifacts(configurationId);
+ }
} catch (GBeanNotFoundException e) {
throw new NoSuchConfigException("No config registered: " + configName, e);
} catch (Exception e) {
@@ -676,9 +653,10 @@
infoFactory.addReference("PersistentConfigurationList", PersistentConfigurationList.class, PersistentConfigurationList.PERSISTENT_CONFIGURATION_LIST);
infoFactory.addReference("ArtifactManager", ArtifactManager.class, "ArtifactManager");
infoFactory.addReference("ArtifactResolver", ArtifactResolver.class, "ArtifactResolver");
+ infoFactory.addReference("Repositories", Repository.class, "Repository");
infoFactory.addAttribute("classLoader", ClassLoader.class, false);
infoFactory.addInterface(ConfigurationManager.class);
- infoFactory.setConstructor(new String[]{"kernel", "Stores", "AttributeStore", "PersistentConfigurationList", "ArtifactManager", "ArtifactResolver", "classLoader"});
+ infoFactory.setConstructor(new String[]{"kernel", "Stores", "AttributeStore", "PersistentConfigurationList", "ArtifactManager", "ArtifactResolver", "Repositories", "classLoader"});
GBEAN_INFO = infoFactory.getBeanInfo();
}
Added: geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/kernel/config/ConfigurationResolver.java
URL: http://svn.apache.org/viewcvs/geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/kernel/config/ConfigurationResolver.java?rev=385232&view=auto
==============================================================================
--- geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/kernel/config/ConfigurationResolver.java (added)
+++ geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/kernel/config/ConfigurationResolver.java Sat Mar 11 17:34:04 2006
@@ -0,0 +1,173 @@
+/**
+ *
+ * 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.config;
+
+import java.util.List;
+import java.util.Collection;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.LinkedHashSet;
+import java.util.Collections;
+import java.io.File;
+import java.net.URI;
+import java.net.MalformedURLException;
+import java.net.URL;
+
+import org.apache.geronimo.kernel.repository.ArtifactResolver;
+import org.apache.geronimo.kernel.repository.MissingDependencyException;
+import org.apache.geronimo.kernel.repository.Dependency;
+import org.apache.geronimo.kernel.repository.Artifact;
+import org.apache.geronimo.kernel.repository.Repository;
+import org.apache.geronimo.kernel.repository.ImportType;
+import org.apache.geronimo.kernel.repository.DefaultArtifactResolver;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class ConfigurationResolver {
+ private final Artifact configurationId;
+ private final ArtifactResolver artifactResolver;
+ private final Collection repositories;
+ private final File baseDir;
+ private final ConfigurationStore configurationStore;
+
+ public ConfigurationResolver(Artifact configurationId, File baseDir) {
+ if (configurationId == null) throw new NullPointerException("configurationId is null");
+ if (baseDir == null) throw new NullPointerException("baseDir is null");
+
+ this.configurationId = configurationId;
+ this.baseDir = baseDir;
+ artifactResolver = null;
+ repositories = Collections.EMPTY_SET;
+ configurationStore = null;
+ }
+
+ public ConfigurationResolver(Artifact configurationId, File baseDir, Collection repositories) {
+ if (configurationId == null) throw new NullPointerException("configurationId is null");
+ if (repositories == null) repositories = Collections.EMPTY_SET;
+ if (baseDir == null) throw new NullPointerException("baseDir is null");
+
+ this.configurationId = configurationId;
+ if (!repositories.isEmpty()) {
+ this.artifactResolver = new DefaultArtifactResolver(null, repositories);
+ } else {
+ this.artifactResolver = null;
+ }
+ this.repositories = repositories;
+ this.baseDir = baseDir;
+ configurationStore = null;
+ }
+
+ public ConfigurationResolver(Artifact configurationId, File baseDir, Collection repositories, ArtifactResolver artifactResolver) {
+ if (configurationId == null) throw new NullPointerException("configurationId is null");
+ if (repositories == null) repositories = Collections.EMPTY_SET;
+ if (baseDir == null) throw new NullPointerException("baseDir is null");
+
+ this.configurationId = configurationId;
+ this.artifactResolver = artifactResolver;
+ this.repositories = repositories;
+ this.baseDir = baseDir;
+ configurationStore = null;
+ }
+
+ public ConfigurationResolver(Artifact configurationId, ConfigurationStore configurationStore, Collection repositories, ArtifactResolver artifactResolver) {
+ if (configurationId == null) throw new NullPointerException("configurationId is null");
+ if (repositories == null) repositories = Collections.EMPTY_SET;
+ if (configurationStore == null) throw new NullPointerException("configurationStore is null");
+
+ this.configurationId = configurationId;
+ this.artifactResolver = artifactResolver;
+ this.repositories = repositories;
+ this.configurationStore = configurationStore;
+ baseDir = null;
+ }
+
+ public File resolve(Artifact artifact) throws MissingDependencyException {
+ for (Iterator j = repositories.iterator(); j.hasNext();) {
+ Repository repository = (Repository) j.next();
+ if (repository.contains(artifact)) {
+ File file = repository.getLocation(artifact);
+ return file;
+ }
+ }
+ throw new MissingDependencyException("Unable to resolve dependency " + artifact);
+ }
+
+ public URL resolve(URI uri) throws MalformedURLException, NoSuchConfigException {
+ if (configurationStore != null) {
+ return configurationStore.resolve(configurationId, uri);
+ } else {
+ return new File(baseDir, uri.toString()).toURL();
+ }
+ }
+
+ public List resolveTransitiveDependencies(Collection parents, List dependencies) throws MissingDependencyException {
+ List resolvedDependencies = new ArrayList();
+ for (Iterator iterator = dependencies.iterator(); iterator.hasNext();) {
+ Dependency dependency = resolveDependency(parents, (Dependency) iterator.next());
+
+ if (!resolvedDependencies.contains(dependency)) {
+ resolvedDependencies.add(dependency);
+
+ List childDependencies = getChildDependencies(dependency);
+ if (!childDependencies.isEmpty()) {
+ childDependencies = resolveTransitiveDependencies(parents, childDependencies);
+ resolvedDependencies.addAll(childDependencies);
+ }
+ }
+ }
+ return resolvedDependencies;
+ }
+
+ private Dependency resolveDependency(Collection parents, Dependency dependency) throws MissingDependencyException {
+ Artifact artifact = dependency.getArtifact();
+
+ // if it is already resolved we are done
+ if (artifact.isResolved()) {
+ return dependency;
+ }
+
+ // we need an artifact resolver at this point
+ if (artifactResolver == null) {
+ throw new MissingDependencyException("Artifact is not resolved and there no artifact resolver available: " + artifact);
+ }
+
+ // resolve the artifact
+ artifact = artifactResolver.resolve(parents, artifact);
+
+ // build a new dependency object to contain the resolved artifact
+ Dependency resolvedDependency = new Dependency(artifact, dependency.getImportType());
+ return resolvedDependency;
+ }
+
+ private ArrayList getChildDependencies(Dependency dependency) {
+ ArrayList childDependencies = new ArrayList();
+ for (Iterator repositoryIterator = repositories.iterator(); repositoryIterator.hasNext();) {
+ Repository repository = (Repository) repositoryIterator.next();
+ if (repository.contains(dependency.getArtifact())) {
+ // get the child artifacts
+ LinkedHashSet childArtifacts = repository.getDependencies(dependency.getArtifact());
+ for (Iterator artifactIterator = childArtifacts.iterator(); artifactIterator.hasNext();) {
+ Artifact artifact = (Artifact) artifactIterator.next();
+ // add each child as a classes-only dependency
+ childDependencies.add(new Dependency(artifact, ImportType.CLASSES));
+ }
+ }
+ }
+ return childDependencies;
+ }
+}
Modified: geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/kernel/config/ConfigurationUtil.java
URL: http://svn.apache.org/viewcvs/geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/kernel/config/ConfigurationUtil.java?rev=385232&r1=385231&r2=385232&view=diff
==============================================================================
--- geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/kernel/config/ConfigurationUtil.java (original)
+++ geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/kernel/config/ConfigurationUtil.java Sat Mar 11 17:34:04 2006
@@ -16,31 +16,30 @@
*/
package org.apache.geronimo.kernel.config;
+import java.io.IOException;
import java.io.InputStream;
import java.io.ObjectInputStream;
-import java.io.OutputStream;
import java.io.ObjectOutputStream;
-import java.io.IOException;
+import java.io.OutputStream;
+import java.util.Collection;
import java.util.Collections;
import java.util.Iterator;
import java.util.Map;
import java.util.Set;
import javax.management.ObjectName;
-import javax.management.MalformedObjectNameException;
+import org.apache.geronimo.gbean.AbstractName;
import org.apache.geronimo.gbean.GBeanData;
import org.apache.geronimo.gbean.GBeanQuery;
-import org.apache.geronimo.gbean.AbstractName;
-import org.apache.geronimo.gbean.AbstractNameQuery;
import org.apache.geronimo.kernel.GBeanNotFoundException;
import org.apache.geronimo.kernel.Kernel;
import org.apache.geronimo.kernel.management.State;
-import org.apache.geronimo.kernel.repository.Environment;
import org.apache.geronimo.kernel.repository.Artifact;
-import org.apache.geronimo.kernel.repository.Repository;
+import org.apache.geronimo.kernel.repository.ArtifactResolver;
+import org.apache.geronimo.kernel.repository.Environment;
/**
- * @version $Rev$ $Date$
+ * @version $Rev: 384351 $ $Date$
*/
public final class ConfigurationUtil {
private ConfigurationUtil() {
@@ -96,11 +95,9 @@
public static void storeBootstrapConfiguration(ConfigurationData configurationData, OutputStream out) throws InvalidConfigException, IOException {
ObjectOutputStream objectOutputStream = null;
try {
- GBeanData configurationGBeanData = toConfigurationGBeanData(configurationData, null);
+ GBeanData configurationGBeanData = toConfigurationGBeanData(configurationData, null, null, null);
objectOutputStream = new ObjectOutputStream(out);
configurationGBeanData.writeExternal(objectOutputStream);
- } catch (MalformedObjectNameException e) {
- throw new InvalidConfigException(e);
} catch (IOException e) {
throw e;
} catch (Exception e) {
@@ -118,7 +115,7 @@
// This method is package protected in an attempt to hide how we turn ConfigurationData into a GBeanData
// user should be using ConfigurationManager to do this work
- static GBeanData toConfigurationGBeanData(ConfigurationData configurationData, ConfigurationStore configurationStore) throws InvalidConfigException, MalformedObjectNameException {
+ static GBeanData toConfigurationGBeanData(ConfigurationData configurationData, ConfigurationStore configurationStore, Collection repositories, ArtifactResolver artifactResolver) throws InvalidConfigException {
Artifact id = configurationData.getId();
AbstractName abstractName = Configuration.getConfigurationAbstractName(id);
GBeanData gbeanData = new GBeanData(abstractName, Configuration.GBEAN_INFO);
@@ -127,10 +124,15 @@
gbeanData.setAttribute("environment", environment);
gbeanData.setAttribute("gBeanState", Configuration.storeGBeans(configurationData.getGBeans()));
gbeanData.setAttribute("classPath", configurationData.getClassPath());
+
+ ConfigurationResolver configurationResolver;
if (configurationStore != null) {
- gbeanData.setAttribute("configurationStore", configurationStore);
+ configurationResolver = new ConfigurationResolver(configurationData.getEnvironment().getConfigId(), configurationStore, repositories, artifactResolver);
+ } else {
+ configurationResolver = new ConfigurationResolver(configurationData.getEnvironment().getConfigId(), configurationData.getConfigurationDir(), repositories, artifactResolver);
}
- gbeanData.setReferencePattern("Repositories", new AbstractNameQuery(Repository.class.getName()));
+ gbeanData.setAttribute("configurationResolver", configurationResolver);
+
return gbeanData;
}
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=385232&r1=385231&r2=385232&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 Sat Mar 11 17:34:04 2006
@@ -32,7 +32,7 @@
/**
* Standard implementation of an editable ConfigurationManager.
*
- * @version $Rev$ $Date$
+ * @version $Rev: 384686 $ $Date$
*/
public class EditableConfigurationManagerImpl extends ConfigurationManagerImpl implements EditableConfigurationManager {
public EditableConfigurationManagerImpl(Kernel kernel,
@@ -41,8 +41,9 @@
PersistentConfigurationList configurationList,
ArtifactManager artifactManager,
ArtifactResolver artifactResolver,
+ Collection repositories,
ClassLoader classLoader) {
- super(kernel, stores, attributeStore, configurationList, artifactManager, artifactResolver, classLoader);
+ super(kernel, stores, attributeStore, configurationList, artifactManager, artifactResolver, repositories, classLoader);
}
public void addGBeanToConfiguration(Artifact configurationId, GBeanData gbean, boolean start) throws InvalidConfigException {
@@ -55,8 +56,8 @@
log.trace("Registering GBean " + gbean.getName());
- // add a dependency on the configuration
- gbean.addDependency(configuration.getAbstractName());
+ // preprocess the gbean data before loading it into the kernel
+ preprocessGBeanData(configuration, gbean);
// register the bean with the kernel
kernel.loadGBean(gbean, configurationClassLoader);
@@ -113,7 +114,7 @@
static {
GBeanInfoBuilder infoFactory = GBeanInfoBuilder.createStatic(EditableConfigurationManagerImpl.class, ConfigurationManagerImpl.GBEAN_INFO, "ConfigurationManager");
infoFactory.addInterface(EditableConfigurationManager.class);
- infoFactory.setConstructor(new String[]{"kernel", "Stores", "AttributeStore", "PersistentConfigurationList", "ArtifactManager", "ArtifactResolver", "classLoader"});
+ infoFactory.setConstructor(new String[]{"kernel", "Stores", "AttributeStore", "PersistentConfigurationList", "ArtifactManager", "ArtifactResolver", "Repositories", "classLoader"});
GBEAN_INFO = infoFactory.getBeanInfo();
}
Modified: geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/kernel/config/MultiParentClassLoader.java
URL: http://svn.apache.org/viewcvs/geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/kernel/config/MultiParentClassLoader.java?rev=385232&r1=385231&r2=385232&view=diff
==============================================================================
--- geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/kernel/config/MultiParentClassLoader.java (original)
+++ geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/kernel/config/MultiParentClassLoader.java Sat Mar 11 17:34:04 2006
@@ -211,6 +211,10 @@
return parents;
}
+ protected void addURL(URL url) {
+ super.addURL(url);
+ }
+
protected synchronized Class loadClass(String name, boolean resolve) throws ClassNotFoundException {
//
// Check if class is in the loaded classes cache
@@ -249,8 +253,10 @@
//
// if we are not using inverse class loading, check local urls now
//
- // todo don't we want to exclude non-overridable classes
- if (/*!inverseClassLoading &&*/ !isDestroyed() /*&& !isNonOverridableClass(name)*/) {
+ // don't worry about excluding non-overridable classes here... we
+ // have alredy checked he parent and the parent didn't have the
+ // class, so we can override now
+ if (!isDestroyed()) {
try {
Class clazz = findClass(name);
return resolveClass(clazz, resolve);
@@ -317,8 +323,10 @@
//
// if we are not using inverse class loading, check local urls now
//
- // todo don't we want to exclude non-overridable resources
- if (/*!inverseClassLoading &&*/ !isDestroyed() /*&& !isNonOverridableResource(name)*/) {
+ // don't worry about excluding non-overridable resources here... we
+ // have alredy checked he parent and the parent didn't have the
+ // resource, so we can override now
+ if (!isDestroyed()) {
// parents didn't have the resource; attempt to load it from my urls
return findResource(name);
}
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=385232&r1=385231&r2=385232&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 Sat Mar 11 17:34:04 2006
@@ -54,7 +54,7 @@
import org.apache.geronimo.kernel.repository.Environment;
/**
- * @version $Rev$ $Date$
+ * @version $Rev: 384999 $ $Date$
*/
public class ConfigTest extends TestCase {
private Kernel kernel;
@@ -73,15 +73,15 @@
assertEquals(State.RUNNING_INDEX, kernel.getGBeanState(configurationName));
assertNotNull(configuration.getConfigurationClassLoader());
- assertTrue(kernel.isLoaded(gbeanName1));
- assertTrue(kernel.isLoaded(gbeanName2));
-
- assertEquals(State.STOPPED_INDEX, kernel.getGBeanState(gbeanName1));
- assertEquals(State.STOPPED_INDEX, kernel.getGBeanState(gbeanName2));
+ assertFalse(kernel.isLoaded(gbeanName1));
+ assertFalse(kernel.isLoaded(gbeanName2));
// start -- gbeans should now be started
configurationManager.startConfiguration(configuration);
+ assertTrue(kernel.isLoaded(gbeanName1));
+ assertTrue(kernel.isLoaded(gbeanName2));
+
assertEquals(State.RUNNING_INDEX, kernel.getGBeanState(gbeanName1));
assertEquals(State.RUNNING_INDEX, kernel.getGBeanState(gbeanName2));
@@ -109,11 +109,8 @@
// stop -- gbeans should now be started, but still registered
configurationManager.stopConfiguration(configuration);
- assertTrue(kernel.isLoaded(gbeanName1));
- assertTrue(kernel.isLoaded(gbeanName2));
-
- assertEquals(State.STOPPED_INDEX, kernel.getGBeanState(gbeanName1));
- assertEquals(State.STOPPED_INDEX, kernel.getGBeanState(gbeanName2));
+ assertFalse(kernel.isLoaded(gbeanName1));
+ assertFalse(kernel.isLoaded(gbeanName2));
// unload -- configuration and gbeans should be unloaded
@@ -133,10 +130,8 @@
assertEquals(State.RUNNING_INDEX, kernel.getGBeanState(configurationName));
assertNotNull(configuration.getConfigurationClassLoader());
- assertTrue(kernel.isLoaded(gbeanName1));
- assertTrue(kernel.isLoaded(gbeanName2));
- assertEquals(State.STOPPED_INDEX, kernel.getGBeanState(gbeanName1));
- assertEquals(State.STOPPED_INDEX, kernel.getGBeanState(gbeanName2));
+ assertFalse(kernel.isLoaded(gbeanName1));
+ assertFalse(kernel.isLoaded(gbeanName2));
// start -- gbeans should now be started
@@ -151,10 +146,8 @@
// stop -- gbeans should now be started, but still registered
configurationManager.stopConfiguration(configuration);
- assertTrue(kernel.isLoaded(gbeanName1));
- assertTrue(kernel.isLoaded(gbeanName2));
- assertEquals(State.STOPPED_INDEX, kernel.getGBeanState(gbeanName1));
- assertEquals(State.STOPPED_INDEX, kernel.getGBeanState(gbeanName2));
+ assertFalse(kernel.isLoaded(gbeanName1));
+ assertFalse(kernel.isLoaded(gbeanName2));
// restart -- gbeans should now be started
@@ -247,7 +240,7 @@
gbeans.add(mockBean2);
- configurationData = new ConfigurationData(ConfigurationModuleType.CAR, null, gbeans, null, environment, null);
+ configurationData = new ConfigurationData(ConfigurationModuleType.CAR, null, gbeans, null, environment, new File("."));
}
private GBeanData buildGBeanData(Artifact artifact, String[] key, String[] value, GBeanInfo info) throws MalformedObjectNameException {
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=385232&r1=385231&r2=385232&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 Sat Mar 11 17:34:04 2006
@@ -85,37 +85,42 @@
assertEquals(State.RUNNING_INDEX, kernel.getGBeanState(artifactManagerData.getAbstractName()));
ArtifactManager artifactManager = (ArtifactManager) kernel.getProxyManager().createProxy(artifactManagerData.getAbstractName(), ArtifactManager.class);
+ TestConfigStore configStore = new TestConfigStore();
+ TestRepository testRepository = new TestRepository();
+ DefaultArtifactResolver artifactResolver = new DefaultArtifactResolver(artifactManager, testRepository);
+
artifact1 = new Artifact("test", "1", "1.1", "bar");
artifact2 = new Artifact("test", "2", "2.2", "bar");
artifact3 = new Artifact("test", "3", "3.3", "bar");
Environment e1 = new Environment();
e1.setConfigId(artifact1);
- GBeanData gbeanData1 = new GBeanData(Configuration.getConfigurationAbstractName(artifact1), Configuration.GBEAN_INFO);
- gbeanData1.setAttribute("environment", e1);
+ ConfigurationData configurationData1 = new ConfigurationData(ConfigurationModuleType.CAR, null, null, null, e1, new File("."));
+ GBeanData gbeanData1 = ConfigurationUtil.toConfigurationGBeanData(configurationData1, configStore, Collections.singleton(testRepository), artifactResolver);
configurations.put(artifact1, gbeanData1);
Environment e2 = new Environment();
e2.setConfigId(artifact2);
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);
+ ConfigurationData configurationData2 = new ConfigurationData(ConfigurationModuleType.CAR, null, null, null, e2, new File("."));
+ GBeanData gbeanData2 = ConfigurationUtil.toConfigurationGBeanData(configurationData2, configStore, Collections.singleton(testRepository), artifactResolver);
configurations.put(artifact2, gbeanData2);
Environment e3 = new Environment();
e3.setConfigId(artifact3);
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);
+ ConfigurationData configurationData3 = new ConfigurationData(ConfigurationModuleType.CAR, null, null, null, e3, new File("."));
+ GBeanData gbeanData3 = ConfigurationUtil.toConfigurationGBeanData(configurationData3, configStore, Collections.singleton(testRepository), artifactResolver);
configurations.put(artifact3, gbeanData3);
- TestRepository testRepository = new TestRepository();
+
configurationManager = new ConfigurationManagerImpl(kernel,
- Collections.singleton(new TestConfigStore()),
+ Collections.singleton(configStore),
null,
null,
artifactManager,
- new DefaultArtifactResolver(artifactManager, testRepository),
+ artifactResolver,
+ Collections.singleton(testRepository),
ConfigurationManagerImpl.class.getClassLoader());
}
@@ -191,7 +196,7 @@
}
public LinkedHashSet getDependencies(Artifact artifact) {
- throw new UnsupportedOperationException();
+ return new LinkedHashSet();
}
}
}
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=385232&r1=385231&r2=385232&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 Sat Mar 11 17:34:04 2006
@@ -20,6 +20,7 @@
import org.apache.geronimo.kernel.ConfigTest;
import org.apache.geronimo.kernel.config.Configuration;
import org.apache.geronimo.kernel.config.ConfigurationModuleType;
+import org.apache.geronimo.kernel.config.ConfigurationResolver;
import java.io.File;
import java.util.Collections;
@@ -87,19 +88,21 @@
ArtifactResolver artifactResolver = new DefaultArtifactResolver(artifactManager, mockRepository);
// create parent which uses version1 explicitly
+ ConfigurationResolver configurationResolver = new ConfigurationResolver(loader,
+ new ConfigTest.MockConfigStore(new File("foo").toURL()),
+ Collections.singleton(mockRepository),
+ artifactResolver);
+
Environment environment = new Environment();
environment.setConfigId(loader);
environment.addDependency(version1, ImportType.CLASSES);
Configuration parent = new Configuration(null,
- Configuration.getConfigurationObjectName(loader).getCanonicalName(),
ConfigurationModuleType.SERVICE,
environment,
null,
null,
- Collections.singleton(mockRepository),
- new ConfigTest.MockConfigStore(new File("foo").toURL()),
- artifactManager,
- artifactResolver);
+ configurationResolver);
+
LinkedHashSet parents = new LinkedHashSet();
parents.add(parent);
Modified: geronimo/branches/1.1/modules/naming-builder/src/java/org/apache/geronimo/naming/deployment/ENCConfigBuilder.java
URL: http://svn.apache.org/viewcvs/geronimo/branches/1.1/modules/naming-builder/src/java/org/apache/geronimo/naming/deployment/ENCConfigBuilder.java?rev=385232&r1=385231&r2=385232&view=diff
==============================================================================
--- geronimo/branches/1.1/modules/naming-builder/src/java/org/apache/geronimo/naming/deployment/ENCConfigBuilder.java (original)
+++ geronimo/branches/1.1/modules/naming-builder/src/java/org/apache/geronimo/naming/deployment/ENCConfigBuilder.java Sat Mar 11 17:34:04 2006
@@ -71,7 +71,7 @@
import java.util.Set;
/**
- * @version $Rev$ $Date$
+ * @version $Rev: 384667 $ $Date$
*/
public class ENCConfigBuilder {
Modified: geronimo/branches/1.1/modules/security-builder/src/java/org/apache/geronimo/security/deployment/LoginConfigBuilder.java
URL: http://svn.apache.org/viewcvs/geronimo/branches/1.1/modules/security-builder/src/java/org/apache/geronimo/security/deployment/LoginConfigBuilder.java?rev=385232&r1=385231&r2=385232&view=diff
==============================================================================
--- geronimo/branches/1.1/modules/security-builder/src/java/org/apache/geronimo/security/deployment/LoginConfigBuilder.java (original)
+++ geronimo/branches/1.1/modules/security-builder/src/java/org/apache/geronimo/security/deployment/LoginConfigBuilder.java Sat Mar 11 17:34:04 2006
@@ -16,6 +16,14 @@
*/
package org.apache.geronimo.security.deployment;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Properties;
+import java.util.Set;
+
import org.apache.geronimo.common.DeploymentException;
import org.apache.geronimo.deployment.DeploymentContext;
import org.apache.geronimo.deployment.service.GBeanBuilder;
@@ -29,6 +37,7 @@
import org.apache.geronimo.gbean.GReferenceInfo;
import org.apache.geronimo.gbean.ReferencePatterns;
import org.apache.geronimo.j2ee.j2eeobjectnames.NameFactory;
+import org.apache.geronimo.kernel.GBeanAlreadyExistsException;
import org.apache.geronimo.security.jaas.JaasLoginModuleUse;
import org.apache.geronimo.security.jaas.LoginModuleGBean;
import org.apache.geronimo.xbeans.geronimo.loginconfig.GerAbstractLoginModuleType;
@@ -40,47 +49,32 @@
import org.apache.xmlbeans.XmlObject;
import org.apache.xmlbeans.XmlOptions;
-import javax.management.MalformedObjectNameException;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Properties;
-import java.util.Set;
-
/**
- * @version $Rev$ $Date$
+ * @version $Rev: 384933 $ $Date$
*/
-public class LoginConfigBuilder implements XmlReferenceBuilder
-{
+public class LoginConfigBuilder implements XmlReferenceBuilder {
public static final String LOGIN_CONFIG_NAMESPACE = "http://geronimo.apache.org/xml/ns/loginconfig-1.0";
- public String getNamespace()
- {
+ public String getNamespace() {
return LOGIN_CONFIG_NAMESPACE;
}
- public ReferencePatterns getReferences(XmlObject xmlObject, DeploymentContext context, AbstractName parentName, ClassLoader classLoader) throws DeploymentException
- {
+ public ReferencePatterns getReferences(XmlObject xmlObject, DeploymentContext context, AbstractName parentName, ClassLoader classLoader) throws DeploymentException {
GerLoginConfigType loginConfig = (GerLoginConfigType) xmlObject.copy().changeType(GerLoginConfigType.type);
XmlOptions xmlOptions = new XmlOptions();
xmlOptions.setLoadLineNumbers();
Collection errors = new ArrayList();
xmlOptions.setErrorListener(errors);
- if (!loginConfig.validate(xmlOptions))
- {
+ if (!loginConfig.validate(xmlOptions)) {
throw new DeploymentException("Invalid login configuration:\n" + errors + "\nDescriptor: " + loginConfig.toString());
}
XmlCursor xmlCursor = loginConfig.newCursor();
List uses = new ArrayList();
Set loginModuleNames = new HashSet();
- try
- {
+ try {
boolean atStart = true;
- while ((atStart && xmlCursor.toFirstChild()) || (!atStart && xmlCursor.toNextSibling()))
- {
+ while ((atStart && xmlCursor.toFirstChild()) || (!atStart && xmlCursor.toNextSibling())) {
atStart = false;
XmlObject child = xmlCursor.getObject();
GerAbstractLoginModuleType abstractLoginModule = (GerAbstractLoginModuleType) child;
@@ -88,8 +82,7 @@
boolean wrapPrincipals = (abstractLoginModule.isSetWrapPrincipals() && abstractLoginModule.getWrapPrincipals());
ReferencePatterns loginModuleReferencePatterns;
String name;
- if (abstractLoginModule instanceof GerLoginModuleRefType)
- {
+ if (abstractLoginModule instanceof GerLoginModuleRefType) {
GerLoginModuleRefType loginModuleRef = (GerLoginModuleRefType) abstractLoginModule;
PatternType patternType = loginModuleRef.getPattern();
AbstractNameQuery loginModuleNameQuery = GBeanBuilder.buildAbstractNameQuery(patternType, USE_REFERENCE_INFO);
@@ -115,24 +108,20 @@
// {
// throw new DeploymentException("Unable to create reference to login module " + name, e);
// }
- }
- else if (abstractLoginModule instanceof GerLoginModuleType)
- {
+ } else if (abstractLoginModule instanceof GerLoginModuleType) {
//create the LoginModuleGBean also
AbstractName loginModuleName;
GerLoginModuleType loginModule = (GerLoginModuleType) abstractLoginModule;
name = trim(loginModule.getLoginDomainName());
- if (!loginModuleNames.add(name))
- {
+ if (!loginModuleNames.add(name)) {
throw new DeploymentException("Security realm contains two login domains called '" + name + "'");
}
String className = trim(loginModule.getLoginModuleClass());
boolean serverSide = loginModule.getServerSide();
Properties options = new Properties();
GerOptionType[] optionArray = loginModule.getOptionArray();
- for (int j = 0; j < optionArray.length; j++)
- {
+ for (int j = 0; j < optionArray.length; j++) {
GerOptionType gerOptionType = optionArray[j];
String key = gerOptionType.getName();
String value = trim(gerOptionType.getStringValue());
@@ -148,9 +137,7 @@
loginModuleGBeanData.setAttribute("wrapPrincipals", Boolean.valueOf(wrapPrincipals));
context.addGBean(loginModuleGBeanData);
- }
- else
- {
+ } else {
throw new DeploymentException("Unknown abstract login module type: " + abstractLoginModule.getClass());
}
AbstractName thisName;
@@ -160,25 +147,23 @@
loginModuleUseGBeanData.setReferencePatterns("LoginModule", loginModuleReferencePatterns);
uses.add(loginModuleUseGBeanData);
}
- for (int i = uses.size() - 1; i >= 0; i--)
- {
+ for (int i = uses.size() - 1; i >= 0; i--) {
GBeanData data = (GBeanData) uses.get(i);
- if (i > 0)
- {
+ if (i > 0) {
((GBeanData) uses.get(i - 1)).setReferencePattern("Next", data.getAbstractName());
}
context.addGBean(data);
}
}
- finally
- {
+ catch (GBeanAlreadyExistsException e) {
+ throw new DeploymentException(e);
+ } finally {
xmlCursor.dispose();
}
return uses.size() == 0 ? null : new ReferencePatterns(((GBeanData) uses.get(0)).getAbstractName());
}
- private String trim(String string)
- {
+ private String trim(String string) {
return string == null ? null : string.trim();
}
@@ -186,8 +171,7 @@
private static final GReferenceInfo USE_REFERENCE_INFO;
- static
- {
+ static {
GBeanInfoBuilder infoBuilder = GBeanInfoBuilder.createStatic(LoginConfigBuilder.class, "XmlReferenceBuilder");
infoBuilder.addInterface(XmlReferenceBuilder.class);
GBEAN_INFO = infoBuilder.getBeanInfo();
@@ -209,8 +193,7 @@
}
- public static GBeanInfo getGBeanInfo()
- {
+ public static GBeanInfo getGBeanInfo() {
return GBEAN_INFO;
}
}
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=385232&r1=385231&r2=385232&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 Sat Mar 11 17:34:04 2006
@@ -37,6 +37,7 @@
import org.apache.geronimo.gbean.AbstractName;
import org.apache.geronimo.j2ee.j2eeobjectnames.NameFactory;
import org.apache.geronimo.kernel.Kernel;
+import org.apache.geronimo.kernel.GBeanAlreadyExistsException;
import org.apache.geronimo.kernel.config.ConfigurationData;
import org.apache.geronimo.kernel.config.ConfigurationModuleType;
import org.apache.geronimo.kernel.config.ConfigurationStore;
@@ -56,11 +57,10 @@
import java.util.Collection;
import java.util.HashMap;
import java.util.Map;
-import java.util.Collections;
import java.util.jar.JarFile;
/**
- * @version $Rev$ $Date$
+ * @version $Rev: 384933 $ $Date$
*/
public class ServiceConfigBuilder implements ConfigurationBuilder {
private final Environment defaultEnvironment;
@@ -164,7 +164,7 @@
} catch (ConfigurationAlreadyExistsException e) {
throw new DeploymentException(e);
}
- DeploymentContext context = new DeploymentContext(outfile, environment, ConfigurationModuleType.SERVICE, Collections.singleton(repository), kernel);
+ DeploymentContext context = new DeploymentContext(outfile, environment, ConfigurationModuleType.SERVICE, kernel);
ClassLoader cl = context.getClassLoader();
@@ -265,8 +265,12 @@
}
}
- GBeanData gBeanData = builder.getGBeanData();
- context.addGBean(gBeanData);
+ GBeanData gbeanData = builder.getGBeanData();
+ try {
+ context.addGBean(gbeanData);
+ } catch (GBeanAlreadyExistsException e) {
+ throw new DeploymentException(e);
+ }
return abstractName;
}
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=385232&r1=385231&r2=385232&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 Sat Mar 11 17:34:04 2006
@@ -28,16 +28,22 @@
import org.apache.geronimo.gbean.ReferenceCollectionListener;
import org.apache.geronimo.j2ee.j2eeobjectnames.NameFactory;
import org.apache.geronimo.kernel.config.ConfigurationModuleType;
+import org.apache.geronimo.kernel.config.Configuration;
+import org.apache.geronimo.kernel.config.ConfigurationResolver;
import org.apache.geronimo.kernel.repository.Environment;
+import org.apache.geronimo.kernel.repository.Repository;
+import org.apache.geronimo.kernel.repository.Artifact;
import javax.management.ObjectName;
import java.io.File;
import java.net.URL;
import java.util.ArrayList;
import java.util.Set;
+import java.util.LinkedHashSet;
+import java.util.Collections;
/**
- * @version $Rev$ $Date$
+ * @version $Rev: 384933 $ $Date$
*/
public class ServiceConfigBuilderTest extends TestCase {
@@ -61,14 +67,20 @@
try {
Environment environment = EnvironmentBuilder.buildEnvironment(plan.getEnvironment());
- DeploymentContext context = new DeploymentContext(outFile, environment, ConfigurationModuleType.SERVICE, null, null);
+ Configuration configuration = new Configuration(null,
+ ConfigurationModuleType.CAR,
+ environment,
+ null,
+ null,
+ new ConfigurationResolver(environment.getConfigId(), outFile, Collections.singleton(new MockRepository())));
+ DeploymentContext context = new DeploymentContext(configuration, outFile);
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();
ServiceConfigBuilder.addGBeans(gbeans, cl, j2eeContext, context);
- Set beanDatas = context.listGBeans(null);
- assertEquals(1, beanDatas.size());
- AbstractName beanName = (AbstractName) beanDatas.iterator().next();
+ Set gbeanNames = context.getGBeanNames();
+ assertEquals(1, gbeanNames.size());
+ AbstractName beanName = (AbstractName) gbeanNames.iterator().next();
GBeanData data = context.getGBeanInstance(beanName);
FooBarBean fooBarBean = (FooBarBean) data.getAttribute("fooBarBean");
assertNotNull(fooBarBean);
@@ -98,6 +110,19 @@
file.delete();
}
+ private static class MockRepository implements Repository {
+ public boolean contains(Artifact artifact) {
+ return true;
+ }
+
+ public File getLocation(Artifact artifact) {
+ return new File(".");
+ }
+
+ public LinkedHashSet getDependencies(Artifact artifact) {
+ return new LinkedHashSet();
+ }
+ }
private static class MockReferenceCollection extends ArrayList implements ReferenceCollection {
public void addReferenceCollectionListener(ReferenceCollectionListener listener) {
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=385232&r1=385231&r2=385232&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 Sat Mar 11 17:34:04 2006
@@ -91,7 +91,7 @@
import org.apache.geronimo.transaction.manager.TransactionManagerImplGBean;
/**
- * @version $Rev$ $Date$
+ * @version $Rev: 384933 $ $Date$
*/
public class TomcatModuleBuilderTest extends TestCase {
private String DOMAIN_NAME = "geronimo.test";
@@ -228,7 +228,6 @@
outputPath,
environment,
ConfigurationModuleType.WAR,
- null,
kernel,
moduleContext.getJ2eeApplicationName(),
tcmName,
Modified: geronimo/branches/1.1/modules/web-builder/src/java/org/apache/geronimo/web/deployment/AbstractWebModuleBuilder.java
URL: http://svn.apache.org/viewcvs/geronimo/branches/1.1/modules/web-builder/src/java/org/apache/geronimo/web/deployment/AbstractWebModuleBuilder.java?rev=385232&r1=385231&r2=385232&view=diff
==============================================================================
--- geronimo/branches/1.1/modules/web-builder/src/java/org/apache/geronimo/web/deployment/AbstractWebModuleBuilder.java (original)
+++ geronimo/branches/1.1/modules/web-builder/src/java/org/apache/geronimo/web/deployment/AbstractWebModuleBuilder.java Sat Mar 11 17:34:04 2006
@@ -22,7 +22,6 @@
import java.util.HashMap;
import java.util.Enumeration;
import java.util.Iterator;
-import java.util.Collections;
import java.util.zip.ZipEntry;
import java.util.jar.JarFile;
import java.io.File;
@@ -69,7 +68,7 @@
import org.apache.geronimo.security.util.URLPattern;
/**
- * @version $Rev$ $Date$
+ * @version $Rev: 384686 $ $Date$
*/
public abstract class AbstractWebModuleBuilder implements ModuleBuilder {
protected static final ObjectName MANAGED_CONNECTION_FACTORY_PATTERN;
@@ -190,7 +189,6 @@
moduleContext = new EARContext(configurationDir,
environment,
ConfigurationModuleType.WAR,
- Collections.singleton(repository),
kernel,
earContext.getJ2EEApplicationName(),
earContext.getTransactionContextManagerObjectName(),