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 [MarshallerComponentSeffBuilder.java]

nameclass, %method, %block, %line, %
MarshallerComponentSeffBuilder.java0%   (0/3)0%   (0/14)0%   (0/315)0%   (0/63)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class MarshallerComponentSeffBuilder0%   (0/1)0%   (0/8)0%   (0/213)0%   (0/48)
$SWITCH_TABLE$de$uka$ipd$sdq$pcm$transformations$builder$infrastructure$Marsh... 0%   (0/1)0%   (0/27)0%   (0/1)
MarshallerComponentSeffBuilder (OperationProvidedRole, OperationRequiredRole,... 0%   (0/1)0%   (0/40)0%   (0/9)
access$1 (MarshallerComponentSeffBuilder, OperationSignature, BytesizeComputa... 0%   (0/1)0%   (0/5)0%   (0/1)
createInputParameterFor (OperationSignature, PrimitiveTypeEnum, BytesizeCompu... 0%   (0/1)0%   (0/37)0%   (0/6)
createMarshallOutParameter (OperationSignature, BytesizeComputationForSignatu... 0%   (0/1)0%   (0/14)0%   (0/3)
findService (OperationInterface, String): OperationSignature 0%   (0/1)0%   (0/24)0%   (0/4)
prepareClient (): void 0%   (0/1)0%   (0/33)0%   (0/12)
prepareServer (): void 0%   (0/1)0%   (0/33)0%   (0/12)
     
class MarshallerComponentSeffBuilder$10%   (0/1)0%   (0/3)0%   (0/51)0%   (0/9)
MarshallerComponentSeffBuilder$1 (MarshallerComponentSeffBuilder, OperationSi... 0%   (0/1)0%   (0/8)0%   (0/2)
getSignatureDependentInputParameter (OperationSignature): Collection 0%   (0/1)0%   (0/37)0%   (0/6)
getSignatureDependentOutputParameter (OperationSignature): Collection 0%   (0/1)0%   (0/6)0%   (0/1)
     
class MarshallerComponentSeffBuilder$20%   (0/1)0%   (0/3)0%   (0/51)0%   (0/9)
MarshallerComponentSeffBuilder$2 (MarshallerComponentSeffBuilder, OperationSi... 0%   (0/1)0%   (0/8)0%   (0/2)
getSignatureDependentInputParameter (OperationSignature): Collection 0%   (0/1)0%   (0/37)0%   (0/6)
getSignatureDependentOutputParameter (OperationSignature): Collection 0%   (0/1)0%   (0/6)0%   (0/1)

1package de.uka.ipd.sdq.pcm.transformations.builder.seff;
2 
3import java.util.ArrayList;
4import java.util.Collection;
5 
6import de.uka.ipd.sdq.pcm.parameter.VariableCharacterisationType;
7import de.uka.ipd.sdq.pcm.parameter.VariableUsage;
8import de.uka.ipd.sdq.pcm.repository.OperationInterface;
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.PrimitiveTypeEnum;
13import de.uka.ipd.sdq.pcm.transformations.BytesizeComputationForSignature;
14import de.uka.ipd.sdq.pcm.transformations.BytesizeComputationForSignature.Modifier;
15import de.uka.ipd.sdq.pcm.transformations.builder.infrastructure.MarshallingComponentBuilder.MarshallerSide;
16import de.uka.ipd.sdq.pcm.transformations.builder.util.NumberOfElementsComputationForSignature;
17 
18public class MarshallerComponentSeffBuilder extends
19                MiddlewareComponentSeffBuilder {
20 
21        PrimitiveTypeEnum[] primitiveTypes = new PrimitiveTypeEnum[]{PrimitiveTypeEnum.INT};
22 
23        private OperationSignature marshallSignature;
24        private OperationSignature demarshallSignature;
25 
26        public MarshallerComponentSeffBuilder(OperationProvidedRole domainProvRole,
27                        OperationRequiredRole domainReqRole, OperationRequiredRole middlewareReqRole, MarshallerSide side) {
28                super(domainProvRole, domainReqRole, middlewareReqRole);
29                this.marshallSignature = findService(middlewareRole.getRequiredInterface__OperationRequiredRole(), "marshall");
30                this.demarshallSignature = findService(middlewareRole.getRequiredInterface__OperationRequiredRole(), "demarshall");
31                
32                switch(side) {
33                case CLIENT:
34                        prepareClient();
35                        break;
36                case SERVER:
37                        prepareServer();
38                        break;
39                }
40        }
41        
42        private void prepareClient() {
43                
44                this.appendPreAction(
45                                new SignatureDependentExternalCallActionDescriptor(
46                                                marshallSignature,
47                                                this.middlewareRole){
48 
49                                                        @Override
50                                                        protected Collection<VariableUsage> getSignatureDependentInputParameter(
51                                                                        OperationSignature currentSignature) {
52                                                                ArrayList<VariableUsage> result = new ArrayList<VariableUsage>();
53                                                                for (PrimitiveTypeEnum type : primitiveTypes){
54                                                                        VariableUsage usage = createInputParameterFor(currentSignature, type, BytesizeComputationForSignature.Modifier.IN);
55                                                                        if (usage != null)
56                                                                                result.add(usage);
57                                                                }
58                                                                return result;
59                                                        }
60 
61                                                        @Override
62                                                        protected Collection<VariableUsage> getSignatureDependentOutputParameter(
63                                                                        OperationSignature currentSignature) {
64                                                                // add size of input parameters to stream
65                                                                return createMarshallOutParameter(currentSignature, Modifier.IN);
66                                                        }
67                        
68                });
69                
70                this.appendPreAction(new BytesizeAddingSetVariableActionDescriptor(
71                                createVariableUsage("stream", VariableCharacterisationType.BYTESIZE, "stream.BYTESIZE"),Modifier.IN));
72 
73                
74                this.appendPostAction(
75                                new ExternalCallActionDescriptor(
76                                                demarshallSignature,
77                                                this.middlewareRole,
78                                                createMiddlewareParameter()));
79        }
80 
81        private void prepareServer() {
82                this.appendPreAction(
83                                new ExternalCallActionDescriptor(
84                                                demarshallSignature,
85                                                this.middlewareRole,
86                                                createMiddlewareParameter()));
87                this.appendPostAction(
88                                new SignatureDependentExternalCallActionDescriptor(
89                                                marshallSignature,
90                                                this.middlewareRole){
91 
92                                                        @Override
93                                                        protected Collection<VariableUsage> getSignatureDependentInputParameter(
94                                                                        OperationSignature currentSignature) {
95                                                                ArrayList<VariableUsage> result = new ArrayList<VariableUsage>();
96                                                                for (PrimitiveTypeEnum type : primitiveTypes) {
97                                                                        VariableUsage usage = createInputParameterFor(currentSignature, type, BytesizeComputationForSignature.Modifier.OUT);
98                                                                        if (usage != null)
99                                                                                result.add(usage);
100                                                                }
101                                                                return result;
102                                                        }
103 
104                                                        @Override
105                                                        protected Collection<VariableUsage> getSignatureDependentOutputParameter(
106                                                                        OperationSignature currentSignature) {
107                                                                // add size of return parameters to stream
108                                                                return createMarshallOutParameter(currentSignature, Modifier.OUT);
109                                                        }
110                });
111                this.appendPostAction(new BytesizeAddingSetVariableActionDescriptor(
112                                createVariableUsage("stream", VariableCharacterisationType.BYTESIZE, "stream.BYTESIZE"),Modifier.OUT));
113        }
114        
115 
116 
117        private OperationSignature findService(OperationInterface middlewareInterface,
118                        String preServiceName) {
119                for (OperationSignature sig : middlewareInterface.getSignatures__OperationInterface()){
120                        if (sig.getEntityName().equals(preServiceName))
121                                return sig;
122                }
123                throw new RuntimeException("Required middleware service not found in middleware interface");
124        }        
125 
126        /**
127         * This method is responsible to determine the size of the stream that has to be sent over the network
128         * after marshalling (i.e. the marshall out data). 
129         * @param currentSignature
130         * @return
131         */
132        private Collection<VariableUsage> createMarshallOutParameter(OperationSignature currentSignature, Modifier modifier) {
133                Collection<VariableUsage> result = new ArrayList<VariableUsage>();
134                
135                result.add(createVariableUsage("stream", VariableCharacterisationType.BYTESIZE, "RETURN.BYTESIZE"));
136                
137                
138                return result; 
139        }
140 
141        /**
142         * This method is responsible for creating the variable characterizations ints.NUMBER_OF_ELEMENTS that appear in the simulation code of connector completions. 
143         * This data is input to the middleware component configured in the models, and can be used by 
144         * the middleware component to calculate the size of the passed stream. 
145         * For example, in the default Glassfish component, ints.NUMBER_OF_ELEMENTS is then transformed to a BYTESIZE characterisation 
146         * with 2 bytes for each int (see default glassfish model).  
147         * 
148         * 
149         * @param currentSignature
150         * @param type
151         * @param in
152         * @return
153         */
154        protected VariableUsage createInputParameterFor(OperationSignature currentSignature,
155                        PrimitiveTypeEnum type, Modifier in) {
156                String specification = NumberOfElementsComputationForSignature.countAmount(currentSignature,type,in);
157                                
158                if (specification != null)
159                        return createVariableUsage(type.getLiteral().toLowerCase()+"s", VariableCharacterisationType.NUMBER_OF_ELEMENTS, 
160                                specification);
161                else
162                        return createVariableUsage(type.getLiteral().toLowerCase()+"s", VariableCharacterisationType.NUMBER_OF_ELEMENTS, 
163                                        "0");
164        }
165 
166        
167}

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