*
* @return The Module, or null if the configuration is not running.
*/
public J2EEDeployedObject getModuleForConfiguration(Artifact configuration) {
ConfigurationManager manager = ConfigurationUtil.getConfigurationManager(kernel);
Configuration config = manager.getConfiguration(configuration);
if (config == null || !manager.isRunning(configuration)) {
return null; // The configuration is not running, so we can't get its contents
}
ConfigurationModuleType type = config.getModuleType();
AbstractName result;
try {
if (type.equals(ConfigurationModuleType.CAR)) {
result = config.findGBean(new AbstractNameQuery(AppClientModule.class.getName()));
} else if (type.equals(ConfigurationModuleType.EAR)) {
result = config.findGBean(new AbstractNameQuery(J2EEApplication.class.getName()));
} else if (type.equals(ConfigurationModuleType.EJB)) {
result = config.findGBean(new AbstractNameQuery(EJBModule.class.getName()));
} else if (type.equals(ConfigurationModuleType.RAR)) {
result = config.findGBean(new AbstractNameQuery(ResourceAdapterModule.class.getName()));
} else if (type.equals(ConfigurationModuleType.WAR)) {
result = config.findGBean(new AbstractNameQuery(WebModule.class.getName()));
} else {
return null;
}
ClassLoader classLoader = kernel.getClassLoaderFor(result);
return (J2EEDeployedObject) kernel.getProxyManager().createProxy(result, classLoader);