This is an automated email from the ASF dual-hosted git repository.
robertlazarski pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/axis-axis2-java-core.git
The following commit(s) were added to refs/heads/master by this push:
new 408f35a439 AXIS2-6071 Add new class JSONBasedDefaultDispatcher that
skips legacy SOAP code
408f35a439 is described below
commit 408f35a439671ab147d552b9441ea5505a26c943
Author: Robert Lazarski
AuthorDate: Thu Jul 18 10:49:31 2024 -1000
AXIS2-6071 Add new class JSONBasedDefaultDispatcher that skips legacy SOAP
code
---
.../apache/axis2/json/factory/JsonConstant.java| 2 +
.../apache/axis2/json/gson/JSONMessageHandler.java | 34 +-
.../gson/rpc/JsonInOnlyRPCMessageReceiver.java | 7 +-
.../json/gson/rpc/JsonRpcMessageReceiver.java | 8 +-
.../org/apache/axis2/json/gson/rpc/JsonUtils.java | 25 +++--
.../axis2/json/moshi/JSONMessageHandler.java | 32 +-
.../moshi/rpc/JsonInOnlyRPCMessageReceiver.java| 7 +-
.../json/moshi/rpc/JsonRpcMessageReceiver.java | 8 +-
.../org/apache/axis2/json/moshi/rpc/JsonUtils.java | 23 ++--
.../org/apache/axis2/deployment/util/Utils.java| 73 +
.../org/apache/axis2/description/AxisService.java | 64 +++
.../dispatchers/JSONBasedDefaultDispatcher.java| 118 +
.../springbootdemo/resources-axis2/conf/axis2.xml | 44 +---
src/site/xdoc/docs/json-springboot-userguide.xml | 2 +-
14 files changed, 370 insertions(+), 77 deletions(-)
diff --git a/modules/json/src/org/apache/axis2/json/factory/JsonConstant.java
b/modules/json/src/org/apache/axis2/json/factory/JsonConstant.java
index 9effd0882f..f4ad434861 100644
--- a/modules/json/src/org/apache/axis2/json/factory/JsonConstant.java
+++ b/modules/json/src/org/apache/axis2/json/factory/JsonConstant.java
@@ -34,6 +34,8 @@ public class JsonConstant {
public static final String MOSHI_XML_STREAM_READER =
"MoshiXMLStreamReader";
+public static final String JSON_MESSAGE_NAME = "jsonMessageName";
+
public static final String XMLNODES = "xmlnodes";
diff --git
a/modules/json/src/org/apache/axis2/json/gson/JSONMessageHandler.java
b/modules/json/src/org/apache/axis2/json/gson/JSONMessageHandler.java
index 7cee12aa4c..f7bfadea3d 100644
--- a/modules/json/src/org/apache/axis2/json/gson/JSONMessageHandler.java
+++ b/modules/json/src/org/apache/axis2/json/gson/JSONMessageHandler.java
@@ -35,7 +35,10 @@ import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.ws.commons.schema.XmlSchema;
+import com.google.gson.stream.JsonReader;
+
import javax.xml.namespace.QName;
+import java.io.IOException;
import java.util.List;
public class JSONMessageHandler extends AbstractHandler {
@@ -73,7 +76,6 @@ public class JSONMessageHandler extends AbstractHandler {
log.debug("JSON MessageReceiver found, proceeding with the
JSON request");
Object tempObj =
msgContext.getProperty(JsonConstant.IS_JSON_STREAM);
if (tempObj != null) {
-log.debug("JSON MessageReceiver found JSON stream,
proceeding with the JSON request");
boolean isJSON = Boolean.valueOf(tempObj.toString());
Object o =
msgContext.getProperty(JsonConstant.GSON_XML_STREAM_READER);
if (o != null) {
@@ -83,7 +85,6 @@ public class JSONMessageHandler extends AbstractHandler {
gsonXMLStreamReader.initXmlStreamReader(elementQname,
schemas, msgContext.getConfigurationContext());
OMXMLParserWrapper stAXOMBuilder =
OMXMLBuilderFactory.createStAXOMBuilder(gsonXMLStreamReader);
OMElement omElement =
stAXOMBuilder.getDocumentElement();
-log.debug("GsonXMLStreamReader found elementQname: " +
elementQname);
msgContext.getEnvelope().getBody().addChild(omElement);
} else {
log.error("GsonXMLStreamReader is null");
@@ -94,7 +95,34 @@ public class JSONMessageHandler extends AbstractHandler {
}
}
} else {
-log.debug("Axis operation is null, message hasn't been dispatched
to operation, ignore it");
+String enableJSONOnly = (String)
msgContext.getAxisService().getParameterValue("enableJSONOnly");
+if (enableJSONOnly !=null &&
enableJSONOnly.equalsIgnoreCase("true")) {
+log.warn("On enableJSONOnly=true Axis operation is null on
JSON request, message hasn't been dispatched to an operation, proceeding on
JSON message name discovery and AxisOperation mapping");
+try{
+Object tempObj =
msgContext.getProperty(JsonConstant.IS_JSON_STREAM);
+if (tempObj != null) {
+boolean isJSON = Boolean.valu