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);