use of org.apache.openejb.assembler.classic.InfoObject in project tomee by apache.
the class VmDeploymentManager method toTargetModuleId.
private static TargetModuleID toTargetModuleId(final AppInfo appInfo, final ModuleType allowedModuleType) {
final List<InfoObject> infos = new ArrayList<InfoObject>();
infos.addAll(appInfo.clients);
infos.addAll(appInfo.ejbJars);
infos.addAll(appInfo.webApps);
infos.addAll(appInfo.connectors);
// if the module id is the same as the appInfo, then it is a standalone module
if (infos.size() == 1) {
final InfoObject infoObject = infos.get(0);
if (infoObject instanceof ClientInfo) {
final ClientInfo clientInfo = (ClientInfo) infoObject;
if (null != appInfo.path && appInfo.path.equals(clientInfo.path)) {
// are client modules allowed
if (allowedModuleType != null && !allowedModuleType.equals(ModuleType.CAR)) {
return null;
}
if (null != clientInfo.moduleId && clientInfo.moduleId.equals(appInfo.path)) {
return new TargetModuleIDImpl(DEFAULT_TARGET, clientInfo.moduleId);
}
}
}
if (infoObject instanceof EjbJarInfo) {
final EjbJarInfo ejbJarInfo = (EjbJarInfo) infoObject;
if (null != appInfo.path && appInfo.path.equals(ejbJarInfo.path)) {
// are ejb modules allowed
if (allowedModuleType != null && !allowedModuleType.equals(ModuleType.EJB)) {
return null;
}
if (null != ejbJarInfo.moduleName && ejbJarInfo.moduleName.equals(appInfo.appId)) {
return new TargetModuleIDImpl(DEFAULT_TARGET, ejbJarInfo.moduleName);
}
}
}
if (infoObject instanceof ConnectorInfo) {
final ConnectorInfo connectorInfo = (ConnectorInfo) infoObject;
if (null != appInfo.path && appInfo.path.equals(connectorInfo.path)) {
// are connector modules allowed
if (allowedModuleType != null && !allowedModuleType.equals(ModuleType.RAR)) {
return null;
}
if (null != connectorInfo.moduleId && connectorInfo.moduleId.equals(appInfo.path)) {
return new TargetModuleIDImpl(DEFAULT_TARGET, connectorInfo.moduleId);
}
}
}
if (infoObject instanceof WebAppInfo) {
final WebAppInfo webAppInfo = (WebAppInfo) infoObject;
if (null != appInfo.path && appInfo.path.equals(webAppInfo.path)) {
// are web app modules allowed
if (allowedModuleType != null && !allowedModuleType.equals(ModuleType.WAR)) {
return null;
}
if (null != webAppInfo.moduleId && webAppInfo.moduleId.equals(appInfo.path)) {
//todo web module
return new TargetModuleIDImpl(DEFAULT_TARGET, webAppInfo.moduleId);
}
}
}
}
// are ear modules allowed
if (allowedModuleType != null && !allowedModuleType.equals(ModuleType.EAR)) {
return null;
}
final TargetModuleIDImpl earModuleId = new TargetModuleIDImpl(DEFAULT_TARGET, appInfo.path);
for (final ClientInfo clientInfo : appInfo.clients) {
final TargetModuleIDImpl clientModuleId = new TargetModuleIDImpl(DEFAULT_TARGET, clientInfo.moduleId);
clientModuleId.setParentTargetModuleID(earModuleId);
}
for (final EjbJarInfo ejbJarInfo : appInfo.ejbJars) {
final TargetModuleIDImpl ejbJarModuleId = new TargetModuleIDImpl(DEFAULT_TARGET, ejbJarInfo.moduleName);
ejbJarModuleId.setParentTargetModuleID(earModuleId);
}
for (final ConnectorInfo connectorInfo : appInfo.connectors) {
final TargetModuleIDImpl clientModuleId = new TargetModuleIDImpl(DEFAULT_TARGET, connectorInfo.moduleId);
clientModuleId.setParentTargetModuleID(earModuleId);
}
for (final WebAppInfo webAppInfo : appInfo.webApps) {
final TargetModuleIDImpl clientModuleId = new TargetModuleIDImpl(DEFAULT_TARGET, webAppInfo.moduleId, webAppInfo.contextRoot);
clientModuleId.setParentTargetModuleID(earModuleId);
}
return earModuleId;
}
use of org.apache.openejb.assembler.classic.InfoObject in project tomee by apache.
the class TypeInfoTestUtil method dumpMap.
private static void dumpMap(String name, Map<Object, Object> map) throws Exception {
for (Map.Entry<Object, Object> entry : map.entrySet()) {
Object key = entry.getKey();
Object value = entry.getValue();
if (isSimpleValue(key) && isSimpleValue(value)) {
System.out.println(name + ".put(" + getSimpleValue(key) + ", " + getSimpleValue(value) + ");");
} else {
String indent = name.substring(0, getIndentSize(name));
String baseName;
if (value instanceof InfoObject) {
baseName = value.getClass().getSimpleName();
if (baseName.endsWith("Info"))
baseName = baseName.substring(0, baseName.length() - 4);
baseName = Character.toLowerCase(baseName.charAt(0)) + baseName.substring(1);
} else {
baseName = name.substring(indent.length()).replace('.', '_');
if (baseName.endsWith("Key"))
baseName = baseName.substring(0, baseName.length() - 3);
}
System.out.println(indent + "{");
dump(indent + " " + baseName + "Key", key);
System.out.println();
dump(indent + " " + baseName, value);
System.out.println();
System.out.println(" " + name + ".put(" + baseName + "Key, " + baseName + ");");
System.out.println(indent + "}");
}
}
}
use of org.apache.openejb.assembler.classic.InfoObject in project tomee by apache.
the class TypeInfoTestUtil method diff.
public static void diff(String name, Object expected, Object actual, List<String> messages) throws Exception {
for (Field field : expected.getClass().getFields()) {
String fieldName = name == null ? field.getName() : name + "." + field.getName();
Object expectedValue = field.get(expected);
Object actualValue = field.get(actual);
if (expectedValue instanceof InfoObject) {
diff(fieldName, expectedValue, actualValue, messages);
} else if (expectedValue instanceof Map) {
//noinspection unchecked
diffMap(fieldName, (Map) expectedValue, (Map) actualValue, messages);
} else {
diffSimple(fieldName, expectedValue, actualValue, messages);
}
}
}
Aggregations