// 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 so the war itself must have been the contribution
Composite appComposite = (Composite)resolved.getObject();
mergeCompositeInfo(appComposite, implementation);
}
// TODO: Obtain includeDefaults value from the composite
boolean includeDefaults = false;
if(includeDefaults || resolved == unresolved) {
// there is either no application composite or we are ignoring it as the
// war is nested inside another contribution
if(jeeOptionalExtension != null) {
jeeOptionalExtension.createImplementationJeeComposite((WebModuleInfo)moduleInfo, implementation);
}
// now resolve the implementation composite as a real composite.
compositeProcessor.resolve((Composite)implementation, resolver);
}
} 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 so the ejb jar itself must have been the contribution
Composite appComposite = (Composite)resolved.getObject();
mergeCompositeInfo(appComposite, implementation);
}
// TODO: Obtain includeDefaults value from the composite
boolean includeDefaults = false;
if(includeDefaults || resolved == unresolved) {
if(jeeExtension != null) {
jeeExtension.createImplementationJeeComposite((EjbModuleInfo)moduleInfo, implementation);
}
if(jeeOptionalExtension != null) {
jeeOptionalExtension.createImplementationJeeComposite((EjbModuleInfo)moduleInfo, implementation);
}
// now resolve the implementation composite as a real composite.
compositeProcessor.resolve((Composite)implementation, resolver);
}
} 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 so copy it's details across into