/** * Returns a corresponding pair instance (existing or newly created). * * @param assemblyComponent * The assemble component for the pair. * @param operation * The operation for the pair. * * @return The corresponding pair instance if it exists, otherwise a new one. */ public final AssemblyComponentOperationPair getPairInstanceByPair(final AssemblyComponent assemblyComponent, final Operation operation) { final String namedIdentifier = assemblyComponent.getId() + "-" + operation.getId(); final AssemblyComponentOperationPair inst = this.getPairByNamedIdentifier(namedIdentifier); if (inst == null) { return this.createAndRegisterPair(namedIdentifier, operation, assemblyComponent); } return inst; }
private AssemblyComponentOperationPair createAndRegisterPair(final String namedIdentifier, final Operation operation, final AssemblyComponent assemblyComponent) { if (this.pairsByName.containsKey(namedIdentifier)) { throw new IllegalArgumentException("Element with name " + namedIdentifier + "exists already"); } final int id = this.getAndIncrementNextId(); final AssemblyComponentOperationPair newInst = new AssemblyComponentOperationPair(id, operation, assemblyComponent); this.pairsById.put(id, newInst); this.pairsByName.put(namedIdentifier, newInst); return newInst; }
/** * {@inheritDoc} */ @Override protected AssemblyComponentOperationPair concreteCreatePair(final SynchronousCallMessage callMsg) { final Execution execution = callMsg.getReceivingExecution(); final AssemblyComponent assemblyComponent = execution.getAllocationComponent().getAssemblyComponent(); final Operation op = execution.getOperation(); return this.getSystemEntityFactory().getAssemblyPairFactory().getPairInstanceByPair(assemblyComponent, op); } }
/** * Creates a new instance of this class using the given parameters. * * @param configuration * The configuration to use for this repository. * @param projectContext * The project context to use for this repository. */ public SystemModelRepository(final Configuration configuration, final IProjectContext projectContext) { super(configuration, projectContext); this.typeRepositoryFactory = new TypeRepository(this); this.assemblyFactory = new AssemblyRepository(this); this.executionEnvironmentFactory = new ExecutionEnvironmentRepository(this); this.allocationFactory = new AllocationRepository(this); this.operationFactory = new OperationRepository(this); this.allocationPairFactory = new AllocationComponentOperationPairFactory(this); this.assemblyPairFactory = new AssemblyComponentOperationPairFactory(this); }
senderPair = this.getGraph().getRootNode().getEntity(); } else { senderPair = pairFactory.getPairInstanceByPair(senderComponent, senderOperation); receiverPair = this.getGraph().getRootNode().getEntity(); } else { receiverPair = pairFactory.getPairInstanceByPair(receiverComponent, receiverOperation);