forked from chenjianjx/wsdl2html
-
Notifications
You must be signed in to change notification settings - Fork 0
/
WebMethodStubSetFactory.java
46 lines (37 loc) · 1.58 KB
/
WebMethodStubSetFactory.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
package org.jaxws.stub2html.service;
import static org.jaxws.stub2html.service.JavaLanguageVariableFactory.createVariableFromMethodReturn;
import static org.jaxws.stub2html.service.JavaLanguageVariableFactory.createVariablesFromMethodParamaters;
import java.lang.reflect.Method;
import java.util.List;
import org.jaxws.stub2html.model.JavaLanguageVariable;
import org.jaxws.stub2html.model.Stub;
import org.jaxws.stub2html.model.WebMethodStubSet;
/**
*
* @author chenjianjx
*
*/
public class WebMethodStubSetFactory {
public static WebMethodStubSet createWebMethodStubSet(Method method) {
WebMethodStubSet stubSet = new WebMethodStubSet();
stubSet.setMethodName(method.getName());
stubSet.setMethodDescription(DescriptionLocatorRepository.getInstance().findDescriptionByMethod(method));
addRequestStubs(method, stubSet);
if (!Void.TYPE.equals(method.getReturnType())) {
addResponseStub(method, stubSet);
}
return stubSet;
}
private static void addResponseStub(Method method, WebMethodStubSet stubSet) {
JavaLanguageVariable variable = createVariableFromMethodReturn(method);
Stub stub = Variable2Stub.convertToStub(variable, null, stubSet.getStubTypeTreeRepository());
stubSet.setResponseStub(stub);
}
private static void addRequestStubs(Method method, WebMethodStubSet stubSet) {
List<JavaLanguageVariable> requestVariables = createVariablesFromMethodParamaters(method);
for (JavaLanguageVariable variable : requestVariables) {
Stub stub = Variable2Stub.convertToStub(variable, null, stubSet.getStubTypeTreeRepository());
stubSet.addRequetStub(stub);
}
}
}