1 | package de.uka.ipd.sdq.pcmsolver.handler; |
2 | |
3 | import de.uka.ipd.sdq.pcm.allocation.AllocationContext; |
4 | import de.uka.ipd.sdq.pcm.core.composition.AssemblyContext; |
5 | import de.uka.ipd.sdq.pcm.seff.ServiceEffectSpecification; |
6 | import de.uka.ipd.sdq.pcm.usagemodel.UsageScenario; |
7 | import de.uka.ipd.sdq.pcmsolver.transformations.ContextWrapper; |
8 | import de.uka.ipd.sdq.pcmsolver.visitors.AggregatedContextSEFFVisitor; |
9 | import de.uka.ipd.sdq.pcmsolver.visitors.SeffVisitor; |
10 | |
11 | /** |
12 | * Extends the {@link ExternalCallActionHandler} by overwriting {@link ExternalCallActionHandler#visitSEFF(ServiceEffectSpecification, ContextWrapper)}. |
13 | * Creates a new {@link AggregatedContextSEFFVisitor} instead of a normal {@link SeffVisitor}. |
14 | * @author martens |
15 | * |
16 | */ |
17 | public class AggregatedContextExternalCallActionHandler extends |
18 | ExternalCallActionHandler { |
19 | |
20 | private double frequency; |
21 | private UsageScenario usageScenario; |
22 | private ServiceEffectSpecification calledSEFF; |
23 | private AssemblyContext calledAssemblyCtxt; |
24 | private AllocationContext calledAllocationContext; |
25 | |
26 | public AggregatedContextExternalCallActionHandler(AggregatedContextSEFFVisitor seffVisitor, UsageScenario usageScenario) { |
27 | super(seffVisitor); |
28 | this.frequency = seffVisitor.getCurrentFrequency(); |
29 | this.usageScenario = usageScenario; |
30 | } |
31 | |
32 | /** |
33 | * Creates a new {@link AggregatedContextSEFFVisitor} instead of a normal {@link SeffVisitor}, which adds the calculation |
34 | * of execution frequencies to the context model. |
35 | */ |
36 | @Override |
37 | SeffVisitor visitSEFF(ServiceEffectSpecification seff, |
38 | ContextWrapper contextWrapper) { |
39 | AggregatedContextSEFFVisitor seffVisitor = new AggregatedContextSEFFVisitor(contextWrapper, this.frequency, seff, this.usageScenario); |
40 | |
41 | this.calledSEFF = seff; |
42 | this.calledAssemblyCtxt = contextWrapper.getAssCtx(); |
43 | this.calledAllocationContext = contextWrapper.getAllCtx(); |
44 | |
45 | seffVisitor.doSwitch(seff); |
46 | return seffVisitor; |
47 | } |
48 | |
49 | |
50 | public ServiceEffectSpecification getCalledSEFF() { |
51 | return calledSEFF; |
52 | } |
53 | |
54 | public AssemblyContext getCalledAssemblyCtxt() { |
55 | return calledAssemblyCtxt; |
56 | } |
57 | |
58 | public AllocationContext getCalledAllocationContext() { |
59 | return calledAllocationContext; |
60 | } |
61 | } |