/** * 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); }
private String htmlEntityRef(final int id, final String caption, final EntityType entityType) { final StringBuilder strBuild = new StringBuilder(64); strBuild.append("<a href=\"#").append(SystemModelRepository.simpleHTMLEscape(entityType.toString())).append('-').append(id).append("\">").append(caption) .append("</a>"); return strBuild.toString(); }
AllocationComponent allocInst = systemModelRepository.getAllocationFactory() .lookupAllocationComponentInstanceByNamedIdentifier(allocationComponentName); if (allocInst == null) { // Allocation component instance doesn't exist AssemblyComponent assemblyComponent = systemModelRepository.getAssemblyFactory() .lookupAssemblyComponentInstanceByNamedIdentifier(assemblyComponentTypeName); if (assemblyComponent == null) { // assembly instance doesn't exist ComponentType componentType = systemModelRepository.getTypeRepositoryFactory().lookupComponentTypeByNamedIdentifier(assemblyComponentTypeName); if (componentType == null) { // NOPMD NOCS (NestedIf) componentType = systemModelRepository.getTypeRepositoryFactory().createAndRegisterComponentType(assemblyComponentTypeName, assemblyComponentTypeName); assemblyComponent = systemModelRepository.getAssemblyFactory() .createAndRegisterAssemblyComponentInstance(assemblyComponentTypeName, componentType); ExecutionContainer execContainer = systemModelRepository.getExecutionEnvironmentFactory() .lookupExecutionContainerByNamedIdentifier(executionContainerName); if (execContainer == null) { // doesn't exist, yet execContainer = systemModelRepository.getExecutionEnvironmentFactory() .createAndRegisterExecutionContainer(executionContainerName, executionContainerName); allocInst = systemModelRepository.getAllocationFactory() .createAndRegisterAllocationComponentInstance(allocationComponentName, assemblyComponent, execContainer); Operation op = systemModelRepository.getOperationFactory().lookupOperationByNamedIdentifier(operationFactoryName); if (op == null) { // Operation doesn't exist op = systemModelRepository.getOperationFactory() .createAndRegisterOperation(operationFactoryName, allocInst.getAssemblyComponent().getType(), operationSignature); allocInst.getAssemblyComponent().getType().addOperation(op);
+ ".space{padding: 4px 10px;}\n" + "</style>"); ps.println("</head><body>"); this.htmlHSpace(ps, 10); this.printOpenSurroundingSpan(ps); this.printOpenHtmlTable(ps, "Component Types", new String[] { "ID", "Package", "Name", "Operations" }); final Collection<ComponentType> componentTypes = this.typeRepositoryFactory.getComponentTypes(); for (final ComponentType type : componentTypes) { final StringBuilder opListBuilder = new StringBuilder(); for (final Operation op : type.getOperations()) { opListBuilder.append("<li>") .append(this.htmlEntityRef(op.getId(), SystemModelRepository.simpleHTMLEscape(op.getSignature().toString()), EntityType.OPERATION)) .append("</li>"); this.htmlEntityLabel(type.getId(), Integer.toString(type.getId()), EntityType.COMPONENT_TYPE), SystemModelRepository.simpleHTMLEscape(type.getPackageName()), SystemModelRepository.simpleHTMLEscape(type.getTypeName()), opListBuilder.toString(), }; this.printHtmlTableRow(ps, cells); this.printCloseHtmlTable(ps); this.printLinebreak(ps); this.printOpenHtmlTable(ps, "Operations", new String[] { "ID", "Component type", "Name", "Parameter types", "Return type" }); final Collection<Operation> operations = this.operationFactory.getOperations(); for (final Operation op : operations) { final StringBuilder paramListStrBuild = new StringBuilder(); for (final String paramType : op.getSignature().getParamTypeList()) { paramListStrBuild.append("<li>").append(SystemModelRepository.simpleHTMLEscape(paramType)).append("</li>"); this.htmlEntityLabel(op.getId(), Integer.toString(op.getId()), EntityType.OPERATION),
/** * Creates a new instance of this class. */ public TestTraceReconstructionFilter() { final SystemModelRepository systemEntityFactory = new SystemModelRepository(new Configuration(), new AnalysisController()); final ExecutionFactory executionFactory = new ExecutionFactory(systemEntityFactory); // Manually create Executions for a trace this.exec0_0__bookstore_searchBook = executionFactory.genExecution("Bookstore", "bookstore", "searchBook", TestTraceReconstructionFilter.TRACE_ID, TestTraceReconstructionFilter.SESSION_ID, 1 * (1000 * 1000), 10 * (1000 * 1000), 0, 0); this.exec1_1__catalog_getBook = executionFactory.genExecution("Catalog", "catalog", "getBook", TestTraceReconstructionFilter.TRACE_ID, TestTraceReconstructionFilter.SESSION_ID, 2 * (1000 * 1000), 4 * (1000 * 1000), 1, 1); this.exec2_1__crm_getOrders = executionFactory.genExecution("CRM", "crm", "getOrders", TestTraceReconstructionFilter.TRACE_ID, TestTraceReconstructionFilter.SESSION_ID, 5 * (1000 * 1000), 8 * (1000 * 1000), 2, 1); this.exec3_2__catalog_getBook = executionFactory.genExecution("Catalog", "catalog", "getBook", TestTraceReconstructionFilter.TRACE_ID, TestTraceReconstructionFilter.SESSION_ID, 6 * (1000 * 1000), 7 * (1000 * 1000), 3, 2); }
@Override protected AllocationComponentOperationPair concreteCreatePair(final SynchronousCallMessage callMsg) { final AllocationComponent allocationComponent = callMsg.getReceivingExecution().getAllocationComponent(); final Operation op = callMsg.getReceivingExecution().getOperation(); final AllocationComponentOperationPair destination = AggregatedAllocationComponentOperationCallTreeFilter.this.getSystemEntityFactory() .getAllocationPairFactory().getPairInstanceByPair(allocationComponent, op); // will never be null! return destination; } }
/** * Returns a corresponding pair instance (existing or newly created). * * @param allocationComponent * The first element of the pair (the allocation component). * @param operation * The second element of the pair (the operation). * * @return A (possible new) pair containing both elements. */ public final AllocationComponentOperationPair getPairInstanceByPair(final AllocationComponent allocationComponent, final Operation operation) { final AllocationComponentOperationPair inst = this.getPairByNamedIdentifier(allocationComponent.getId() + "-" + operation.getId()); if (inst == null) { return this.createAndRegisterPair(operation, allocationComponent); } return inst; }
/** * 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; }
/** * {@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); } }
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; }
public final AllocationComponent createAndRegisterAllocationComponentInstance(final String namedIdentifier, final AssemblyComponent assemblyComponentInstance, final ExecutionContainer executionContainer) { if (this.allocationComponentInstancesByName.containsKey(namedIdentifier)) { throw new IllegalArgumentException("Element with name " + namedIdentifier + "exists already"); } final int id = this.getAndIncrementNextId(); final AllocationComponent newInst = new AllocationComponent(id, assemblyComponentInstance, executionContainer); this.allocationComponentInstancesById.put(id, newInst); this.allocationComponentInstancesByName.put(namedIdentifier, newInst); return newInst; }
private final AllocationComponentOperationPair createAndRegisterPair(final String namedIdentifier, final Operation operation, final AllocationComponent allocationComponent) { if (this.pairsByName.containsKey(namedIdentifier)) { throw new IllegalArgumentException("Element with name " + namedIdentifier + "exists already"); } final int id = this.getAndIncrementNextId(); final AllocationComponentOperationPair newInst = new AllocationComponentOperationPair(id, operation, allocationComponent); this.pairsById.put(id, newInst); this.pairsByName.put(namedIdentifier, newInst); return newInst; }
public final Operation createAndRegisterOperation(final String namedIdentifier, final ComponentType componentType, final Signature signature) { if (this.operationsByName.containsKey(namedIdentifier)) { throw new IllegalArgumentException("Element with name " + namedIdentifier + "exists already"); } final int id = this.getAndIncrementNextId(); final Operation newInst = new Operation(id, componentType, signature); this.operationsById.put(id, newInst); this.operationsByName.put(namedIdentifier, newInst); return newInst; }
/** * This method creates a new execution container and registers it as well. * * @param namedIdentifier * The identifier of the new container. * @param name * The name of the new container. * * @return The newly created execution container. */ public final ExecutionContainer createAndRegisterExecutionContainer(final String namedIdentifier, final String name) { if (this.executionContainersByName.containsKey(namedIdentifier)) { throw new IllegalArgumentException("Element with name " + namedIdentifier + "exists already"); } final int id = this.getAndIncrementNextId(); final ExecutionContainer newInst = new ExecutionContainer(id, null, name); this.executionContainersById.put(id, newInst); this.executionContainersByName.put(namedIdentifier, newInst); return newInst; }
/** * Creates a new assembly component instance and registers it as well. * * @param namedIdentifier * The identifier of the new component. * @param componentType * The new component type. * * @return The newly created assembly component. */ public final AssemblyComponent createAndRegisterAssemblyComponentInstance(final String namedIdentifier, final ComponentType componentType) { if (this.assemblyComponentInstancesByName.containsKey(namedIdentifier)) { throw new IllegalArgumentException("Element with name " + namedIdentifier + "exists already"); } final int id = this.getAndIncrementNextId(); final AssemblyComponent newInst = new AssemblyComponent(id, "@" + id, componentType); this.assemblyComponentInstancesById.put(id, newInst); this.assemblyComponentInstancesByName.put(namedIdentifier, newInst); return newInst; }
/** * Creates and registers a component type that has not been registered yet. * * @param namedIdentifier * The identifier of the new component type. * @param fullqualifiedName * The fully qualfieid name of the new component type. * * @return the created component type */ public final ComponentType createAndRegisterComponentType(final String namedIdentifier, final String fullqualifiedName) { final ComponentType newInst; synchronized (this) { if (this.componentTypesByName.containsKey(namedIdentifier)) { throw new IllegalArgumentException("Element with name " + namedIdentifier + "exists already"); } final int id = this.getAndIncrementNextId(); newInst = new ComponentType(id, fullqualifiedName); this.componentTypesById.put(id, newInst); this.componentTypesByName.put(namedIdentifier, newInst); } return newInst; }
/** * Creates a new pair using both elements and registers it was well. * * @param operation * The second element of the pair (the operation). * @param allocationComponent * The first element of the pair (the allocation component). * * @return The newly created pair. */ private final AllocationComponentOperationPair createAndRegisterPair(final Operation operation, final AllocationComponent allocationComponent) { return this.createAndRegisterPair(allocationComponent.getId() + "-" + operation.getId(), operation, allocationComponent); }
ComponentType componentTypeA = this.systemEntityFactory.getTypeRepositoryFactory().lookupComponentTypeByNamedIdentifier(componentTypeName); if (componentTypeA == null) { componentTypeA = this.systemEntityFactory.getTypeRepositoryFactory().createAndRegisterComponentType(componentTypeName, componentTypeName); Operation operationAa = this.systemEntityFactory.getOperationFactory().lookupOperationByNamedIdentifier(operationName); if (operationAa == null) { operationAa = this.systemEntityFactory.getOperationFactory().createAndRegisterOperation( operationName, componentTypeA, new Signature(operationName, modifierList, returnType, paramTypeList)); AssemblyComponent assemblyComponentA = this.systemEntityFactory.getAssemblyFactory().lookupAssemblyComponentInstanceByNamedIdentifier(componentInstanceName); if (assemblyComponentA == null) { assemblyComponentA = this.systemEntityFactory.getAssemblyFactory().createAndRegisterAssemblyComponentInstance(componentInstanceName, componentTypeA); ExecutionContainer containerC = this.systemEntityFactory.getExecutionEnvironmentFactory().lookupExecutionContainerByNamedIdentifier(executionContainerName); if (containerC == null) { containerC = this.systemEntityFactory.getExecutionEnvironmentFactory().createAndRegisterExecutionContainer(executionContainerName, executionContainerName); this.systemEntityFactory.getAllocationFactory().lookupAllocationComponentInstanceByNamedIdentifier(allocationName); if (allocationComponentA == null) { allocationComponentA = this.systemEntityFactory.getAllocationFactory().createAndRegisterAllocationComponentInstance(allocationName, assemblyComponentA, containerC);
private String htmlEntityLabel(final int id, final String caption, final EntityType entityType) { final StringBuilder strBuild = new StringBuilder(64); strBuild.append("<a name=\"").append(SystemModelRepository.simpleHTMLEscape(entityType.toString())).append('-').append(id).append("\">").append(caption) .append("</a>"); return strBuild.toString(); }
@Override public AllocationComponentOperationPair createPair(final SynchronousCallMessage callMsg) { final AllocationComponent allocationComponent = callMsg.getReceivingExecution().getAllocationComponent(); final Operation op = callMsg.getReceivingExecution().getOperation(); final AllocationComponentOperationPair destination = TraceCallTreeFilter.this.getSystemEntityFactory().getAllocationPairFactory() .getPairInstanceByPair(allocationComponent, op); // will never be null! return destination; } }, mt, TraceCallTreeFilter.this.dotOutputFn + "-" + mt.getTraceId() + ".dot", false, TraceCallTreeFilter.this.shortLabels); // no weights