Skip to content
Snippets Groups Projects
Commit 1d041ca8 authored by Simon Spinner's avatar Simon Spinner
Browse files

Add support for application external calls.

parent 198792a7
No related branches found
No related tags found
No related merge requests found
......@@ -419,11 +419,26 @@ public class ModelExtractionService extends AgentController implements Service<M
}
RepositoryComponent callerComponent = implementationComponent;
// 4. Now add the called component (if applicable)
// 4. Check if this is a call that goes to a destination outside of the
// system.
InterfaceRequiringRole systemRequiringRole = null;
if (callerRequiringRole != null) {
String systemRequiringRoleName = getSystemInterfaceRequiringRoleName(outgoingIrec);
systemRequiringRole = RepositoryFactory.eINSTANCE.createInterfaceRequiringRole();
systemRequiringRole.setName(toName(systemRequiringRoleName));
systemRequiringRole.setInterface(outgoingInterface);
systemRequiringRole = ModelSkeletonUtil.find(
((ApplicationScope) getContainerScope()).getApplication().getInterfaceRequiringRoles(),
systemRequiringRole);
}
// 5. Now add the called component (if applicable)
// IMPORTANT: Only do this if the call is within the same application
// (i.e., systemRequiringRole == null)
InterfaceProvidingRole calledProvidingRole = null;
RepositoryComponent calledComponent = null;
boolean differentModule = false;
if (callerRequiringRole != null) {
if (callerRequiringRole != null && systemRequiringRole == null) {
differentModule = isDifferentModule(incomingCrec, outgoingCrec);
calledComponent = createCalledComponent(outgoingCrec, differentModule);
String calledProvingRoleName;
......@@ -453,7 +468,7 @@ public class ModelExtractionService extends AgentController implements Service<M
}
}
// 5. Now wrap the implementation in a composite component (if
// 6. Now wrap the implementation in a composite component (if
// necessary)
CompositeComponent compositeComponent = createCompositeComponent(incomingCrec, callerComponent);
AssemblyContext innerAssemblyContext = null;
......@@ -512,28 +527,30 @@ public class ModelExtractionService extends AgentController implements Service<M
requiringConnector.setAssemblyContext(innerAssemblyContext);
ModelSkeletonUtil.insert(compositeComponent.getRequiringDelegationConnectors(), requiringConnector);
} else {
// Local call: Also add an assembly context for the called
// component within the composite component
// and connect it with an assembly connector.
AssemblyContext calledAssembly = addAssemblyContext(compositeComponent, outgoingCrec,
calledComponent);
AssemblyConnector connector = RepositoryFactory.eINSTANCE.createAssemblyConnector();
connector.setName(toName(innerAssemblyContext.getName() + " -> " + calledAssembly.getName()));
connector.setInterfaceProvidingRole(calledProvidingRole);
connector.setInterfaceRequiringRole(callerRequiringRole);
connector.setProvidingAssemblyContext(calledAssembly);
connector.setRequiringAssemblyContext(innerAssemblyContext);
ModelSkeletonUtil.insert(compositeComponent.getAssemblyConnectors(), connector);
if (calledComponent != null) {
// Local call: Also add an assembly context for the
// called component within the composite component
// and connect it with an assembly connector.
AssemblyContext calledAssembly = addAssemblyContext(compositeComponent, outgoingCrec,
calledComponent);
AssemblyConnector connector = RepositoryFactory.eINSTANCE.createAssemblyConnector();
connector.setName(toName(innerAssemblyContext.getName() + " -> " + calledAssembly.getName()));
connector.setInterfaceProvidingRole(calledProvidingRole);
connector.setInterfaceRequiringRole(callerRequiringRole);
connector.setProvidingAssemblyContext(calledAssembly);
connector.setRequiringAssemblyContext(innerAssemblyContext);
ModelSkeletonUtil.insert(compositeComponent.getAssemblyConnectors(), connector);
}
}
}
callerRequiringRole = remoteRequiringRole;
callerComponent = compositeComponent;
}
// 6. Now create the assembly contexts
// 7. Now create the assembly contexts
AssemblyContext callerContext = addAssemblyContext(skeleton.getSystem(), incomingCrec, callerComponent);
if (callerRequiringRole != null) {
if (calledComponent != null) {
AssemblyContext calledContext = addAssemblyContext(skeleton.getSystem(), outgoingCrec, calledComponent);
AssemblyConnector connector = RepositoryFactory.eINSTANCE.createAssemblyConnector();
......@@ -543,9 +560,21 @@ public class ModelExtractionService extends AgentController implements Service<M
connector.setProvidingAssemblyContext(calledContext);
connector.setRequiringAssemblyContext(callerContext);
ModelSkeletonUtil.insert(skeleton.getSystem().getAssemblyConnectors(), connector);
} else if (systemRequiringRole != null) {
// This is a call to a component in a different application
systemRequiringRole = ModelSkeletonUtil.adopt(this, systemRequiringRole);
skeleton.getSystem().getInterfaceRequiringRoles().add(systemRequiringRole);
RequiringDelegationConnector systemRequiringConnector = RepositoryFactory.eINSTANCE
.createRequiringDelegationConnector();
systemRequiringConnector.setName(toName(callerContext.getName()));
systemRequiringConnector.setInnerInterfaceRequiringRole(callerRequiringRole);
systemRequiringConnector.setOuterInterfaceRequiringRole(systemRequiringRole);
systemRequiringConnector.setAssemblyContext(callerContext);
ModelSkeletonUtil.insert(skeleton.getSystem().getRequiringDelegationConnectors(), systemRequiringConnector);
}
// 7. Expose the provided remote interfaces as system interfaces (if
// 8. Expose the provided remote interfaces as system interfaces (if
// this port is marked as system interface)
String systemProvidingRoleName = getInterfaceProvidingRoleName(incomingIrec, callerContext.getName());
// Do not create a new providing/requiring role for the system, only use
......@@ -572,31 +601,7 @@ public class ModelExtractionService extends AgentController implements Service<M
ModelSkeletonUtil.insert(skeleton.getSystem().getProvidingDelegationConnectors(), systemProvidingConnector);
}
if (callerRequiringRole != null) {
String systemRequiringRoleName = getInterfaceRequiringRoleName(outgoingIrec, callerContext.getName());
InterfaceRequiringRole systemRequiringRole = RepositoryFactory.eINSTANCE.createInterfaceRequiringRole();
systemRequiringRole.setName(toName(systemRequiringRoleName));
systemRequiringRole.setInterface(outgoingInterface);
systemRequiringRole = ModelSkeletonUtil.find(
((ApplicationScope) getContainerScope()).getApplication().getInterfaceRequiringRoles(),
systemRequiringRole);
if (systemRequiringRole != null) {
systemRequiringRole = ModelSkeletonUtil.adopt(this, systemRequiringRole);
skeleton.getSystem().getInterfaceRequiringRoles()
.add(ModelSkeletonUtil.adopt(this, systemRequiringRole));
RequiringDelegationConnector systemRequiringConnector = RepositoryFactory.eINSTANCE
.createRequiringDelegationConnector();
systemRequiringConnector.setName(toName(callerContext.getName()));
systemRequiringConnector.setInnerInterfaceRequiringRole(callerRequiringRole);
systemRequiringConnector.setOuterInterfaceRequiringRole(systemRequiringRole);
systemRequiringConnector.setAssemblyContext(callerContext);
ModelSkeletonUtil.insert(skeleton.getSystem().getRequiringDelegationConnectors(),
systemRequiringConnector);
}
}
// 8. Add sensor descriptions for application metrics
// 9. Add sensor descriptions for application metrics
List<AssemblyContext> instancePath = new LinkedList<>();
instancePath.add(callerContext);
if (innerAssemblyContext != null) {
......@@ -604,7 +609,7 @@ public class ModelExtractionService extends AgentController implements Service<M
}
addSensors(incomingIrec, outgoingIrec, instancePath, innerCallerProvidingRole, incomingSignature, externalCall);
// 9. Remember to deploy this context (only for the caller component)
// 10. Remember to deploy this context (only for the caller component)
undeployedAssemblyContexts.add(callerContext);
}
......@@ -938,6 +943,20 @@ public class ModelExtractionService extends AgentController implements Service<M
return res.toString();
}
private String getSystemInterfaceRequiringRoleName(InvocationRecord record) {
StringBuilder res = new StringBuilder();
res.append(record.getOperation().getProtocol());
res.append("://");
res.append(record.getOperation().getComponent().getServerNode());
res.append("/");
if (!record.getOperation().getComponent().getApplication().isEmpty()) {
res.append(record.getOperation().getComponent().getApplication());
res.append("/");
}
res.append(record.getOperation().getComponent().getComponentName());
return res.toString();
}
private String getInterfaceRequiringRoleName(InvocationRecord record, String assembly) {
StringBuilder res = new StringBuilder();
res.append(record.getOperation().getProtocol());
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment