EMMA Coverage Report (generated Sun Feb 05 10:43:15 CET 2012)
[all classes][de.uka.ipd.sdq.pcm.transformations.builder.seff]

COVERAGE SUMMARY FOR SOURCE FILE [DelegatorComponentSeffBuilder.java]

nameclass, %method, %block, %line, %
DelegatorComponentSeffBuilder.java0%   (0/1)0%   (0/7)0%   (0/197)0%   (0/42)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class DelegatorComponentSeffBuilder0%   (0/1)0%   (0/7)0%   (0/197)0%   (0/42)
DelegatorComponentSeffBuilder (OperationProvidedRole, OperationRequiredRole):... 0%   (0/1)0%   (0/24)0%   (0/7)
appendPostAction (AbstractActionDescriptor): void 0%   (0/1)0%   (0/6)0%   (0/2)
appendPreAction (AbstractActionDescriptor): void 0%   (0/1)0%   (0/6)0%   (0/2)
build (): void 0%   (0/1)0%   (0/24)0%   (0/4)
buildSeff (OperationSignature): ResourceDemandingSEFF 0%   (0/1)0%   (0/112)0%   (0/21)
getSeffs (): List 0%   (0/1)0%   (0/4)0%   (0/1)
setSignatureInActions (ArrayList, OperationSignature): void 0%   (0/1)0%   (0/21)0%   (0/5)

1package de.uka.ipd.sdq.pcm.transformations.builder.seff;
2 
3import java.util.ArrayList;
4import java.util.Collections;
5import java.util.List;
6 
7import de.uka.ipd.sdq.completions.CompletionsFactory;
8import de.uka.ipd.sdq.completions.DelegatingExternalCallAction;
9import de.uka.ipd.sdq.pcm.repository.OperationProvidedRole;
10import de.uka.ipd.sdq.pcm.repository.OperationRequiredRole;
11import de.uka.ipd.sdq.pcm.repository.OperationSignature;
12import de.uka.ipd.sdq.pcm.repository.Signature;
13import de.uka.ipd.sdq.pcm.seff.AbstractAction;
14import de.uka.ipd.sdq.pcm.seff.ResourceDemandingSEFF;
15import de.uka.ipd.sdq.pcm.seff.SeffFactory;
16import de.uka.ipd.sdq.pcm.seff.StartAction;
17import de.uka.ipd.sdq.pcm.seff.StopAction;
18 
19/**
20 * A builder which builds identical SEFFs for all services contained in the passed interface. Useful for creating components which delegate their 
21 * call to other components
22 * @author Snowball
23 *
24 */
25public class DelegatorComponentSeffBuilder extends AbstractSeffBuilder 
26implements ISeffBuilder {
27        
28        protected ArrayList<AbstractActionDescriptor> preActions = new ArrayList<AbstractActionDescriptor>();
29        protected ArrayList<AbstractActionDescriptor> postActions = new ArrayList<AbstractActionDescriptor>();
30        protected OperationRequiredRole domainReqRole;
31        protected OperationProvidedRole domainProvRole;
32        private ArrayList<ResourceDemandingSEFF> createdSeffs = new ArrayList<ResourceDemandingSEFF>();
33 
34        public DelegatorComponentSeffBuilder(OperationProvidedRole domainProvRole, OperationRequiredRole domainReqRole) {
35                this.domainReqRole = domainReqRole;
36                this.domainProvRole = domainProvRole;
37        }
38 
39        /**
40         * Append an internal action in the chain of actions to be executed before the delegating call
41         * @param signatureDependentDemand A description of the internal action's demand
42         */
43        public void appendPreAction(
44                        AbstractActionDescriptor signatureDependentDemand) {
45                this.preActions.add(signatureDependentDemand);
46        }
47 
48        /**
49         * Append an internal action in the chain of actions to be executed after the delegating call
50         * @param signatureDependentDemand A description of the internal action's demand
51         */
52        public void appendPostAction(
53                        AbstractActionDescriptor signatureDependentDemand) {
54                this.postActions.add(signatureDependentDemand);
55        }        
56        
57        public void build() {
58                for (OperationSignature providedService : domainProvRole.getProvidedInterface__OperationProvidedRole().getSignatures__OperationInterface()){
59                        ResourceDemandingSEFF seff = buildSeff(providedService);
60                        this.createdSeffs.add(seff);
61                }
62        }
63        
64        
65        @Override
66        protected ResourceDemandingSEFF buildSeff(OperationSignature signature) {
67                ResourceDemandingSEFF seff = super.buildSeff(signature);
68                StartAction start = SeffFactory.eINSTANCE.createStartAction();
69                AbstractAction lastAction = start;
70                
71                setSignatureInActions(preActions,signature);
72                setSignatureInActions(postActions,signature);
73                
74                for (AbstractActionDescriptor descriptor : preActions) {
75                        AbstractAction action = descriptor.createAction();
76                        lastAction = createControlFlow(lastAction,action);
77                        seff.getSteps_Behaviour().add(action);
78                }
79        
80                DelegatingExternalCallAction delegatingCall = CompletionsFactory.eINSTANCE.createDelegatingExternalCallAction();
81                delegatingCall.setCalledService_ExternalService(signature);
82                delegatingCall.setRole_ExternalService(domainReqRole);
83                lastAction = createControlFlow(lastAction, delegatingCall);
84        
85                for (AbstractActionDescriptor descriptor : postActions) {
86                        AbstractAction action = descriptor.createAction();
87                        lastAction = createControlFlow(lastAction,action);
88                        seff.getSteps_Behaviour().add(action);
89                }
90                
91                StopAction stop = SeffFactory.eINSTANCE.createStopAction();
92                createControlFlow(lastAction, stop);
93                
94                Collections.addAll(seff.getSteps_Behaviour(), start,stop,delegatingCall);
95                
96                return seff;
97        }
98 
99        private void setSignatureInActions(
100                        ArrayList<AbstractActionDescriptor> actions, OperationSignature sig) {
101                for (AbstractActionDescriptor descriptor : actions) {
102                        if (descriptor instanceof ISignatureDependentAction) {
103                                ISignatureDependentAction sigDescriptor = (ISignatureDependentAction) descriptor;
104                                sigDescriptor.setCurrentSignature(sig);
105                        }
106                }
107                
108        }
109 
110        /* (non-Javadoc)
111         * @see de.uka.sdq.pcm.transformations.builder.seff.ISeffBuilder#getSeff(de.uka.ipd.sdq.pcm.repository.Signature)
112         */
113        public List<ResourceDemandingSEFF> getSeffs() {
114                return Collections.unmodifiableList(this.createdSeffs);
115        }
116}

[all classes][de.uka.ipd.sdq.pcm.transformations.builder.seff]
EMMA 2.0.9414 (unsupported private build) (C) Vladimir Roubtsov