in modules/kernel/src/org/apache/axis2/deployment/util/Utils.java [400:550]
public static void fillAxisService(final AxisService axisService,
AxisConfiguration axisConfig, ArrayList<String> excludeOperations,
ArrayList<String> nonRpcMethods) throws Exception {
Class<?> serviceClass = org.apache.axis2.util.Utils.getServiceClass(axisService);
if (serviceClass == null) {
return;
}
String enableJSONOnly = (String) axisConfig.getParameterValue("enableJSONOnly");
if (enableJSONOnly !=null && enableJSONOnly.equalsIgnoreCase("true")) {
log.debug("on enableJSONOnly: " +enableJSONOnly+ " starting fillAxisService(), serviceClass.name: " + serviceClass.getName());
List<Method> serviceMethods = new ArrayList<Method>();
Map<String, Method> uniqueMethods = new LinkedHashMap<String, Method>();
for (Method method : serviceClass.getMethods()) {
if (method.getDeclaringClass() == Object.class) {
continue;
}
if (!Modifier.isPublic(method.getModifiers())) {
// skip non public methods
continue;
}
String methodName = method.getName();
if (excludeOperations.contains(methodName)) {
continue;
}
boolean addToService = false;
AxisOperation axisOperation = axisService.getOperation(new QName(methodName));
if (axisOperation == null) {
axisOperation = getAxisOperationForJmethod(method);
axisService.addOperation(axisOperation);
log.debug("on methodName: " +methodName+ " , enableJSONOnly: " +enableJSONOnly+ " , axisOperation added to service: " +axisService.getName());
}
// by now axis operation should be assigned but we better recheck & add the paramether
if (axisOperation != null) {
axisOperation.addParameter("JAXRSAnnotaion", JAXRSUtils.getMethodModel(JAXRSUtils.getClassModel(serviceClass), method));
}
if (method.getDeclaringClass() != Object.class) {
serviceMethods.add(method);
}
}
// The order of the methods returned by getMethods is undefined, but the test cases assume that the
// order is the same on all Java versions. Java 6 seems to use reverse lexical order, so we use that
// here to make things deterministic.
Collections.sort(serviceMethods, new Comparator<Method>() {
public int compare(Method o1, Method o2) {
return -o1.getName().compareTo(o2.getName());
}
});
log.debug("fillAxisService() on enableJSONOnly=true found serviceMethods: " +serviceMethods);
PhasesInfo pinfo = axisConfig.getPhasesInfo();
for (Method jmethod : serviceMethods) {
String opName = jmethod.getName();
AxisOperation operation = axisService
.getOperation(new QName(opName));
// if the operation there in services.xml then try to set it schema
// element name
if (operation == null) {
operation = axisService.getOperation(new QName(
jmethod.getName()));
}
MessageReceiver mr =
axisService.getMessageReceiver(operation.getMessageExchangePattern());
if (mr == null) {
mr = axisConfig.getMessageReceiver(operation.getMessageExchangePattern());
}
if (operation.getMessageReceiver() == null) {
operation.setMessageReceiver(mr);
}
pinfo.setOperationPhases(operation);
axisService.addOperation(operation);
axisService.addJSONMessageNameToOperationMapping(opName, operation);
}
log.debug("fillAxisService() completed on enableJSONOnly=true , axisService name: " + axisService.getName());
return;
}
ClassLoader serviceClassLoader = axisService.getClassLoader();
// adding name spaces
NamespaceMap map = new NamespaceMap();
map.put(Java2WSDLConstants.AXIS2_NAMESPACE_PREFIX,
Java2WSDLConstants.AXIS2_XSD);
map.put(Java2WSDLConstants.DEFAULT_SCHEMA_NAMESPACE_PREFIX,
Java2WSDLConstants.URI_2001_SCHEMA_XSD);
axisService.setNamespaceMap(map);
SchemaGenerator schemaGenerator;
Parameter generateBare = axisService
.getParameter(Java2WSDLConstants.DOC_LIT_BARE_PARAMETER);
if (generateBare != null && "true".equals(generateBare.getValue())) {
schemaGenerator = new DocLitBareSchemaGenerator(serviceClassLoader,
serviceClass.getName(),
axisService.getSchemaTargetNamespace(),
axisService
.getSchemaTargetNamespacePrefix(),
axisService);
} else {
schemaGenerator = new DefaultSchemaGenerator(serviceClassLoader,
serviceClass.getName(),
axisService.getSchemaTargetNamespace(),
axisService
.getSchemaTargetNamespacePrefix(),
axisService);
}
schemaGenerator.setExcludeMethods(excludeOperations);
schemaGenerator.setNonRpcMethods(nonRpcMethods);
if (!axisService.isElementFormDefault()) {
schemaGenerator
.setElementFormDefault(Java2WSDLConstants.FORM_DEFAULT_UNQUALIFIED);
}
// package to namespace map
schemaGenerator.setPkg2nsmap(axisService.getP2nMap());
Collection schemas = schemaGenerator.generateSchema();
axisService.addSchema(schemas);
axisService.setSchemaTargetNamespace(schemaGenerator
.getSchemaTargetNameSpace());
axisService.setTypeTable(schemaGenerator.getTypeTable());
if (Java2WSDLConstants.DEFAULT_TARGET_NAMESPACE.equals(axisService
.getTargetNamespace())) {
axisService
.setTargetNamespace(schemaGenerator.getTargetNamespace());
}
Method[] method = schemaGenerator.getMethods();
PhasesInfo pinfo = axisConfig.getPhasesInfo();
for (Method jmethod : method) {
String opName = jmethod.getName();
AxisOperation operation = axisService
.getOperation(new QName(opName));
// if the operation there in services.xml then try to set it schema
// element name
if (operation == null) {
operation = axisService.getOperation(new QName(
jmethod.getName()));
}
MessageReceiver mr =
axisService.getMessageReceiver(operation.getMessageExchangePattern());
if (mr == null) {
mr = axisConfig.getMessageReceiver(operation.getMessageExchangePattern());
}
if (operation.getMessageReceiver() == null) {
operation.setMessageReceiver(mr);
}
pinfo.setOperationPhases(operation);
axisService.addOperation(operation);
if (operation.getSoapAction() == null) {
operation.setSoapAction("urn:" + opName);
}
}
}