// Resolve the component type
String uri = implementation.getURI();
String archive = implementation.getArchive();
if (uri != null) {
Object moduleInfo = null;
ExternalEarInfo extEar = null;
if(uri.equals("")) {
if(moduleInfo == null) {
WebModuleInfo unresolved = new WebModuleInfoImpl();
unresolved.setUri(URI.create(archive));
WebModuleInfo resolved = resolver.resolveModel(WebModuleInfo.class, unresolved);
if(unresolved != resolved) {
moduleInfo = resolved;
}
}
if(moduleInfo == null) {
EjbModuleInfo unresolved = new EjbModuleInfoImpl();
unresolved.setUri(URI.create(archive));
EjbModuleInfo resolved = resolver.resolveModel(EjbModuleInfo.class, unresolved);
if(unresolved != resolved) {
moduleInfo = resolved;
}
}
if(moduleInfo == null) {
JavaEEApplicationInfo unresolved = new JavaEEApplicationInfoImpl();
unresolved.setUri(URI.create(archive));
JavaEEApplicationInfo resolved = resolver.resolveModel(JavaEEApplicationInfo.class, unresolved);
if(unresolved != resolved) {
moduleInfo = resolved;
}
}
} else if(uri.endsWith(".war")) {
WebModuleInfo webModuleInfo = new WebModuleInfoImpl();
webModuleInfo.setUri(URI.create(archive));
webModuleInfo = resolver.resolveModel(WebModuleInfo.class, webModuleInfo);
moduleInfo = webModuleInfo;
} else if(uri.endsWith(".jar")) {
EjbModuleInfo ejbModuleInfo = new EjbModuleInfoImpl();
ejbModuleInfo.setUri(URI.create(archive));
ejbModuleInfo = resolver.resolveModel(EjbModuleInfo.class, ejbModuleInfo);
moduleInfo = ejbModuleInfo;
} else if(uri.endsWith(".ear")) {
final JavaEEApplicationInfo appInfo = new JavaEEApplicationInfoImpl();
appInfo.setUri(URI.create(archive));
ExternalEarInfo unresolved = new ExternalEarInfo() {
public JavaEEApplicationInfo getAppInfo() {
return appInfo;
}
public Composite getAppComposite() {
return null;
}};
ExternalEarInfo resolved = resolver.resolveModel(ExternalEarInfo.class, unresolved);
if(resolved != unresolved) {
extEar = resolved;
}
moduleInfo = resolved.getAppInfo();
}
if(moduleInfo instanceof WebModuleInfo) {
// Check for web composite
ModelObject unresolved = new ModelObjectImpl();
unresolved.setUri(URI.create("WEB-INF/web.composite"));
ModelObject resolved = resolver.resolveModel(ModelObject.class, unresolved);
if(resolved != unresolved) {
// Found web composite
Composite appComposite = (Composite)resolved.getObject();
implementation.getServices().addAll(appComposite.getServices());
implementation.getReferences().addAll(appComposite.getReferences());
implementation.getProperties().addAll(appComposite.getProperties());
}
// TODO: Obtain includeDefaults value from the composite
boolean includeDefaults = false;
if(includeDefaults || resolved == unresolved) {
if(jeeOptionalExtension != null) {
ComponentType ct = jeeOptionalExtension.createImplementationJeeComponentType((WebModuleInfo)moduleInfo);
implementation.getReferences().addAll(ct.getReferences());
implementation.getProperties().addAll(ct.getProperties());
}
}
} else if(moduleInfo instanceof EjbModuleInfo) {
// Check for ejb-jar composite
ModelObject unresolved = new ModelObjectImpl();
unresolved.setUri(URI.create("META-INF/ejb-jar.composite"));
ModelObject resolved = resolver.resolveModel(ModelObject.class, unresolved);
if(resolved != unresolved) {
// Found ejb-jar composite
Composite appComposite = (Composite)resolved.getObject();
implementation.getServices().addAll(appComposite.getServices());
implementation.getReferences().addAll(appComposite.getReferences());
implementation.getProperties().addAll(appComposite.getProperties());
}
// TODO: Obtain includeDefaults value from the composite
boolean includeDefaults = false;
if(includeDefaults || resolved == unresolved) {
if(jeeExtension != null) {
ComponentType ct = jeeExtension.createImplementationJeeComponentType((EjbModuleInfo)moduleInfo);
implementation.getServices().addAll(ct.getServices());
}
if(jeeOptionalExtension != null) {
ComponentType ct = jeeOptionalExtension.createImplementationJeeComponentType((EjbModuleInfo)moduleInfo);
implementation.getServices().addAll(ct.getServices());
implementation.getReferences().addAll(ct.getReferences());
implementation.getProperties().addAll(ct.getProperties());
}
}
} else if(moduleInfo instanceof JavaEEApplicationInfo) {
// Check for application composite
Composite appComposite = null;
if(extEar != null) {
appComposite = extEar.getAppComposite();
} else {
ModelObject unresolved = new ModelObjectImpl();
unresolved.setUri(URI.create("META-INF/application.composite"));
ModelObject resolved = resolver.resolveModel(ModelObject.class, unresolved);
if(resolved != unresolved) {
// Found application composite
appComposite = (Composite)resolved.getObject();
}
}
if(appComposite != null) {
// Found application composite