/**
* Creates a component named "source" with a reference to target/Target
*/
public static ComponentDefinition<SystemImplementation> createSourceWithTargetReference()
throws NoSuchMethodException {
SystemImplementation impl = new SystemImplementation();
PojoComponentType componentType = new PojoComponentType();
componentType.setImplementationScope(Scope.MODULE);
componentType
.setConstructorDefinition(
new ConstructorDefinition<SourceImpl>(SourceImpl.class.getConstructor((Class[]) null)));
JavaMappedReference reference;
try {
reference = new JavaMappedReference();
reference.setName("target");
reference.setMember(SourceImpl.class.getMethod("setTarget", Target.class));
JavaServiceContract contract = new JavaServiceContract();
contract.setInterfaceClass(Target.class);
reference.setServiceContract(contract);
componentType.add(reference);
} catch (NoSuchMethodException e) {
throw new AssertionError(e);
}
impl.setComponentType(componentType);
impl.setImplementationClass(SourceImpl.class);
ComponentDefinition<SystemImplementation> sourceComponentDefinition =
new ComponentDefinition<SystemImplementation>(impl);
sourceComponentDefinition.setName("source");
ReferenceTarget referenceTarget = new ReferenceTarget();