You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-commits@axis.apache.org by am...@apache.org on 2012/07/07 11:27:16 UTC
svn commit: r1358530 - in /axis/axis2/java/core/trunk/modules:
distribution/src/main/assembly/ json/ json/src/org/apache/axis2/json/impl/
json/src/org/apache/axis2/json/impl/rpc/
json/src/org/apache/axis2/json/impl/utils/ parent/ samples/json/ samples/...
Author: amilas
Date: Sat Jul 7 09:27:15 2012
New Revision: 1358530
URL: http://svn.apache.org/viewvc?rev=1358530&view=rev
Log:
apply the patch for AXIS2-5270
Added:
axis/axis2/java/core/trunk/modules/json/src/org/apache/axis2/json/impl/
axis/axis2/java/core/trunk/modules/json/src/org/apache/axis2/json/impl/JsonBuilder.java
axis/axis2/java/core/trunk/modules/json/src/org/apache/axis2/json/impl/JsonFormatter.java
axis/axis2/java/core/trunk/modules/json/src/org/apache/axis2/json/impl/rpc/
axis/axis2/java/core/trunk/modules/json/src/org/apache/axis2/json/impl/rpc/JsonInOnlyRPCMessageReceiver.java
axis/axis2/java/core/trunk/modules/json/src/org/apache/axis2/json/impl/rpc/JsonRpcMessageReceiver.java
axis/axis2/java/core/trunk/modules/json/src/org/apache/axis2/json/impl/utils/
axis/axis2/java/core/trunk/modules/json/src/org/apache/axis2/json/impl/utils/JsonConstant.java
axis/axis2/java/core/trunk/modules/json/src/org/apache/axis2/json/impl/utils/JsonUtils.java
axis/axis2/java/core/trunk/modules/samples/json/
axis/axis2/java/core/trunk/modules/samples/json/README.txt
axis/axis2/java/core/trunk/modules/samples/json/build.xml
axis/axis2/java/core/trunk/modules/samples/json/resources/
axis/axis2/java/core/trunk/modules/samples/json/resources/axis2.xml
axis/axis2/java/core/trunk/modules/samples/json/src/
axis/axis2/java/core/trunk/modules/samples/json/src/META-INF/
axis/axis2/java/core/trunk/modules/samples/json/src/META-INF/services.xml
axis/axis2/java/core/trunk/modules/samples/json/src/sample/
axis/axis2/java/core/trunk/modules/samples/json/src/sample/json/
axis/axis2/java/core/trunk/modules/samples/json/src/sample/json/client/
axis/axis2/java/core/trunk/modules/samples/json/src/sample/json/client/JsonClient.java
axis/axis2/java/core/trunk/modules/samples/json/src/sample/json/service/
axis/axis2/java/core/trunk/modules/samples/json/src/sample/json/service/Address.java
axis/axis2/java/core/trunk/modules/samples/json/src/sample/json/service/JsonService.java
axis/axis2/java/core/trunk/modules/samples/json/src/sample/json/service/User.java
Modified:
axis/axis2/java/core/trunk/modules/distribution/src/main/assembly/bin-assembly.xml
axis/axis2/java/core/trunk/modules/json/pom.xml
axis/axis2/java/core/trunk/modules/parent/pom.xml
Modified: axis/axis2/java/core/trunk/modules/distribution/src/main/assembly/bin-assembly.xml
URL: http://svn.apache.org/viewvc/axis/axis2/java/core/trunk/modules/distribution/src/main/assembly/bin-assembly.xml?rev=1358530&r1=1358529&r2=1358530&view=diff
==============================================================================
--- axis/axis2/java/core/trunk/modules/distribution/src/main/assembly/bin-assembly.xml (original)
+++ axis/axis2/java/core/trunk/modules/distribution/src/main/assembly/bin-assembly.xml Sat Jul 7 09:27:15 2012
@@ -133,6 +133,7 @@
<include>jaxws-interop/**/*</include>
<include>jaxws-dynamic/**/*</include>
<include>jaxws-version/**/*</include>
+ <include>json/**/*</include>
<include>mtom/**/*</include>
<include>pojo/**/*</include>
<include>pojoguide/**/*</include>
Modified: axis/axis2/java/core/trunk/modules/json/pom.xml
URL: http://svn.apache.org/viewvc/axis/axis2/java/core/trunk/modules/json/pom.xml?rev=1358530&r1=1358529&r2=1358530&view=diff
==============================================================================
--- axis/axis2/java/core/trunk/modules/json/pom.xml (original)
+++ axis/axis2/java/core/trunk/modules/json/pom.xml Sat Jul 7 09:27:15 2012
@@ -65,7 +65,10 @@
<groupId>${project.groupId}</groupId>
<artifactId>axis2-adb</artifactId>
<version>${project.version}</version>
- <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>com.google.code.gson</groupId>
+ <artifactId>gson</artifactId>
</dependency>
</dependencies>
<url>http://axis.apache.org/axis2/java/core/</url>
Added: axis/axis2/java/core/trunk/modules/json/src/org/apache/axis2/json/impl/JsonBuilder.java
URL: http://svn.apache.org/viewvc/axis/axis2/java/core/trunk/modules/json/src/org/apache/axis2/json/impl/JsonBuilder.java?rev=1358530&view=auto
==============================================================================
--- axis/axis2/java/core/trunk/modules/json/src/org/apache/axis2/json/impl/JsonBuilder.java (added)
+++ axis/axis2/java/core/trunk/modules/json/src/org/apache/axis2/json/impl/JsonBuilder.java Sat Jul 7 09:27:15 2012
@@ -0,0 +1,45 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.axis2.json.impl;
+
+import org.apache.axiom.om.OMAbstractFactory;
+import org.apache.axiom.om.OMElement;
+import org.apache.axiom.soap.SOAPEnvelope;
+import org.apache.axiom.soap.SOAPFactory;
+import org.apache.axis2.AxisFault;
+import org.apache.axis2.builder.Builder;
+import org.apache.axis2.context.MessageContext;
+import org.apache.axis2.json.impl.utils.JsonConstant;
+
+import java.io.InputStream;
+
+public class JsonBuilder implements Builder {
+ @Override
+ public OMElement processDocument(InputStream inputStream, String s, MessageContext messageContext) throws AxisFault {
+ messageContext.setProperty(JsonConstant.INPUT_STREAM ,inputStream);
+ messageContext.setProperty(JsonConstant.IS_JSON_STREAM , true);
+ // dummy envelop
+ SOAPFactory soapFactory = OMAbstractFactory.getSOAP11Factory();
+ SOAPEnvelope soapEnvelope = soapFactory.getDefaultEnvelope();
+
+ return soapEnvelope;
+ }
+
+}
Added: axis/axis2/java/core/trunk/modules/json/src/org/apache/axis2/json/impl/JsonFormatter.java
URL: http://svn.apache.org/viewvc/axis/axis2/java/core/trunk/modules/json/src/org/apache/axis2/json/impl/JsonFormatter.java?rev=1358530&view=auto
==============================================================================
--- axis/axis2/java/core/trunk/modules/json/src/org/apache/axis2/json/impl/JsonFormatter.java (added)
+++ axis/axis2/java/core/trunk/modules/json/src/org/apache/axis2/json/impl/JsonFormatter.java Sat Jul 7 09:27:15 2012
@@ -0,0 +1,94 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.axis2.json.impl;
+
+import com.google.gson.Gson;
+import com.google.gson.stream.JsonWriter;
+import org.apache.axiom.om.OMOutputFormat;
+import org.apache.axis2.AxisFault;
+import org.apache.axis2.Constants;
+import org.apache.axis2.context.MessageContext;
+import org.apache.axis2.json.impl.utils.JsonConstant;
+import org.apache.axis2.transport.MessageFormatter;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import java.io.IOException;
+import java.io.OutputStream;
+import java.io.OutputStreamWriter;
+import java.io.UnsupportedEncodingException;
+import java.lang.reflect.Type;
+import java.net.URL;
+
+
+public class JsonFormatter implements MessageFormatter {
+ private static final Log log = LogFactory.getLog(JsonFormatter.class);
+
+ @Override
+ public byte[] getBytes(MessageContext messageContext, OMOutputFormat omOutputFormat) throws AxisFault {
+ return new byte[0];
+ }
+
+ @Override
+ public void writeTo(MessageContext outMsgCtxt, OMOutputFormat omOutputFormat, OutputStream outputStream, boolean b) throws AxisFault {
+ JsonWriter writer = null;
+ String msg;
+
+ try {
+ String charSetEncoding = (String) outMsgCtxt.getProperty(Constants.Configuration.CHARACTER_SET_ENCODING);
+ writer = new JsonWriter(new OutputStreamWriter(outputStream, charSetEncoding ));
+ Gson gson = new Gson();
+ Object retObj = outMsgCtxt.getProperty(JsonConstant.RETURN_OBJECT);
+ writer.beginObject();
+ writer.name(JsonConstant.RESPONSE);
+ Type returnType = (Type) outMsgCtxt.getProperty(JsonConstant.RETURN_TYPE);
+
+ gson.toJson(retObj, returnType, writer);
+ writer.endObject();
+ writer.flush();
+ } catch (UnsupportedEncodingException e) {
+ msg = "Exception occur when try to encode output stream usig " +
+ Constants.Configuration.CHARACTER_SET_ENCODING + " charset";
+ log.error(msg , e);
+ throw AxisFault.makeFault(e);
+ } catch (IOException e) {
+ msg = "Exception occur while writting to JsonWriter at the JsonFormatter ";
+ log.error(msg, e);
+ throw AxisFault.makeFault(e);
+ }
+ }
+
+ @Override
+ public String getContentType(MessageContext outMsgCtxt, OMOutputFormat omOutputFormat, String s) {
+ String contentType = (String)outMsgCtxt.getProperty(Constants.Configuration.CONTENT_TYPE);
+ outMsgCtxt.setProperty(Constants.Configuration.CONTENT_TYPE , "application/json-impl");
+ return "application/json-impl";
+ }
+
+ @Override
+ public URL getTargetAddress(MessageContext messageContext, OMOutputFormat omOutputFormat, URL url) throws AxisFault {
+ return null;
+ }
+
+ @Override
+ public String formatSOAPAction(MessageContext messageContext, OMOutputFormat omOutputFormat, String s) {
+ return null;
+ }
+}
Added: axis/axis2/java/core/trunk/modules/json/src/org/apache/axis2/json/impl/rpc/JsonInOnlyRPCMessageReceiver.java
URL: http://svn.apache.org/viewvc/axis/axis2/java/core/trunk/modules/json/src/org/apache/axis2/json/impl/rpc/JsonInOnlyRPCMessageReceiver.java?rev=1358530&view=auto
==============================================================================
--- axis/axis2/java/core/trunk/modules/json/src/org/apache/axis2/json/impl/rpc/JsonInOnlyRPCMessageReceiver.java (added)
+++ axis/axis2/java/core/trunk/modules/json/src/org/apache/axis2/json/impl/rpc/JsonInOnlyRPCMessageReceiver.java Sat Jul 7 09:27:15 2012
@@ -0,0 +1,82 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.axis2.json.impl.rpc;
+
+import org.apache.axis2.AxisFault;
+import org.apache.axis2.Constants;
+import org.apache.axis2.context.MessageContext;
+import org.apache.axis2.description.AxisOperation;
+import org.apache.axis2.json.impl.utils.JsonConstant;
+import org.apache.axis2.json.impl.utils.JsonUtils;
+import org.apache.axis2.rpc.receivers.RPCInOnlyMessageReceiver;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+
+public class JsonInOnlyRPCMessageReceiver extends RPCInOnlyMessageReceiver {
+
+ private static Log log = LogFactory.getLog(JsonInOnlyRPCMessageReceiver.class);
+ @Override
+ public void invokeBusinessLogic(MessageContext inMessage) throws AxisFault {
+ InputStream inputStream = (InputStream)inMessage.getProperty(JsonConstant.INPUT_STREAM);
+ if (inputStream != null) {
+ Method method = null;
+ String msg;
+
+ Object serviceObj = getTheImplementationObject(inMessage);
+ Class implClass = serviceObj.getClass();
+ Method[] allmethods = implClass.getDeclaredMethods();
+ AxisOperation op = inMessage.getOperationContext().getAxisOperation();
+ String operation = op.getName().getLocalPart();
+ method = JsonUtils.getOpMethod(operation, allmethods);
+ Class [] paramClasses = method.getParameterTypes();
+ String charSetEncoding = (String) inMessage.getProperty(Constants.Configuration.CHARACTER_SET_ENCODING);
+ try {
+ int paramCount=paramClasses.length;
+
+ JsonUtils.invokeServiceClass(inputStream,
+ serviceObj, method, paramClasses, paramCount, charSetEncoding);
+
+ } catch (IllegalAccessException e) {
+ msg = "Does not have access to " +
+ "the definition of the specified class, field, method or constructor";
+ log.error(msg, e);
+ throw AxisFault.makeFault(e);
+
+ } catch (InvocationTargetException e) {
+ msg = "Exception occurred while trying to invoke service method " +
+ (method != null ? method.getName() : "null");
+ log.error(msg, e);
+ throw AxisFault.makeFault(e);
+ } catch (IOException e) {
+ msg = "Exception occur while encording or " +
+ "access to the input string at the JsonRpcMessageReceiver";
+ log.error(msg, e);
+ throw AxisFault.makeFault(e);
+ }
+ } else{
+ super.invokeBusinessLogic(inMessage); // call RPCMessageReceiver if inputstream is null
+ }
+ }
+}
Added: axis/axis2/java/core/trunk/modules/json/src/org/apache/axis2/json/impl/rpc/JsonRpcMessageReceiver.java
URL: http://svn.apache.org/viewvc/axis/axis2/java/core/trunk/modules/json/src/org/apache/axis2/json/impl/rpc/JsonRpcMessageReceiver.java?rev=1358530&view=auto
==============================================================================
--- axis/axis2/java/core/trunk/modules/json/src/org/apache/axis2/json/impl/rpc/JsonRpcMessageReceiver.java (added)
+++ axis/axis2/java/core/trunk/modules/json/src/org/apache/axis2/json/impl/rpc/JsonRpcMessageReceiver.java Sat Jul 7 09:27:15 2012
@@ -0,0 +1,99 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.axis2.json.impl.rpc;
+
+import org.apache.axis2.AxisFault;
+import org.apache.axis2.Constants;
+import org.apache.axis2.context.MessageContext;
+import org.apache.axis2.description.AxisOperation;
+import org.apache.axis2.json.impl.utils.JsonConstant;
+import org.apache.axis2.json.impl.utils.JsonUtils;
+import org.apache.axis2.rpc.receivers.RPCMessageReceiver;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+
+
+public class JsonRpcMessageReceiver extends RPCMessageReceiver {
+
+ private static Log log = LogFactory.getLog(RPCMessageReceiver.class);
+ @Override
+ public void invokeBusinessLogic(MessageContext inMessage, MessageContext outMessage) throws AxisFault {
+ Object tempObj = inMessage.getProperty(JsonConstant.IS_JSON_STREAM);
+ boolean isJsonStream = false;
+ if (tempObj != null) {
+ isJsonStream = Boolean.valueOf(tempObj.toString());
+ }
+
+ if (isJsonStream) {
+ InputStream inputStream = (InputStream) inMessage.getProperty(JsonConstant.INPUT_STREAM);
+ Method method = null;
+ String msg;
+
+ if (inputStream == null) {
+ msg = "Input Stream is null";
+ log.error(msg);
+ throw new AxisFault(msg);
+ }
+
+ Object serviceObj = getTheImplementationObject(inMessage);
+ Class implClass = serviceObj.getClass();
+ Method[] allMethods = implClass.getDeclaredMethods();
+ AxisOperation op = inMessage.getOperationContext().getAxisOperation();
+ String operation = op.getName().getLocalPart();
+ method = JsonUtils.getOpMethod(operation, allMethods);
+ Class[] paramClasses = method.getParameterTypes();
+ String charSetEncoding = (String) inMessage.getProperty(Constants.Configuration.CHARACTER_SET_ENCODING);
+ try {
+ int paramCount = paramClasses.length;
+
+ Object retObj = JsonUtils.invokeServiceClass(inputStream,
+ serviceObj, method, paramClasses, paramCount, charSetEncoding);
+
+ outMessage.setProperty(JsonConstant.RETURN_OBJECT, retObj);
+ outMessage.setProperty(JsonConstant.RETURN_TYPE, method.getReturnType());
+
+ } catch (IllegalAccessException e) {
+ msg = "Does not have access to " +
+ "the definition of the specified class, field, method or constructor";
+ log.error(msg, e);
+ throw AxisFault.makeFault(e);
+
+ } catch (InvocationTargetException e) {
+ msg = "Exception occurred while trying to invoke service method " +
+ (method != null ? method.getName() : "null");
+ log.error(msg, e);
+ throw AxisFault.makeFault(e);
+ } catch (IOException e) {
+ msg = "Exception occur while encording or " +
+ "access to the input string at the JsonRpcMessageReceiver";
+ log.error(msg, e);
+ throw AxisFault.makeFault(e);
+ }
+ } else {
+ super.invokeBusinessLogic(inMessage, outMessage); // call RPCMessageReceiver if inputstream is null
+ }
+ }
+
+
+}
Added: axis/axis2/java/core/trunk/modules/json/src/org/apache/axis2/json/impl/utils/JsonConstant.java
URL: http://svn.apache.org/viewvc/axis/axis2/java/core/trunk/modules/json/src/org/apache/axis2/json/impl/utils/JsonConstant.java?rev=1358530&view=auto
==============================================================================
--- axis/axis2/java/core/trunk/modules/json/src/org/apache/axis2/json/impl/utils/JsonConstant.java (added)
+++ axis/axis2/java/core/trunk/modules/json/src/org/apache/axis2/json/impl/utils/JsonConstant.java Sat Jul 7 09:27:15 2012
@@ -0,0 +1,34 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.axis2.json.impl.utils;
+
+
+public class JsonConstant {
+
+
+ public static final String RESPONSE = "response";
+
+ public static final String INPUT_STREAM = "inputStream";
+ public static final String RETURN_OBJECT = "returnObject";
+ public static final String RETURN_TYPE = "returnType";
+
+ public static final String IS_JSON_STREAM = "isJsonStream";
+
+}
Added: axis/axis2/java/core/trunk/modules/json/src/org/apache/axis2/json/impl/utils/JsonUtils.java
URL: http://svn.apache.org/viewvc/axis/axis2/java/core/trunk/modules/json/src/org/apache/axis2/json/impl/utils/JsonUtils.java?rev=1358530&view=auto
==============================================================================
--- axis/axis2/java/core/trunk/modules/json/src/org/apache/axis2/json/impl/utils/JsonUtils.java (added)
+++ axis/axis2/java/core/trunk/modules/json/src/org/apache/axis2/json/impl/utils/JsonUtils.java Sat Jul 7 09:27:15 2012
@@ -0,0 +1,83 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.axis2.json.impl.utils;
+
+import com.google.gson.Gson;
+import com.google.gson.stream.JsonReader;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+
+
+public class JsonUtils {
+
+ public static Object invokeServiceClass(InputStream inputStream ,
+ Object service,
+ Method operation ,
+ Class[] paramClasses ,
+ int paramCount , String charSetEncoding ) throws InvocationTargetException,
+ IllegalAccessException, IOException {
+
+ Object[] methodParam = new Object[paramCount];
+ Gson gson = new Gson();
+ String[] argNames = new String[paramCount];
+ JsonReader jsonReader = null;
+
+ jsonReader = new JsonReader(new InputStreamReader(inputStream,charSetEncoding));
+
+ if( ! jsonReader.isLenient()){
+ jsonReader.setLenient(true);
+ }
+ jsonReader.beginObject();
+ String requestMethodName=jsonReader.nextName(); // get request method name from input json stream
+ if (paramCount > 1) {
+ jsonReader.beginArray();
+ }
+ int i = 0;
+ for (Class paramType : paramClasses) {
+ jsonReader.beginObject();
+ argNames[i] = jsonReader.nextName();
+ methodParam[i] = gson.fromJson(jsonReader, paramType); // gson handle all types well and retuen an object from it
+ jsonReader.endObject();
+ i++;
+ }
+ if (paramCount > 1) {
+ jsonReader.endArray();
+ }
+ jsonReader.endObject();
+
+ return operation.invoke(service, methodParam);
+
+ }
+
+ public static Method getOpMethod(String methodName, Method[] methodSet) {
+ for (Method method : methodSet) {
+ String mName = method.getName();
+ if (mName.equals(methodName)) {
+ return method;
+ }
+ }
+ return null;
+ }
+
+}
Modified: axis/axis2/java/core/trunk/modules/parent/pom.xml
URL: http://svn.apache.org/viewvc/axis/axis2/java/core/trunk/modules/parent/pom.xml?rev=1358530&r1=1358529&r2=1358530&view=diff
==============================================================================
--- axis/axis2/java/core/trunk/modules/parent/pom.xml (original)
+++ axis/axis2/java/core/trunk/modules/parent/pom.xml Sat Jul 7 09:27:15 2012
@@ -89,6 +89,7 @@
<geronimo.spec.metadata.version>1.1.2</geronimo.spec.metadata.version>
<geronimo.spec.saaj.version>1.0.1</geronimo.spec.saaj.version>
<geronimo.spec.jaxws.version>1.0</geronimo.spec.jaxws.version>
+ <google.gson.version>2.1</google.gson.version>
<httpcore.version>4.2</httpcore.version>
<httpclient.version>4.2</httpclient.version>
<intellij.version>5.0</intellij.version>
@@ -581,6 +582,11 @@
</exclusions>
</dependency>
<dependency>
+ <groupId>com.google.code.gson</groupId>
+ <artifactId>gson</artifactId>
+ <version>${google.gson.version}</version>
+ </dependency>
+ <dependency>
<groupId>org.jibx</groupId>
<artifactId>jibx-bind</artifactId>
<version>${jibx.version}</version>
Added: axis/axis2/java/core/trunk/modules/samples/json/README.txt
URL: http://svn.apache.org/viewvc/axis/axis2/java/core/trunk/modules/samples/json/README.txt?rev=1358530&view=auto
==============================================================================
--- axis/axis2/java/core/trunk/modules/samples/json/README.txt (added)
+++ axis/axis2/java/core/trunk/modules/samples/json/README.txt Sat Jul 7 09:27:15 2012
@@ -0,0 +1,46 @@
+Sample for JSON implementation first approach
+=============================================
+
+Introduction
+============
+
+This is an example for new JSON implementation which provide capability to send pure JSON string instead of any
+convention.
+
+In this sample it sends
+
+{"echoUser":{"user":{"name":"My_Name","surname":"MY_Surname","middleName":"My_MiddleName","age":123,
+ "address":{"country":"My_Country","city":"My_City","street":"My_Street","building":"My_Building","flat":"My_Flat","zipCode":"My_ZipCode"}}}}
+
+JSON request to the echoUser method and get the response as
+
+{"Response":{"name":"My_Name","surname":"MY_Surname","middleName":"My_MiddleName","age":123,
+ "address":{"country":"My_Country","city":"My_City","street":"My_Street","building":"My_Building","flat":"My_Flat","zipCode":"My_ZipCode"}}}
+
+
+Pre-Requisites
+==============
+
+Apache Ant 1.6.2 or later
+
+Running The Sample
+==================
+
+First of all add following message builder and message formatter to axis2.xml configuration file. You can find this
+configuration file in AXIS2_HOME/conf/ directory.
+
+<messageBuilder contentType="application/json-impl"
+ class="org.apache.axis2.json.impl.JsonBuilder" />
+
+<messageFormatter contentType="application/json-impl"
+ class="org.apache.axis2.json.impl.JsonFormatter" />
+
+Goto AXIS2_HOME/sample/json/ directory and
+
+Type "ant" or "ant generate.service" to generate sample JsonService.aar and cp it to AXIS2_HOME/repository/services/
+
+Then type "ant run.client" to compile client code and run the client
+
+Help
+====
+Please contact axis-user list (axis-user@ws.apache.org) if you have any trouble running the sample.
\ No newline at end of file
Added: axis/axis2/java/core/trunk/modules/samples/json/build.xml
URL: http://svn.apache.org/viewvc/axis/axis2/java/core/trunk/modules/samples/json/build.xml?rev=1358530&view=auto
==============================================================================
--- axis/axis2/java/core/trunk/modules/samples/json/build.xml (added)
+++ axis/axis2/java/core/trunk/modules/samples/json/build.xml Sat Jul 7 09:27:15 2012
@@ -0,0 +1,82 @@
+<!--
+ ~ Licensed to the Apache Software Foundation (ASF) under one
+ ~ or more contributor license agreements. See the NOTICE file
+ ~ distributed with this work for additional information
+ ~ regarding copyright ownership. The ASF licenses this file
+ ~ to you under the Apache License, Version 2.0 (the
+ ~ "License"); you may not use this file except in compliance
+ ~ with the License. You may obtain a copy of the License at
+ ~
+ ~ http://www.apache.org/licenses/LICENSE-2.0
+ ~
+ ~ Unless required by applicable law or agreed to in writing,
+ ~ software distributed under the License is distributed on an
+ ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ ~ KIND, either express or implied. See the License for the
+ ~ specific language governing permissions and limitations
+ ~ under the License.
+ -->
+
+<project name="json" basedir="." default="generate.service">
+
+ <property name="dest.dir" value="build" />
+
+ <property name="dest.dir.classes" value="${dest.dir}/classes" />
+
+ <property name="dest.dir.lib" value="${dest.dir}/lib" />
+
+ <property name="axis2.home" value="../.." />
+
+ <property name="repository.path" value="${axis2.home}/repository/services" />
+
+ <path id="axis.classpath">
+ <fileset dir="${axis2.home}/lib">
+ <include name="*.jar" />
+ </fileset>
+ <pathelement location="${dest.dir}/json-client.jar" />
+ </path>
+
+ <target name="clean">
+ <delete dir="${dest.dir}" />
+ </target>
+
+ <target name="prepare" >
+ <mkdir dir="${dest.dir}" />
+ <mkdir dir="${dest.dir.classes}" />
+ <mkdir dir="${dest.dir.lib}" />
+ <mkdir dir="${dest.dir.classes}/META-INF" />
+ <!--<copy file="resources/axis2.xml" tofile="${axis2.home}/conf/axis2.xml" overwrite="true" />-->
+
+ </target>
+
+ <target name="generate.service" depends="clean,prepare">
+ <copy file="src/META-INF/services.xml" tofile="${dest.dir.classes}/META-INF/services.xml" overwrite="true" />
+
+ <javac srcdir="src" destdir="${dest.dir.classes}">
+ <classpath refid="axis.classpath" />
+ </javac>
+
+ <jar basedir="${dest.dir.classes}" destfile="${dest.dir}/JsonService.aar" includes="sample/json/service/**,META-INF/**/"/>
+
+ <copy file="${dest.dir}/JsonService.aar" tofile="${repository.path}/JsonService.aar" overwrite="true" />
+
+ </target>
+
+ <target name="client.compile">
+ <javac srcdir="src" destdir="${dest.dir.classes}" includes="sample.json.client/**">
+ <classpath refid="axis.classpath"/>
+ </javac>
+ </target>
+
+ <target name="client.jar" depends="client.compile">
+ <jar basedir="${dest.dir.classes}" destfile="${dest.dir}/json-client.jar" includes="sample/json/client/**"/>
+ </target>
+
+ <target name="run.client" depends="client.jar">
+ <java classname="sample.json.client.JsonClient" fork="true">
+ <classpath refid="axis.classpath" />
+ </java>
+ </target>
+
+
+</project>
\ No newline at end of file
Added: axis/axis2/java/core/trunk/modules/samples/json/resources/axis2.xml
URL: http://svn.apache.org/viewvc/axis/axis2/java/core/trunk/modules/samples/json/resources/axis2.xml?rev=1358530&view=auto
==============================================================================
--- axis/axis2/java/core/trunk/modules/samples/json/resources/axis2.xml (added)
+++ axis/axis2/java/core/trunk/modules/samples/json/resources/axis2.xml Sat Jul 7 09:27:15 2012
@@ -0,0 +1,534 @@
+<!--
+ ~ Licensed to the Apache Software Foundation (ASF) under one
+ ~ or more contributor license agreements. See the NOTICE file
+ ~ distributed with this work for additional information
+ ~ regarding copyright ownership. The ASF licenses this file
+ ~ to you under the Apache License, Version 2.0 (the
+ ~ "License"); you may not use this file except in compliance
+ ~ with the License. You may obtain a copy of the License at
+ ~
+ ~ http://www.apache.org/licenses/LICENSE-2.0
+ ~
+ ~ Unless required by applicable law or agreed to in writing,
+ ~ software distributed under the License is distributed on an
+ ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ ~ KIND, either express or implied. See the License for the
+ ~ specific language governing permissions and limitations
+ ~ under the License.
+ -->
+
+<axisconfig name="AxisJava2.0">
+ <!-- ================================================= -->
+ <!-- Parameters -->
+ <!-- ================================================= -->
+ <parameter name="hotdeployment">true</parameter>
+ <parameter name="hotupdate">false</parameter>
+ <parameter name="enableMTOM">false</parameter>
+ <parameter name="enableSwA">false</parameter>
+
+ <!--Uncomment if you want to enable file caching for attachments -->
+ <!--parameter name="cacheAttachments">true</parameter>
+ <parameter name="attachmentDIR"></parameter>
+ <parameter name="sizeThreshold">4000</parameter-->
+
+ <parameter name="EnableChildFirstClassLoading">false</parameter>
+
+ <!--
+ The exposeServiceMetadata parameter decides whether the metadata (WSDL, schema, policy) of
+ the services deployed on Axis2 should be visible when ?wsdl, ?wsdl2, ?xsd, ?policy requests
+ are received.
+ This parameter can be defined in the axi2.xml file, in which case this will be applicable
+ globally, or in the services.xml files, in which case, it will be applicable to the
+ Service groups and/or services, depending on the level at which the parameter is declared.
+ This value of this parameter defaults to true.
+ -->
+ <parameter name="exposeServiceMetadata">true</parameter>
+
+
+ <!--Uncomment if you want to plugin your own attachments lifecycle implementation -->
+ <!--<attachmentsLifecycleManager class="org.apache.axiom.attachments.lifecycle.impl.LifecycleManagerImpl"/>-->
+
+
+ <!--Uncomment if you want to enable the reduction of the in-memory cache of WSDL definitions -->
+ <!--In some server environments, the available memory heap is limited and can fill up under load -->
+ <!--Since in-memory copies of WSDL definitions can be large, some steps can be taken-->
+ <!--to reduce the memory needed for the cached WSDL definitions. -->
+ <!--parameter name="reduceWSDLMemoryCache">true</parameter-->
+
+ <!--This will give out the timout of the configuration contexts, in milliseconds-->
+ <parameter name="ConfigContextTimeoutInterval">30000</parameter>
+
+ <!--During a fault, stack trace can be sent with the fault message. The following flag will control -->
+ <!--that behavior.-->
+ <parameter name="sendStacktraceDetailsWithFaults">false</parameter>
+
+ <!--If there aren't any information available to find out the fault reason, we set the message of the exception-->
+ <!--as the faultreason/Reason. But when a fault is thrown from a service or some where, it will be -->
+ <!--wrapped by different levels. Due to this the initial exception message can be lost. If this flag-->
+ <!--is set, then Axis2 tries to get the first exception and set its message as the faultreason/Reason.-->
+ <parameter name="DrillDownToRootCauseForFaultReason">false</parameter>
+
+ <parameter name="userName">admin</parameter>
+ <parameter name="password">axis2</parameter>
+
+ <!--To override repository/services you need to uncomment following parameter and value SHOULD be absolute file path.-->
+ <!--ServicesDirectory only works on the following cases-->
+ <!---File based configurator and in that case the value should be a file URL (http:// not allowed)-->
+ <!---When creating URL Based configurator with URL file:// -->
+ <!--- War based configurator with expanded case , -->
+
+ <!--All the other scenarios it will be ignored.-->
+ <!--<parameter name="ServicesDirectory">service</parameter>-->
+ <!--To override repository/modules you need to uncomment following parameter and value SHOULD be absolute file path-->
+ <!--<parameter name="ModulesDirectory">modules</parameter>-->
+
+
+ <!--Following params will set the proper context paths for invocations. All the endpoints will have a commons context-->
+ <!--root which can configured using the following contextRoot parameter-->
+ <!--<parameter name="contextRoot">axis2</parameter>-->
+
+ <!--Our HTTP endpoints can handle both REST and SOAP. Following parameters can be used to distinguiush those endpoints-->
+ <!--In case of a servlet, if you change this you have to manually change the settings of your servlet container to map this -->
+ <!--context path to proper Axis2 servlets-->
+ <!--<parameter name="servicePath">services</parameter>-->
+ <!--<parameter name="restPath">rest</parameter>-->
+
+ <!-- Following parameter will completely disable REST handling in Axis2-->
+ <parameter name="disableREST" locked="false">false</parameter>
+
+ <!-- Following parameter will suppress generation of SOAP 1.2 bindings in auto-generated WSDL files -->
+ <parameter name="disableSOAP12" locked="true">false</parameter>
+
+ <!--POJO deployer , this will alow users to drop .class file and make that into a service-->
+ <deployer extension=".class" directory="pojo" class="org.apache.axis2.deployment.POJODeployer"/>
+ <deployer extension=".jar" directory="servicejars"
+ class="org.apache.axis2.jaxws.framework.JAXWSDeployer"/>
+ <deployer extension=".jar" directory="transports"
+ class="org.apache.axis2.deployment.TransportDeployer"/>
+
+ <!--CORBA deployer , this will alow users to invoke remote CORBA services through Axis2-->
+ <!--<deployer extension=".xml" directory="corba" class="org.apache.axis2.corba.deployer.CorbaDeployer"/>-->
+
+ <!--<deployer extension=".jsa" directory="rmiservices" class="org.apache.axis2.rmi.deploy.RMIServiceDeployer"/>-->
+
+
+ <!-- Following parameter will set the host name for the epr-->
+ <!--<parameter name="hostname" locked="true">myhost.com</parameter>-->
+
+ <!-- If you have a front end host which exposes this webservice using a different public URL -->
+ <!-- use this parameter to override autodetected url -->
+ <!--<parameter name="httpFrontendHostUrl">https://someotherhost/context</parameter>-->
+
+ <!--By default, JAXWS services are created by reading annotations. WSDL and schema are generated-->
+ <!--using a separate WSDL generator only when ?wsdl is called. Therefore, even if you engage-->
+ <!--policies etc.. to AxisService, it doesn't appear in the WSDL. By setting the following property-->
+ <!--to true, you can create the AxisService using the generated WSDL and remove the need for a-->
+ <!--WSDL generator. When ?wsdl is called, WSDL is generated in the normal way.-->
+ <parameter name="useGeneratedWSDLinJAXWS">false</parameter>
+
+ <!-- The way of adding listener to the system-->
+ <!-- <listener class="org.apache.axis2.ObserverIMPL">-->
+ <!-- <parameter name="RSS_URL">http://127.0.0.1/rss</parameter>-->
+ <!-- </listener>-->
+
+ <threadContextMigrators>
+ <threadContextMigrator listId="JAXWS-ThreadContextMigrator-List"
+ class="org.apache.axis2.jaxws.addressing.migrator.EndpointContextMapMigrator"/>
+ </threadContextMigrators>
+
+ <!-- ================================================= -->
+ <!-- Message Receivers -->
+ <!-- ================================================= -->
+ <!--This is the default MessageReceiver for the system , if you want to have MessageReceivers for -->
+ <!--all the other MEP implement it and add the correct entry to here , so that you can refer from-->
+ <!--any operation -->
+ <!--Note : You can override this for a particular service by adding the same element with your requirement-->
+ <messageReceivers>
+ <messageReceiver mep="http://www.w3.org/2004/08/wsdl/in-only"
+ class="org.apache.axis2.receivers.RawXMLINOnlyMessageReceiver"/>
+ <messageReceiver mep="http://www.w3.org/2004/08/wsdl/in-out"
+ class="org.apache.axis2.receivers.RawXMLINOutMessageReceiver"/>
+ <messageReceiver mep="http://www.w3.org/2006/01/wsdl/in-only"
+ class="org.apache.axis2.receivers.RawXMLINOnlyMessageReceiver"/>
+ <messageReceiver mep="http://www.w3.org/2006/01/wsdl/in-out"
+ class="org.apache.axis2.receivers.RawXMLINOutMessageReceiver"/>
+ <messageReceiver mep="http://www.w3.org/ns/wsdl/in-only"
+ class="org.apache.axis2.receivers.RawXMLINOnlyMessageReceiver"/>
+ <messageReceiver mep="http://www.w3.org/ns/wsdl/in-out"
+ class="org.apache.axis2.receivers.RawXMLINOutMessageReceiver"/>
+ </messageReceivers>
+
+ <!-- ================================================= -->
+ <!-- Message Formatter -->
+ <!-- ================================================= -->
+ <!--Following content type to message formatter mapping can be used to implement support for different message -->
+ <!--format serialization in Axis2. These message formats are expected to be resolved based on the content type. -->
+ <messageFormatters>
+ <messageFormatter contentType="application/x-www-form-urlencoded"
+ class="org.apache.axis2.transport.http.XFormURLEncodedFormatter"/>
+ <messageFormatter contentType="multipart/form-data"
+ class="org.apache.axis2.transport.http.MultipartFormDataFormatter"/>
+ <messageFormatter contentType="application/xml"
+ class="org.apache.axis2.transport.http.ApplicationXMLFormatter"/>
+ <messageFormatter contentType="text/xml"
+ class="org.apache.axis2.transport.http.SOAPMessageFormatter"/>
+ <messageFormatter contentType="application/soap+xml"
+ class="org.apache.axis2.transport.http.SOAPMessageFormatter"/>
+
+ <messageFormatter contentType="application/json-impl"
+ class="org.apache.axis2.json.impl.JsonFormatter" />
+ </messageFormatters>
+
+ <!-- ================================================= -->
+ <!-- Message Builders -->
+ <!-- ================================================= -->
+ <!--Following content type to builder mapping can be used to implement support for different message -->
+ <!--formats in Axis2. These message formats are expected to be resolved based on the content type. -->
+ <messageBuilders>
+ <messageBuilder contentType="application/xml"
+ class="org.apache.axis2.builder.ApplicationXMLBuilder"/>
+ <messageBuilder contentType="application/x-www-form-urlencoded"
+ class="org.apache.axis2.builder.XFormURLEncodedBuilder"/>
+ <messageBuilder contentType="multipart/form-data"
+ class="org.apache.axis2.builder.MultipartFormDataBuilder"/>
+
+ <messageBuilder contentType="application/json-impl"
+ class="org.apache.axis2.json.impl.JsonBuilder" />
+ </messageBuilders>
+
+ <!-- ================================================= -->
+ <!-- Transport Ins -->
+ <!-- ================================================= -->
+ <transportReceiver name="http"
+ class="org.apache.axis2.transport.http.SimpleHTTPServer">
+ <parameter name="port">8080</parameter>
+ <!-- Here is the complete list of supported parameters (see example settings further below):
+ port: the port to listen on (default 6060)
+ hostname: if non-null, url prefix used in reply-to endpoint references (default null)
+ originServer: value of http Server header in outgoing messages (default "Simple-Server/1.1")
+ requestTimeout: value in millis of time that requests can wait for data (default 20000)
+ requestTcpNoDelay: true to maximize performance and minimize latency (default true)
+ false to minimize bandwidth consumption by combining segments
+ requestCoreThreadPoolSize: number of threads available for request processing (unless queue fills up) (default 25)
+ requestMaxThreadPoolSize: number of threads available for request processing if queue fills up (default 150)
+ note that default queue never fills up: see HttpFactory
+ threadKeepAliveTime: time to keep threads in excess of core size alive while inactive (default 180)
+ note that no such threads can exist with default unbounded request queue
+ threadKeepAliveTimeUnit: TimeUnit of value in threadKeepAliveTime (default SECONDS) (default SECONDS)
+ -->
+ <!-- <parameter name="hostname">http://www.myApp.com/ws</parameter> -->
+ <!-- <parameter name="originServer">My-Server/1.1</parameter> -->
+ <!-- <parameter name="requestTimeout">10000</parameter> -->
+ <!-- <parameter name="requestTcpNoDelay">false</parameter> -->
+ <!-- <parameter name="requestCoreThreadPoolSize">50</parameter> -->
+ <!-- <parameter name="requestMaxThreadPoolSize">100</parameter> -->
+ <!-- <parameter name="threadKeepAliveTime">240000</parameter> -->
+ <!-- <parameter name="threadKeepAliveTimeUnit">MILLISECONDS</parameter> -->
+ </transportReceiver>
+
+ <!-- This is where you'd put custom transports. See the transports project -->
+ <!-- for more. http://ws.apache.org/commons/transport -->
+
+ <!-- ================================================= -->
+ <!-- Transport Outs -->
+ <!-- ================================================= -->
+
+ <transportSender name="local"
+ class="org.apache.axis2.transport.local.LocalTransportSender"/>
+ <transportSender name="http"
+ class="org.apache.axis2.transport.http.CommonsHTTPTransportSender">
+ <parameter name="PROTOCOL">HTTP/1.1</parameter>
+ <parameter name="Transfer-Encoding">chunked</parameter>
+
+ <!-- If following is set to 'true', optional action part of the Content-Type will not be added to the SOAP 1.2 messages -->
+ <!-- <parameter name="OmitSOAP12Action">true</parameter> -->
+ </transportSender>
+
+ <transportSender name="https"
+ class="org.apache.axis2.transport.http.CommonsHTTPTransportSender">
+ <parameter name="PROTOCOL">HTTP/1.1</parameter>
+ <parameter name="Transfer-Encoding">chunked</parameter>
+ </transportSender>
+
+ <!-- Please enable this if you need the java transport -->
+ <!-- <transportSender name="java"
+ class="org.apache.axis2.transport.java.JavaTransportSender"/> -->
+
+ <!-- ================================================= -->
+ <!-- Global Modules -->
+ <!-- ================================================= -->
+ <!-- Comment this to disable Addressing -->
+ <module ref="addressing"/>
+
+ <!--Configuring module , providing parameters for modules whether they refer or not-->
+ <!--<moduleConfig name="addressing">-->
+ <!--<parameter name="addressingPara">N/A</parameter>-->
+ <!--</moduleConfig>-->
+
+ <!-- ================================================= -->
+ <!-- Clustering -->
+ <!-- ================================================= -->
+ <!--
+ To enable clustering for this node, set the value of "enable" attribute of the "clustering"
+ element to "true". The initialization of a node in the cluster is handled by the class
+ corresponding to the "class" attribute of the "clustering" element. It is also responsible for
+ getting this node to join the cluster.
+ -->
+ <clustering class="org.apache.axis2.clustering.tribes.TribesClusteringAgent" enable="false">
+
+ <!--
+ This parameter indicates whether the cluster has to be automatically initalized
+ when the AxisConfiguration is built. If set to "true" the initialization will not be
+ done at that stage, and some other party will have to explictly initialize the cluster.
+ -->
+ <parameter name="AvoidInitiation">true</parameter>
+
+ <!--
+ The membership scheme used in this setup. The only values supported at the moment are
+ "multicast" and "wka"
+
+ 1. multicast - membership is automatically discovered using multicasting
+ 2. wka - Well-Known Address based multicasting. Membership is discovered with the help
+ of one or more nodes running at a Well-Known Address. New members joining a
+ cluster will first connect to a well-known node, register with the well-known node
+ and get the membership list from it. When new members join, one of the well-known
+ nodes will notify the others in the group. When a member leaves the cluster or
+ is deemed to have left the cluster, it will be detected by the Group Membership
+ Service (GMS) using a TCP ping mechanism.
+ -->
+ <parameter name="membershipScheme">multicast</parameter>
+
+ <!--
+ The clustering domain/group. Nodes in the same group will belong to the same multicast
+ domain. There will not be interference between nodes in different groups.
+ -->
+ <parameter name="domain">wso2.carbon.domain</parameter>
+
+ <!--
+ When a Web service request is received, and processed, before the response is sent to the
+ client, should we update the states of all members in the cluster? If the value of
+ this parameter is set to "true", the response to the client will be sent only after
+ all the members have been updated. Obviously, this can be time consuming. In some cases,
+ such this overhead may not be acceptable, in which case the value of this parameter
+ should be set to "false"
+ -->
+ <parameter name="synchronizeAll">true</parameter>
+
+ <!--
+ The maximum number of times we need to retry to send a message to a particular node
+ before giving up and considering that node to be faulty
+ -->
+ <parameter name="maxRetries">10</parameter>
+
+ <!-- The multicast address to be used -->
+ <parameter name="mcastAddress">228.0.0.4</parameter>
+
+ <!-- The multicast port to be used -->
+ <parameter name="mcastPort">45564</parameter>
+
+ <!-- The frequency of sending membership multicast messages (in ms) -->
+ <parameter name="mcastFrequency">500</parameter>
+
+ <!-- The time interval within which if a member does not respond, the member will be
+ deemed to have left the group (in ms)
+ -->
+ <parameter name="memberDropTime">3000</parameter>
+
+ <!--
+ The IP address of the network interface to which the multicasting has to be bound to.
+ Multicasting would be done using this interface.
+ -->
+ <parameter name="mcastBindAddress">127.0.0.1</parameter>
+
+ <!-- The host name or IP address of this member -->
+ <parameter name="localMemberHost">127.0.0.1</parameter>
+
+ <!--
+ The TCP port used by this member. This is the port through which other nodes will
+ contact this member
+ -->
+ <parameter name="localMemberPort">4000</parameter>
+
+ <!--
+ Preserve message ordering. This will be done according to sender order.
+ -->
+ <parameter name="preserveMessageOrder">true</parameter>
+
+ <!--
+ Maintain atmost-once message processing semantics
+ -->
+ <parameter name="atmostOnceMessageSemantics">true</parameter>
+
+ <!--
+ Properties specific to this member
+ -->
+ <parameter name="properties">
+ <property name="backendServerURL" value="https://${hostName}:${httpsPort}/services/"/>
+ <property name="mgtConsoleURL" value="https://${hostName}:${httpsPort}/"/>
+ </parameter>
+
+ <!--
+ The list of static or well-known members. These entries will only be valid if the
+ "membershipScheme" above is set to "wka"
+ -->
+ <members>
+ <member>
+ <hostName>127.0.0.1</hostName>
+ <port>4000</port>
+ </member>
+ <member>
+ <hostName>127.0.0.1</hostName>
+ <port>4001</port>
+ </member>
+ </members>
+
+ <!--
+ Enable the groupManagement entry if you need to run this node as a cluster manager.
+ Multiple application domains with different GroupManagementAgent implementations
+ can be defined in this section.
+ -->
+ <groupManagement enable="false">
+ <applicationDomain name="apache.axis2.application.domain"
+ description="Axis2 group"
+ agent="org.apache.axis2.clustering.management.DefaultGroupManagementAgent"/>
+ </groupManagement>
+
+ <!--
+ This interface is responsible for handling management of a specific node in the cluster
+ The "enable" attribute indicates whether Node management has been enabled
+ -->
+ <nodeManager class="org.apache.axis2.clustering.management.DefaultNodeManager"
+ enable="true"/>
+
+ <!--
+ This interface is responsible for handling state replication. The property changes in
+ the Axis2 context hierarchy in this node, are propagated to all other nodes in the cluster.
+
+ The "excludes" patterns can be used to specify the prefixes (e.g. local_*) or
+ suffixes (e.g. *_local) of the properties to be excluded from replication. The pattern
+ "*" indicates that all properties in a particular context should not be replicated.
+
+ The "enable" attribute indicates whether context replication has been enabled
+ -->
+ <stateManager class="org.apache.axis2.clustering.state.DefaultStateManager"
+ enable="true">
+ <replication>
+ <defaults>
+ <exclude name="local_*"/>
+ <exclude name="LOCAL_*"/>
+ </defaults>
+ <context class="org.apache.axis2.context.ConfigurationContext">
+ <exclude name="local_*"/>
+ </context>
+ <context class="org.apache.axis2.context.ServiceGroupContext">
+ <exclude name="local_*"/>
+ </context>
+ <context class="org.apache.axis2.context.ServiceContext">
+ <exclude name="local_*"/>
+ </context>
+ </replication>
+ </stateManager>
+ </clustering>
+
+ <!-- ================================================= -->
+ <!-- Phases -->
+ <!-- ================================================= -->
+ <phaseOrder type="InFlow">
+ <!-- System predefined phases -->
+ <phase name="Transport">
+ <handler name="RequestURIBasedDispatcher"
+ class="org.apache.axis2.dispatchers.RequestURIBasedDispatcher">
+ <order phase="Transport"/>
+ </handler>
+ <handler name="SOAPActionBasedDispatcher"
+ class="org.apache.axis2.dispatchers.SOAPActionBasedDispatcher">
+ <order phase="Transport"/>
+ </handler>
+ </phase>
+ <phase name="Addressing">
+ <handler name="AddressingBasedDispatcher"
+ class="org.apache.axis2.dispatchers.AddressingBasedDispatcher">
+ <order phase="Addressing"/>
+ </handler>
+ </phase>
+ <phase name="Security"/>
+ <phase name="PreDispatch"/>
+ <phase name="Dispatch" class="org.apache.axis2.engine.DispatchPhase">
+ <handler name="RequestURIBasedDispatcher"
+ class="org.apache.axis2.dispatchers.RequestURIBasedDispatcher"/>
+ <handler name="SOAPActionBasedDispatcher"
+ class="org.apache.axis2.dispatchers.SOAPActionBasedDispatcher"/>
+ <handler name="RequestURIOperationDispatcher"
+ class="org.apache.axis2.dispatchers.RequestURIOperationDispatcher"/>
+ <handler name="SOAPMessageBodyBasedDispatcher"
+ class="org.apache.axis2.dispatchers.SOAPMessageBodyBasedDispatcher"/>
+ <handler name="HTTPLocationBasedDispatcher"
+ class="org.apache.axis2.dispatchers.HTTPLocationBasedDispatcher"/>
+ <handler name="GenericProviderDispatcher"
+ class="org.apache.axis2.jaxws.dispatchers.GenericProviderDispatcher"/>
+ <handler name="MustUnderstandValidationDispatcher"
+ class="org.apache.axis2.jaxws.dispatchers.MustUnderstandValidationDispatcher"/>
+ </phase>
+ <phase name="RMPhase"/>
+ <!-- System predefined phases -->
+ <!-- After Postdispatch phase module author or service author can add any phase he want -->
+ <phase name="OperationInPhase">
+ <handler name="MustUnderstandChecker"
+ class="org.apache.axis2.jaxws.dispatchers.MustUnderstandChecker">
+ <order phase="OperationInPhase"/>
+ </handler>
+ </phase>
+ <phase name="soapmonitorPhase"/>
+ </phaseOrder>
+ <phaseOrder type="OutFlow">
+ <!-- user can add his own phases to this area -->
+ <phase name="soapmonitorPhase"/>
+ <phase name="OperationOutPhase"/>
+ <!--system predefined phase-->
+ <!--these phase will run irrespective of the service-->
+ <phase name="RMPhase"/>
+ <phase name="PolicyDetermination"/>
+ <phase name="MessageOut"/>
+ <phase name="Security"/>
+ </phaseOrder>
+ <phaseOrder type="InFaultFlow">
+ <phase name="Addressing">
+ <handler name="AddressingBasedDispatcher"
+ class="org.apache.axis2.dispatchers.AddressingBasedDispatcher">
+ <order phase="Addressing"/>
+ </handler>
+ </phase>
+ <phase name="Security"/>
+ <phase name="PreDispatch"/>
+ <phase name="Dispatch" class="org.apache.axis2.engine.DispatchPhase">
+ <handler name="RequestURIBasedDispatcher"
+ class="org.apache.axis2.dispatchers.RequestURIBasedDispatcher"/>
+ <handler name="SOAPActionBasedDispatcher"
+ class="org.apache.axis2.dispatchers.SOAPActionBasedDispatcher"/>
+ <handler name="RequestURIOperationDispatcher"
+ class="org.apache.axis2.dispatchers.RequestURIOperationDispatcher"/>
+ <handler name="SOAPMessageBodyBasedDispatcher"
+ class="org.apache.axis2.dispatchers.SOAPMessageBodyBasedDispatcher"/>
+ <handler name="HTTPLocationBasedDispatcher"
+ class="org.apache.axis2.dispatchers.HTTPLocationBasedDispatcher"/>
+ <handler name="GenericProviderDispatcher"
+ class="org.apache.axis2.jaxws.dispatchers.GenericProviderDispatcher"/>
+ <handler name="MustUnderstandValidationDispatcher"
+ class="org.apache.axis2.jaxws.dispatchers.MustUnderstandValidationDispatcher"/>
+ </phase>
+ <phase name="RMPhase"/>
+ <!-- user can add his own phases to this area -->
+ <phase name="OperationInFaultPhase"/>
+ <phase name="soapmonitorPhase"/>
+ </phaseOrder>
+ <phaseOrder type="OutFaultFlow">
+ <!-- user can add his own phases to this area -->
+ <phase name="soapmonitorPhase"/>
+ <phase name="OperationOutFaultPhase"/>
+ <phase name="RMPhase"/>
+ <phase name="PolicyDetermination"/>
+ <phase name="MessageOut"/>
+ <phase name="Security"/>
+ </phaseOrder>
+</axisconfig>
+
Added: axis/axis2/java/core/trunk/modules/samples/json/src/META-INF/services.xml
URL: http://svn.apache.org/viewvc/axis/axis2/java/core/trunk/modules/samples/json/src/META-INF/services.xml?rev=1358530&view=auto
==============================================================================
--- axis/axis2/java/core/trunk/modules/samples/json/src/META-INF/services.xml (added)
+++ axis/axis2/java/core/trunk/modules/samples/json/src/META-INF/services.xml Sat Jul 7 09:27:15 2012
@@ -0,0 +1,12 @@
+<service name="JsonService">
+ <Description>
+ This is a sample service to test json implementation
+ </Description>
+ <messageReceivers>
+ <messageReceiver mep="http://www.w3.org/ns/wsdl/in-out"
+ class="org.apache.axis2.json.impl.rpc.JsonRpcMessageReceiver" />
+ <messageReceiver mep="http://www.w3.org/ns/wsdl/in-only"
+ class="org.apache.axis2.json.impl.rpc.JsonInOnlyRPCMessageReceiver"/>
+ </messageReceivers>
+ <parameter name="ServiceClass" locked="false">sample.json.service.JsonService</parameter>
+</service>
\ No newline at end of file
Added: axis/axis2/java/core/trunk/modules/samples/json/src/sample/json/client/JsonClient.java
URL: http://svn.apache.org/viewvc/axis/axis2/java/core/trunk/modules/samples/json/src/sample/json/client/JsonClient.java?rev=1358530&view=auto
==============================================================================
--- axis/axis2/java/core/trunk/modules/samples/json/src/sample/json/client/JsonClient.java (added)
+++ axis/axis2/java/core/trunk/modules/samples/json/src/sample/json/client/JsonClient.java Sat Jul 7 09:27:15 2012
@@ -0,0 +1,65 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package sample.json.client;
+
+import org.apache.commons.httpclient.HttpClient;
+import org.apache.commons.httpclient.HttpException;
+import org.apache.commons.httpclient.methods.PostMethod;
+import org.apache.commons.httpclient.methods.RequestEntity;
+import org.apache.commons.httpclient.methods.StringRequestEntity;
+
+import java.io.IOException;
+import java.io.UnsupportedEncodingException;
+
+public class JsonClient{
+
+ private String url = "http://localhost:8080/axis2/services/JsonService/echoUser";
+ private String contentType = "application/json-impl";
+ private String charSet = "UTF-8";
+
+ public static void main(String[] args)throws IOException {
+ String echoUser = "{\"echoUser\":{\"user\":{\"name\":\"My_Name\",\"surname\":\"MY_Surname\",\"middleName\":" +
+ "\"My_MiddleName\",\"age\":123,\"address\":{\"country\":\"My_Country\",\"city\":\"My_City\",\"street\":" +
+ "\"My_Street\",\"building\":\"My_Building\",\"flat\":\"My_Flat\",\"zipCode\":\"My_ZipCode\"}}}}";
+
+ JsonClient jsonClient = new JsonClient();
+ jsonClient.post(sampleString);
+ }
+
+ public boolean post(String message) throws UnsupportedEncodingException {
+ PostMethod post = new PostMethod(url);
+ RequestEntity entity = new StringRequestEntity(message , contentType, charSet);
+ post.setRequestEntity(entity);
+ HttpClient httpclient = new HttpClient();
+ try {
+ int result = httpclient.executeMethod(post);
+ System.out.println("Response status code: " + result);
+ System.out.println("Response body: ");
+ System.out.println(post.getResponseBodyAsString());
+ } catch (HttpException e) {
+ e.printStackTrace();
+ } catch (IOException e) {
+ e.printStackTrace();
+ } finally {
+ post.releaseConnection();
+ }
+ return false;
+ }
+}
Added: axis/axis2/java/core/trunk/modules/samples/json/src/sample/json/service/Address.java
URL: http://svn.apache.org/viewvc/axis/axis2/java/core/trunk/modules/samples/json/src/sample/json/service/Address.java?rev=1358530&view=auto
==============================================================================
--- axis/axis2/java/core/trunk/modules/samples/json/src/sample/json/service/Address.java (added)
+++ axis/axis2/java/core/trunk/modules/samples/json/src/sample/json/service/Address.java Sat Jul 7 09:27:15 2012
@@ -0,0 +1,78 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package sample.json.service;
+
+
+public class Address {
+ private String country;
+ private String city;
+ private String street;
+ private String building;
+ private String flat;
+ private String zipCode;
+
+ public String getCountry() {
+ return country;
+ }
+
+ public void setCountry(String country) {
+ this.country = country;
+ }
+
+ public String getCity() {
+ return city;
+ }
+
+ public void setCity(String city) {
+ this.city = city;
+ }
+
+ public String getStreet() {
+ return street;
+ }
+
+ public void setStreet(String street) {
+ this.street = street;
+ }
+
+ public String getBuilding() {
+ return building;
+ }
+
+ public void setBuilding(String building) {
+ this.building = building;
+ }
+
+ public String getFlat() {
+ return flat;
+ }
+
+ public void setFlat(String flat) {
+ this.flat = flat;
+ }
+
+ public String getZipCode() {
+ return zipCode;
+ }
+
+ public void setZipCode(String zipCode) {
+ this.zipCode = zipCode;
+ }
+}
\ No newline at end of file
Added: axis/axis2/java/core/trunk/modules/samples/json/src/sample/json/service/JsonService.java
URL: http://svn.apache.org/viewvc/axis/axis2/java/core/trunk/modules/samples/json/src/sample/json/service/JsonService.java?rev=1358530&view=auto
==============================================================================
--- axis/axis2/java/core/trunk/modules/samples/json/src/sample/json/service/JsonService.java (added)
+++ axis/axis2/java/core/trunk/modules/samples/json/src/sample/json/service/JsonService.java Sat Jul 7 09:27:15 2012
@@ -0,0 +1,42 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package sample.json.service;
+
+import org.apache.axiom.om.OMElement;
+import java.lang.String;
+
+public class JsonService {
+
+ public User echoUser(User user) {
+ return user;
+ }
+
+ public String echoString(String echoString){
+ System.out.println(echoString);
+ return echoString;
+ }
+
+ public void pingString(String pingString) {
+
+ }
+
+
+
+}
\ No newline at end of file
Added: axis/axis2/java/core/trunk/modules/samples/json/src/sample/json/service/User.java
URL: http://svn.apache.org/viewvc/axis/axis2/java/core/trunk/modules/samples/json/src/sample/json/service/User.java?rev=1358530&view=auto
==============================================================================
--- axis/axis2/java/core/trunk/modules/samples/json/src/sample/json/service/User.java (added)
+++ axis/axis2/java/core/trunk/modules/samples/json/src/sample/json/service/User.java Sat Jul 7 09:27:15 2012
@@ -0,0 +1,68 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package sample.json.service;
+
+public class User {
+ private String name;
+ private String surname;
+ private String middleName;
+ private int age;
+ private Address address;
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public String getSurname() {
+ return surname;
+ }
+
+ public void setSurname(String surname) {
+ this.surname = surname;
+ }
+
+ public String getMiddleName() {
+ return middleName;
+ }
+
+ public void setMiddleName(String middleName) {
+ this.middleName = middleName;
+ }
+
+ public int getAge() {
+ return age;
+ }
+
+ public void setAge(int age) {
+ this.age = age;
+ }
+
+ public Address getAddress() {
+ return address;
+ }
+
+ public void setAddress(Address address) {
+ this.address = address;
+ }
+}
\ No newline at end of file