for (Iterator i = stores.iterator(); i.hasNext();) {
AbstractName storeName = (AbstractName) i.next();
try {
List infos = mgr.listConfigurations(storeName);
for (Iterator j = infos.iterator(); j.hasNext();) {
ConfigurationInfo info = (ConfigurationInfo) j.next();
AbstractName configuration = Configuration.getConfigurationAbstractName(info.getConfigID());
if (type == null || type.getValue() == info.getType().getValue()) {
J2EEDeployedObject module = getModuleForConfiguration(info.getConfigID());
results.add(new ConfigurationData(info.getConfigID(), configuration, null, info.getState(), info.getType(), module == null ? null : kernel.getAbstractNameFor(module)));
}
if (includeChildModules && info.getType().getValue() == ConfigurationModuleType.EAR.getValue() && info.getState().toInt() == State.RUNNING_INDEX)
{
J2EEApplication app = (J2EEApplication) getModuleForConfiguration(info.getConfigID());
if (app == null) {
throw new IllegalStateException("Unable to load children for J2EE Application '" + info.getConfigID() + "' (no J2EEApplication found)");
}
Object[] modules = null;
if (type == null) {
modules = app.getModulesInstances();
} else if (type.equals(ConfigurationModuleType.CAR)) {
modules = app.getClientModules();
} else if (type.equals(ConfigurationModuleType.EJB)) {
modules = app.getEJBModules();
} else if (type.equals(ConfigurationModuleType.RAR)) {
modules = app.getRAModules();
} else if (type.equals(ConfigurationModuleType.WAR)) {
modules = app.getWebModules();
} //todo: handle dynamically registered module types, etc.
if (modules == null) continue;
for (int k = 0; k < modules.length; k++) {
Object module = modules[k];
ConfigurationModuleType moduleType = type;
if (moduleType == null) {
if (module instanceof WebModule) {
moduleType = ConfigurationModuleType.WAR;
} else if (module instanceof EJBModule) {
moduleType = ConfigurationModuleType.EJB;
} else if (module instanceof ResourceAdapterModule) {
moduleType = ConfigurationModuleType.RAR;
} else if (module instanceof AppClientModule) moduleType = ConfigurationModuleType.CAR;
}
String moduleName;
if (type != null && type.equals(ConfigurationModuleType.WAR)) {
moduleName = ((WebModule) module).getWARName();
} else {
//todo: solutions for other module types
moduleName = (String) kernel.getAbstractNameFor(module).getName().get(NameFactory.J2EE_NAME);
}
results.add(new ConfigurationData(info.getConfigID(), configuration, moduleName, info.getState(), moduleType, kernel.getAbstractNameFor(module)));
}
}
}
} catch (NoSuchStoreException e) {
// we just got this list so this should not happen