1 | package de.uka.ipd.sdq.pcm.transformations.builder.connectors; |
2 | |
3 | import de.uka.ipd.sdq.pcm.core.composition.AssemblyConnector; |
4 | import de.uka.ipd.sdq.pcm.repository.OperationInterface; |
5 | import de.uka.ipd.sdq.pcm.repository.OperationProvidedRole; |
6 | import de.uka.ipd.sdq.pcm.repository.OperationRequiredRole; |
7 | import de.uka.ipd.sdq.pcm.repository.RequiredRole; |
8 | import de.uka.ipd.sdq.pcm.resourceenvironment.ResourceContainer; |
9 | import de.uka.ipd.sdq.pcm.transformations.builder.IComponentBuilder; |
10 | import de.uka.ipd.sdq.pcm.transformations.builder.infrastructure.IMiddlewareInteractingComponentBuilder; |
11 | import de.uka.ipd.sdq.pcm.transformations.builder.util.PCMAndCompletionModelHolder; |
12 | |
13 | public abstract class AbstractClientServerConnectorCompletionBuilder |
14 | extends AbstractConnectorCompletionBuilder |
15 | implements IClientServerConnectorCompletionComponentBuilder { |
16 | |
17 | protected OperationInterface middlewareInterface; |
18 | private OperationRequiredRole myClientRole; |
19 | private OperationRequiredRole myServerRole; |
20 | private IComponentBuilder innerBuilder; |
21 | |
22 | private IMiddlewareInteractingComponentBuilder serverBuilder; |
23 | private IMiddlewareInteractingComponentBuilder clientBuilder; |
24 | |
25 | protected ResourceContainer fromResourceContainer; |
26 | protected ResourceContainer toResourceContainer; |
27 | |
28 | public AbstractClientServerConnectorCompletionBuilder( |
29 | PCMAndCompletionModelHolder models, |
30 | AssemblyConnector connector, |
31 | ResourceContainer fromResourceContainer, |
32 | ResourceContainer toResourceContainer, |
33 | IComponentBuilder innerBuilder, |
34 | String componentName) { |
35 | super(models, connector, componentName); |
36 | |
37 | assert (models.getMiddlewareRepository().getInterfaces__Repository().get(0) instanceof OperationInterface); |
38 | middlewareInterface = (OperationInterface)models.getMiddlewareRepository().getInterfaces__Repository().get(0); |
39 | this.fromResourceContainer = fromResourceContainer; |
40 | this.toResourceContainer = toResourceContainer; |
41 | this.innerBuilder = innerBuilder; |
42 | } |
43 | |
44 | public OperationRequiredRole getClientSideMiddlewareRole() { |
45 | return myClientRole; |
46 | } |
47 | |
48 | public OperationRequiredRole getServerSideMiddlewareRole() { |
49 | return myServerRole; |
50 | } |
51 | |
52 | protected IMiddlewareInteractingComponentBuilder getClientSideBuilder() { |
53 | return clientBuilder; |
54 | } |
55 | |
56 | protected IMiddlewareInteractingComponentBuilder getServerSideBuilder() { |
57 | return serverBuilder; |
58 | } |
59 | |
60 | protected abstract IMiddlewareInteractingComponentBuilder createClientSideBuilder(); |
61 | protected abstract IMiddlewareInteractingComponentBuilder createServerSideBuilder(); |
62 | |
63 | @Override |
64 | public void build() { |
65 | super.build(); |
66 | this.clientBuilder = createClientSideBuilder(); |
67 | this.serverBuilder = createServerSideBuilder(); |
68 | |
69 | innerBuilder.build(); |
70 | getComposedStructure().getAssemblyContexts__ComposedStructure().add(innerBuilder.getAssemblyContext()); |
71 | |
72 | myClientRole = addOperationRequiredRole(middlewareInterface,"ClientMiddleware"); |
73 | myServerRole = addOperationRequiredRole(middlewareInterface,"ServerMiddleware"); |
74 | |
75 | getClientSideBuilder().build(); |
76 | this.getComposedStructure().getAssemblyContexts__ComposedStructure().add(getClientSideBuilder().getAssemblyContext()); |
77 | getServerSideBuilder().build(); |
78 | this.getComposedStructure().getAssemblyContexts__ComposedStructure().add(getServerSideBuilder().getAssemblyContext()); |
79 | |
80 | assert(myComponent.getProvidedRoles_InterfaceProvidingEntity().get(0) instanceof OperationProvidedRole); |
81 | addProvidedDelegationConnector(getClientSideBuilder().getOperationProvidedRole(), getClientSideBuilder().getAssemblyContext(), (OperationProvidedRole)myComponent.getProvidedRoles_InterfaceProvidingEntity().get(0)); |
82 | assert (myComponent.getRequiredRoles_InterfaceRequiringEntity().get(0) instanceof OperationRequiredRole); |
83 | addRequiredDelegationConnector(getServerSideBuilder().getOperationRequiredRole(),getServerSideBuilder().getAssemblyContext(),(OperationRequiredRole)myComponent.getRequiredRoles_InterfaceRequiringEntity().get(0)); |
84 | |
85 | addAssemblyConnector(getClientSideBuilder().getOperationRequiredRole(), getClientSideBuilder().getAssemblyContext(), |
86 | innerBuilder.getOperationProvidedRole(), innerBuilder.getAssemblyContext()); |
87 | addAssemblyConnector(innerBuilder.getOperationRequiredRole(),innerBuilder.getAssemblyContext(), |
88 | getServerSideBuilder().getOperationProvidedRole(), getServerSideBuilder().getAssemblyContext()); |
89 | |
90 | if (innerBuilder instanceof IClientServerConnectorCompletionComponentBuilder) { |
91 | IClientServerConnectorCompletionComponentBuilder csBuilder = (IClientServerConnectorCompletionComponentBuilder) innerBuilder; |
92 | addRequiredDelegationConnector(csBuilder.getClientSideMiddlewareRole(), csBuilder.getAssemblyContext(), getClientSideMiddlewareRole()); |
93 | addRequiredDelegationConnector(csBuilder.getServerSideMiddlewareRole(), csBuilder.getAssemblyContext(), getServerSideMiddlewareRole()); |
94 | } |
95 | |
96 | addRequiredDelegationConnector(getClientSideBuilder().getMiddlewareRole(), getClientSideBuilder().getAssemblyContext(), getClientSideMiddlewareRole()); |
97 | addRequiredDelegationConnector(getServerSideBuilder().getMiddlewareRole(), getServerSideBuilder().getAssemblyContext(), getServerSideMiddlewareRole()); |
98 | } |
99 | } |