1 package net.sf.crispy.strategy;
2
3 import java.util.Map;
4
5 import net.sf.crispy.InvocationStrategy;
6 import net.sf.crispy.util.Converter;
7
8 /**
9 * Call Class: <code>test.crispy.example.service.Calculator</code> with Method: <code>add</code>:
10 * <code>class=test.crispy.example.service.Calculator&method=add</code> OR
11 * <code>method=service.calculator.add</code>.
12 *
13 * @author Linke
14 *
15 */
16 public class RestInvocationStrategy implements InvocationStrategy {
17
18 public Object convert(Map pvPropertyMap) {
19 String lvClass = (String) pvPropertyMap.get(InvocationStrategy.CLASS_NAME);
20 String lvMethod = (String) pvPropertyMap.get(InvocationStrategy.METHOD_NAME);
21 String lvUrl = (String) pvPropertyMap.get(InvocationStrategy.URL);
22 String lvNameSpace = (String) pvPropertyMap.get(InvocationStrategy.CONST_NAMESPACE);
23
24 StringBuffer lvReturn = new StringBuffer(lvUrl);
25 if (lvNameSpace == null) {
26 lvReturn.append("?class=").append(lvClass).append("&method=").append(lvMethod);
27 } else {
28 String lvClassName = Converter.getClassWithoutPackage(lvClass, true);
29 lvReturn.append("?method=").append(lvNameSpace).append(".").append(lvClassName)
30 .append(".").append(lvMethod);
31
32 }
33
34 return lvReturn.toString();
35 }
36
37 }