// First resolve its class
ClassReference classReference = new ClassReference(implementation.getPOJOName());
classReference = resolver.resolveModel(ClassReference.class, classReference);
Class<?> pojoClass = classReference.getJavaClass();
if (pojoClass == null) {
throw new ContributionResolveException("Class could not be resolved: " + implementation.getPOJOName());
}
implementation.setPOJOClass(pojoClass);
// Check to see if we have a .componentType file describing the POJO class
ComponentType componentType = assemblyFactory.createComponentType();
componentType.setUnresolved(true);
componentType.setURI(implementation.getURI() + ".componentType");
componentType = resolver.resolveModel(ComponentType.class, componentType);
if (!componentType.isUnresolved()) {
// We have a component type description, merge it into the POJO model
implementation.getServices().addAll(componentType.getServices());
implementation.getReferences().addAll(componentType.getReferences());
implementation.getProperties().addAll(componentType.getProperties());
} else {
// We have no component type description, simply introspect the POJO and
// create a single Service for it
Service service = assemblyFactory.createService();
service.setName(pojoClass.getSimpleName());
JavaInterface javaInterface;
try {
javaInterface = javaFactory.createJavaInterface(pojoClass);
} catch (InvalidInterfaceException e) {
throw new ContributionResolveException(e);
}
JavaInterfaceContract interfaceContract = javaFactory.createJavaInterfaceContract();
interfaceContract.setInterface(javaInterface);
service.setInterfaceContract(interfaceContract);
implementation.getServices().add(service);