String name = config.getName();
Descriptor desc = getDescriptor();
if (name.equals(CompositeModel.COMPOSITE)) {
return new V1CompositeModel(config, desc);
} else if (name.equals(CompositeServiceModel.SERVICE)) {
Configuration config_parent = config.getParent();
if (config_parent != null) {
if (config_parent.getName().equals(CompositeModel.COMPOSITE)) {
return new V1CompositeServiceModel(config, desc);
} else if (config_parent.getName().equals(ComponentModel.COMPONENT)) {
return new V1ComponentServiceModel(config, desc);
}
}
} else if (name.startsWith(BindingModel.BINDING)) {
if (name.endsWith("." + SCABindingModel.SCA)) {
return new V1SCABindingModel(config, desc);
} else {
return new V1BindingModel(config, desc);
}
} else if (name.equals(ComponentModel.COMPONENT)) {
return new V1ComponentModel(config, desc);
} else if (name.startsWith(ComponentImplementationModel.IMPLEMENTATION)) {
if (name.equals(IMPLEMENTATION_BPEL)) {
return new V1BPELComponentImplementationModel(config, getDescriptor());
}
return new V1ComponentImplementationModel(config, desc);
} else if (name.startsWith(InterfaceModel.INTERFACE)) {
Configuration config_parent = config.getParent();
if (config_parent != null) {
// only pick up standard SCA interface types
if (name.endsWith(InterfaceModel.JAVA) || name.endsWith(InterfaceModel.WSDL)) {
return new V1InterfaceModel(config, desc);
}
}
} else if (name.equals(ComponentReferenceModel.REFERENCE)) {
Configuration config_parent = config.getParent();
if (config_parent != null) {
if (config_parent.getName().equals(CompositeModel.COMPOSITE)) {
return new V1CompositeReferenceModel(config, desc);
} else if (config_parent.getName().equals(ComponentModel.COMPONENT)) {
return new V1ComponentReferenceModel(config, desc);
}
}
} else if (name.equals(PropertyModel.PROPERTY)) {
return new V1PropertyModel(config,desc);