You are viewing a plain text version of this content. The canonical link for it is here.
Posted to axis-cvs@ws.apache.org by de...@apache.org on 2008/04/30 08:06:58 UTC
svn commit: r652280 [3/4] - in /webservices/axis2/trunk/java/modules:
adb/src/org/apache/axis2/databinding/utils/ distribution/ documentation/
fastinfoset/ integration/ integration/test-resources/ComplexDataTypes/
integration/test-resources/ComplexData...
Modified: webservices/axis2/trunk/java/modules/integration/test-resources/ComplexDataTypesDocLitBare/ComplexDataTypesDocLitBare.wsdl
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/integration/test-resources/ComplexDataTypesDocLitBare/ComplexDataTypesDocLitBare.wsdl?rev=652280&r1=652279&r2=652280&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/integration/test-resources/ComplexDataTypesDocLitBare/ComplexDataTypesDocLitBare.wsdl (original)
+++ webservices/axis2/trunk/java/modules/integration/test-resources/ComplexDataTypesDocLitBare/ComplexDataTypesDocLitBare.wsdl Tue Apr 29 23:06:57 2008
@@ -217,7 +217,7 @@
<xs:complexType name="Person">
<xs:sequence>
<xs:element minOccurs="0" name="age" nillable="true" type="xs:double"/>
- <xs:element minOccurs="0" name="iD" nillable="true" type="xs:float"/>
+ <xs:element minOccurs="0" name="id" nillable="true" type="xs:float"/>
<xs:element minOccurs="0" name="male" nillable="true" type="xs:boolean"/>
<xs:element minOccurs="0" name="name" nillable="true" type="xs:string"/>
Modified: webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/rpc/complex/ComplexDataTypesComplexDataTypesSOAP11Test.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/rpc/complex/ComplexDataTypesComplexDataTypesSOAP11Test.java?rev=652280&r1=652279&r2=652280&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/rpc/complex/ComplexDataTypesComplexDataTypesSOAP11Test.java (original)
+++ webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/rpc/complex/ComplexDataTypesComplexDataTypesSOAP11Test.java Tue Apr 29 23:06:57 2008
@@ -236,7 +236,7 @@
Person input = new Person();
input.setAge(23);
- input.setID(345);
+ input.setId(345);
input.setMale(false);
input.setName("Why?");
assertNotNull(stub.retStructSN(input));
@@ -253,7 +253,7 @@
ArrayOfPerson input = new ArrayOfPerson();
Person p1 = new Person();
p1.setAge(34);
- p1.setID(2345);
+ p1.setId(2345);
p1.setMale(true);
p1.setName("HJHJH");
input.setPerson(new Person[]{p1});
Modified: webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/rpc/complex/ComplexDataTypesDocLitBareTest.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/rpc/complex/ComplexDataTypesDocLitBareTest.java?rev=652280&r1=652279&r2=652280&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/rpc/complex/ComplexDataTypesDocLitBareTest.java (original)
+++ webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/rpc/complex/ComplexDataTypesDocLitBareTest.java Tue Apr 29 23:06:57 2008
@@ -232,7 +232,7 @@
ComplexDataTypesDocLitBareStub.Person input = new ComplexDataTypesDocLitBareStub.Person();
input.setAge(23);
- input.setID(345);
+ input.setId(345);
input.setMale(false);
input.setName("Why?");
req.setInStructSN(input);
@@ -252,7 +252,7 @@
ComplexDataTypesDocLitBareStub.ArrayOfPerson input = new ComplexDataTypesDocLitBareStub.ArrayOfPerson();
ComplexDataTypesDocLitBareStub.Person p1 = new ComplexDataTypesDocLitBareStub.Person();
p1.setAge(34);
- p1.setID(2345);
+ p1.setId(2345);
p1.setMale(true);
p1.setName("HJHJH");
input.setPerson(new ComplexDataTypesDocLitBareStub.Person[]{p1});
Modified: webservices/axis2/trunk/java/modules/integration/test/org/tempuri/complex/data/Person.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/integration/test/org/tempuri/complex/data/Person.java?rev=652280&r1=652279&r2=652280&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/integration/test/org/tempuri/complex/data/Person.java (original)
+++ webservices/axis2/trunk/java/modules/integration/test/org/tempuri/complex/data/Person.java Tue Apr 29 23:06:57 2008
@@ -52,18 +52,19 @@
* @return possible object is
* {@link Float }
*/
- public Float getID() {
+ public Float getId() {
return id;
}
/**
* Sets the value of the id property.
*
- * @param value allowed object is
* {@link Float }
*/
- public void setID(Float value) {
- this.id = value;
+
+
+ public void setId(Float id) {
+ this.id = id;
}
/**
Modified: webservices/axis2/trunk/java/modules/java2wsdl/pom.xml
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/java2wsdl/pom.xml?rev=652280&r1=652279&r2=652280&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/java2wsdl/pom.xml (original)
+++ webservices/axis2/trunk/java/modules/java2wsdl/pom.xml Tue Apr 29 23:06:57 2008
@@ -38,6 +38,11 @@
<version>${version}</version>
</dependency>
<dependency>
+ <groupId>org.apache.axis2</groupId>
+ <artifactId>axis2-jws-api</artifactId>
+ <version>${version}</version>
+ </dependency>
+ <dependency>
<groupId>org.apache.ant</groupId>
<artifactId>ant</artifactId>
</dependency>
@@ -61,10 +66,6 @@
<artifactId>jaxen</artifactId>
</dependency>
<dependency>
- <groupId>annogen</groupId>
- <artifactId>annogen</artifactId>
- </dependency>
- <dependency>
<groupId>xalan</groupId>
<artifactId>xalan</artifactId>
<scope>test</scope>
Modified: webservices/axis2/trunk/java/modules/jaxbri/src/org/apache/axis2/jaxbri/JaxbSchemaGenerator.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxbri/src/org/apache/axis2/jaxbri/JaxbSchemaGenerator.java?rev=652280&r1=652279&r2=652280&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxbri/src/org/apache/axis2/jaxbri/JaxbSchemaGenerator.java (original)
+++ webservices/axis2/trunk/java/modules/jaxbri/src/org/apache/axis2/jaxbri/JaxbSchemaGenerator.java Tue Apr 29 23:06:57 2008
@@ -67,7 +67,7 @@
*/
public void generateSchemaForParameters() throws Exception {
Set<Class<?>> classes = new HashSet<Class<?>>();
- classes.addAll(processMethods(serviceClass.getMethods()));
+ classes.addAll(processJaxBeMethods(serviceClass.getMethods()));
if (extraClasses != null) {
for (Object extraClass : extraClasses) {
@@ -127,7 +127,7 @@
}
- protected List<Class<?>> processMethods(Method[] declaredMethods) throws Exception {
+ protected List<Class<?>> processJaxBeMethods(Method[] declaredMethods) throws Exception {
List<Class<?>> list = new ArrayList<Class<?>>();
for (int i = 0; i < declaredMethods.length; i++) {
Modified: webservices/axis2/trunk/java/modules/kernel/pom.xml
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/pom.xml?rev=652280&r1=652279&r2=652280&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/kernel/pom.xml (original)
+++ webservices/axis2/trunk/java/modules/kernel/pom.xml Tue Apr 29 23:06:57 2008
@@ -34,6 +34,11 @@
</description>
<dependencies>
<dependency>
+ <groupId>org.apache.axis2</groupId>
+ <artifactId>axis2-jws-api</artifactId>
+ <version>${version}</version>
+ </dependency>
+ <dependency>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
</dependency>
@@ -96,10 +101,6 @@
</exclusions>
</dependency>
<dependency>
- <groupId>annogen</groupId>
- <artifactId>annogen</artifactId>
- </dependency>
- <dependency>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
</dependency>
@@ -164,7 +165,7 @@
<excludes>
<exclude>**/*Abstract*.java</exclude>
<exclude>**/*Util*.java</exclude>
- <exclude>**/*PhaseResolvingTest.java</exclude>
+ <exclude>**/*MessageContextChangeTest.java</exclude>
<exclude>**/MessageContextChangeTest.java</exclude> <!-- Removed because of problem on Java5. Needs reinstated -->
</excludes>
<includes>
Modified: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/context/MessageContext.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/context/MessageContext.java?rev=652280&r1=652279&r2=652280&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/context/MessageContext.java (original)
+++ webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/context/MessageContext.java Tue Apr 29 23:06:57 2008
@@ -1187,7 +1187,7 @@
// If there is an attachment map, the Attachments keep track
// of the inbound content length.
if (attachments != null) {
- return attachments.getContentLength();
+// return attachments.getContentLength();
}
// Otherwise the length is accumulated by the DetachableInputStream.
Modified: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/deployment/POJODeployer.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/deployment/POJODeployer.java?rev=652280&r1=652279&r2=652280&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/deployment/POJODeployer.java (original)
+++ webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/deployment/POJODeployer.java Tue Apr 29 23:06:57 2008
@@ -28,20 +28,14 @@
import org.apache.axis2.description.AxisService;
import org.apache.axis2.description.AxisServiceGroup;
import org.apache.axis2.description.WSDL2Constants;
-import org.apache.axis2.description.java2wsdl.AnnotationConstants;
import org.apache.axis2.engine.MessageReceiver;
import org.apache.axis2.i18n.Messages;
import org.apache.axis2.util.Loader;
import org.apache.axis2.wsdl.WSDLConstants;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.codehaus.jam.JAnnotation;
-import org.codehaus.jam.JClass;
-import org.codehaus.jam.JamClassIterator;
-import org.codehaus.jam.JamService;
-import org.codehaus.jam.JamServiceFactory;
-import org.codehaus.jam.JamServiceParams;
+import javax.jws.WebService;
import java.io.File;
import java.io.FileInputStream;
import java.io.PrintWriter;
@@ -72,56 +66,43 @@
if ("class".equals(extension)) {
File file = deploymentFileData.getFile();
File parentFile = file.getParentFile();
- if (file != null) {
- ClassLoader classLoader =
- Utils.getClassLoader(configCtx.getAxisConfiguration().
- getSystemClassLoader(), parentFile);
-
- Thread.currentThread().setContextClassLoader(classLoader);
- String className = file.getName();
- className = className.replaceAll(".class", "");
-
- log.info(Messages.getMessage(DeploymentErrorMsgs.DEPLOYING_POJO,
- className,
- deploymentFileData.getFile().getAbsolutePath()));
-
- JamServiceFactory factory = JamServiceFactory.getInstance();
- JamServiceParams jamServiceParams = factory.createServiceParams();
- jamServiceParams.addClassLoader(classLoader);
- jamServiceParams.includeClass(className);
- JamService service = factory.createService(jamServiceParams);
- JamClassIterator jClassIter = service.getClasses();
- while (jClassIter.hasNext()) {
- JClass jclass = (JClass) jClassIter.next();
- if (jclass.getQualifiedName().equals(className)) {
- /**
- * Schema genertaion done in two stage 1. Load all the methods and
- * create type for methods parameters (if the parameters are Bean
- * then it will create Complex types for those , and if the
- * parameters are simple type which decribe in SimpleTypeTable
- * nothing will happen) 2. In the next stage for all the methods
- * messages and port types will be creteated
- */
- JAnnotation annotation =
- jclass.getAnnotation(AnnotationConstants.WEB_SERVICE);
- if (annotation != null) {
- // try to see whether JAX-WS jars in the class path , if so use them
- // to process annotated pojo else use annogen to process the pojo class
- AxisService axisService;
- axisService =
- createAxisService(classLoader,
- className,
- deploymentFileData.getFile().toURL());
- configCtx.getAxisConfiguration().addService(axisService);
- } else {
- AxisService axisService =
- createAxisServiceUsingAnnogen(className,
- classLoader,
- deploymentFileData.getFile().toURL());
- configCtx.getAxisConfiguration().addService(axisService);
- }
- }
- }
+ ClassLoader classLoader =
+ Utils.getClassLoader(configCtx.getAxisConfiguration().
+ getSystemClassLoader(), parentFile);
+
+ Thread.currentThread().setContextClassLoader(classLoader);
+ String className = file.getName();
+ className = className.replaceAll(".class", "");
+ Class clazz = Class.forName(className);
+ log.info(Messages.getMessage(DeploymentErrorMsgs.DEPLOYING_POJO,
+ className,
+ deploymentFileData.getFile().getAbsolutePath()));
+
+
+ /**
+ * Schema genertaion done in two stage 1. Load all the methods and
+ * create type for methods parameters (if the parameters are Bean
+ * then it will create Complex types for those , and if the
+ * parameters are simple type which decribe in SimpleTypeTable
+ * nothing will happen) 2. In the next stage for all the methods
+ * messages and port types will be creteated
+ */
+ WebService annotation = (WebService) clazz.getAnnotation(WebService.class);
+ if (annotation != null) {
+ // try to see whether JAX-WS jars in the class path , if so use them
+ // to process annotated pojo else use annogen to process the pojo class
+ AxisService axisService;
+ axisService =
+ createAxisService(classLoader,
+ className,
+ deploymentFileData.getFile().toURL());
+ configCtx.getAxisConfiguration().addService(axisService);
+ } else {
+ AxisService axisService =
+ createAxisServiceUsingAnnogen(className,
+ classLoader,
+ deploymentFileData.getFile().toURL());
+ configCtx.getAxisConfiguration().addService(axisService);
}
} else if ("jar".equals(extension)) {
@@ -171,39 +152,27 @@
Thread.currentThread().setContextClassLoader(classLoader);
className = className.replaceAll(".class", "");
className = className.replaceAll("/", ".");
- JamServiceFactory factory = JamServiceFactory.getInstance();
- JamServiceParams jamServiceParams = factory.createServiceParams();
- jamServiceParams.addClassLoader(classLoader);
- jamServiceParams.includeClass(className);
- JamService service = factory.createService(jamServiceParams);
- JamClassIterator jClassIter = service.getClasses();
- while (jClassIter.hasNext()) {
- JClass jclass = (JClass) jClassIter.next();
- if (jclass.getQualifiedName().equals(className)) {
- /**
- * Schema generation done in two stage 1. Load all the methods and
- * create type for methods parameters (if the parameters are Bean
- * then it will create Complex types for those , and if the
- * parameters are simple type which decribe in SimpleTypeTable
- * nothing will happen) 2. In the next stage for all the methods
- * messages and port types will be creteated
- */
- JAnnotation annotation =
- jclass.getAnnotation(AnnotationConstants.WEB_SERVICE);
- if(annotation == null) {
- annotation = jclass.getAnnotation(AnnotationConstants.WEB_SERVICE_PROVIDER);
- }
- if (annotation != null) {
- AxisService axisService;
- axisService =
- createAxisService(classLoader,
- className,
- deploymentFileData.getFile().toURL());
- axisServiceList.add(axisService);
- }
- }
+ Class clazz = Class.forName(className);
+
+ /**
+ * Schema generation done in two stage 1. Load all the methods and
+ * create type for methods parameters (if the parameters are Bean
+ * then it will create Complex types for those , and if the
+ * parameters are simple type which decribe in SimpleTypeTable
+ * nothing will happen) 2. In the next stage for all the methods
+ * messages and port types will be creteated
+ */
+ WebService annotation = (WebService) clazz.getAnnotation(WebService.class);
+ if (annotation != null) {
+ AxisService axisService;
+ axisService =
+ createAxisService(classLoader,
+ className,
+ deploymentFileData.getFile().toURL());
+ axisServiceList.add(axisService);
}
}
+
if (axisServiceList.size() > 0) {
AxisServiceGroup serviceGroup = new AxisServiceGroup();
serviceGroup.setServiceGroupName(deploymentFileData.getName());
@@ -214,15 +183,15 @@
configCtx.getAxisConfiguration().addServiceGroup(serviceGroup);
} else {
String msg = "Error:\n No annotated classes found in the jar: " +
- deploymentFileData.getFile().getName() +
- ". Service deployment failed.";
+ deploymentFileData.getFile().getName() +
+ ". Service deployment failed.";
log.error(msg);
configCtx.getAxisConfiguration().getFaultyServices().
put(deploymentFileData.getFile().getAbsolutePath(), msg);
}
}
} catch (Exception e) {
- log.debug(Messages.getMessage(DeploymentErrorMsgs.STORING_FAULTY_SERVICE,e.getMessage()),e);
+ log.debug(Messages.getMessage(DeploymentErrorMsgs.STORING_FAULTY_SERVICE,e.getMessage()),e);
storeFaultyService(deploymentFileData, e);
} catch (Throwable t) {
log.debug(Messages.getMessage(DeploymentErrorMsgs.STORING_FAULTY_SERVICE,t.getMessage()),t);
@@ -246,9 +215,9 @@
private AxisService createAxisService(ClassLoader classLoader,
String className,
URL serviceLocation) throws ClassNotFoundException,
- InstantiationException,
- IllegalAccessException,
- AxisFault {
+ InstantiationException,
+ IllegalAccessException,
+ AxisFault {
AxisService axisService;
try {
Class claxx = Class.forName(
@@ -280,9 +249,9 @@
axisService.setElementFormDefault(false);
axisService.setFileName(serviceLocation);
Utils.fillAxisService(axisService,
- configCtx.getAxisConfiguration(),
- new ArrayList(),
- new ArrayList());
+ configCtx.getAxisConfiguration(),
+ new ArrayList(),
+ new ArrayList());
//Not needed at this case, the message receivers always set to RPC if this executes
//setMessageReceivers(axisService);
@@ -299,30 +268,30 @@
ClassLoader classLoader,
URL serviceLocation)
throws ClassNotFoundException,
- InstantiationException,
- IllegalAccessException,
- AxisFault {
+ InstantiationException,
+ IllegalAccessException,
+ AxisFault {
HashMap messageReciverMap = new HashMap();
Class inOnlyMessageReceiver = Loader.loadClass(
"org.apache.axis2.rpc.receivers.RPCInOnlyMessageReceiver");
MessageReceiver messageReceiver =
(MessageReceiver) inOnlyMessageReceiver.newInstance();
messageReciverMap.put(WSDL2Constants.MEP_URI_IN_ONLY,
- messageReceiver);
+ messageReceiver);
Class inoutMessageReceiver = Loader.loadClass(
"org.apache.axis2.rpc.receivers.RPCMessageReceiver");
MessageReceiver inOutmessageReceiver =
(MessageReceiver) inoutMessageReceiver.newInstance();
messageReciverMap.put(WSDL2Constants.MEP_URI_IN_OUT,
- inOutmessageReceiver);
+ inOutmessageReceiver);
messageReciverMap.put(WSDL2Constants.MEP_URI_ROBUST_IN_ONLY,
- inOutmessageReceiver);
+ inOutmessageReceiver);
AxisService axisService =
AxisService.createService(className,
- configCtx.getAxisConfiguration(),
- messageReciverMap,
- null, null,
- classLoader);
+ configCtx.getAxisConfiguration(),
+ messageReciverMap,
+ null, null,
+ classLoader);
axisService.setFileName(serviceLocation);
return axisService;
}
@@ -335,8 +304,8 @@
if (MEP != null) {
try {
if (WSDLConstants.WSDL20_2006Constants.MEP_URI_IN_ONLY.equals(MEP)
- || WSDLConstants.WSDL20_2004_Constants.MEP_URI_IN_ONLY.equals(MEP)
- || WSDL2Constants.MEP_URI_IN_ONLY.equals(MEP)) {
+ || WSDLConstants.WSDL20_2004_Constants.MEP_URI_IN_ONLY.equals(MEP)
+ || WSDL2Constants.MEP_URI_IN_ONLY.equals(MEP)) {
Class inOnlyMessageReceiver = Loader.loadClass(
"org.apache.axis2.rpc.receivers.RPCInOnlyMessageReceiver");
MessageReceiver messageReceiver =
@@ -375,7 +344,7 @@
configCtx.getAxisConfiguration().removeServiceGroup(className);
configCtx.removeServiceGroupContext(serviceGroup);
log.info(Messages.getMessage(DeploymentErrorMsgs.SERVICE_REMOVED,
- fileName));
+ fileName));
} catch (AxisFault axisFault) {
//May be a faulty service
log.debug(Messages.getMessage(DeploymentErrorMsgs.FAULTY_SERVICE_REMOVAL,axisFault.getMessage()),axisFault);
@@ -387,7 +356,7 @@
configCtx.getAxisConfiguration().removeServiceGroup(fileName);
configCtx.removeServiceGroupContext(serviceGroup);
log.info(Messages.getMessage(DeploymentErrorMsgs.SERVICE_REMOVED,
- fileName));
+ fileName));
} catch (AxisFault axisFault) {
//May be a faulty service
log.debug(Messages.getMessage(DeploymentErrorMsgs.FAULTY_SERVICE_REMOVAL,axisFault.getMessage()),axisFault);
Modified: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/deployment/util/Utils.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/deployment/util/Utils.java?rev=652280&r1=652279&r2=652280&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/deployment/util/Utils.java (original)
+++ webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/deployment/util/Utils.java Tue Apr 29 23:06:57 2008
@@ -19,44 +19,6 @@
package org.apache.axis2.deployment.util;
-import java.io.BufferedReader;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.io.OutputStreamWriter;
-import java.io.UnsupportedEncodingException;
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
-import java.lang.reflect.Modifier;
-import java.net.MalformedURLException;
-import java.net.URL;
-import java.net.URLClassLoader;
-import java.net.URLDecoder;
-import java.security.AccessController;
-import java.security.PrivilegedAction;
-import java.security.PrivilegedActionException;
-import java.security.PrivilegedExceptionAction;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Map;
-import java.util.Stack;
-import java.util.StringTokenizer;
-import java.util.zip.ZipEntry;
-import java.util.zip.ZipInputStream;
-
-import javax.xml.namespace.QName;
-import javax.xml.stream.FactoryConfigurationError;
-import javax.xml.stream.XMLStreamException;
-
import org.apache.axiom.om.OMAbstractFactory;
import org.apache.axiom.om.OMElement;
import org.apache.axiom.om.OMFactory;
@@ -70,26 +32,8 @@
import org.apache.axis2.deployment.DeploymentException;
import org.apache.axis2.deployment.repository.util.ArchiveReader;
import org.apache.axis2.deployment.repository.util.DeploymentFileData;
-import org.apache.axis2.description.AxisBinding;
-import org.apache.axis2.description.AxisBindingMessage;
-import org.apache.axis2.description.AxisBindingOperation;
-import org.apache.axis2.description.AxisEndpoint;
-import org.apache.axis2.description.AxisMessage;
-import org.apache.axis2.description.AxisModule;
-import org.apache.axis2.description.AxisOperation;
-import org.apache.axis2.description.AxisOperationFactory;
-import org.apache.axis2.description.AxisService;
-import org.apache.axis2.description.AxisServiceGroup;
-import org.apache.axis2.description.Flow;
-import org.apache.axis2.description.HandlerDescription;
-import org.apache.axis2.description.Parameter;
-import org.apache.axis2.description.TransportInDescription;
-import org.apache.axis2.description.WSDL2Constants;
-import org.apache.axis2.description.java2wsdl.AnnotationConstants;
-import org.apache.axis2.description.java2wsdl.DefaultSchemaGenerator;
-import org.apache.axis2.description.java2wsdl.DocLitBareSchemaGenerator;
-import org.apache.axis2.description.java2wsdl.Java2WSDLConstants;
-import org.apache.axis2.description.java2wsdl.SchemaGenerator;
+import org.apache.axis2.description.*;
+import org.apache.axis2.description.java2wsdl.*;
import org.apache.axis2.engine.AxisConfiguration;
import org.apache.axis2.engine.Handler;
import org.apache.axis2.engine.MessageReceiver;
@@ -101,8 +45,27 @@
import org.apache.commons.logging.LogFactory;
import org.apache.neethi.PolicyComponent;
import org.apache.ws.commons.schema.utils.NamespaceMap;
-import org.codehaus.jam.JAnnotation;
-import org.codehaus.jam.JMethod;
+
+import javax.jws.WebMethod;
+import javax.jws.WebService;
+import javax.xml.namespace.QName;
+import javax.xml.stream.FactoryConfigurationError;
+import javax.xml.stream.XMLStreamException;
+import java.io.*;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.lang.reflect.Modifier;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.net.URLClassLoader;
+import java.net.URLDecoder;
+import java.security.AccessController;
+import java.security.PrivilegedAction;
+import java.security.PrivilegedActionException;
+import java.security.PrivilegedExceptionAction;
+import java.util.*;
+import java.util.zip.ZipEntry;
+import java.util.zip.ZipInputStream;
public class Utils {
@@ -269,14 +232,14 @@
Boolean exists = (Boolean) org.apache.axis2.java.security.AccessController
.doPrivileged(new PrivilegedAction() {
public Object run() {
- return new Boolean(tempFile.exists());
+ return Boolean.valueOf(tempFile.exists());
}
});
if (!exists.booleanValue()) {
Boolean mkdirs = (Boolean) org.apache.axis2.java.security.AccessController
.doPrivileged(new PrivilegedAction() {
public Object run() {
- return new Boolean(tempFile.mkdirs());
+ return Boolean.valueOf(tempFile.mkdirs());
}
});
if (!mkdirs.booleanValue()) {
@@ -318,7 +281,7 @@
return null;
}
});
- FileOutputStream out = null;
+ FileOutputStream out;
try {
out = (FileOutputStream) org.apache.axis2.java.security.AccessController
.doPrivileged(new PrivilegedExceptionAction() {
@@ -396,7 +359,7 @@
Boolean exists = (Boolean) org.apache.axis2.java.security.AccessController
.doPrivileged(new PrivilegedAction() {
public Object run() {
- return new Boolean(libfiles.exists());
+ return Boolean.valueOf(libfiles.exists());
}
});
if (exists.booleanValue()) {
@@ -544,19 +507,19 @@
.setTargetNamespace(schemaGenerator.getTargetNamespace());
}
- JMethod[] method = schemaGenerator.getMethods();
+ Method[] method = schemaGenerator.getMethods();
PhasesInfo pinfo = axisConfig.getPhasesInfo();
for (int i = 0; i < method.length; i++) {
- JMethod jmethod = method[i];
- String opName = getSimpleName(jmethod);
+ Method jmethod = method[i];
+ 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(
- getSimpleName(jmethod)));
+ jmethod.getName()));
}
MessageReceiver mr = axisService.getMessageReceiver(operation
.getMessageExchangePattern());
@@ -576,11 +539,11 @@
}
}
- public static AxisOperation getAxisOperationForJmethod(JMethod jmethod)
+ public static AxisOperation getAxisOperationForJmethod(Method method)
throws AxisFault {
AxisOperation operation;
- if (jmethod.getReturnType().isVoidType()) {
- if (jmethod.getExceptionTypes().length > 0) {
+ if ("void".equals(method.getReturnType().getName())) {
+ if (method.getExceptionTypes().length > 0) {
operation = AxisOperationFactory
.getAxisOperation(WSDLConstants.MEP_CONSTANT_ROBUST_IN_ONLY);
} else {
@@ -591,13 +554,11 @@
operation = AxisOperationFactory
.getAxisOperation(WSDLConstants.MEP_CONSTANT_IN_OUT);
}
- String opName = getSimpleName(jmethod);
+ String opName = method.getName();
operation.setName(new QName(opName));
- JAnnotation methodAnnon = jmethod
- .getAnnotation(AnnotationConstants.WEB_METHOD);
- if (methodAnnon != null) {
- String action = methodAnnon.getValue(AnnotationConstants.ACTION)
- .asString();
+ WebMethod methodAnnon = method.getAnnotation(WebMethod.class);
+ if (methodAnnon != null) {
+ String action = methodAnnon.action();
if (action != null && !"".equals(action)) {
operation.setSoapAction(action);
}
@@ -605,22 +566,6 @@
return operation;
}
- public static String getSimpleName(JMethod method) {
- JAnnotation methodAnnon = method
- .getAnnotation(AnnotationConstants.WEB_METHOD);
- if (methodAnnon != null) {
- if (methodAnnon.getValue(AnnotationConstants.OPERATION_NAME) != null) {
- String methodName = methodAnnon.getValue(
- AnnotationConstants.OPERATION_NAME).asString();
- if (methodName.equals("")) {
- methodName = method.getSimpleName();
- }
- return methodName;
- }
- }
- return method.getSimpleName();
- }
-
public static OMElement getParameter(String name, String value,
boolean locked) {
OMFactory fac = OMAbstractFactory.getOMFactory();
@@ -991,23 +936,6 @@
}
}
- /**
- * This will split a bean exclude property values into ArrayList
- *
- * @param value :
- * String to be splited
- * @return : Arryalist of the splited string
- */
- private static List getArrayFromString(String value) {
- String values[] = value.split(",");
- ArrayList list = new ArrayList();
- for (int i = 0; i < values.length; i++) {
- String s = values[i];
- list.add(s);
- }
- return list;
- }
-
public static String getShortFileName(String filename) {
File file = new File(filename);
return file.getName();
@@ -1023,11 +951,10 @@
* @return String version of the ServiceName according to the JSR 181 spec
*/
public static String getAnnotatedServiceName(Class serviceClass,
- JAnnotation serviceAnnotation) {
+ WebService serviceAnnotation) {
String serviceName = "";
- if (serviceAnnotation.getValue(AnnotationConstants.SERVICE_NAME) != null) {
- serviceName = (serviceAnnotation
- .getValue(AnnotationConstants.SERVICE_NAME)).asString();
+ if (serviceAnnotation.serviceName() != null) {
+ serviceName = serviceAnnotation.serviceName();
}
if (serviceName.equals("")) {
serviceName = serviceClass.getName();
Modified: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/description/AxisService.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/description/AxisService.java?rev=652280&r1=652279&r2=652280&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/description/AxisService.java (original)
+++ webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/description/AxisService.java Tue Apr 29 23:06:57 2008
@@ -29,30 +29,13 @@
import org.apache.axis2.client.ServiceClient;
import org.apache.axis2.context.MessageContext;
import org.apache.axis2.context.ServiceContext;
-import org.apache.axis2.dataretrieval.AxisDataLocator;
-import org.apache.axis2.dataretrieval.AxisDataLocatorImpl;
-import org.apache.axis2.dataretrieval.DRConstants;
-import org.apache.axis2.dataretrieval.Data;
-import org.apache.axis2.dataretrieval.DataRetrievalException;
-import org.apache.axis2.dataretrieval.DataRetrievalRequest;
-import org.apache.axis2.dataretrieval.LocatorType;
-import org.apache.axis2.dataretrieval.OutputForm;
-import org.apache.axis2.dataretrieval.SchemaSupplier;
-import org.apache.axis2.dataretrieval.WSDLSupplier;
+import org.apache.axis2.dataretrieval.*;
import org.apache.axis2.deployment.DeploymentConstants;
import org.apache.axis2.deployment.util.ExcludeInfo;
import org.apache.axis2.deployment.util.PhasesInfo;
import org.apache.axis2.deployment.util.Utils;
-import org.apache.axis2.description.java2wsdl.DefaultSchemaGenerator;
-import org.apache.axis2.description.java2wsdl.DocLitBareSchemaGenerator;
-import org.apache.axis2.description.java2wsdl.Java2WSDLConstants;
-import org.apache.axis2.description.java2wsdl.SchemaGenerator;
-import org.apache.axis2.description.java2wsdl.TypeTable;
-import org.apache.axis2.engine.AxisConfiguration;
-import org.apache.axis2.engine.DefaultObjectSupplier;
-import org.apache.axis2.engine.MessageReceiver;
-import org.apache.axis2.engine.ObjectSupplier;
-import org.apache.axis2.engine.ServiceLifeCycle;
+import org.apache.axis2.description.java2wsdl.*;
+import org.apache.axis2.engine.*;
import org.apache.axis2.i18n.Messages;
import org.apache.axis2.phaseresolver.PhaseResolver;
import org.apache.axis2.transport.TransportListener;
@@ -71,20 +54,10 @@
import org.apache.ws.commons.schema.XmlSchemaObjectCollection;
import org.apache.ws.commons.schema.utils.NamespaceMap;
import org.apache.ws.commons.schema.utils.NamespacePrefixList;
-import org.codehaus.jam.JMethod;
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-import org.w3c.dom.NamedNodeMap;
-import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
+import org.w3c.dom.*;
import org.xml.sax.SAXException;
-import javax.wsdl.Definition;
-import javax.wsdl.Import;
-import javax.wsdl.Port;
-import javax.wsdl.Service;
-import javax.wsdl.Types;
-import javax.wsdl.WSDLException;
+import javax.wsdl.*;
import javax.wsdl.extensions.http.HTTPAddress;
import javax.wsdl.extensions.schema.Schema;
import javax.wsdl.extensions.soap.SOAPAddress;
@@ -94,26 +67,12 @@
import javax.wsdl.xml.WSDLWriter;
import javax.xml.namespace.QName;
import javax.xml.parsers.ParserConfigurationException;
-import java.io.File;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.io.OutputStreamWriter;
-import java.io.PrintWriter;
+import java.io.*;
+import java.lang.reflect.Method;
import java.net.SocketException;
import java.net.URL;
import java.security.PrivilegedAction;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.Date;
-import java.util.Enumeration;
-import java.util.HashMap;
-import java.util.Hashtable;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.Vector;
+import java.util.*;
/**
* Class AxisService
@@ -2279,12 +2238,12 @@
if (targetNamespace != null && !"".equals(targetNamespace)) {
axisService.setTargetNamespace(targetNamespace);
}
- JMethod[] method = schemaGenerator.getMethods();
+ Method[] method = schemaGenerator.getMethods();
PhasesInfo pinfo = axisConfiguration.getPhasesInfo();
for (int i = 0; i < method.length; i++) {
- JMethod jmethod = method[i];
+ Method jmethod = method[i];
AxisOperation operation = axisService.getOperation(new QName(
- jmethod.getSimpleName()));
+ jmethod.getName()));
String mep = operation.getMessageExchangePattern();
MessageReceiver mr;
if (messageReceiverClassMap != null) {
Modified: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/description/java2wsdl/DefaultSchemaGenerator.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/description/java2wsdl/DefaultSchemaGenerator.java?rev=652280&r1=652279&r2=652280&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/description/java2wsdl/DefaultSchemaGenerator.java (original)
+++ webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/description/java2wsdl/DefaultSchemaGenerator.java Tue Apr 29 23:06:57 2008
@@ -30,49 +30,27 @@
import org.apache.axis2.wsdl.WSDLConstants;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.apache.ws.commons.schema.XmlSchema;
-import org.apache.ws.commons.schema.XmlSchemaCollection;
-import org.apache.ws.commons.schema.XmlSchemaComplexContent;
-import org.apache.ws.commons.schema.XmlSchemaComplexContentExtension;
-import org.apache.ws.commons.schema.XmlSchemaComplexType;
-import org.apache.ws.commons.schema.XmlSchemaElement;
-import org.apache.ws.commons.schema.XmlSchemaForm;
-import org.apache.ws.commons.schema.XmlSchemaImport;
-import org.apache.ws.commons.schema.XmlSchemaObject;
-import org.apache.ws.commons.schema.XmlSchemaSequence;
+import org.apache.ws.commons.schema.*;
import org.apache.ws.commons.schema.utils.NamespaceMap;
import org.apache.ws.commons.schema.utils.NamespacePrefixList;
-import org.codehaus.jam.JAnnotation;
-import org.codehaus.jam.JClass;
-import org.codehaus.jam.JComment;
-import org.codehaus.jam.JField;
-import org.codehaus.jam.JMethod;
-import org.codehaus.jam.JPackage;
-import org.codehaus.jam.JParameter;
-import org.codehaus.jam.JProperty;
-import org.codehaus.jam.JamClassIterator;
-import org.codehaus.jam.JamService;
-import org.codehaus.jam.JamServiceFactory;
-import org.codehaus.jam.JamServiceParams;
import org.w3c.dom.Document;
+import javax.activation.DataHandler;
+import javax.jws.WebMethod;
+import javax.jws.WebParam;
+import javax.jws.WebResult;
+import javax.jws.WebService;
import javax.xml.namespace.QName;
import javax.xml.parsers.DocumentBuilderFactory;
-import java.io.BufferedReader;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.IOException;
-import java.io.InputStreamReader;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Hashtable;
-import java.util.Iterator;
-import java.util.Locale;
-import java.util.Map;
-import java.util.Set;
+import java.io.*;
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Field;
+import java.lang.reflect.Method;
+import java.lang.reflect.Modifier;
+import java.util.*;
+import java.beans.BeanInfo;
+import java.beans.Introspector;
+import java.beans.PropertyDescriptor;
public class DefaultSchemaGenerator implements Java2WSDLConstants, SchemaGenerator {
@@ -96,7 +74,7 @@
protected TypeTable typeTable = new TypeTable();
// to keep loadded method using JAM
- protected JMethod methods[];
+ protected Method methods[];
//to store byte code method using Axis 1.x codes
protected MethodTable methodTable;
@@ -132,7 +110,7 @@
protected String mappingFileLocation;
//To check whether we need to generate Schema element for Exception
- protected boolean generateBaseException ;
+ protected boolean generateBaseException;
public NamespaceGenerator getNsGen() throws Exception {
if (nsGen == null) {
@@ -178,53 +156,54 @@
}
//This will locad the custom schema file and add that into the schema map
- private void loadCustomSchemaFile(){
- if (customSchemaLocation != null) {
- try {
- DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance();
- documentBuilderFactory.setNamespaceAware(true);
- Document doc = documentBuilderFactory.newDocumentBuilder().parse(new File(customSchemaLocation));
- XmlSchema schema = xmlSchemaCollection.read(doc,null);
- schemaMap.put(schema.getTargetNamespace() ,schema);
- } catch (Exception e) {
- log.info(e.getMessage());
- }
- }
+ private void loadCustomSchemaFile() {
+ if (customSchemaLocation != null) {
+ try {
+ DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance();
+ documentBuilderFactory.setNamespaceAware(true);
+ Document doc = documentBuilderFactory.newDocumentBuilder().parse(new File(customSchemaLocation));
+ XmlSchema schema = xmlSchemaCollection.read(doc, null);
+ schemaMap.put(schema.getTargetNamespace(), schema);
+ } catch (Exception e) {
+ log.info(e.getMessage());
+ }
+ }
}
- /**This will load the mapping file and update the Typetable with the Class name and the Qname
+ /**
+ * This will load the mapping file and update the Typetable with the Class name and the Qname
* Mapping file look like
* org.foo.bar.FooException|http://www.abc.com/soaframework/common/types|ErrorMessage
*/
- private void loadMappingFile(){
- if(mappingFileLocation != null){
+ private void loadMappingFile() {
+ if (mappingFileLocation != null) {
File file = new File(mappingFileLocation);
BufferedReader input = null;
- try {
- input = new BufferedReader(new InputStreamReader(new FileInputStream(file)));
- String line;
- while ((line = input.readLine()) != null) {
- line = line.trim();
- if (line.length() > 0 && line.charAt(0)!='#') {
- String values [] = line.split("\\|");
- if (values != null && values.length >2) {
- typeTable.addComplexSchema(values[0],new QName(values[1] , values[2]));
- }
- }
- }
- } catch (IOException ex) {
- ex.printStackTrace();
- } finally {
try {
- if (input != null) {
- input.close();
+ input = new BufferedReader(new InputStreamReader(new FileInputStream(file)));
+ String line;
+ while ((line = input.readLine()) != null) {
+ line = line.trim();
+ if (line.length() > 0 && line.charAt(0) != '#') {
+ String values[] = line.split("\\|");
+ if (values != null && values.length > 2) {
+ typeTable.addComplexSchema(values[0], new QName(values[1], values[2]));
+ }
+ }
}
- }
- catch (IOException ex) {
+ } catch (IOException ex) {
ex.printStackTrace();
+ } finally {
+ try {
+ if (input != null) {
+ input.close();
+ }
+ }
+ catch (IOException ex) {
+ ex.printStackTrace();
+ }
}
}
- }
}
@@ -238,62 +217,33 @@
public Collection generateSchema() throws Exception {
loadCustomSchemaFile();
loadMappingFile();
- JamServiceFactory factory = JamServiceFactory.getInstance();
- JamServiceParams jam_service_parms = factory.createServiceParams();
- //setting the classLoder
- //it can posible to add the classLoader as well
- jam_service_parms.addClassLoader(classLoader);
- jam_service_parms.includeClass(className);
-
- for (int count = 0; count < getExtraClasses().size(); ++count) {
- jam_service_parms.includeClass((String) getExtraClasses().get(count));
- }
- JamService jamService = factory.createService(jam_service_parms);
- QName extraSchemaTypeName;
- JamClassIterator jClassIter = jamService.getClasses();
//all most all the time the ittr will have only one class in it
- while (jClassIter.hasNext()) {
- JClass jclass = (JClass) jClassIter.next();
- if (getActualQualifiedName(jclass).equals(className)) {
- /**
- * Schema genertaion done in two stage 1. Load all the methods and
- * create type for methods parameters (if the parameters are Bean
- * then it will create Complex types foer those , and if the
- * parameters are simple type which decribe in SimpleTypeTable
- * nothing will happen) 2. In the next stage for all the methods
- * messages and port types will be creteated
- */
- JAnnotation annotation = jclass.getAnnotation(AnnotationConstants.WEB_SERVICE);
- JComment comment = jclass.getComment();
- if (comment !=null) {
- System.out.println(comment.getText());
- }
- if (annotation != null) {
- String tns =
- annotation.getValue(AnnotationConstants.TARGETNAMESPACE).asString();
- if (tns != null && !"".equals(tns)) {
- targetNamespace = tns;
- schemaTargetNameSpace = tns;
- }
- service.setName(Utils.getAnnotatedServiceName(serviceClass,annotation));
- }
- methods = processMethods(jclass.getDeclaredMethods());
-
- } else {
- //generate the schema type for extra classes
- extraSchemaTypeName = typeTable.getSimpleSchemaTypeName(getQualifiedName(jclass));
- if (extraSchemaTypeName == null) {
- generateSchema(jclass);
- }
+ /**
+ * Schema genertaion done in two stage 1. Load all the methods and
+ * create type for methods parameters (if the parameters are Bean
+ * then it will create Complex types foer those , and if the
+ * parameters are simple type which decribe in SimpleTypeTable
+ * nothing will happen) 2. In the next stage for all the methods
+ * messages and port types will be creteated
+ */
+ WebService webervice = (WebService) serviceClass.getAnnotation(WebService.class);
+ if (webervice != null) {
+ String tns = webervice.targetNamespace();
+ if (tns != null && !"".equals(tns)) {
+ targetNamespace = tns;
+ schemaTargetNameSpace = tns;
}
+ service.setName(Utils.getAnnotatedServiceName(serviceClass, webervice));
}
+ methods = processMethods(serviceClass.getDeclaredMethods());
return schemaMap.values();
}
- protected JMethod[] processMethods(JMethod[] declaredMethods) throws Exception {
+ protected Method[] processMethods(Method[] declaredMethods) throws Exception {
ArrayList list = new ArrayList();
//short the elements in the array
- Arrays.sort(declaredMethods);
+ Arrays.sort(declaredMethods, new MathodComparator());
+
// since we do not support overload
HashMap uniqueMethods = new HashMap();
@@ -301,14 +251,14 @@
XmlSchemaSequence sequence = null;
for (int i = 0; i < declaredMethods.length; i++) {
- JMethod jMethod = declaredMethods[i];
- JAnnotation methodAnnon = jMethod.getAnnotation(AnnotationConstants.WEB_METHOD);
+ Method jMethod = declaredMethods[i];
+ WebMethod methodAnnon = jMethod.getAnnotation(WebMethod.class);
if (methodAnnon != null) {
- if (methodAnnon.getValue(AnnotationConstants.EXCLUDE).asBoolean()) {
+ if (methodAnnon.exclude()) {
continue;
}
}
- String methodName = getSimpleName(jMethod);
+ String methodName = jMethod.getName();
// no need to think abt this method , since that is system
// config method
if (excludeMethods.contains(methodName)) {
@@ -317,11 +267,10 @@
if (uniqueMethods.get(methodName) != null) {
log.warn("We don't support method overloading. Ignoring [" +
- jMethod.getQualifiedName() + "]");
+ methodName + "]");
continue;
}
-
- if (!jMethod.isPublic()) {
+ if (!Modifier.isPublic(jMethod.getModifiers())) {
// no need to generate Schema for non public methods
continue;
}
@@ -330,10 +279,10 @@
if (axisOperation == null) {
axisOperation = Utils.getAxisOperationForJmethod(jMethod);
if (WSDL2Constants.MEP_URI_ROBUST_IN_ONLY.equals(
- axisOperation.getMessageExchangePattern())){
+ axisOperation.getMessageExchangePattern())) {
AxisMessage outMessage = axisOperation.getMessage(
WSDLConstants.MESSAGE_LABEL_OUT_VALUE);
- if (outMessage !=null ){
+ if (outMessage != null) {
outMessage.setName(methodName + RESPONSE);
}
}
@@ -342,15 +291,15 @@
// Maintain a list of methods we actually work with
list.add(jMethod);
- processException(jMethod,axisOperation);
+ processException(jMethod, axisOperation);
uniqueMethods.put(methodName, jMethod);
- JParameter[] paras = jMethod.getParameters();
+ Class[] parameters = jMethod.getParameterTypes();
String parameterNames[] = null;
AxisMessage inMessage = axisOperation.getMessage(WSDLConstants.MESSAGE_LABEL_IN_VALUE);
if (inMessage != null) {
inMessage.setName(methodName + Java2WSDLConstants.MESSAGE_SUFFIX);
}
- if (paras.length > 0) {
+ if (parameters.length > 0) {
parameterNames = methodTable.getParameterNames(methodName);
sequence = new XmlSchemaSequence();
@@ -360,47 +309,34 @@
service.addMessageElementQNameToOperationMapping(methodSchemaType.getQName(),
axisOperation);
}
-
- for (int j = 0; j < paras.length; j++) {
- JParameter methodParameter = paras[j];
- String parameterName = null;
- JAnnotation paramterAnnon =
- methodParameter.getAnnotation(AnnotationConstants.WEB_PARAM);
- if (paramterAnnon != null) {
- parameterName =
- paramterAnnon.getValue(AnnotationConstants.NAME).asString();
- }
- if (parameterName == null || "".equals(parameterName)) {
- parameterName = (parameterNames != null && parameterNames[j] != null) ?
- parameterNames[j] : getSimpleName(methodParameter);
- }
- JClass paraType = methodParameter.getType();
- if (nonRpcMethods.contains(getSimpleName(jMethod))) {
- generateSchemaForType(sequence, null, getSimpleName(jMethod));
+ Annotation[][] parameterAnnotation = jMethod.getParameterAnnotations();
+ for (int j = 0; j < parameters.length; j++) {
+ Class methodParameter = parameters[j];
+ String parameterName = getParameterName(parameterAnnotation, j, parameterNames);
+ if (nonRpcMethods.contains(jMethod.getName())) {
+ generateSchemaForType(sequence, null, jMethod.getName());
break;
} else {
- generateSchemaForType(sequence, paraType, parameterName);
+ generateSchemaForType(sequence, methodParameter, parameterName);
}
}
// for its return type
- JClass returnType = jMethod.getReturnType();
-
- if (!returnType.isVoidType()) {
+ Class returnType = jMethod.getReturnType();
+ if (!"void".equals(jMethod.getReturnType().getName())) {
String partQname = methodName + RESPONSE;
methodSchemaType =
createSchemaTypeForMethodPart(partQname);
sequence = new XmlSchemaSequence();
methodSchemaType.setParticle(sequence);
- JAnnotation returnAnnon =
- jMethod.getAnnotation(AnnotationConstants.WEB_RESULT);
+ WebResult returnAnnon = jMethod.getAnnotation(WebResult.class);
String returnName = "return";
if (returnAnnon != null) {
- returnName = returnAnnon.getValue(AnnotationConstants.NAME).asString();
+ returnName = returnAnnon.name();
if (returnName != null && !"".equals(returnName)) {
returnName = "return";
}
}
- if (nonRpcMethods.contains(getSimpleName(jMethod))) {
+ if (nonRpcMethods.contains(jMethod.getName())) {
generateSchemaForType(sequence, null, returnName);
} else {
generateSchemaForType(sequence, returnType, returnName);
@@ -416,21 +352,21 @@
service.addOperation(axisOperation);
}
}
- return (JMethod[]) list.toArray(new JMethod[list.size()]);
+ return (Method[]) list.toArray(new Method[list.size()]);
}
/**
- * This method will generate Schema element for all the excetion types in a given JMethod
- * - No matter what it will generate Schema element for java.lang.Exception so that for other
- * exception which extend java.lang.Excetion can use as the base class type
+ * This method will generate Schema element for all the excetion types in a given JMethod
+ * - No matter what it will generate Schema element for java.lang.Exception so that for other
+ * exception which extend java.lang.Excetion can use as the base class type
*/
- protected void processException(JMethod jMethod,
+ protected void processException(Method jMethod,
AxisOperation axisOperation) throws Exception {
XmlSchemaComplexType methodSchemaType;
XmlSchemaSequence sequence;
if (jMethod.getExceptionTypes().length > 0) {
if (!generateBaseException) {
- if (typeTable.getComplexSchemaType(Exception.class.getName()) !=null) {
+ if (typeTable.getComplexSchemaType(Exception.class.getName()) != null) {
} else {
sequence = new XmlSchemaSequence();
@@ -452,10 +388,10 @@
}
generateBaseException = true;
}
- JClass[] extypes = jMethod.getExceptionTypes();
+ Class[] extypes = jMethod.getExceptionTypes();
for (int j = 0; j < extypes.length; j++) {
- JClass extype = extypes[j];
- if (AxisFault.class.getName().equals(extype.getQualifiedName())) {
+ Class extype = extypes[j];
+ if (AxisFault.class.getName().equals(extype.getName())) {
continue;
}
String partQname = extype.getSimpleName();
@@ -463,7 +399,7 @@
QName elementName =
new QName(this.schemaTargetNameSpace, partQname, this.schema_namespace_prefix);
sequence = new XmlSchemaSequence();
- if (Exception.class.getName().equals(extype.getQualifiedName())) {
+ if (Exception.class.getName().equals(extype.getName())) {
QName schemaTypeName = typeTable.getComplexSchemaType(Exception.class.getName());
addContentToMethodSchemaType(sequence,
schemaTypeName,
@@ -472,16 +408,16 @@
methodSchemaType.setParticle(sequence);
typeTable.addComplexSchema(Exception.class.getPackage().getName(),
methodSchemaType.getQName());
- String schemaNamespace = resolveSchemaNamespace(Exception.class.getPackage().getName());
- addImport(getXmlSchema(schemaTargetNameSpace),schemaTypeName );
+ resolveSchemaNamespace(Exception.class.getPackage().getName());
+ addImport(getXmlSchema(schemaTargetNameSpace), schemaTypeName);
} else {
generateSchemaForType(sequence, extype, extype.getSimpleName());
methodSchemaType.setParticle(sequence);
}
- typeTable.addComplexSchema(partQname,elementName);
+ typeTable.addComplexSchema(partQname, elementName);
- if (AxisFault.class.getName().equals(extype.getQualifiedName())) {
+ if (AxisFault.class.getName().equals(extype.getName())) {
continue;
}
AxisMessage faultMessage = new AxisMessage();
@@ -493,33 +429,18 @@
}
/**
- * JAM converts the first letter of a field into uppercase, so field "foo" would end up
- * called "Foo". This method corrects that problem.
- *
- * @param wrongName
- * @return the right name, using english as the locale for case conversion
- */
- public static String getCorrectName(String wrongName) {
- if (wrongName.length() > 1) {
- return wrongName.substring(0, 1).toLowerCase(Locale.ENGLISH)
- + wrongName.substring(1, wrongName.length());
- } else {
- return wrongName.substring(0, 1).toLowerCase(Locale.ENGLISH);
- }
- }
-
- /**
* Generate schema construct for given type
+ *
* @param javaType : Class to whcih need to generate Schema
* @return : Generated QName
*/
- private QName generateSchema(JClass javaType) throws Exception {
- String name = getQualifiedName(javaType);
+ protected QName generateSchema(Class javaType) throws Exception {
+ String name = getClassName(javaType);
QName schemaTypeName = typeTable.getComplexSchemaType(name);
if (schemaTypeName == null) {
- String simpleName = getSimpleName(javaType);
+ String simpleName = javaType.getSimpleName();
- String packageName = getQualifiedName(javaType.getContainingPackage());
+ String packageName = getQualifiedName(javaType.getPackage());
String targetNameSpace = resolveSchemaNamespace(packageName);
XmlSchema xmlSchema = getXmlSchema(targetNameSpace);
@@ -539,13 +460,12 @@
eltOuter.setName(simpleName);
eltOuter.setQName(schemaTypeName);
- JClass sup = javaType.getSuperclass();
-
- if ((sup != null) && !("java.lang.Object".compareTo(sup.getQualifiedName()) == 0) &&
- !("org.apache.axis2".compareTo(sup.getContainingPackage().getQualifiedName()) == 0)
- &&!("java.util".compareTo(sup.getContainingPackage().getQualifiedName()) == 0)) {
- String superClassName = sup.getQualifiedName();
- String superclassname = getSimpleName(sup);
+ Class sup = javaType.getSuperclass();
+ if ((sup != null) && !("java.lang.Object".compareTo(sup.getName()) == 0) &&
+ !(getQualifiedName(sup.getPackage()).indexOf("org.apache.axis2") > 0)
+ && !(getQualifiedName(sup.getPackage()).indexOf("java.util") > 0)) {
+ String superClassName = sup.getName();
+ String superclassname = sup.getSimpleName();
String tgtNamespace;
String tgtNamespacepfx;
QName qName = typeTable.getSimpleSchemaTypeName(superClassName);
@@ -553,16 +473,14 @@
tgtNamespace = qName.getNamespaceURI();
tgtNamespacepfx = qName.getPrefix();
} else {
- tgtNamespace =
- resolveSchemaNamespace(sup.getContainingPackage().getQualifiedName());
+ tgtNamespace = resolveSchemaNamespace(getQualifiedName(sup.getPackage()));
tgtNamespacepfx = (String) targetNamespacePrefixMap.get(tgtNamespace);
QName superClassQname = generateSchema(sup);
- if(superClassQname!=null){
+ if (superClassQname != null) {
tgtNamespacepfx = superClassQname.getPrefix();
tgtNamespace = superClassQname.getNamespaceURI();
}
}
-
if (tgtNamespacepfx == null) {
tgtNamespacepfx = generatePrefix();
targetNamespacePrefixMap.put(tgtNamespace, tgtNamespacepfx);
@@ -574,19 +492,14 @@
importElement.setNamespace(tgtNamespace);
xmlSchema.getItems().add(importElement);
((NamespaceMap) xmlSchema.getNamespaceContext()).
- put(generatePrefix(),tgtNamespace);
+ put(generatePrefix(), tgtNamespace);
}
QName basetype = new QName(tgtNamespace, superclassname, tgtNamespacepfx);
-
-
complexExtension.setBaseTypeName(basetype);
complexExtension.setParticle(sequence);
-
XmlSchemaComplexContent contentModel = new XmlSchemaComplexContent();
-
contentModel.setContent(complexExtension);
-
complexType.setContentModel(contentModel);
} else {
@@ -605,133 +518,126 @@
// adding this type to the table
typeTable.addComplexSchema(name, eltOuter.getQName());
// adding this type's package to the table, to support inheritance.
- typeTable.addComplexSchema(javaType.getContainingPackage().getQualifiedName(),
- eltOuter.getQName());
+ typeTable.addComplexSchema(getQualifiedName(javaType.getPackage()), eltOuter.getQName());
Set propertiesSet = new HashSet();
Set propertiesNames = new HashSet();
-
- JProperty[] tempProperties = javaType.getDeclaredProperties();
+ Field tempProperties[] = javaType.getDeclaredFields();
BeanExcludeInfo beanExcludeInfo = null;
- if (service.getExcludeInfo() !=null) {
- beanExcludeInfo = service.getExcludeInfo().getBeanExcludeInfoForClass(
- javaType.getQualifiedName());
+ if (service.getExcludeInfo() != null) {
+ beanExcludeInfo = service.getExcludeInfo().getBeanExcludeInfoForClass(getClassName(javaType));
}
+
for (int i = 0; i < tempProperties.length; i++) {
- JProperty tempProperty = tempProperties[i];
- String propertyName = getCorrectName(tempProperty.getSimpleName());
- if ((beanExcludeInfo == null) || !beanExcludeInfo.isExcludedProperty(propertyName)){
+ Field tempProperty = tempProperties[i];
+ String propertyName;
+ if (Modifier.isFinal(tempProperty.getModifiers()) ||
+ Modifier.isStatic(tempProperty.getModifiers())) {
+// We do not need to expose static fields
+ continue;
+ }
+ propertyName = tempProperty.getName();
+ if ("this$0".equals(propertyName)) {
+ continue;
+ }
+ if ((beanExcludeInfo == null) || !beanExcludeInfo.isExcludedProperty(propertyName)) {
propertiesSet.add(tempProperty);
}
}
-
- JProperty[] properties = (JProperty[]) propertiesSet.toArray(new JProperty[0]);
- Arrays.sort(properties);
+ Field[] properties = (Field[]) propertiesSet.toArray(new Field[0]);
+ Arrays.sort(properties, new FieldComparator());
for (int i = 0; i < properties.length; i++) {
- JProperty property = properties[i];
- boolean isArryType = property.getType().isArrayType();
-
- String propname = getCorrectName(property.getSimpleName());
-
+ Field property = properties[i];
+ boolean isArryType = property.getType().isArray();
+ String propname = property.getName();
propertiesNames.add(propname);
-
this.generateSchemaforFieldsandProperties(xmlSchema, sequence, property.getType(),
propname, isArryType);
}
-
- JField[] tempFields = javaType.getDeclaredFields();
+ Field[] tempFields = javaType.getDeclaredFields();
HashMap FieldMap = new HashMap();
-
-
for (int i = 0; i < tempFields.length; i++) {
+ Field tempFiled = tempFields[i];
// create a element for the field only if it is public
// and there is no property with the same name
- if (tempFields[i].isPublic()) {
- if (tempFields[i].isStatic()){
+ if (Modifier.isPublic(tempFiled.getModifiers())) {
+ if (Modifier.isStatic(tempFiled.getModifiers())) {
// We do not need to expose static fields
continue;
}
- String propertyName = getCorrectName(tempFields[i].getSimpleName());
+ String propertyName = tempFiled.getName();
+ if ("this$0".equals(propertyName)) {
+ continue;
+ }
if ((beanExcludeInfo == null) || !beanExcludeInfo.isExcludedProperty(propertyName)) {
// skip field with same name as a property
- if (!propertiesNames.contains(tempFields[i].getSimpleName())) {
-
- FieldMap.put(tempFields[i].getSimpleName(), tempFields[i]);
+ if (!propertiesNames.contains(propertyName)) {
+ FieldMap.put(propertyName, tempFiled);
}
}
-
}
-
}
-
// remove fields from super classes patch for defect Annogen-21
// getDeclaredFields is incorrectly returning fields of super classes as well
// getDeclaredProperties used earlier works correctly
- JClass supr = javaType.getSuperclass();
- while (supr != null && supr.getQualifiedName().compareTo("java.lang.Object") != 0) {
- JField[] suprFields = supr.getFields();
+ Class supr = javaType.getSuperclass();
+ while (supr != null && getQualifiedName(supr.getPackage()).indexOf("java.lang.Object") < 0) {
+ Field[] suprFields = supr.getFields();
for (int i = 0; i < suprFields.length; i++) {
- FieldMap.remove(suprFields[i].getSimpleName());
+ FieldMap.remove(suprFields[i].getName());
}
supr = supr.getSuperclass();
}
// end patch for Annogen -21
- JField[] froperties = (JField[]) FieldMap.values().toArray(new JField[0]);
+ Field[] froperties = (Field[]) FieldMap.values().toArray(new Field[0]);
Arrays.sort(froperties);
for (int i = 0; i < froperties.length; i++) {
- JField field = froperties[i];
- boolean isArryType = field.getType().isArrayType();
-
+ Field field = froperties[i];
+ boolean isArryType = field.getType().isArray();
this.generateSchemaforFieldsandProperties(xmlSchema, sequence, field.getType(),
- field.getSimpleName(), isArryType);
+ field.getName(), isArryType);
}
-
-
}
return schemaTypeName;
}
- // moved code common to Fields & properties out of above method
+ // moved code common to Fields & properties out of above method
protected void generateSchemaforFieldsandProperties(XmlSchema xmlSchema,
- XmlSchemaSequence sequence, JClass type,
+ XmlSchemaSequence sequence, Class type,
String name, boolean isArryType)
throws Exception {
-
String propertyName;
-
if (isArryType) {
- propertyName = getQualifiedName(type.getArrayComponentType());
- } else
- propertyName = getQualifiedName(type);
-
+ propertyName = type.getComponentType().getName();
+ } else {
+ propertyName = type.getName();
+ }
if (isArryType && "byte".equals(propertyName)) {
propertyName = "base64Binary";
}
if (isDataHandler(type)) {
propertyName = "base64Binary";
}
-
if (typeTable.isSimpleType(propertyName)) {
XmlSchemaElement elt1 = new XmlSchemaElement();
elt1.setName(name);
elt1.setSchemaTypeName(typeTable.getSimpleSchemaTypeName(propertyName));
sequence.getItems().add(elt1);
-
if (isArryType && (!propertyName.equals("base64Binary"))) {
elt1.setMaxOccurs(Long.MAX_VALUE);
}
elt1.setMinOccurs(0);
- if (!type.isPrimitiveType()) {
+ if (!type.isPrimitive()) {
elt1.setNillable(true);
}
} else {
if (isArryType) {
- generateSchema(type.getArrayComponentType());
+ generateSchema(type.getComponentType());
} else {
generateSchema(type);
}
@@ -745,7 +651,7 @@
elt1.setMinOccurs(0);
elt1.setNillable(true);
- if (!((NamespaceMap) xmlSchema.getNamespaceContext()).values().
+ if (typeTable.getComplexSchemaType(propertyName) != null && !((NamespaceMap) xmlSchema.getNamespaceContext()).values().
contains(typeTable.getComplexSchemaType(propertyName).getNamespaceURI())) {
XmlSchemaImport importElement = new XmlSchemaImport();
importElement.setNamespace(
@@ -761,15 +667,15 @@
}
- private QName generateSchemaForType(XmlSchemaSequence sequence, JClass type, String partName)
+ private QName generateSchemaForType(XmlSchemaSequence sequence, Class type, String partName)
throws Exception {
boolean isArrayType = false;
if (type != null) {
- isArrayType = type.isArrayType();
+ isArrayType = type.isArray();
}
if (isArrayType) {
- type = type.getArrayComponentType();
+ type = type.getComponentType();
}
if (AxisFault.class.getName().equals(type)) {
return null;
@@ -778,7 +684,7 @@
if (type == null) {
classTypeName = "java.lang.Object";
} else {
- classTypeName = getQualifiedName(type);
+ classTypeName = type.getName();
}
if (isArrayType && "byte".equals(classTypeName)) {
classTypeName = "base64Binary";
@@ -796,7 +702,7 @@
partName,
isArrayType);
String schemaNamespace;
- schemaNamespace = resolveSchemaNamespace(getQualifiedName(type.getContainingPackage()));
+ schemaNamespace = resolveSchemaNamespace(getQualifiedName(type.getPackage()));
addImport(getXmlSchema(schemaNamespace), schemaTypeName);
} else {
@@ -809,24 +715,8 @@
return schemaTypeName;
}
- protected boolean isDataHandler(JClass clazz){
- if(clazz == null ){
- return false;
- }
- String classType = clazz.getQualifiedName();
- if("java.lang.Object".equals(classType)){
- return false;
- }
- if ("javax.activation.DataHandler".equals(classType)) {
- return true;
- } else {
- JClass supuerClass = clazz.getSuperclass();
- if (supuerClass != null) {
- return isDataHandler(supuerClass);
- } else {
- return false;
- }
- }
+ protected boolean isDataHandler(Class clazz) {
+ return clazz != null && DataHandler.class.isAssignableFrom(clazz);
}
protected void addContentToMethodSchemaType(XmlSchemaSequence sequence,
@@ -849,7 +739,7 @@
"long".equals(schemaTypeName.getLocalPart()) ||
"boolean".equals(schemaTypeName.getLocalPart()) ||
"short".equals(schemaTypeName.getLocalPart()) ||
- "float".equals(schemaTypeName.getLocalPart()) )) {
+ "float".equals(schemaTypeName.getLocalPart()))) {
elt1.setNillable(true);
}
}
@@ -940,7 +830,7 @@
return typeTable;
}
- public JMethod[] getMethods() {
+ public Method[] getMethods() {
return methods;
}
@@ -961,7 +851,7 @@
NamespacePrefixList map = xmlSchema.getNamespaceContext();
if (map == null ||
((map instanceof NamespaceMap) && ((NamespaceMap) map).values() == null) ||
- schemaTypeName == null){
+ schemaTypeName == null) {
return;
}
if (map instanceof NamespaceMap && !((NamespaceMap) map).values().
@@ -1058,51 +948,20 @@
return targetNamespace;
}
- protected String getSimpleName(JMethod method) {
- return Utils.getSimpleName(method);
- }
-
- protected String getSimpleName(JClass type) {
- String name = type.getSimpleName();
- if (name.indexOf("$")>0){
- name = name.replace('$','_');
+ protected String getClassName(Class type) {
+ String name = type.getName();
+ if (name.indexOf("$") > 0) {
+ name = name.replace('$', '_');
}
return name;
}
- protected String getSimpleName(JProperty peroperty) {
- return peroperty.getSimpleName();
- }
-
- protected String getSimpleName(JParameter parameter) {
- return parameter.getSimpleName();
- }
-
- protected String getQualifiedName(JMethod method) {
- return method.getQualifiedName();
- }
-
- protected String getActualQualifiedName(JClass type ) {
- return type.getQualifiedName();
- }
- protected String getQualifiedName(JClass type) {
- String name = type.getQualifiedName();
- if (name.indexOf("$")>0){
- name = name.replace('$','_');
+ protected String getQualifiedName(Package packagez) {
+ if (packagez != null) {
+ return packagez.getName();
+ } else {
+ return "";
}
- return name;
- }
-
- protected String getQualifiedName(JProperty peroperty) {
- return peroperty.getQualifiedName();
- }
-
- protected String getQualifiedName(JParameter parameter) {
- return parameter.getQualifiedName();
- }
-
- protected String getQualifiedName(JPackage packagez) {
- return packagez.getQualifiedName();
}
public void setNonRpcMethods(ArrayList nonRpcMethods) {
@@ -1131,4 +990,58 @@
public void setMappingFileLocation(String mappingFileLocation) {
this.mappingFileLocation = mappingFileLocation;
}
-}
+
+ protected String getParameterName(Annotation[][] parameterAnnotation,
+ int j,
+ String[] parameterNames) {
+ String parameterName = null;
+ if (parameterAnnotation.length > 0) {
+ Annotation[] tempAnnon = parameterAnnotation[j];
+ if (tempAnnon.length > 0) {
+ WebParam para = (WebParam) tempAnnon[0];
+ if (para != null) {
+ parameterName = para.name();
+ }
+ }
+ }
+ if (parameterName == null || "".equals(parameterName)) {
+ parameterName = parameterNames[j];
+ if (parameterName == null || "".equals(parameterName)) {
+ parameterName = "args" + j;
+ }
+ }
+ return parameterName;
+ }
+
+ public class MathodComparator implements Comparator {
+ public int compare(Object o1, Object o2) {
+ Method method1 = (Method) o1;
+ Method method2 = (Method) o2;
+ String[] values = new String[2];
+ values[0] = method1.getName();
+ values[1] = method2.getName();
+ Arrays.sort(values);
+ if (values[0].equals(method1.getName())) {
+ return 1;
+ } else {
+ return 0;
+ }
+ }
+ }
+
+ public class PropertyComparator implements Comparator {
+ public int compare(Object o1, Object o2) {
+ PropertyDescriptor propertyDescriptor1 = (PropertyDescriptor) o1;
+ PropertyDescriptor propertyDescriptor2 = (PropertyDescriptor) o2;
+ String[] values = new String[2];
+ values[0] = propertyDescriptor1.getName();
+ values[1] = propertyDescriptor2.getName();
+ Arrays.sort(values);
+ if (values[0].equals(propertyDescriptor1.getName())) {
+ return 0;
+ } else {
+ return 1;
+ }
+ }
+ }
+}
\ No newline at end of file
---------------------------------------------------------------------
To unsubscribe, e-mail: axis-cvs-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-cvs-help@ws.apache.org