You are viewing a plain text version of this content. The canonical link for it is here.
Posted to scm@geronimo.apache.org by dj...@apache.org on 2011/04/27 01:19:34 UTC
svn commit: r1096952 [2/4] - in /geronimo/server/trunk: ./ framework/
framework/buildsupport/car-maven-plugin/
framework/buildsupport/car-maven-plugin/src/main/java/org/apache/geronimo/mavenplugins/car/
framework/configs/j2ee-system/ framework/configs/...
Modified: geronimo/server/trunk/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/config/ConfigurationUtil.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/config/ConfigurationUtil.java?rev=1096952&r1=1096951&r2=1096952&view=diff
==============================================================================
--- geronimo/server/trunk/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/config/ConfigurationUtil.java (original)
+++ geronimo/server/trunk/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/config/ConfigurationUtil.java Tue Apr 26 23:19:31 2011
@@ -158,66 +158,66 @@ public final class ConfigurationUtil {
return configurationMarshaler.newGBeanState(gbeans);
}
- public static AbstractName loadBootstrapConfiguration(Kernel kernel, InputStream in, BundleContext bundleContext) throws Exception {
- return loadBootstrapConfiguration(kernel, in, bundleContext, false);
- }
-
- public static AbstractName loadBootstrapConfiguration(Kernel kernel, InputStream in, BundleContext bundleContext, boolean enableBootRepo) throws Exception {
- ConfigurationData configurationData = readConfigurationData(in);
- return loadBootstrapConfiguration(kernel, configurationData, bundleContext, enableBootRepo);
- }
-
- public static AbstractName loadBootstrapConfiguration(Kernel kernel, ConfigurationData configurationData, BundleContext bundleContext) throws Exception {
- return loadBootstrapConfiguration(kernel, configurationData, bundleContext, false);
- }
-
- public static AbstractName loadBootstrapConfiguration(Kernel kernel, ConfigurationData configurationData, BundleContext bundleContext, boolean enableBootRepo) throws Exception {
- if (kernel == null) throw new NullPointerException("kernel is null");
- if (configurationData == null) throw new NullPointerException("configurationData is null");
- if (bundleContext == null) throw new NullPointerException("bundle is null");
-
- configurationData.setBundle(bundleContext.getBundle());
-
- // build the gbean data
- Artifact configId = configurationData.getId();
- AbstractName abstractName = Configuration.getConfigurationAbstractName(configId);
- GBeanData gbeanData = new GBeanData(abstractName, Configuration.class);
- gbeanData.setAttribute("configurationData", configurationData);
-
- Collection repositories = null;
- ArtifactResolver artifactResolver = null;
- if (enableBootRepo) {
- String repository = System.getProperty("Xorg.apache.geronimo.repository.boot.path", "repository");
- Maven2Repository bootRepository = new Maven2Repository(new File(getBootDirectory(), repository));
- repositories = Collections.singleton(bootRepository);
- artifactResolver = new DefaultArtifactResolver(new DefaultArtifactManager(), bootRepository);
- } else {
- // a bootstrap configuration can not have any dependencies
-// List dependencies = configurationData.getEnvironment().getDependencies();
-// if (!dependencies.isEmpty()) {
-// configurationData.getEnvironment().setDependencies(Collections.EMPTY_SET);
-// }
- }
- ConfigurationResolver configurationResolver = new ConfigurationResolver(configurationData, repositories, artifactResolver);
-
- DependencyNode dependencyNode = new DependencyNode(configId, new LinkedHashSet<Artifact>(), new LinkedHashSet<Artifact>());
- gbeanData.setAttribute("dependencyNode", dependencyNode);
- gbeanData.setAttribute("allServiceParents", Collections.<Configuration>emptyList());
-
-
- // load and start the gbean
- kernel.loadGBean(gbeanData, bundleContext);
- kernel.startGBean(gbeanData.getAbstractName());
-
- Configuration configuration = (Configuration) kernel.getGBean(gbeanData.getAbstractName());
-
- // start the gbeans
- startConfigurationGBeans(configuration.getAbstractName(), configuration, kernel);
-
- ConfigurationManager configurationManager = getConfigurationManager(kernel);
- configurationManager.loadConfiguration(configId);
- return gbeanData.getAbstractName();
- }
+// public static AbstractName loadBootstrapConfiguration(Kernel kernel, InputStream in, BundleContext bundleContext) throws Exception {
+// return loadBootstrapConfiguration(kernel, in, bundleContext, false);
+// }
+//
+// static AbstractName loadBootstrapConfiguration(Kernel kernel, InputStream in, BundleContext bundleContext, boolean enableBootRepo) throws Exception {
+// ConfigurationData configurationData = readConfigurationData(in);
+// return loadBootstrapConfiguration(kernel, configurationData, bundleContext, enableBootRepo);
+// }
+//
+// static AbstractName loadBootstrapConfiguration(Kernel kernel, ConfigurationData configurationData, BundleContext bundleContext) throws Exception {
+// return loadBootstrapConfiguration(kernel, configurationData, bundleContext, false);
+// }
+//
+// static AbstractName loadBootstrapConfiguration(Kernel kernel, ConfigurationData configurationData, BundleContext bundleContext, boolean enableBootRepo) throws Exception {
+// if (kernel == null) throw new NullPointerException("kernel is null");
+// if (configurationData == null) throw new NullPointerException("configurationData is null");
+// if (bundleContext == null) throw new NullPointerException("bundle is null");
+// if (true) throw new IllegalStateException("Don't call this");
+// configurationData.setBundle(bundleContext.getBundle());
+//
+// // build the gbean data
+// Artifact configId = configurationData.getId();
+// AbstractName abstractName = Configuration.getConfigurationAbstractName(configId);
+// GBeanData gbeanData = new GBeanData(abstractName, Configuration.class);
+// gbeanData.setAttribute("configurationData", configurationData);
+//
+// Collection repositories = null;
+// ArtifactResolver artifactResolver = null;
+// if (enableBootRepo) {
+// String repository = System.getProperty("Xorg.apache.geronimo.repository.boot.path", "repository");
+// Maven2Repository bootRepository = new Maven2Repository(new File(getBootDirectory(), repository));
+// repositories = Collections.singleton(bootRepository);
+// artifactResolver = new DefaultArtifactResolver(new DefaultArtifactManager(), bootRepository);
+// } else {
+// // a bootstrap configuration can not have any dependencies
+//// List dependencies = configurationData.getEnvironment().getDependencies();
+//// if (!dependencies.isEmpty()) {
+//// configurationData.getEnvironment().setDependencies(Collections.EMPTY_SET);
+//// }
+// }
+// ConfigurationResolver configurationResolver = new ConfigurationResolver(configurationData, repositories, artifactResolver);
+//
+// DependencyNode dependencyNode = new DependencyNode(configId, new LinkedHashSet<Artifact>(), new LinkedHashSet<Artifact>());
+// gbeanData.setAttribute("dependencyNode", dependencyNode);
+// gbeanData.setAttribute("allServiceParents", Collections.<Configuration>emptyList());
+//
+//
+// // load and start the gbean
+// kernel.loadGBean(gbeanData, bundleContext.getBundle());
+// kernel.startGBean(gbeanData.getAbstractName());
+//
+// Configuration configuration = (Configuration) kernel.getGBean(gbeanData.getAbstractName());
+//
+// // start the gbeans
+// startConfigurationGBeans(configuration, kernel);
+//
+// ConfigurationManager configurationManager = getConfigurationManager(kernel);
+// configurationManager.loadConfiguration(configId);
+// return gbeanData.getAbstractName();
+// }
public static void writeConfigurationData(ConfigurationData configurationData, OutputStream out) throws IOException {
configurationMarshaler.writeConfigurationData(configurationData, out);
@@ -302,27 +302,27 @@ public final class ConfigurationUtil {
* @return Its AbstractName
* @throws IllegalStateException Occurs if a ConfigurationManager cannot be identified
*/
- public static AbstractName getConfigurationManagerName(Kernel kernel) {
- Set names = kernel.listGBeans(new AbstractNameQuery(ConfigurationManager.class.getName()));
- for (Iterator iterator = names.iterator(); iterator.hasNext();) {
- AbstractName abstractName = (AbstractName) iterator.next();
- if (!kernel.isRunning(abstractName)) {
- iterator.remove();
- }
- }
- if (names.isEmpty()) {
- throw new IllegalStateException("A Configuration Manager could not be found in the kernel");
- }
- if (names.size() > 1) {
- String error = "More than one Configuration Manager was found in the kernel: ";
- for (Object name : names) {
- AbstractName abName = (AbstractName)name;
- error = error + "\"" + abName.toString() + "\" ";
- }
- throw new IllegalStateException(error);
- }
- return (AbstractName) names.iterator().next();
- }
+// public static AbstractName getConfigurationManagerName(Kernel kernel) {
+// Set names = kernel.listGBeans(new AbstractNameQuery(ConfigurationManager.class.getName()));
+// for (Iterator iterator = names.iterator(); iterator.hasNext();) {
+// AbstractName abstractName = (AbstractName) iterator.next();
+// if (!kernel.isRunning(abstractName)) {
+// iterator.remove();
+// }
+// }
+// if (names.isEmpty()) {
+// throw new IllegalStateException("A Configuration Manager could not be found in the kernel");
+// }
+// if (names.size() > 1) {
+// String error = "More than one Configuration Manager was found in the kernel: ";
+// for (Object name : names) {
+// AbstractName abName = (AbstractName)name;
+// error = error + "\"" + abName.toString() + "\" ";
+// }
+// throw new IllegalStateException(error);
+// }
+// return (AbstractName) names.iterator().next();
+// }
/**
@@ -341,33 +341,33 @@ public final class ConfigurationUtil {
* @return The EdtiableConfigurationManager, or none if there is not one available.
* @throws IllegalStateException Occurs if there are multiple EditableConfigurationManagers in the kernel.
*/
- public static EditableConfigurationManager getEditableConfigurationManager(Kernel kernel) {
- Set names = kernel.listGBeans(new AbstractNameQuery(EditableConfigurationManager.class.getName()));
- for (Iterator iterator = names.iterator(); iterator.hasNext();) {
- AbstractName abstractName = (AbstractName) iterator.next();
- if (!kernel.isRunning(abstractName)) {
- iterator.remove();
- }
- }
- if (names.isEmpty()) {
- return null; // may be one, just not editable
- }
- if (names.size() > 1) {
- throw new IllegalStateException("More than one Configuration Manager was found in the kernel");
- }
- AbstractName configurationManagerName = (AbstractName) names.iterator().next();
- try {
- return (EditableConfigurationManager) kernel.getGBean(configurationManagerName);
- } catch (GBeanNotFoundException e) {
- return null;
- }
- }
+// public static EditableConfigurationManager getEditableConfigurationManager(Kernel kernel) {
+// Set names = kernel.listGBeans(new AbstractNameQuery(EditableConfigurationManager.class.getName()));
+// for (Iterator iterator = names.iterator(); iterator.hasNext();) {
+// AbstractName abstractName = (AbstractName) iterator.next();
+// if (!kernel.isRunning(abstractName)) {
+// iterator.remove();
+// }
+// }
+// if (names.isEmpty()) {
+// return null; // may be one, just not editable
+// }
+// if (names.size() > 1) {
+// throw new IllegalStateException("More than one Configuration Manager was found in the kernel");
+// }
+// AbstractName configurationManagerName = (AbstractName) names.iterator().next();
+// try {
+// return (EditableConfigurationManager) kernel.getGBean(configurationManagerName);
+// } catch (GBeanNotFoundException e) {
+// return null;
+// }
+// }
public static void releaseConfigurationManager(Kernel kernel, ConfigurationManager configurationManager) {
// kernel.getProxyManager().destroyProxy(configurationManager);
}
- static void preprocessGBeanData(AbstractName configurationName, Configuration configuration, GBeanData gbeanData) throws InvalidConfigException {
+ static void preprocessGBeanData(Configuration configuration, GBeanData gbeanData) throws InvalidConfigException {
if (log.isDebugEnabled()) {
log.debug("resolving dependencies for " + gbeanData.getAbstractName());
}
@@ -426,15 +426,14 @@ public final class ConfigurationUtil {
}
*/
// add a dependency from the gbean to the configuration
- gbeanData.addDependency(configurationName);
+// gbeanData.addDependency(configuration.getAbstractName());
}
- public static void startConfigurationGBeans(AbstractName configurationName, Configuration configuration, Kernel kernel) throws InvalidConfigException {
+ public static void loadConfigurationGBeans(Configuration configuration, Kernel kernel) throws InvalidConfigException {
List<GBeanData> gbeans = new ArrayList<GBeanData>(configuration.getGBeans().values());
Collections.sort(gbeans, new GBeanData.PriorityComparator());
List<AbstractName> loaded = new ArrayList<AbstractName>(gbeans.size());
- List<AbstractName> started = new ArrayList<AbstractName>(gbeans.size());
try {
// register all the GBeans
@@ -444,10 +443,10 @@ public final class ConfigurationUtil {
gbeanData = new GBeanData(gbeanData);
// preprocess the gbeanData (resolve references, set base url, declare dependency, etc.)
- preprocessGBeanData(configurationName, configuration, gbeanData);
+ preprocessGBeanData(configuration, gbeanData);
try {
- kernel.loadGBean(gbeanData, configuration.getBundleContext());
+ kernel.loadGBean(gbeanData, configuration.getBundle());
loaded.add(gbeanData.getAbstractName());
} catch (GBeanAlreadyExistsException e) {
throw new InvalidConfigException(e);
@@ -457,6 +456,37 @@ public final class ConfigurationUtil {
}
}
+
+ for (Configuration childConfiguration : configuration.getChildren()) {
+ ConfigurationUtil.loadConfigurationGBeans(childConfiguration, kernel);
+ }
+ } catch (Throwable e) {
+ for (AbstractName gbeanName : loaded) {
+ try {
+ kernel.unloadGBean(gbeanName);
+ } catch (GBeanNotFoundException ignored) {
+ } catch (IllegalStateException ignored) {
+ } catch (InternalKernelException kernelException) {
+ log.debug("Error cleaning up after failed start of configuration " + configuration.getId() + " gbean " + gbeanName, kernelException);
+ }
+ }
+ if (e instanceof Error) {
+ throw (Error) e;
+ }
+ if (e instanceof InvalidConfigException) {
+ throw (InvalidConfigException) e;
+ }
+ throw new InvalidConfigException("Unknown start exception", e);
+ }
+ }
+ public static void startConfigurationGBeans(Configuration configuration, Kernel kernel) throws InvalidConfigException {
+ List<GBeanData> gbeans = new ArrayList<GBeanData>(configuration.getGBeans().values());
+ Collections.sort(gbeans, new GBeanData.PriorityComparator());
+
+ List<AbstractName> started = new ArrayList<AbstractName>(gbeans.size());
+
+ try {
+
try {
// start the gbeans
for (GBeanData gbeanData : gbeans) {
@@ -495,7 +525,7 @@ public final class ConfigurationUtil {
}
for (Configuration childConfiguration : configuration.getChildren()) {
- ConfigurationUtil.startConfigurationGBeans(configurationName, childConfiguration, kernel);
+ ConfigurationUtil.startConfigurationGBeans(childConfiguration, kernel);
}
} catch (Throwable e) {
for (AbstractName gbeanName : started) {
@@ -507,15 +537,6 @@ public final class ConfigurationUtil {
log.debug("Error cleaning up after failed start of configuration " + configuration.getId() + " gbean " + gbeanName, kernelException);
}
}
- for (AbstractName gbeanName : loaded) {
- try {
- kernel.unloadGBean(gbeanName);
- } catch (GBeanNotFoundException ignored) {
- } catch (IllegalStateException ignored) {
- } catch (InternalKernelException kernelException) {
- log.debug("Error cleaning up after failed start of configuration " + configuration.getId() + " gbean " + gbeanName, kernelException);
- }
- }
if (e instanceof Error) {
throw (Error) e;
}
@@ -525,4 +546,32 @@ public final class ConfigurationUtil {
throw new InvalidConfigException("Unknown start exception", e);
}
}
+
+ public static void stopConfigurationGBeans(Configuration configuration, Kernel kernel) throws InvalidConfigException {
+ List<AbstractName> missing = new ArrayList<AbstractName>();
+ for (AbstractName name: configuration.getGBeans().keySet()) {
+ try {
+ kernel.stopGBean(name);
+ } catch (GBeanNotFoundException e) {
+ missing.add(name);
+ }
+ }
+ if (!missing.isEmpty()) {
+ throw new InvalidConfigException("Could not stop these gbeans: " + missing);
+ }
+ }
+
+ public static void unloadConfigurationGBeans(Configuration configuration, Kernel kernel) throws InvalidConfigException {
+ List<AbstractName> missing = new ArrayList<AbstractName>();
+ for (AbstractName name: configuration.getGBeans().keySet()) {
+ try {
+ kernel.unloadGBean(name);
+ } catch (GBeanNotFoundException e) {
+ missing.add(name);
+ }
+ }
+ if (!missing.isEmpty()) {
+ throw new InvalidConfigException("Could not unload these gbeans: " + missing);
+ }
+ }
}
Modified: geronimo/server/trunk/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/config/EditableKernelConfigurationManager.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/config/EditableKernelConfigurationManager.java?rev=1096952&r1=1096951&r2=1096952&view=diff
==============================================================================
--- geronimo/server/trunk/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/config/EditableKernelConfigurationManager.java (original)
+++ geronimo/server/trunk/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/config/EditableKernelConfigurationManager.java Tue Apr 26 23:19:31 2011
@@ -126,10 +126,10 @@ public class EditableKernelConfiguration
// preprocess the gbean data before loading it into the kernel
- ConfigurationUtil.preprocessGBeanData(configuration.getAbstractName(), configuration, gbean);
+ ConfigurationUtil.preprocessGBeanData(configuration, gbean);
// register the bean with the kernel
- kernel.loadGBean(gbean, configuration.getBundleContext());
+ kernel.loadGBean(gbean, configuration.getBundle());
// start the configuration
if (start) {
Modified: geronimo/server/trunk/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/config/KernelConfigurationManager.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/config/KernelConfigurationManager.java?rev=1096952&r1=1096951&r2=1096952&view=diff
==============================================================================
--- geronimo/server/trunk/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/config/KernelConfigurationManager.java (original)
+++ geronimo/server/trunk/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/config/KernelConfigurationManager.java Tue Apr 26 23:19:31 2011
@@ -182,7 +182,7 @@ public class KernelConfigurationManager
// load the configuration
try {
//TODO OSGI more likely use the configuration bundle??
- kernel.loadGBean(gbeanData, bundleContext);
+ kernel.loadGBean(gbeanData, bundleContext.getBundle());
} catch (GBeanAlreadyExistsException e) {
throw new InvalidConfigException("Unable to load configuration gbean " + configurationId, e);
}
@@ -225,7 +225,7 @@ public class KernelConfigurationManager
@Override
protected void startInternal(Configuration configuration) throws InvalidConfigException {
if (online) {
- ConfigurationUtil.startConfigurationGBeans(configuration.getAbstractName(), configuration, kernel);
+ ConfigurationUtil.startConfigurationGBeans(configuration, kernel);
}
if (configurationList != null && configuration.getConfigurationData().isAutoStart()) {
Modified: geronimo/server/trunk/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/util/MainConfigurationBootstrapper.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/util/MainConfigurationBootstrapper.java?rev=1096952&r1=1096951&r2=1096952&view=diff
==============================================================================
--- geronimo/server/trunk/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/util/MainConfigurationBootstrapper.java (original)
+++ geronimo/server/trunk/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/util/MainConfigurationBootstrapper.java Tue Apr 26 23:19:31 2011
@@ -53,9 +53,10 @@ public class MainConfigurationBootstrapp
protected Kernel kernel;
public Main getMain(BundleContext bundleContext) {
+ if (true) throw new IllegalStateException("use configurationExtender");
try {
bootKernel(bundleContext);
- loadBootConfiguration(bundleContext);
+// loadBootConfiguration(bundleContext);
loadPersistentConfigurations();
return getMain();
} catch (Exception e) {
@@ -81,9 +82,10 @@ public class MainConfigurationBootstrapp
}
public void loadBootConfiguration(BundleContext bundleContext) throws Exception {
+ if (true) throw new Exception("use ConfigurationExtender");
InputStream in = bundleContext.getBundle().getResource("META-INF/config.ser").openStream();
try {
- ConfigurationUtil.loadBootstrapConfiguration(kernel, in, bundleContext, true);
+// ConfigurationUtil.loadBootstrapConfiguration(kernel, in, bundleContext, true);
} finally {
if (in != null) {
try {
Modified: geronimo/server/trunk/framework/modules/geronimo-kernel/src/test/java/org/apache/geronimo/gbean/Speed.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/framework/modules/geronimo-kernel/src/test/java/org/apache/geronimo/gbean/Speed.java?rev=1096952&r1=1096951&r2=1096952&view=diff
==============================================================================
--- geronimo/server/trunk/framework/modules/geronimo-kernel/src/test/java/org/apache/geronimo/gbean/Speed.java (original)
+++ geronimo/server/trunk/framework/modules/geronimo-kernel/src/test/java/org/apache/geronimo/gbean/Speed.java Tue Apr 26 23:19:31 2011
@@ -99,7 +99,7 @@ public class Speed extends TestSupport {
GBeanData mockGBean = new GBeanData(abstractName, MockGBean.getGBeanInfo());
mockGBean.setAttribute("Name", "bar");
mockGBean.setAttribute("FinalInt", new Integer(57));
- kernel.loadGBean(mockGBean, getBundleContext());
+ kernel.loadGBean(mockGBean, getBundleContext().getBundle());
kernel.startGBean(abstractName);
// reflect proxy
@@ -228,7 +228,7 @@ public class Speed extends TestSupport {
GBeanData mockGBean = new GBeanData(abstractName, MockGBean.getGBeanInfo());
mockGBean.setAttribute("Name", "bar");
mockGBean.setAttribute("FinalInt", new Integer(57));
- kernel.loadGBean(mockGBean, getBundleContext());
+ kernel.loadGBean(mockGBean, getBundleContext().getBundle());
kernel.startGBean(mockGBean.getAbstractName());
// reflect proxy
Modified: geronimo/server/trunk/framework/modules/geronimo-kernel/src/test/java/org/apache/geronimo/gbean/runtime/GBeanAttributeTest.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/framework/modules/geronimo-kernel/src/test/java/org/apache/geronimo/gbean/runtime/GBeanAttributeTest.java?rev=1096952&r1=1096951&r2=1096952&view=diff
==============================================================================
--- geronimo/server/trunk/framework/modules/geronimo-kernel/src/test/java/org/apache/geronimo/gbean/runtime/GBeanAttributeTest.java (original)
+++ geronimo/server/trunk/framework/modules/geronimo-kernel/src/test/java/org/apache/geronimo/gbean/runtime/GBeanAttributeTest.java Tue Apr 26 23:19:31 2011
@@ -343,7 +343,7 @@ public class GBeanAttributeTest extends
kernel,
kernel.getDependencyManager(),
new MyLifecycleBroadcaster(),
- bundleContext);
+ bundleContext.getBundle());
getInvoker = new MethodInvoker() {
public Object invoke(Object target, Object[] arguments) throws Exception {
Modified: geronimo/server/trunk/framework/modules/geronimo-kernel/src/test/java/org/apache/geronimo/gbean/runtime/GBeanDependencyTest.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/framework/modules/geronimo-kernel/src/test/java/org/apache/geronimo/gbean/runtime/GBeanDependencyTest.java?rev=1096952&r1=1096951&r2=1096952&view=diff
==============================================================================
--- geronimo/server/trunk/framework/modules/geronimo-kernel/src/test/java/org/apache/geronimo/gbean/runtime/GBeanDependencyTest.java (original)
+++ geronimo/server/trunk/framework/modules/geronimo-kernel/src/test/java/org/apache/geronimo/gbean/runtime/GBeanDependencyTest.java Tue Apr 26 23:19:31 2011
@@ -39,10 +39,10 @@ public class GBeanDependencyTest extends
GBeanData gbeanDataParent = new GBeanData(parentName, MockGBean.getGBeanInfo());
GBeanData gbeanDataChild = new GBeanData(kernel.getNaming().createChildName(parentName, "child", "child"), MockGBean.getGBeanInfo());
gbeanDataChild.addDependency(new ReferencePatterns(parentName));
- kernel.loadGBean(gbeanDataChild, bundleContext);
+ kernel.loadGBean(gbeanDataChild, bundleContext.getBundle());
kernel.startGBean(gbeanDataChild.getAbstractName());
assertEquals(State.STARTING_INDEX, kernel.getGBeanState(gbeanDataChild.getAbstractName()));
- kernel.loadGBean(gbeanDataParent, bundleContext);
+ kernel.loadGBean(gbeanDataParent, bundleContext.getBundle());
assertEquals(State.STARTING_INDEX, kernel.getGBeanState(gbeanDataChild.getAbstractName()));
kernel.startGBean(parentName);
assertEquals(State.RUNNING_INDEX, kernel.getGBeanState(gbeanDataChild.getAbstractName()));
Modified: geronimo/server/trunk/framework/modules/geronimo-kernel/src/test/java/org/apache/geronimo/kernel/ConfigTest.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/framework/modules/geronimo-kernel/src/test/java/org/apache/geronimo/kernel/ConfigTest.java?rev=1096952&r1=1096951&r2=1096952&view=diff
==============================================================================
--- geronimo/server/trunk/framework/modules/geronimo-kernel/src/test/java/org/apache/geronimo/kernel/ConfigTest.java (original)
+++ geronimo/server/trunk/framework/modules/geronimo-kernel/src/test/java/org/apache/geronimo/kernel/ConfigTest.java Tue Apr 26 23:19:31 2011
@@ -43,23 +43,22 @@ public class ConfigTest extends TestCase
private AbstractName gbeanName1;
private AbstractName gbeanName2;
private ConfigurationData configurationData;
- private ConfigurationManager configurationManager;
+// private ConfigurationManager configurationManager;
public void testConfigLifecycle() throws Exception {
Artifact configurationId = configurationData.getId();
// load -- config should be running and gbean registered but not started
- configurationManager.loadConfiguration(configurationData);
- Configuration configuration = configurationManager.getConfiguration(configurationId);
- assertNull(configuration);
+ Configuration configuration = new Configuration(configurationData, null);
+ ConfigurationUtil.loadConfigurationGBeans(configuration, kernel);
+// assertNull(configuration);
// start -- gbeans should now be started
- configurationManager.startConfiguration(configurationId);
+ ConfigurationUtil.startConfigurationGBeans(configuration, kernel);
- configuration = configurationManager.getConfiguration(configurationId);
AbstractName configurationName = Configuration.getConfigurationAbstractName(configurationId);
assertNotNull(configuration.getBundle());
- assertEquals(State.RUNNING_INDEX, kernel.getGBeanState(configurationName));
+// assertEquals(State.RUNNING_INDEX, kernel.getGBeanState(configurationName));
assertTrue(kernel.isLoaded(gbeanName1));
assertTrue(kernel.isLoaded(gbeanName2));
@@ -88,16 +87,16 @@ public class ConfigTest extends TestCase
// stop -- gbeans should now be started, but still registered
- configurationManager.stopConfiguration(configurationId);
+ ConfigurationUtil.stopConfigurationGBeans(configuration, kernel);
- assertFalse(kernel.isLoaded(gbeanName1));
- assertFalse(kernel.isLoaded(gbeanName2));
+ assertFalse(kernel.isRunning(gbeanName1));
+ assertFalse(kernel.isRunning(gbeanName2));
// unload -- configuration and gbeans should be unloaded
- configurationManager.unloadConfiguration(configurationId);
+ ConfigurationUtil.unloadConfigurationGBeans(configuration, kernel);
- assertFalse(kernel.isLoaded(configurationName));
+// assertFalse(kernel.isLoaded(configurationName));
assertFalse(kernel.isLoaded(gbeanName1));
assertFalse(kernel.isLoaded(gbeanName2));
@@ -107,20 +106,20 @@ public class ConfigTest extends TestCase
Artifact configurationId = configurationData.getId();
// load -- config should be running and gbean registered but not started
- configurationManager.loadConfiguration(configurationData);
- Configuration configuration = configurationManager.getConfiguration(configurationId);
- assertNull(configuration);
+ Configuration configuration = new Configuration(configurationData, null);
+ ConfigurationUtil.loadConfigurationGBeans(configuration, kernel);
+// assertNull(configuration);
// start -- gbeans should now be started
- configurationManager.startConfiguration(configurationId);
+ ConfigurationUtil.startConfigurationGBeans(configuration, kernel);
- configuration = configurationManager.getConfiguration(configurationId);
+// configuration = configurationManager.getConfiguration(configurationId);
assertNotNull(configuration);
AbstractName configurationName = Configuration.getConfigurationAbstractName(configurationId);
- assertEquals(State.RUNNING_INDEX, kernel.getGBeanState(configurationName));
+// assertEquals(State.RUNNING_INDEX, kernel.getGBeanState(configurationName));
assertNotNull(configuration.getBundle());
assertTrue(kernel.isLoaded(gbeanName1));
@@ -130,27 +129,35 @@ public class ConfigTest extends TestCase
// stop -- gbeans should now be started, but still registered
- configurationManager.stopConfiguration(configurationId);
-
- assertFalse(kernel.isLoaded(gbeanName1));
- assertFalse(kernel.isLoaded(gbeanName2));
-
-
- // restart -- gbeans should now be started
- configurationManager.startConfiguration(configurationId);
+ for (AbstractName abstractName: configuration.getGBeans().keySet()) {
+// try {
+ kernel.stopGBean(abstractName);
+// } catch (GBeanNotFoundException e) {
+// logger.error("Could not stop gbean " + abstractName + " from bundle " + bundle.getLocation(), e);
+// }
+ }
assertTrue(kernel.isLoaded(gbeanName1));
assertTrue(kernel.isLoaded(gbeanName2));
- assertEquals(State.RUNNING_INDEX, kernel.getGBeanState(gbeanName1));
- assertEquals(State.RUNNING_INDEX, kernel.getGBeanState(gbeanName2));
+ assertEquals(State.STOPPED_INDEX, kernel.getGBeanState(gbeanName1));
+ assertEquals(State.STOPPED_INDEX, kernel.getGBeanState(gbeanName2));
- // unload -- configuration and gbeans should be unloaded
- configurationManager.stopConfiguration(configurationId);
- configurationManager.unloadConfiguration(configurationId);
- assertFalse(kernel.isLoaded(configurationName));
- assertFalse(kernel.isLoaded(gbeanName1));
- assertFalse(kernel.isLoaded(gbeanName2));
+ // restart -- gbeans should now be started
+// configurationManager.startConfiguration(configurationId);
+//
+// assertTrue(kernel.isLoaded(gbeanName1));
+// assertTrue(kernel.isLoaded(gbeanName2));
+// assertEquals(State.RUNNING_INDEX, kernel.getGBeanState(gbeanName1));
+// assertEquals(State.RUNNING_INDEX, kernel.getGBeanState(gbeanName2));
+//
+// // unload -- configuration and gbeans should be unloaded
+// configurationManager.stopConfiguration(configurationId);
+// configurationManager.unloadConfiguration(configurationId);
+//
+// assertFalse(kernel.isLoaded(configurationName));
+// assertFalse(kernel.isLoaded(gbeanName1));
+// assertFalse(kernel.isLoaded(gbeanName2));
}
@@ -185,20 +192,20 @@ public class ConfigTest extends TestCase
kernel = new BasicKernel();
// kernel.boot();
- ConfigurationData bootstrap = new ConfigurationData(new Artifact("bootstrap", "bootstrap", "", "car"), kernel.getNaming());
-
- GBeanData artifactManagerData = bootstrap.addGBean("ArtifactManager", DefaultArtifactManager.GBEAN_INFO);
-
- GBeanData artifactResolverData = bootstrap.addGBean("ArtifactResolver", DefaultArtifactResolver.class);
- artifactResolverData.setReferencePattern("ArtifactManager", artifactManagerData.getAbstractName());
-
- GBeanData configurationManagerData = bootstrap.addGBean("ConfigurationManager", KernelConfigurationManager.class);
- configurationManagerData.setReferencePattern("ArtifactManager", artifactManagerData.getAbstractName());
- configurationManagerData.setReferencePattern("ArtifactResolver", artifactResolverData.getAbstractName());
-
- ConfigurationUtil.loadBootstrapConfiguration(kernel, bootstrap, bundleContext);
-
- configurationManager = ConfigurationUtil.getConfigurationManager(kernel);
+// ConfigurationData bootstrap = new ConfigurationData(new Artifact("bootstrap", "bootstrap", "", "car"), kernel.getNaming());
+//
+// GBeanData artifactManagerData = bootstrap.addGBean("ArtifactManager", DefaultArtifactManager.GBEAN_INFO);
+//
+// GBeanData artifactResolverData = bootstrap.addGBean("ArtifactResolver", DefaultArtifactResolver.class);
+// artifactResolverData.setReferencePattern("ArtifactManager", artifactManagerData.getAbstractName());
+//
+// GBeanData configurationManagerData = bootstrap.addGBean("ConfigurationManager", KernelConfigurationManager.class);
+// configurationManagerData.setReferencePattern("ArtifactManager", artifactManagerData.getAbstractName());
+// configurationManagerData.setReferencePattern("ArtifactResolver", artifactResolverData.getAbstractName());
+//
+// ConfigurationUtil.loadBootstrapConfiguration(kernel, bootstrap, bundleContext);
+//
+// configurationManager = ConfigurationUtil.getConfigurationManager(kernel);
configurationData = new ConfigurationData(new Artifact("test", "test", "", "car"), kernel.getNaming());
Modified: geronimo/server/trunk/framework/modules/geronimo-kernel/src/test/java/org/apache/geronimo/kernel/GBeanTest.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/framework/modules/geronimo-kernel/src/test/java/org/apache/geronimo/kernel/GBeanTest.java?rev=1096952&r1=1096951&r2=1096952&view=diff
==============================================================================
--- geronimo/server/trunk/framework/modules/geronimo-kernel/src/test/java/org/apache/geronimo/kernel/GBeanTest.java (original)
+++ geronimo/server/trunk/framework/modules/geronimo-kernel/src/test/java/org/apache/geronimo/kernel/GBeanTest.java Tue Apr 26 23:19:31 2011
@@ -32,6 +32,7 @@ import org.apache.geronimo.kernel.basic.
import org.apache.geronimo.kernel.management.State;
import org.apache.geronimo.kernel.repository.Artifact;
import org.apache.geronimo.kernel.osgi.MockBundleContext;
+import org.osgi.framework.Bundle;
import org.osgi.framework.BundleContext;
/**
@@ -39,6 +40,7 @@ import org.osgi.framework.BundleContext;
*/
public class GBeanTest extends TestCase {
private BundleContext bundleContext = new MockBundleContext(getClass().getClassLoader(), null, null, null);
+ private Bundle bundle = bundleContext.getBundle();
private static KernelWrapper kernelWrapper = new KernelWrapper();
private BasicKernel realKernel;
private Kernel kernel;
@@ -85,7 +87,7 @@ public class GBeanTest extends TestCase
public void testListGBeans() throws Exception {
GBeanData gbean = buildGBeanData("name", "test", MockGBean.getGBeanInfo());
- kernel.loadGBean(gbean, bundleContext);
+ kernel.loadGBean(gbean, bundle);
kernel.startGBean(gbean.getAbstractName());
assertEquals(State.RUNNING_INDEX, kernel.getGBeanState(gbean.getAbstractName()));
@@ -102,7 +104,7 @@ public class GBeanTest extends TestCase
assertFalse(kernel.isLoaded(gbean.getAbstractName()));
assertFalse(kernel.isRunning(gbean.getAbstractName()));
- kernel.loadGBean(gbean, bundleContext);
+ kernel.loadGBean(gbean, bundle);
assertTrue(kernel.isLoaded(gbean.getAbstractName()));
assertFalse(kernel.isRunning(gbean.getAbstractName()));
@@ -123,7 +125,7 @@ public class GBeanTest extends TestCase
assertFalse(kernel.isLoaded("name"));
assertFalse(kernel.isRunning("name"));
- kernel.loadGBean(gbean, bundleContext);
+ kernel.loadGBean(gbean, bundle);
assertTrue(kernel.isLoaded("name"));
assertFalse(kernel.isRunning("name"));
@@ -144,7 +146,7 @@ public class GBeanTest extends TestCase
assertFalse(kernel.isLoaded(MockGBean.class));
assertFalse(kernel.isRunning(MockGBean.class));
- kernel.loadGBean(gbean, bundleContext);
+ kernel.loadGBean(gbean, bundle);
assertTrue(kernel.isLoaded(MockGBean.class));
assertFalse(kernel.isRunning(MockGBean.class));
@@ -165,7 +167,7 @@ public class GBeanTest extends TestCase
assertFalse(kernel.isLoaded("name", MockGBean.class));
assertFalse(kernel.isRunning("name", MockGBean.class));
- kernel.loadGBean(gbean, bundleContext);
+ kernel.loadGBean(gbean, bundle);
assertTrue(kernel.isLoaded("name", MockGBean.class));
assertFalse(kernel.isRunning("name", MockGBean.class));
@@ -187,7 +189,7 @@ public class GBeanTest extends TestCase
GBeanData gbean = buildGBeanData("name", "test", MockGBean.getGBeanInfo());
gbean.setAttribute("finalInt", new Integer(123));
- kernel.loadGBean(gbean, bundleContext);
+ kernel.loadGBean(gbean, bundle);
kernel.startGBean(gbean.getAbstractName());
assertTrue(kernel.isRunning(gbean.getAbstractName()));
@@ -222,7 +224,7 @@ public class GBeanTest extends TestCase
String otherValue = "other-value";
gbean.setAttribute("value", testValue);
- kernel.loadGBean(gbean, bundleContext);
+ kernel.loadGBean(gbean, bundle);
kernel.startGBean(gbean.getAbstractName());
assertTrue(kernel.isRunning(gbean.getAbstractName()));
MockGBean mockGBean = (MockGBean) kernel.getGBean(gbean.getAbstractName());
@@ -332,7 +334,7 @@ public class GBeanTest extends TestCase
gbean.setAttribute("name", "Test");
gbean.setAttribute("finalInt", new Integer(123));
- kernel.loadGBean(gbean, bundleContext);
+ kernel.loadGBean(gbean, bundle);
kernel.startGBean(gbean.getAbstractName());
assertEquals(State.RUNNING_INDEX, kernel.getGBeanState(gbean.getAbstractName()));
assertEquals("Hello", kernel.invoke(gbean.getAbstractName(), "doSomething", new Object[]{"Hello"}, new String[]{String.class.getName()}));
@@ -357,13 +359,13 @@ public class GBeanTest extends TestCase
// ClassLoader cl = MockGBean.class.getClassLoader();
GBeanData gbean1 = buildGBeanData("name", "test", MockGBean.getGBeanInfo());
gbean1.setAttribute("finalInt", new Integer(123));
- kernel.loadGBean(gbean1, bundleContext);
+ kernel.loadGBean(gbean1, bundle);
kernel.startGBean(gbean1.getAbstractName());
GBeanData gbean2 = buildGBeanData("name", "test2", MockGBean.getGBeanInfo());
gbean2.setAttribute("finalInt", new Integer(123));
gbean2.setReferencePattern("MockEndpoint", gbean1.getAbstractName());
- kernel.loadGBean(gbean2, bundleContext);
+ kernel.loadGBean(gbean2, bundle);
kernel.startGBean(gbean2.getAbstractName());
assertEquals("endpointCheck", kernel.invoke(gbean2.getAbstractName(), "checkEndpoint", null, null));
@@ -373,13 +375,13 @@ public class GBeanTest extends TestCase
// ClassLoader cl = MockGBean.class.getClassLoader();
GBeanData gbean1 = buildGBeanData("name", "test", MockGBean.getGBeanInfo());
gbean1.setAttribute("finalInt", new Integer(123));
- kernel.loadGBean(gbean1, bundleContext);
+ kernel.loadGBean(gbean1, bundle);
kernel.startGBean(gbean1.getAbstractName());
GBeanData gbean2 = buildGBeanData("name", "test2", MockGBean.getGBeanInfo());
gbean2.setAttribute("finalInt", new Integer(123));
gbean2.setReferencePattern("MockEndpoint", gbean1.getAbstractName());
- kernel.loadGBean(gbean2, bundleContext);
+ kernel.loadGBean(gbean2, bundle);
kernel.startGBean(gbean2.getAbstractName());
@@ -395,11 +397,11 @@ public class GBeanTest extends TestCase
// GBeanData gbean = buildGBeanData("name", "test", MockGBean.getGBeanInfo());
// gbean.setAttribute("name", "Test");
// gbean.setAttribute("finalInt", new Integer(123));
-// kernel.loadGBean(gbean, bundleContext);
+// kernel.loadGBean(gbean, bundle);
// kernel.startGBean(gbean.getAbstractName());
// ProxyManager mgr = kernel.getProxyManager();
//
-// Object test = mgr.createProxy(gbean.getAbstractName(), bundleContext);
+// Object test = mgr.createProxy(gbean.getAbstractName(), bundle);
// assertTrue(test instanceof MockEndpoint);
// assertTrue(test instanceof MockParentInterface1);
// assertTrue(test instanceof MockParentInterface2);
Modified: geronimo/server/trunk/framework/modules/geronimo-kernel/src/test/java/org/apache/geronimo/kernel/SimpleGBeanTest.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/framework/modules/geronimo-kernel/src/test/java/org/apache/geronimo/kernel/SimpleGBeanTest.java?rev=1096952&r1=1096951&r2=1096952&view=diff
==============================================================================
--- geronimo/server/trunk/framework/modules/geronimo-kernel/src/test/java/org/apache/geronimo/kernel/SimpleGBeanTest.java (original)
+++ geronimo/server/trunk/framework/modules/geronimo-kernel/src/test/java/org/apache/geronimo/kernel/SimpleGBeanTest.java Tue Apr 26 23:19:31 2011
@@ -20,13 +20,14 @@ import org.apache.geronimo.gbean.GBeanDa
import org.apache.geronimo.gbean.GBeanInfo;
import org.apache.geronimo.gbean.GBeanInfoBuilder;
import org.apache.geronimo.kernel.basic.BasicKernel;
+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.ConfigurationExtender;
import org.apache.geronimo.kernel.config.ConfigurationUtil;
-import org.apache.geronimo.kernel.config.KernelConfigurationManager;
import org.apache.geronimo.kernel.repository.Artifact;
import org.apache.geronimo.kernel.osgi.MockBundleContext;
import junit.framework.TestCase;
+import org.osgi.framework.BundleEvent;
/**
* @version $Rev$ $Date$
@@ -38,12 +39,15 @@ public class SimpleGBeanTest extends Tes
// boot the kernel
BasicKernel kernel = new BasicKernel();
// kernel.boot();
-
+ ConfigurationExtender configurationExtender = new ConfigurationExtender();
+ configurationExtender.setKernel(kernel);
+ configurationExtender.start(bundleContext);
// load the configuration manager bootstrap service
- ConfigurationData bootstrap = new ConfigurationData(new Artifact("bootstrap", "bootstrap", "", "car"), kernel.getNaming());
- bootstrap.addGBean("ConfigurationManager", KernelConfigurationManager.class);
- ConfigurationUtil.loadBootstrapConfiguration(kernel, bootstrap, bundleContext);
- ConfigurationManager configurationManager = kernel.getGBean(ConfigurationManager.class);
+// ConfigurationData bootstrap = new ConfigurationData(new Artifact("bootstrap", "bootstrap", "", "car"), kernel.getNaming());
+// bootstrap.addGBean("ConfigurationManager", KernelConfigurationManager.class);
+
+// ConfigurationUtil.loadBootstrapConfiguration(kernel, bootstrap, bundleContext);
+// ConfigurationManager configurationManager = kernel.getGBean(ConfigurationManager.class);
// create a configuration for our test bean
Artifact configurationId = new Artifact("test", "test", "", "car");
@@ -51,10 +55,14 @@ public class SimpleGBeanTest extends Tes
configurationData.setBundle(bundleContext.getBundle());
GBeanData mockBean1 = configurationData.addGBean("MyBean", TestGBean.getGBeanInfo());
mockBean1.setAttribute("value", "1234");
-
+ Configuration configuration = new Configuration(configurationData, null);
// load and start the configuration
- configurationManager.loadConfiguration(configurationData);
- configurationManager.startConfiguration(configurationId);
+ ConfigurationUtil.loadConfigurationGBeans(configuration, kernel);
+ ConfigurationUtil.startConfigurationGBeans(configuration, kernel);
+// bundleContext.bundleEvent(BundleEvent.RESOLVED, bundleContext.getBundle());
+// bundleContext.bundleEvent(BundleEvent.STARTED, bundleContext.getBundle());
+// configurationManager.loadConfiguration(configurationData);
+// configurationManager.startConfiguration(configurationId);
// invoke GBean directly
TestGBean testGBean = (TestGBean) kernel.getGBean("MyBean");
@@ -76,8 +84,10 @@ public class SimpleGBeanTest extends Tes
assertEquals("1234", kernel.invoke("MyBean", TestGBean.class, "fetchValue"));
// stop and unload configuration
- configurationManager.stopConfiguration(configurationId);
- configurationManager.unloadConfiguration(configurationId);
+// bundleContext.bundleEvent(BundleEvent.STOPPED, bundleContext.getBundle());
+// bundleContext.bundleEvent(BundleEvent.UNRESOLVED, bundleContext.getBundle());
+// configurationManager.stopConfiguration(configurationId);
+// configurationManager.unloadConfiguration(configurationId);
// stop the kernel
kernel.shutdown();