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 2005/11/04 09:19:48 UTC
svn commit: r330746 - in /webservices/axis2/trunk/java/modules:
codegen/src/org/apache/axis2/util/ core/src/org/apache/axis2/transport/http/
integration/test/org/apache/axis2/rpc/
Author: deepal
Date: Fri Nov 4 00:19:26 2005
New Revision: 330746
URL: http://svn.apache.org/viewcvs?rev=330746&view=rev
Log:
1. Added getting service info from SimpleHTTPServer.java (http://localhost:8080/axis2)
2. Fixed a bug in SimpleHTTPServer.java (when sending more that 10 request it fails , due to socket close)
3. Fixing some bugs in BeanSerializerUtil.java , some array problems
Modified:
webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/util/BeanSerializerUtil.java
webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/transport/http/AxisServlet.java
webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/transport/http/HTTPTransportReceiver.java
webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/transport/http/SimpleHTTPServer.java
webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/rpc/RPCCallTest.java
Modified: webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/util/BeanSerializerUtil.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/util/BeanSerializerUtil.java?rev=330746&r1=330745&r2=330746&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/util/BeanSerializerUtil.java (original)
+++ webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/util/BeanSerializerUtil.java Fri Nov 4 00:19:26 2005
@@ -18,25 +18,25 @@
package org.apache.axis2.util;
-import org.apache.axis2.rpc.receivers.SimpleTypeMapper;
+import org.apache.axis2.AxisFault;
import org.apache.axis2.databinding.utils.ADBPullParser;
-import org.apache.axis2.om.OMElement;
-import org.apache.axis2.om.OMAttribute;
import org.apache.axis2.om.OMAbstractFactory;
+import org.apache.axis2.om.OMAttribute;
+import org.apache.axis2.om.OMElement;
import org.apache.axis2.om.impl.llom.builder.StAXOMBuilder;
import org.apache.axis2.om.impl.llom.factory.OMXMLBuilderFactory;
-import org.apache.axis2.AxisFault;
+import org.apache.axis2.rpc.receivers.SimpleTypeMapper;
import javax.xml.namespace.QName;
import javax.xml.stream.XMLStreamReader;
+import java.beans.BeanInfo;
+import java.beans.IntrospectionException;
+import java.beans.Introspector;
+import java.beans.PropertyDescriptor;
import java.lang.reflect.InvocationTargetException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
-import java.beans.PropertyDescriptor;
-import java.beans.Introspector;
-import java.beans.IntrospectionException;
-import java.beans.BeanInfo;
public class BeanSerializerUtil {
@@ -44,10 +44,11 @@
/**
* To Serilize Bean object this method is used, this will create an object array using given
* bean object
+ *
* @param beanObject
* @param beanName
*/
- public static XMLStreamReader getPullParser(Object beanObject, QName beanName ) {
+ public static XMLStreamReader getPullParser(Object beanObject, QName beanName) {
try {
BeanInfo beanInfo = Introspector.getBeanInfo(beanObject.getClass());
PropertyDescriptor [] propDescs = beanInfo.getPropertyDescriptors();
@@ -55,20 +56,35 @@
for (int i = 0; i < propDescs.length; i++) {
PropertyDescriptor propDesc = propDescs[i];
Class ptype = propDesc.getPropertyType();
- if(propDesc.getName().equals("class")){
+ if (propDesc.getName().equals("class")) {
continue;
}
- if(SimpleTypeMapper.isSimpleType(ptype)){
- Object value = propDesc.getReadMethod().invoke(beanObject,null);
+ if (SimpleTypeMapper.isSimpleType(ptype)) {
+ Object value = propDesc.getReadMethod().invoke(beanObject, null);
objetc.add(propDesc.getName());
objetc.add(value.toString());
- } else if(SimpleTypeMapper.isArrayList(ptype)){
- objetc.add(new QName(propDesc.getName()));
- Object value = propDesc.getReadMethod().invoke(beanObject,null);
- objetc.add(((ArrayList) value).toArray());
+ } else if (SimpleTypeMapper.isArrayList(ptype)) {
+ Object value = propDesc.getReadMethod().invoke(beanObject, null);
+ ArrayList objList = (ArrayList) value;
+ if(objList!=null && objList.size()>0 ){
+ //this was given error , when the array.size = 0
+ // and if the array contain simple type , then the ADBPullParser asked
+ // PullParser from That simpel type
+ for (int j = 0; j < objList.size(); j++) {
+ Object o = objList.get(j);
+ if(SimpleTypeMapper.isSimpleType(o)){
+ objetc.add(propDesc.getName());
+ objetc.add(o);
+ } else {
+ objetc.add(new QName(propDesc.getName()));
+ objetc.add(o);
+ }
+ }
+
+ }
} else {
objetc.add(new QName(propDesc.getName()));
- Object value = propDesc.getReadMethod().invoke(beanObject,null);
+ Object value = propDesc.getReadMethod().invoke(beanObject, null);
objetc.add(value);
}
}
@@ -82,10 +98,13 @@
}
}
- public static Object deserialize(Class beanClass, OMElement beanElement) throws AxisFault{
- Object beanObj ;
+ public static Object deserialize(Class beanClass, OMElement beanElement) throws AxisFault {
+ Object beanObj;
try {
- HashMap properties = new HashMap() ;
+ if(SimpleTypeMapper.isSimpleType(beanClass)){
+ return SimpleTypeMapper.getSimpleTypeObject(beanClass,beanElement);
+ }
+ HashMap properties = new HashMap();
BeanInfo beanInfo = Introspector.getBeanInfo(beanClass);
PropertyDescriptor [] propDescs = beanInfo.getPropertyDescriptors();
for (int i = 0; i < propDescs.length; i++) {
@@ -99,7 +118,7 @@
OMElement parts = (OMElement) elements.next();
// if parts/@href != null then need to find element with id and deserialize. before that first check wheher already have in hashtable
String partsLocalName = parts.getLocalName();
- PropertyDescriptor prty =(PropertyDescriptor)properties.get(partsLocalName.toLowerCase());
+ PropertyDescriptor prty = (PropertyDescriptor) properties.get(partsLocalName.toLowerCase());
// if (prty == null) {
/**
* I think this can be happen , that is because there is a method whcih take Man
@@ -108,16 +127,18 @@
*/
// throw new AxisFault("User Error , In vaild bean ! prty does not exist " + "set" +
// partsLocalName);
- if(prty !=null){
+ if (prty != null) {
Class parameters = prty.getPropertyType();
if (prty.equals("class"))
continue;
Object partObj;
- if(SimpleTypeMapper.isSimpleType(parameters)){
+ if (SimpleTypeMapper.isSimpleType(parameters)) {
partObj = SimpleTypeMapper.getSimpleTypeObject(parameters, parts);
- } else if(SimpleTypeMapper.isArrayList(parameters)){
- partObj = SimpleTypeMapper.getArrayList((OMElement)parts.getParent(),prty.getName());
+ } else if (SimpleTypeMapper.isArrayList(parameters)) {
+ //todo : Deepal , the array handling is compltely wrong , this has to be
+ // imroved
+ partObj = SimpleTypeMapper.getArrayList((OMElement) parts.getParent(), prty.getName());
} else {
partObj = deserialize(parameters, parts);
}
@@ -126,7 +147,7 @@
// partObj = deserialize(parameters, parts);
// }
Object [] parms = new Object[]{partObj};
- prty.getWriteMethod().invoke(beanObj,parms);
+ prty.getWriteMethod().invoke(beanObj, parms);
}
}
} catch (InstantiationException e) {
@@ -141,10 +162,10 @@
return beanObj;
}
- public static Object deserialize(Class beanClass, OMElement beanElement, MultirefHelper helper) throws AxisFault{
- Object beanObj ;
+ public static Object deserialize(Class beanClass, OMElement beanElement, MultirefHelper helper) throws AxisFault {
+ Object beanObj;
try {
- HashMap properties = new HashMap() ;
+ HashMap properties = new HashMap();
BeanInfo beanInfo = Introspector.getBeanInfo(beanClass);
PropertyDescriptor [] propDescs = beanInfo.getPropertyDescriptors();
for (int i = 0; i < propDescs.length; i++) {
@@ -156,25 +177,25 @@
Iterator elements = beanElement.getChildren();
while (elements.hasNext()) {
Object child = elements.next();
- OMElement parts ;
- if(child instanceof OMElement){
- parts= (OMElement) child;
+ OMElement parts;
+ if (child instanceof OMElement) {
+ parts = (OMElement) child;
} else {
continue;
}
String partsLocalName = parts.getLocalName();
- PropertyDescriptor prty =(PropertyDescriptor)properties.get(partsLocalName.toLowerCase());
- if(prty !=null){
+ PropertyDescriptor prty = (PropertyDescriptor) properties.get(partsLocalName.toLowerCase());
+ if (prty != null) {
Class parameters = prty.getPropertyType();
if (prty.equals("class"))
continue;
Object partObj;
OMAttribute attr = MultirefHelper.processRefAtt(parts);
- if(attr != null){
+ if (attr != null) {
String refId = MultirefHelper.getAttvalue(attr);
- partObj = helper.getObject(refId);
- if(partObj == null){
- partObj = helper.processRef(parameters,refId);
+ partObj = helper.getObject(refId);
+ if (partObj == null) {
+ partObj = helper.processRef(parameters, refId);
}
} else {
partObj = SimpleTypeMapper.getSimpleTypeObject(parameters, parts);
@@ -183,7 +204,7 @@
}
}
Object [] parms = new Object[]{partObj};
- prty.getWriteMethod().invoke(beanObj,parms);
+ prty.getWriteMethod().invoke(beanObj, parms);
}
}
} catch (InstantiationException e) {
@@ -204,12 +225,13 @@
* in that case that element will be converted to the JavaType specified by the javaTypes array
* The algo is as follows, get the childerns of the response element , and if it conatian more than
* one element then check the retuen type of that element and conver that to corresponding JavaType
- * @param response OMElement
+ *
+ * @param response OMElement
* @param javaTypes Array of JavaTypes
- * @return Array of objects
+ * @return Array of objects
* @throws AxisFault
*/
- public static Object [] deserialize(OMElement response , Object [] javaTypes ) throws AxisFault {
+ public static Object [] deserialize(OMElement response, Object [] javaTypes) throws AxisFault {
/**
* Take the number of paramters in the method and , only take that much of child elements
* from the OMElement , other are ignore , as an example
@@ -223,7 +245,7 @@
* only the val1 and Val2 take into account
*/
int length = javaTypes.length;
- int count =0;
+ int count = 0;
Object [] retObjs = new Object[length];
/**
@@ -244,54 +266,53 @@
Iterator parts = response.getChildren();
//to handle multirefs
//have to check the instnceof
- MultirefHelper helper = new MultirefHelper((OMElement)response.getParent());
+ MultirefHelper helper = new MultirefHelper((OMElement) response.getParent());
boolean hasRef = false;
//to support array . if the paramter type is array , then all the omelemnts with that paramtre name
// has to get and add to the list
- Class classType = null;
+ Class classType;
while (parts.hasNext() && count < length) {
Object objValue = parts.next();
OMElement omElement;
- if(objValue instanceof OMElement){
+ if (objValue instanceof OMElement) {
omElement = (OMElement) objValue;
- } else {
+ } else {
continue;
}
- classType = (Class)javaTypes[count];
+ classType = (Class) javaTypes[count];
//handling refs
OMAttribute omatribute = MultirefHelper.processRefAtt(omElement);
- String ref=null;
- if(omatribute !=null) {
+ String ref = null;
+ if (omatribute != null) {
hasRef = true;
ref = MultirefHelper.getAttvalue(omatribute);
}
- if(OMElement.class.isAssignableFrom(classType)){
- if(hasRef){
+ if (OMElement.class.isAssignableFrom(classType)) {
+ if (hasRef) {
OMElement elemnt = helper.getOMElement(ref);
- if(elemnt == null){
+ if (elemnt == null) {
retObjs[count] = helper.processOMElementRef(ref);
} else {
- retObjs[count] =omElement;
+ retObjs[count] = omElement;
}
// throw new AxisFault("The method take OMElenent as argument , and the body contains" +
// "refs , encounter processing error ");
} else
- retObjs[count] =omElement;
+ retObjs[count] = omElement;
} else {
- if(hasRef){
- if(helper.getObject(ref) !=null) {
- retObjs[count] = helper.getObject(ref);
+ if (hasRef) {
+ if (helper.getObject(ref) != null) {
+ retObjs[count] = helper.getObject(ref);
} else {
- retObjs[count] = helper.processRef(classType,ref) ;
- }
- } else{
- if(SimpleTypeMapper.isSimpleType(classType)){
- retObjs[count] = SimpleTypeMapper.getSimpleTypeObject(classType, omElement);
- } else if(SimpleTypeMapper.isArrayList(classType)){
- retObjs[count] = SimpleTypeMapper.getArrayList(omElement);
+ retObjs[count] = helper.processRef(classType, ref);
}
- else {
+ } else {
+ if (SimpleTypeMapper.isSimpleType(classType)) {
+ retObjs[count] = SimpleTypeMapper.getSimpleTypeObject(classType, omElement);
+ } else if (SimpleTypeMapper.isArrayList(classType)) {
+ retObjs[count] = SimpleTypeMapper.getArrayList(omElement);
+ } else {
retObjs[count] = BeanSerializerUtil.deserialize(classType, omElement);
}
}
@@ -300,28 +321,28 @@
count ++;
}
helper.clean();
- return retObjs;
+ return retObjs;
}
- public static OMElement getOMElement(QName opName ,Object [] args) {
- ArrayList objects ;
+ public static OMElement getOMElement(QName opName, Object [] args) {
+ ArrayList objects;
objects = new ArrayList();
- int argCount =0;
+ int argCount = 0;
for (int i = 0; i < args.length; i++) {
Object arg = args[i];
//todo if the request paramter has name other than argi (0<i<n) , there should be a
//was to do that , to solve that problem we need to have RPCRequestParameter
//note that The value of request paramter can either be simple type or JavaBean
- if(SimpleTypeMapper.isSimpleType(arg)){
+ if (SimpleTypeMapper.isSimpleType(arg)) {
objects.add("arg" + argCount);
objects.add(arg.toString());
- } else {
+ } else {
objects.add(new QName("arg" + argCount));
objects.add(arg);
}
argCount ++;
}
- XMLStreamReader xr = ADBPullParser.createPullParser(opName,objects.toArray(),null);
+ XMLStreamReader xr = ADBPullParser.createPullParser(opName, objects.toArray(), null);
StAXOMBuilder stAXOMBuilder =
OMXMLBuilderFactory.createStAXOMBuilder(
OMAbstractFactory.getSOAP11Factory(), xr);
Modified: webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/transport/http/AxisServlet.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/transport/http/AxisServlet.java?rev=330746&r1=330745&r2=330746&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/transport/http/AxisServlet.java (original)
+++ webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/transport/http/AxisServlet.java Fri Nov 4 00:19:26 2005
@@ -46,7 +46,7 @@
private static final String CONFIGURATION_CONTEXT = "CONFIGURATION_CONTEXT";
private ConfigurationContext configContext;
public static final String SESSION_ID = "SessionId";
- private ServletContext servletContext;
+// private ServletContext servletContext;
/**
* Method init
@@ -67,7 +67,7 @@
configContext.setRootDir(new File(context.getRealPath("/WEB-INF")));
lister = new ListingAgent(configContext);
context.setAttribute(CONFIGURATION_CONTEXT, configContext);
- servletContext = getServletContext();
+// servletContext = getServletContext();
} catch (Exception e) {
throw new ServletException(e);
}
Modified: webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/transport/http/HTTPTransportReceiver.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/transport/http/HTTPTransportReceiver.java?rev=330746&r1=330745&r2=330746&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/transport/http/HTTPTransportReceiver.java (original)
+++ webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/transport/http/HTTPTransportReceiver.java Fri Nov 4 00:19:26 2005
@@ -17,13 +17,14 @@
package org.apache.axis2.transport.http;
import org.apache.axis2.AxisFault;
+import org.apache.axis2.description.AxisService;
+import org.apache.axis2.description.AxisOperation;
import org.apache.axis2.context.ConfigurationContext;
import org.apache.axis2.i18n.Messages;
import java.io.IOException;
import java.io.InputStream;
-import java.util.HashMap;
-import java.util.Map;
+import java.util.*;
/**
* Class HTTPTransportReceiver
@@ -279,6 +280,67 @@
public static String getServicesHTML(
ConfigurationContext configurationContext) {
String temp = "";
+ Map services =
+ configurationContext.getAxisConfiguration().getServices();
+ Hashtable erroneousServices =
+ configurationContext.getAxisConfiguration().getFaultyServices();
+ boolean status = false;
+
+ if (services != null && !services.isEmpty()) {
+ status = true;
+ Collection serviceCollection = services.values();
+ temp += "<h2>" + "Deployed services" + "</h2>";
+ for (Iterator it = serviceCollection.iterator(); it.hasNext();) {
+ Map operations;
+ Collection operationsList;
+ AxisService axisService = (AxisService) it.next();
+ operations = axisService.getOperations();
+ operationsList = operations.values();
+
+ temp += "<h3>" + axisService.getName().getLocalPart() +
+ "</h3>";
+ if (operationsList.size() > 0) {
+ temp += "Available operations <ul>";
+ for (Iterator iterator1 = operationsList.iterator();
+ iterator1.hasNext();
+ ) {
+ AxisOperation axisOperation =
+ (AxisOperation) iterator1.next();
+ temp += "<li>"
+ + axisOperation.getName().getLocalPart()
+ + "</li>";
+ }
+ temp += "</ul>";
+ } else {
+ temp += "No operations speficied for this service";
+ }
+ }
+ }
+
+ if (erroneousServices != null && !erroneousServices.isEmpty()) {
+
+ temp += "<hr><h2><font color=\"blue\">Faulty Services</font></h2>";
+ status = true;
+ Enumeration faultyservices = erroneousServices.keys();
+ while (faultyservices.hasMoreElements()) {
+ String faultyserviceName =
+ (String) faultyservices.nextElement();
+ temp += "<h3><font color=\"blue\">"
+ + faultyserviceName
+ + "</font></h3>";
+ }
+ }
+
+ if (!status) {
+ temp = "<h2>There are no services deployed</h2>";
+ }
+
+ temp =
+ "<html><head><title>Axis2: Services</title></head>"
+ + "<body>"
+ + temp
+ + "</body></html>";
+
return temp;
}
Modified: webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/transport/http/SimpleHTTPServer.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/transport/http/SimpleHTTPServer.java?rev=330746&r1=330745&r2=330746&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/transport/http/SimpleHTTPServer.java (original)
+++ webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/transport/http/SimpleHTTPServer.java Fri Nov 4 00:19:26 2005
@@ -154,10 +154,10 @@
*
* @throws Throwable
*/
- protected void finalize() throws Throwable {
- stop();
- super.finalize();
- }
+// protected void finalize() throws Throwable {
+// stop();
+// super.finalize();
+// }
/**
* Start this server as a NON-daemon.
Modified: webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/rpc/RPCCallTest.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/rpc/RPCCallTest.java?rev=330746&r1=330745&r2=330746&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/rpc/RPCCallTest.java (original)
+++ webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/rpc/RPCCallTest.java Fri Nov 4 00:19:26 2005
@@ -20,7 +20,6 @@
import junit.framework.TestCase;
import org.apache.axis2.AxisFault;
import org.apache.axis2.Constants;
-import org.apache.axis2.databinding.utils.ADBPullParser;
import org.apache.axis2.addressing.EndpointReference;
import org.apache.axis2.context.MessageContext;
import org.apache.axis2.context.ServiceContext;
@@ -49,7 +48,10 @@
import javax.xml.stream.XMLStreamReader;
import java.io.ByteArrayInputStream;
import java.text.SimpleDateFormat;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.Calendar;
+import java.util.Date;
+import java.util.TimeZone;
public class RPCCallTest extends TestCase {
@@ -312,18 +314,6 @@
ps.add(p3);
com.setPersons(ps);
-
-// List list = new ArrayList();
-// list.add(new QName(com.getName()));
-// list.add(com);
-// list.add(new QName("Persons"));
-// list.add(ps.toArray());
-//
-// XMLStreamReader pullParser = ADBPullParser.createPullParser(new QName("UdaEka"), list.toArray(), null);
-// OMElement documentElement = new StAXOMBuilder(pullParser).getDocumentElement();
-// System.out.println("documentElement = " + documentElement);
-
-
ArrayList args = new ArrayList();
args.add(com);
OMElement response = call.invokeBlocking(operationName, args.toArray());
@@ -459,7 +449,6 @@
args.add("foo");
-
OMElement response = call.invokeBlocking(operationName, args.toArray());
// assertEquals(response.getFirstElement().getText(), "foo");
call.close();
@@ -476,13 +465,13 @@
Constants.TRANSPORT_HTTP,
false);
- OMElement elem = call.invokeBlocking("handleArrayList", getpayLoad());
+ OMElement elem = call.invokeBlocking("handleArrayList", getpayLoad());
assertEquals(elem.getFirstElement().getText(), "abcdefghiklm10");
call.close();
}
private OMElement getpayLoad() throws AxisFault {
- String str= "<handleArrayList>\n" +
+ String str = "<handleArrayList>\n" +
" <arg0>\n" +
" <item0>abc</item0>\n" +
" <item0>def</item0>\n" +
@@ -490,22 +479,21 @@
" <item0>klm</item0>\n" +
" </arg0><arg1>10</arg1>" +
"</handleArrayList>";
- StAXOMBuilder staxOMBuilder ;
+ StAXOMBuilder staxOMBuilder;
try {
- XMLStreamReader xmlReader= XMLInputFactory.newInstance().createXMLStreamReader(new
+ XMLStreamReader xmlReader = XMLInputFactory.newInstance().createXMLStreamReader(new
ByteArrayInputStream(str.getBytes()));
OMFactory fac = OMAbstractFactory.getOMFactory();
staxOMBuilder = new
- StAXOMBuilder(fac,xmlReader);
+ StAXOMBuilder(fac, xmlReader);
} catch (XMLStreamException e) {
- throw new AxisFault(e);
+ throw new AxisFault(e);
} catch (FactoryConfigurationError factoryConfigurationError) {
- throw new AxisFault(factoryConfigurationError);
+ throw new AxisFault(factoryConfigurationError);
}
- return staxOMBuilder.getDocumentElement();
+ return staxOMBuilder.getDocumentElement();
}
-
}