diff --git a/AlgebraicDataflowArchitectureModel/src/generators/CodeGenerator.java b/AlgebraicDataflowArchitectureModel/src/generators/CodeGenerator.java index 06ebf11..eb84521 100644 --- a/AlgebraicDataflowArchitectureModel/src/generators/CodeGenerator.java +++ b/AlgebraicDataflowArchitectureModel/src/generators/CodeGenerator.java @@ -52,7 +52,9 @@ public static final String fieldOfResourceState = "value"; public static final String getterPrefix = "get"; public static final String getterOfResourceState = "getValue"; - public static final String updateMethodName = "update"; + public static final String updateMethodPrefix = "update"; + public static final String from = "From"; + public static final String _for = "For"; private static String mainTypeName = null; private static ILanguageSpecific langSpec = null; @@ -451,7 +453,7 @@ protected MethodDeclaration getUpdateMethod(Edge inEdge, TypeDeclaration component, Map>> dataFlowInform, ILanguageSpecific langSpec) { List passedResoueces = dataFlowInform.get(inEdge).get(PushPullValue.PUSH); - String methodName = updateMethodName; + String methodName = updateMethodPrefix; for (ResourceNode rn: passedResoueces) { methodName += langSpec.toComponentName(rn.getResourceName()); } diff --git a/AlgebraicDataflowArchitectureModel/src/generators/CodeGeneratorFromDataFlowGraph.java b/AlgebraicDataflowArchitectureModel/src/generators/CodeGeneratorFromDataFlowGraph.java index 722a4a7..c18bfc2 100644 --- a/AlgebraicDataflowArchitectureModel/src/generators/CodeGeneratorFromDataFlowGraph.java +++ b/AlgebraicDataflowArchitectureModel/src/generators/CodeGeneratorFromDataFlowGraph.java @@ -635,7 +635,7 @@ private Map.Entry, Map>> declareCacheFieldsAndUpdateMethods(ResourceNode resourceNode, TypeDeclaration component, TypeDeclaration parentComponent, ILanguageSpecific langSpec) { // Declare cash fields and update methods in the component. - String resComponentName = langSpec.toComponentName(resourceNode.getResourceName()); + String resComponentName = getComponentName(resourceNode.getResourceHierarchy(), langSpec); List constructorStatements = new ArrayList<>(); Map> updateStatements = new HashMap<>(); for (Edge chToRes: resourceNode.getInEdges()) { @@ -643,8 +643,8 @@ DataTransferChannel ch = ((ChannelNode) resToCh.getDestination()).getChannel(); DataFlowEdge re = (DataFlowEdge) resToCh; ResourcePath srcRes = ((ResourceNode) re.getSource()).getOutSideResource(); - String srcResName = srcRes.getResourceName(); - String srcResComponentName = langSpec.toComponentName(srcResName); + String srcResComponentName = getComponentName(srcRes.getResourceHierarchy(), langSpec); + String srcResName = langSpec.toVariableName(srcResComponentName); // Check if the input resource is outside of the channel scope. boolean outsideInputResource = false; for (ChannelMember cm: ch.getInputChannelMembers()) { @@ -665,10 +665,12 @@ vars.add(langSpec.newVariableDeclaration(ref.getResourceStateType(), ref.getResourceName())); } } - MethodDeclaration update = langSpec.newMethodDeclaration(updateMethodName + srcResComponentName, false, null, vars); + MethodDeclaration update = null; if (component != null) { + update = langSpec.newMethodDeclaration(updateMethodPrefix + from + srcResComponentName, false, null, vars); component.addMethod(update); } else if (parentComponent != null) { + update = langSpec.newMethodDeclaration(updateMethodPrefix + resComponentName + from + srcResComponentName, false, null, vars); parentComponent.addMethod(update); } @@ -737,7 +739,7 @@ String[] sideEffects2 = new String[] {""}; String newMap = selector.toImplementation(sideEffects2); updateStatement += sideEffects2[0]; - } else { + } else if (!(updateExp instanceof Term && ((Term) updateExp).getSymbol().isImplWithSideEffect())) { String resourceName = langSpec.toVariableName(getComponentName(outRes, langSpec)); updateStatement += langSpec.getFieldAccessor(resourceName) + langSpec.getAssignment() + newState + langSpec.getStatementDelimiter(); } @@ -886,17 +888,21 @@ if (!generatesComponent(srcRes2)) { srcRes2 = srcRes2.getParent(); } + String updateMethodName = null; ResourceHierarchy dstRes = ((ResourceNode) chToRes2.getDestination()).getResourceHierarchy(); if (!generatesComponent(dstRes)) { + updateMethodName = updateMethodPrefix + getComponentName(dstRes, langSpec) + from + resComponentName; dstRes = dstRes.getParent(); + } else { + updateMethodName = updateMethodPrefix + from + resComponentName; } String dstCompName = langSpec.toVariableName(getComponentName(dstRes, langSpec)); if (srcRes2 != dstRes) { - update.addStatement(langSpec.getMethodInvocation(langSpec.getFieldAccessor(dstCompName), updateMethodName + resComponentName, params) - + langSpec.getStatementDelimiter()); // this.dst.updateSrc(value, refParams); + update.addStatement(langSpec.getMethodInvocation(langSpec.getFieldAccessor(dstCompName), updateMethodName, params) + + langSpec.getStatementDelimiter()); // this.dst.updateDstFromSrc(value, refParams); } else { - update.addStatement(langSpec.getMethodInvocation(updateMethodName + resComponentName, params) - + langSpec.getStatementDelimiter()); // this.updateSrc(value, refParams); + update.addStatement(langSpec.getMethodInvocation(updateMethodName, params) + + langSpec.getStatementDelimiter()); // this.updateDstFromSrc(value, refParams); } } } @@ -1040,7 +1046,7 @@ } String inputMethodName = ((Term) message).getSymbol().getImplName(); if (((DataTransferChannel) ch).getOutputChannelMembers().size() > 1) { - inputMethodName += getComponentName(out.getResource().getResourceHierarchy(), langSpec); + inputMethodName += _for + getComponentName(out.getResource().getResourceHierarchy(), langSpec); } input = langSpec.newMethodDeclaration(inputMethodName, false, null, resInputParams); if (component != null) { @@ -1103,7 +1109,7 @@ } String inputMethodName = ((Variable) message).getName(); if (((DataTransferChannel) ch).getOutputChannelMembers().size() > 1) { - inputMethodName += getComponentName(out.getResource().getResourceHierarchy(), langSpec); + inputMethodName += _for + getComponentName(out.getResource().getResourceHierarchy(), langSpec); } if (resInputParams.size() == 0) { input = langSpec.newMethodDeclaration(inputMethodName, null); @@ -1225,7 +1231,7 @@ String[] sideEffects2 = new String[] {""}; String newMap = selector.toImplementation(sideEffects2); updateStatement += sideEffects2[0]; - } else { + } else if (!(updateExp instanceof Term && ((Term) updateExp).getSymbol().isImplWithSideEffect())) { String resourceName = langSpec.toVariableName(getComponentName(resource, langSpec)); updateStatement += langSpec.getFieldAccessor(resourceName) + langSpec.getAssignment() + newState + langSpec.getStatementDelimiter(); } @@ -1291,17 +1297,21 @@ if (!generatesComponent(srcRes)) { srcRes = srcRes.getParent(); } + String updateMethodName = null; ResourceHierarchy dstRes = ((ResourceNode) chToRes.getDestination()).getResourceHierarchy(); if (!generatesComponent(dstRes)) { + updateMethodName = updateMethodPrefix + getComponentName(dstRes, langSpec) + from + resComponentName; dstRes = dstRes.getParent(); + } else { + updateMethodName = updateMethodPrefix + from + resComponentName; } String dstCompName = langSpec.toVariableName(getComponentName(dstRes, langSpec)); if (srcRes != dstRes) { - input.addStatement(langSpec.getMethodInvocation(langSpec.getFieldAccessor(dstCompName), updateMethodName + resComponentName, params) - + langSpec.getStatementDelimiter()); // this.dst.updateSrc(value, refParams); + input.addStatement(langSpec.getMethodInvocation(langSpec.getFieldAccessor(dstCompName), updateMethodName, params) + + langSpec.getStatementDelimiter()); // this.dst.updateDstFromSrc(value, refParams); } else { - input.addStatement(langSpec.getMethodInvocation(updateMethodName + resComponentName, params) - + langSpec.getStatementDelimiter()); // this.updateSrc(value, refParams); + input.addStatement(langSpec.getMethodInvocation(updateMethodName, params) + + langSpec.getStatementDelimiter()); // this.updateDstFromSrc(value, refParams); } } } diff --git a/AlgebraicDataflowArchitectureModel/src/generators/JavaCodeGenerator.java b/AlgebraicDataflowArchitectureModel/src/generators/JavaCodeGenerator.java index 72c4200..00d86f6 100644 --- a/AlgebraicDataflowArchitectureModel/src/generators/JavaCodeGenerator.java +++ b/AlgebraicDataflowArchitectureModel/src/generators/JavaCodeGenerator.java @@ -148,7 +148,6 @@ // For each resource node. for (ResourceNode resourceNode: resources) { TypeDeclaration component = null; - boolean bComponentCreated = false; Set depends = new HashSet<>(); Set refs = new HashSet<>(); if (generatesComponent(resourceNode.getResourceHierarchy())) { @@ -158,7 +157,6 @@ component = resourceComponents.get(resourceNode.getResourceHierarchy()); if (component == null) { // Add compilation unit for each resource. - bComponentCreated = true; component = new TypeDeclaration(resourceName); resourceComponents.put(resourceNode.getResourceHierarchy(), component); CompilationUnit cu = new CompilationUnit(component); @@ -555,12 +553,15 @@ vars.add(new VariableDeclaration(ref.getResourceStateType(), ref.getResourceName())); } } - MethodDeclaration update = new MethodDeclaration("update" + srcResName, false, typeVoid, vars); + MethodDeclaration update = null; if (component != null) { // A component is created for this resource. + update = new MethodDeclaration("updateFrom" + srcResName, false, typeVoid, vars); component.addMethod(update); } else { // No component is created for this resource. + String resourceName = getComponentName(resourceNode.getResourceHierarchy()); + update = new MethodDeclaration("update" + resourceName + "From" + srcResName, false, typeVoid, vars); updates.add(new AbstractMap.SimpleEntry<>(resourceNode.getParent().getResourceHierarchy(), update)); } } @@ -680,7 +681,7 @@ } String inputMethodName = ((Term) message).getSymbol().getImplName(); if (((DataTransferChannel) ch).getOutputChannelMembers().size() > 1) { - inputMethodName += getComponentName(cm.getResource().getResourceHierarchy()); + inputMethodName += "For" + getComponentName(cm.getResource().getResourceHierarchy()); } MethodDeclaration input = new MethodDeclaration(inputMethodName, false, typeVoid, resInputParams); if (component != null) { @@ -741,7 +742,7 @@ } String inputMethodName = ((Variable) message).getName(); if (((DataTransferChannel) ch).getOutputChannelMembers().size() > 1) { - inputMethodName += getComponentName(cm.getResource().getResourceHierarchy()); + inputMethodName += "For" + getComponentName(cm.getResource().getResourceHierarchy()); } MethodDeclaration input = null; if (resInputParams.size() > 0) { diff --git a/AlgebraicDataflowArchitectureModel/src/generators/JavaMethodBodyGenerator.java b/AlgebraicDataflowArchitectureModel/src/generators/JavaMethodBodyGenerator.java index d72ab8b..3d51562 100644 --- a/AlgebraicDataflowArchitectureModel/src/generators/JavaMethodBodyGenerator.java +++ b/AlgebraicDataflowArchitectureModel/src/generators/JavaMethodBodyGenerator.java @@ -89,17 +89,14 @@ } if (pushPull.getOptions().get(0) == PushPullValue.PUSH && !outsideInputResource) { // for push data transfer - String srcResName = null; - if (srcComponent == null) { - srcResName = srcResourceName; - } else { - srcResName = srcComponent.getTypeName(); - } + MethodDeclaration update = null; if (dstComponent == null) { String dstParentResourceName = JavaCodeGenerator.getComponentName(dst.getResourceHierarchy().getParent()); dstComponent = componentMap.get(dstParentResourceName); + update = getUpdateMethod(dstComponent, dstResourceName, srcResourceName); + } else { + update = getUpdateMethod(dstComponent, null, srcResourceName); } - MethodDeclaration update = getUpdateMethod(dstComponent, srcResName); if (((StoreAttribute) dst.getAttribute()).isStored()) { // update stored state of dst side resource (when every incoming edge is in push style) Expression updateExp = null; @@ -162,7 +159,7 @@ String[] sideEffects2 = new String[] {""}; String newMap = selector.toImplementation(sideEffects2); updateStatement += sideEffects2[0]; - } else { + } else if (!(updateExp instanceof Term && ((Term) updateExp).getSymbol().isImplWithSideEffect())) { updateStatement += "this." + JavaCodeGenerator.toVariableName(JavaCodeGenerator.getComponentName(outRes)) + " = " + newState + ";"; } if (update.getBody() == null || !update.getBody().getStatements().contains(updateStatement)) { @@ -222,11 +219,13 @@ break; } } + String srcResName = null; if (srcComponent == null) { String srcParentResourceName = JavaCodeGenerator.getComponentName(src.getResourceHierarchy().getParent()); srcComponent = componentMap.get(srcParentResourceName); + srcResName = srcResourceName; } - for (MethodDeclaration srcUpdate: getUpdateMethods(srcComponent)) { + for (MethodDeclaration srcUpdate: getUpdateMethods(srcComponent, srcResName)) { String refParams = ""; Set referredSet = referredResources.get(srcUpdate); for (ChannelMember rc: ch.getReferenceChannelMembers()) { @@ -249,10 +248,16 @@ refParams += ", " + refVarName; } } - if (srcComponent != dstComponent) { - srcUpdate.addStatement("this." + JavaCodeGenerator.toVariableName(dstComponent.getTypeName()) + ".update" + src.getResourceName() + "(value" + refParams + ");"); + String updateMethodName = null; + if (JavaCodeGenerator.generatesComponent(dst.getResourceHierarchy())) { + updateMethodName = "updateFrom" + srcResourceName; } else { - srcUpdate.addStatement("this.update" + src.getResourceName() + "(value" + refParams + ");"); + updateMethodName = "update" + dstResourceName + "From" + srcResourceName; + } + if (srcComponent != dstComponent) { + srcUpdate.addStatement("this." + JavaCodeGenerator.toVariableName(dstComponent.getTypeName()) + "." + updateMethodName + "(value" + refParams + ");"); + } else { + srcUpdate.addStatement("this." + updateMethodName + "(value" + refParams + ");"); } } for (MethodDeclaration srcInput: getInputMethods(srcComponent, src, model)) { @@ -278,10 +283,16 @@ refParams += ", " + refVarName; } } - if (srcComponent != dstComponent) { - srcInput.addStatement("this." + JavaCodeGenerator.toVariableName(dstComponent.getTypeName()) + ".update" + src.getResourceName()+ "(value" + refParams + ");"); + String updateMethodName = null; + if (JavaCodeGenerator.generatesComponent(dst.getResourceHierarchy())) { + updateMethodName = "updateFrom" + srcResourceName; } else { - srcInput.addStatement("this.update" + src.getResourceName() + "(value" + refParams + ");"); + updateMethodName = "update" + dstResourceName + "From" + srcResourceName; + } + if (srcComponent != dstComponent) { + srcInput.addStatement("this." + JavaCodeGenerator.toVariableName(dstComponent.getTypeName()) + "." + updateMethodName + "(value" + refParams + ");"); + } else { + srcInput.addStatement("this." + updateMethodName + "(value" + refParams + ");"); } } } else if ((pushPull.getOptions().get(0) != PushPullValue.PUSH && !outsideOutputResource) || outsideInputResource) { @@ -405,7 +416,13 @@ for (Edge resToCh2: chToRes2.getSource().getInEdges()) { // In an update method of the parent component. ResourceNode dependingResSrc = (ResourceNode) resToCh2.getSource(); - MethodDeclaration update = getUpdateMethod(dependingComponent, JavaCodeGenerator.getComponentName(dependingResSrc.getResourceHierarchy())); + MethodDeclaration update = null; + if (JavaCodeGenerator.generatesComponent(dependingRes.getResourceHierarchy())) { + update = getUpdateMethod(dependingComponent, null, JavaCodeGenerator.getComponentName(dependingResSrc.getResourceHierarchy())); + } else { + String dependingResName = JavaCodeGenerator.getComponentName(dependingRes.getResourceHierarchy()); + update = getUpdateMethod(dependingComponent, dependingResName, JavaCodeGenerator.getComponentName(dependingResSrc.getResourceHierarchy())); + } update.addStatement("this." + outsideResName + " = " + outsideAccessor + ";"); // change the reference field. } // Update constructor. @@ -418,7 +435,13 @@ } else { if (pushPull2.getOptions().get(0) == PushPullValue.PUSH) { // In an update method of the destination component. - MethodDeclaration update = getUpdateMethod(dstComponent, JavaCodeGenerator.getComponentName(dependingRes.getResourceHierarchy())); + MethodDeclaration update = null; + if (JavaCodeGenerator.generatesComponent(dst.getResourceHierarchy())) { + update = getUpdateMethod(dstComponent, null, JavaCodeGenerator.getComponentName(dependingRes.getResourceHierarchy())); + } else { + String dstResName = JavaCodeGenerator.getComponentName(dst.getResourceHierarchy()); + update = getUpdateMethod(dstComponent, dstResName, JavaCodeGenerator.getComponentName(dependingRes.getResourceHierarchy())); + } String[] sideEffects = new String[] {""}; String outsideAccessor = outsideExp.toImplementation(sideEffects); update.addStatement("this." + outsideResName + " = " + outsideAccessor + ";"); // change the reference field. @@ -599,7 +622,7 @@ String[] sideEffects2 = new String[] {""}; String newMap = selector.toImplementation(sideEffects2); updateStatement += sideEffects2[0]; - } else { + } else if (!(updateExp instanceof Term && ((Term) updateExp).getSymbol().isImplWithSideEffect())) { updateStatement += "this." + JavaCodeGenerator.toVariableName(JavaCodeGenerator.getComponentName(resource)) + " = " + newState + ";"; } if (updateStatement != null && (input.getBody() == null || !input.getBody().getStatements().contains(updateStatement))) { @@ -719,18 +742,28 @@ return null; } - private static MethodDeclaration getUpdateMethod(TypeDeclaration component, String fromResName) { + private static MethodDeclaration getUpdateMethod(TypeDeclaration component, String dstResName, String srcResName) { for (MethodDeclaration m: component.getMethods()) { - if (m.getName().equals("update" + fromResName)) return m; + if (dstResName == null) { + if (m.getName().equals("updateFrom" + srcResName)) return m; + } else { + if (m.getName().equals("update" + dstResName + "From" + srcResName)) return m; + } } return null; } - private static List getUpdateMethods(TypeDeclaration component) { + private static List getUpdateMethods(TypeDeclaration component, String resName) { List updates = new ArrayList<>(); for (MethodDeclaration m: component.getMethods()) { - if (m.getName().startsWith("update")) { - updates.add(m); + if (resName == null) { + if (m.getName().startsWith("updateFrom")) { + updates.add(m); + } + } else { + if (m.getName().startsWith("update" + resName + "From")) { + updates.add(m); + } } } return updates; @@ -804,7 +837,7 @@ inputMethodName = message.getName(); } if (outNumber > 1) { - inputMethodName += JavaCodeGenerator.getComponentName(cm.getResource().getResourceHierarchy()); + inputMethodName += "For" + JavaCodeGenerator.getComponentName(cm.getResource().getResourceHierarchy()); } MethodDeclaration input = getMethod(component, inputMethodName); return input; diff --git a/AlgebraicDataflowArchitectureModel/src/generators/JerseyCodeGenerator.java b/AlgebraicDataflowArchitectureModel/src/generators/JerseyCodeGenerator.java index ca7b332..be40bf7 100644 --- a/AlgebraicDataflowArchitectureModel/src/generators/JerseyCodeGenerator.java +++ b/AlgebraicDataflowArchitectureModel/src/generators/JerseyCodeGenerator.java @@ -533,7 +533,15 @@ vars.add(param); } } - MethodDeclaration update = new MethodDeclaration("update" + srcResName, false, typeVoid, vars); + MethodDeclaration update = null; + if (component != null) { + // A component is created for this resource. + update = new MethodDeclaration("updateFrom" + srcResName, false, typeVoid, vars); + } else { + // No component is created for this resource. + String resourceName = getComponentName(resourceNode.getResourceHierarchy()); + update = new MethodDeclaration("update" + resourceName + "From" + srcResName, false, typeVoid, vars); + } for (ChannelMember cm: ((ChannelNode) re.getDestination()).getChannel().getOutputChannelMembers()) { if (resourceNode.getInSideResources().contains(cm.getResource())) { if (cm.getStateTransition().isRightUnary()) { @@ -625,7 +633,7 @@ if (resourceNode.getResourceHierarchy().getParent() != null && resourceNode.getResourceHierarchy().getParent().getParent() != null) { String inputMethodName = ((Term) message).getSymbol().getImplName(); if (((DataTransferChannel) ch).getOutputChannelMembers().size() > 1) { - inputMethodName += getComponentName(cm.getResource().getResourceHierarchy()); + inputMethodName += "For" + getComponentName(cm.getResource().getResourceHierarchy()); } MethodDeclaration input = new MethodDeclaration(inputMethodName, false, typeVoid, resInputParams); if (component != null) { @@ -675,7 +683,7 @@ if (cm.getResource().getResourceHierarchy().getParent() != null && cm.getResource().getResourceHierarchy().getParent().getParent() != null) { String inputMethodName = ((Variable) message).getName(); if (((DataTransferChannel) ch).getOutputChannelMembers().size() > 1) { - inputMethodName += getComponentName(cm.getResource().getResourceHierarchy()); + inputMethodName += "For" + getComponentName(cm.getResource().getResourceHierarchy()); } MethodDeclaration input = new MethodDeclaration(inputMethodName, false, typeVoid, null); if (component != null) { diff --git a/AlgebraicDataflowArchitectureModel/src/generators/JerseyMethodBodyGenerator.java b/AlgebraicDataflowArchitectureModel/src/generators/JerseyMethodBodyGenerator.java index 6651106..efc172a 100644 --- a/AlgebraicDataflowArchitectureModel/src/generators/JerseyMethodBodyGenerator.java +++ b/AlgebraicDataflowArchitectureModel/src/generators/JerseyMethodBodyGenerator.java @@ -95,11 +95,14 @@ } if (pushPull.getOptions().get(0) == PushPullValue.PUSH && !outsideInputResource) { // for push data transfer + MethodDeclaration update = null; if (dstComponent == null) { String dstParentResourceName = JerseyCodeGenerator.getComponentName(dst.getResourceHierarchy().getParent()); dstComponent = componentMap.get(dstParentResourceName); + update = getUpdateMethod(dstComponent, dstResourceName, srcResourceName); + } else { + update = getUpdateMethod(dstComponent, null, srcResourceName); } - MethodDeclaration update = getUpdateMethod(dstComponent, srcResourceName); if (((StoreAttribute) dst.getAttribute()).isStored()) { // update stored state of dst side resource (when every incoming edge is in push style) Expression updateExp = null; @@ -174,7 +177,7 @@ String[] sideEffects2 = new String[] {""}; String newMap = selector.toImplementation(sideEffects2); updateStatement += sideEffects2[0]; - } else { + } else if (!(updateExp instanceof Term && ((Term) updateExp).getSymbol().isImplWithSideEffect())) { updateStatement += "this." + JerseyCodeGenerator.toVariableName(JerseyCodeGenerator.getComponentName(outRes)) + " = " + newState + ";"; } if (update.getBody() == null || !update.getBody().getStatements().contains(updateStatement)) { @@ -288,11 +291,13 @@ } else { httpMethod = "post"; } + String srcName = null; if (srcComponent == null) { String srcParentResourceName = JerseyCodeGenerator.getComponentName(src.getResourceHierarchy().getParent()); srcComponent = componentMap.get(srcParentResourceName); + srcName = srcResourceName; } - for (MethodDeclaration srcUpdate: getUpdateMethods(srcComponent)) { + for (MethodDeclaration srcUpdate: getUpdateMethods(srcComponent, srcName)) { if (srcUpdate != null) { List>> params = new ArrayList<>(); Set referredSet = referredResources.get(srcUpdate); @@ -622,7 +627,7 @@ String[] sideEffects2 = new String[] {""}; String newMap = selector.toImplementation(sideEffects2); updateStatement += sideEffects2[0]; - } else { + } else if (!(updateExp instanceof Term && ((Term) updateExp).getSymbol().isImplWithSideEffect())) { updateStatement += "this." + JerseyCodeGenerator.toVariableName(JerseyCodeGenerator.getComponentName(resource)) + " = " + newState + ";"; } if (updateStatement != null && (input.getBody() == null || !input.getBody().getStatements().contains(updateStatement))) { @@ -892,9 +897,13 @@ return null; } - private static MethodDeclaration getUpdateMethod(TypeDeclaration component, String from) { + private static MethodDeclaration getUpdateMethod(TypeDeclaration component, String dstResName, String srcResName) { for (MethodDeclaration m: component.getMethods()) { - if (m.getName().equals("update" + from)) return m; + if (dstResName == null) { + if (m.getName().equals("updateFrom" + srcResName)) return m; + } else { + if (m.getName().equals("update" + dstResName + "From" + srcResName)) return m; + } } return null; } @@ -906,11 +915,17 @@ return null; } - private static List getUpdateMethods(TypeDeclaration component) { + private static List getUpdateMethods(TypeDeclaration component, String resName) { List updates = new ArrayList<>(); for (MethodDeclaration m: component.getMethods()) { - if (m.getName().startsWith("update")) { - updates.add(m); + if (resName == null) { + if (m.getName().startsWith("updateFrom")) { + updates.add(m); + } + } else { + if (m.getName().startsWith("update" + resName + "From")) { + updates.add(m); + } } } return updates; @@ -962,7 +977,7 @@ inputMethodName = message.getName(); } if (outNumber > 1) { - inputMethodName += JerseyCodeGenerator.getComponentName(cm.getResource().getResourceHierarchy()); + inputMethodName += "For" + JerseyCodeGenerator.getComponentName(cm.getResource().getResourceHierarchy()); } MethodDeclaration input = getMethod(component, inputMethodName); return input;