*/
public static Module createModuleWithWiredComponentsOfDifferentInterface(Scope sourceScope, Scope targetScope) {
// create the target component
AtomicComponent target = factory.createSimpleComponent();
target.setName("target");
JavaImplementation targetImpl = factory.createJavaImplementation();
targetImpl.setComponentType(factory.createComponentType());
targetImpl.setImplementationClass(OtherTargetImpl.class);
target.setImplementation(targetImpl);
Service targetService = factory.createService();
JavaServiceContract targetContract = factory.createJavaServiceContract();
targetContract.setInterface(OtherTarget.class);
targetService.setServiceContract(targetContract);
targetService.setName("Target");
targetImpl.getComponentType().getServices().add(targetService);
targetContract.setScope(targetScope);
ConfiguredService cTargetService = factory.createConfiguredService();
cTargetService.setPort(targetService);
cTargetService.initialize(assemblyContext);
target.getConfiguredServices().add(cTargetService);
target.initialize(assemblyContext);
// create the source component
AtomicComponent source = factory.createSimpleComponent();
ComponentType componentType = factory.createComponentType();
source.setName("source");
JavaImplementation impl = factory.createJavaImplementation();
impl.setComponentType(componentType);
impl.setImplementationClass(SourceImpl.class);
source.setImplementation(impl);
Service s = systemFactory.createService();
JavaServiceContract contract = systemFactory.createJavaServiceContract();
contract.setInterface(Source.class);
s.setServiceContract(contract);
contract.setScope(sourceScope);
impl.getComponentType().getServices().add(s);
source.setImplementation(impl);
// wire source to target
JavaServiceContract refContract = systemFactory.createJavaServiceContract();
refContract.setInterface(Target.class);
Reference reference = systemFactory.createReference();
reference.setName("setTarget");
reference.setServiceContract(refContract);
componentType.getReferences().add(reference);
ConfiguredReference cReference = systemFactory.createConfiguredReference(reference.getName(), "target");
cReference.initialize(assemblyContext);
source.getConfiguredReferences().add(cReference);
// wire multiplicity using a setter
JavaServiceContract refContract2 = systemFactory.createJavaServiceContract();
refContract2.setInterface(Target.class);
Reference reference2 = systemFactory.createReference();
reference2.setName("setTargets");
reference2.setServiceContract(refContract2);
reference2.setMultiplicity(Multiplicity.ONE_N);
componentType.getReferences().add(reference2);
ConfiguredReference cReference2 = systemFactory.createConfiguredReference(reference2.getName(), "target");
cReference2.initialize(assemblyContext);
source.getConfiguredReferences().add(cReference2);
// wire multiplicity using a field
JavaServiceContract refContract3 = systemFactory.createJavaServiceContract();
refContract3.setInterface(Target.class);
Reference reference3 = systemFactory.createReference();
reference3.setName("targetsThroughField");
reference3.setServiceContract(refContract3);
reference3.setMultiplicity(Multiplicity.ONE_N);
componentType.getReferences().add(reference3);
ConfiguredReference cReference3 = systemFactory.createConfiguredReference(reference3.getName(), "target");
cReference3.initialize(assemblyContext);
source.getConfiguredReferences().add(cReference3);
// wire multiplicity using a array
JavaServiceContract refContract4 = systemFactory.createJavaServiceContract();
refContract4.setInterface(Target.class);
Reference reference4 = systemFactory.createReference();
reference4.setName("setArrayOfTargets");
reference4.setServiceContract(refContract4);
reference4.setMultiplicity(Multiplicity.ONE_N);
componentType.getReferences().add(reference4);
ConfiguredReference cReference4 = systemFactory.createConfiguredReference(reference4.getName(), "target");
cReference4.initialize(assemblyContext);
source.getConfiguredReferences().add(cReference4);
source.initialize(assemblyContext);
Module module = systemFactory.createModule();
module.setName("system.module");
module.getComponents().add(source);