AP-6003 create org.apache.axis2.json.factory and use it for gson and moshi
diff --git a/modules/json/src/org/apache/axis2/json/gson/factory/JSONType.java b/modules/json/src/org/apache/axis2/json/factory/JSONType.java
similarity index 95%
rename from modules/json/src/org/apache/axis2/json/gson/factory/JSONType.java
rename to modules/json/src/org/apache/axis2/json/factory/JSONType.java
index b9ad859..8ecfe3e 100644
--- a/modules/json/src/org/apache/axis2/json/gson/factory/JSONType.java
+++ b/modules/json/src/org/apache/axis2/json/factory/JSONType.java
@@ -17,7 +17,7 @@
* under the License.
*/
-package org.apache.axis2.json.gson.factory;
+package org.apache.axis2.json.factory;
public enum JSONType {
ARRAY,
diff --git a/modules/json/src/org/apache/axis2/json/moshi/factory/JsonConstant.java b/modules/json/src/org/apache/axis2/json/factory/JsonConstant.java
similarity index 96%
rename from modules/json/src/org/apache/axis2/json/moshi/factory/JsonConstant.java
rename to modules/json/src/org/apache/axis2/json/factory/JsonConstant.java
index 3f887b4..9effd08 100644
--- a/modules/json/src/org/apache/axis2/json/moshi/factory/JsonConstant.java
+++ b/modules/json/src/org/apache/axis2/json/factory/JsonConstant.java
@@ -17,7 +17,7 @@
* under the License.
*/
-package org.apache.axis2.json.moshi.factory;
+package org.apache.axis2.json.factory;
public class JsonConstant {
diff --git a/modules/json/src/org/apache/axis2/json/gson/factory/JsonObject.java b/modules/json/src/org/apache/axis2/json/factory/JsonObject.java
similarity index 96%
rename from modules/json/src/org/apache/axis2/json/gson/factory/JsonObject.java
rename to modules/json/src/org/apache/axis2/json/factory/JsonObject.java
index d3d1c05..d65ea52 100644
--- a/modules/json/src/org/apache/axis2/json/gson/factory/JsonObject.java
+++ b/modules/json/src/org/apache/axis2/json/factory/JsonObject.java
@@ -17,7 +17,7 @@
* under the License.
*/
-package org.apache.axis2.json.gson.factory;
+package org.apache.axis2.json.factory;
public class JsonObject {
diff --git a/modules/json/src/org/apache/axis2/json/moshi/factory/XmlNode.java b/modules/json/src/org/apache/axis2/json/factory/XmlNode.java
similarity index 97%
rename from modules/json/src/org/apache/axis2/json/moshi/factory/XmlNode.java
rename to modules/json/src/org/apache/axis2/json/factory/XmlNode.java
index 47c2ded..a2e6d1d 100644
--- a/modules/json/src/org/apache/axis2/json/moshi/factory/XmlNode.java
+++ b/modules/json/src/org/apache/axis2/json/factory/XmlNode.java
@@ -17,7 +17,7 @@
* under the License.
*/
-package org.apache.axis2.json.moshi.factory;
+package org.apache.axis2.json.factory;
import java.util.ArrayList;
import java.util.List;
diff --git a/modules/json/src/org/apache/axis2/json/moshi/factory/XmlNodeGenerator.java b/modules/json/src/org/apache/axis2/json/factory/XmlNodeGenerator.java
similarity index 99%
rename from modules/json/src/org/apache/axis2/json/moshi/factory/XmlNodeGenerator.java
rename to modules/json/src/org/apache/axis2/json/factory/XmlNodeGenerator.java
index f72aaae..7c65d2b 100644
--- a/modules/json/src/org/apache/axis2/json/moshi/factory/XmlNodeGenerator.java
+++ b/modules/json/src/org/apache/axis2/json/factory/XmlNodeGenerator.java
@@ -17,7 +17,7 @@
* under the License.
*/
-package org.apache.axis2.json.moshi.factory;
+package org.apache.axis2.json.factory;
import org.apache.axis2.AxisFault;
import org.apache.ws.commons.schema.utils.XmlSchemaRef;
diff --git a/modules/json/src/org/apache/axis2/json/gson/GsonXMLStreamReader.java b/modules/json/src/org/apache/axis2/json/gson/GsonXMLStreamReader.java
index f975729..3823546 100644
--- a/modules/json/src/org/apache/axis2/json/gson/GsonXMLStreamReader.java
+++ b/modules/json/src/org/apache/axis2/json/gson/GsonXMLStreamReader.java
@@ -23,11 +23,11 @@
import com.google.gson.stream.JsonToken;
import org.apache.axis2.AxisFault;
import org.apache.axis2.context.ConfigurationContext;
-import org.apache.axis2.json.gson.factory.JSONType;
-import org.apache.axis2.json.gson.factory.JsonConstant;
-import org.apache.axis2.json.gson.factory.JsonObject;
-import org.apache.axis2.json.gson.factory.XmlNode;
-import org.apache.axis2.json.gson.factory.XmlNodeGenerator;
+import org.apache.axis2.json.factory.JSONType;
+import org.apache.axis2.json.factory.JsonConstant;
+import org.apache.axis2.json.factory.JsonObject;
+import org.apache.axis2.json.factory.XmlNode;
+import org.apache.axis2.json.factory.XmlNodeGenerator;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.ws.commons.schema.XmlSchema;
diff --git a/modules/json/src/org/apache/axis2/json/gson/GsonXMLStreamWriter.java b/modules/json/src/org/apache/axis2/json/gson/GsonXMLStreamWriter.java
index 16cf8f6..95646b1 100644
--- a/modules/json/src/org/apache/axis2/json/gson/GsonXMLStreamWriter.java
+++ b/modules/json/src/org/apache/axis2/json/gson/GsonXMLStreamWriter.java
@@ -21,11 +21,11 @@
import com.google.gson.stream.JsonWriter;
import org.apache.axis2.context.ConfigurationContext;
-import org.apache.axis2.json.gson.factory.JSONType;
-import org.apache.axis2.json.gson.factory.JsonConstant;
-import org.apache.axis2.json.gson.factory.JsonObject;
-import org.apache.axis2.json.gson.factory.XmlNode;
-import org.apache.axis2.json.gson.factory.XmlNodeGenerator;
+import org.apache.axis2.json.factory.JSONType;
+import org.apache.axis2.json.factory.JsonConstant;
+import org.apache.axis2.json.factory.JsonObject;
+import org.apache.axis2.json.factory.XmlNode;
+import org.apache.axis2.json.factory.XmlNodeGenerator;
import org.apache.ws.commons.schema.XmlSchema;
import javax.xml.namespace.NamespaceContext;
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 bccb485..4a75d95 100644
--- a/modules/json/src/org/apache/axis2/json/gson/JSONMessageHandler.java
+++ b/modules/json/src/org/apache/axis2/json/gson/JSONMessageHandler.java
@@ -27,7 +27,7 @@
import org.apache.axis2.description.AxisOperation;
import org.apache.axis2.engine.MessageReceiver;
import org.apache.axis2.handlers.AbstractHandler;
-import org.apache.axis2.json.gson.factory.JsonConstant;
+import org.apache.axis2.json.factory.JsonConstant;
import org.apache.axis2.json.gson.rpc.JsonInOnlyRPCMessageReceiver;
import org.apache.axis2.json.gson.rpc.JsonRpcMessageReceiver;
import org.apache.axis2.wsdl.WSDLConstants;
diff --git a/modules/json/src/org/apache/axis2/json/gson/JsonBuilder.java b/modules/json/src/org/apache/axis2/json/gson/JsonBuilder.java
index d063c4a..b65ecb7 100644
--- a/modules/json/src/org/apache/axis2/json/gson/JsonBuilder.java
+++ b/modules/json/src/org/apache/axis2/json/gson/JsonBuilder.java
@@ -27,7 +27,7 @@
import org.apache.axis2.Constants;
import org.apache.axis2.builder.Builder;
import org.apache.axis2.context.MessageContext;
-import org.apache.axis2.json.gson.factory.JsonConstant;
+import org.apache.axis2.json.factory.JsonConstant;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
diff --git a/modules/json/src/org/apache/axis2/json/gson/JsonFormatter.java b/modules/json/src/org/apache/axis2/json/gson/JsonFormatter.java
index dad4494..4aaa8c9 100644
--- a/modules/json/src/org/apache/axis2/json/gson/JsonFormatter.java
+++ b/modules/json/src/org/apache/axis2/json/gson/JsonFormatter.java
@@ -26,7 +26,7 @@
import org.apache.axis2.AxisFault;
import org.apache.axis2.Constants;
import org.apache.axis2.context.MessageContext;
-import org.apache.axis2.json.gson.factory.JsonConstant;
+import org.apache.axis2.json.factory.JsonConstant;
import org.apache.axis2.transport.MessageFormatter;
import org.apache.axis2.wsdl.WSDLConstants;
import org.apache.commons.logging.Log;
diff --git a/modules/json/src/org/apache/axis2/json/gson/factory/JsonConstant.java b/modules/json/src/org/apache/axis2/json/gson/factory/JsonConstant.java
deleted file mode 100644
index 60c9511..0000000
--- a/modules/json/src/org/apache/axis2/json/gson/factory/JsonConstant.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * 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.gson.factory;
-
-
-public class JsonConstant {
-
-
- public static final String RESPONSE = "response";
-
- public static final String RETURN_OBJECT = "returnObject";
- public static final String RETURN_TYPE = "returnType";
-
- public static final String IS_JSON_STREAM = "isJsonStream";
-
- public static final String GSON_XML_STREAM_READER = "GsonXMLStreamReader";
-
- public static final String XMLNODES = "xmlnodes";
-
-
-// error messages
-
- public static final String IN_JSON_MESSAGE_NOT_VALID = "Input JSON message is not valid ";
-
-}
diff --git a/modules/json/src/org/apache/axis2/json/gson/factory/XmlNode.java b/modules/json/src/org/apache/axis2/json/gson/factory/XmlNode.java
deleted file mode 100644
index fc2d3c9..0000000
--- a/modules/json/src/org/apache/axis2/json/gson/factory/XmlNode.java
+++ /dev/null
@@ -1,71 +0,0 @@
-/*
- * 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.gson.factory;
-
-import java.util.ArrayList;
-import java.util.List;
-
-public class XmlNode {
-
- private String name;
- private boolean isAttribute;
- private boolean isArray;
- private List<XmlNode> childrenList = new ArrayList<XmlNode>();
- private String valueType;
- private String namespaceUri;
-
- public XmlNode(String name,String namespaceUri, boolean attribute, boolean array , String valueType) {
- this.name = name;
- this.namespaceUri = namespaceUri;
- isAttribute = attribute;
- isArray = array;
- this.valueType = valueType;
- }
-
-
- public void addChildToList(XmlNode child) {
- childrenList.add(child);
- }
-
-
- public String getName() {
- return name;
- }
-
- public boolean isAttribute() {
- return isAttribute;
- }
-
- public boolean isArray() {
- return isArray;
- }
-
- public List<XmlNode> getChildrenList() {
- return childrenList;
- }
-
- public String getValueType() {
- return valueType;
- }
-
- public String getNamespaceUri() {
- return namespaceUri;
- }
-}
diff --git a/modules/json/src/org/apache/axis2/json/gson/factory/XmlNodeGenerator.java b/modules/json/src/org/apache/axis2/json/gson/factory/XmlNodeGenerator.java
deleted file mode 100644
index 8990fbb..0000000
--- a/modules/json/src/org/apache/axis2/json/gson/factory/XmlNodeGenerator.java
+++ /dev/null
@@ -1,206 +0,0 @@
-/*
- * 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.gson.factory;
-
-import org.apache.axis2.AxisFault;
-import org.apache.ws.commons.schema.utils.XmlSchemaRef;
-
-import org.apache.ws.commons.schema.XmlSchema;
-import org.apache.ws.commons.schema.XmlSchemaComplexType;
-import org.apache.ws.commons.schema.XmlSchemaElement;
-import org.apache.ws.commons.schema.XmlSchemaParticle;
-import org.apache.ws.commons.schema.XmlSchemaSequence;
-import org.apache.ws.commons.schema.XmlSchemaSequenceMember;
-import org.apache.ws.commons.schema.XmlSchemaSimpleType;
-import org.apache.ws.commons.schema.XmlSchemaType;
-
-import javax.xml.namespace.QName;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Queue;
-
-public class XmlNodeGenerator {
-
- List<XmlSchema> xmlSchemaList;
-
- QName elementQname;
-
- private XmlNode mainXmlNode;
-
- Queue<JsonObject> queue = new LinkedList<JsonObject>();
-
- public XmlNodeGenerator(List<XmlSchema> xmlSchemaList, QName elementQname) {
- this.xmlSchemaList = xmlSchemaList;
- this.elementQname = elementQname;
- }
-
- public XmlNodeGenerator() {
- }
-
- private void processSchemaList() throws AxisFault {
- // get the operation schema and process.
- XmlSchema operationSchema = getXmlSchema(elementQname);
- XmlSchemaElement messageElement = operationSchema.getElementByName(elementQname.getLocalPart());
- mainXmlNode = new XmlNode(elementQname.getLocalPart(), elementQname.getNamespaceURI() , false, (messageElement.getMaxOccurs() == 1 ? false : true) , "");
-
- QName messageSchemaTypeName = messageElement.getSchemaTypeName();
- XmlSchemaType schemaType = null;
- XmlSchema schemaOfType = null;
- if (messageSchemaTypeName != null) {
- schemaType = operationSchema.getTypeByName(messageSchemaTypeName);
- if (schemaType == null) {
- schemaOfType = getXmlSchema(messageSchemaTypeName);
- schemaType = schemaOfType.getTypeByName(messageSchemaTypeName.getLocalPart());
- } else {
- schemaOfType = operationSchema;
- }
- } else {
- schemaType = messageElement.getSchemaType();
- schemaOfType = operationSchema;
- }
-
- if (schemaType != null) {
- processSchemaType(schemaType, mainXmlNode, schemaOfType);
- } else {
- // nothing to do
- }
- }
-
- private void processElement(XmlSchemaElement element, XmlNode parentNode , XmlSchema schema) throws AxisFault {
- String targetNamespace = schema.getTargetNamespace();
- XmlNode xmlNode;
- QName schemaTypeName = element.getSchemaTypeName();
- XmlSchemaType schemaType = element.getSchemaType();
- if (schemaTypeName != null) {
- xmlNode = new XmlNode(element.getName(), targetNamespace, false, (element.getMaxOccurs() == 1 ? false : true), schemaTypeName.getLocalPart());
- parentNode.addChildToList(xmlNode);
- if (("http://www.w3.org/2001/XMLSchema").equals(schemaTypeName.getNamespaceURI())) {
- } else {
- XmlSchema schemaOfType;
- // see whether Schema type is in the same schema
- XmlSchemaType childSchemaType = schema.getTypeByName(schemaTypeName.getLocalPart());
- if (childSchemaType == null) {
- schemaOfType = getXmlSchema(schemaTypeName);
- childSchemaType = schemaOfType.getTypeByName(schemaTypeName.getLocalPart());
- }else{
- schemaOfType = schema;
- }
- processSchemaType(childSchemaType, xmlNode, schemaOfType);
- }
- }else if (schemaType != null) {
- xmlNode = new XmlNode(element.getName(), targetNamespace, false, (element.getMaxOccurs() == 1 ? false : true), schemaType.getQName().getLocalPart());
- parentNode.addChildToList(xmlNode);
- processSchemaType(schemaType, xmlNode, schema);
- }else if (element.getRef() != null) {
- // Handle ref element
- XmlSchemaRef xmlSchemaRef = element.getRef();
- QName targetQname = xmlSchemaRef.getTargetQName();
- if (targetQname == null) {
- throw new AxisFault("target QName is null while processing ref:" + element.getName());
- }
- getXmlSchema(targetQname);
- xmlNode = new XmlNode(targetQname.getLocalPart(), targetNamespace, false, (element.getMaxOccurs() != 1), targetQname.getLocalPart());
- parentNode.addChildToList(xmlNode);
- if (("http://www.w3.org/2001/XMLSchema").equals(targetQname.getNamespaceURI())) {
- } else {
- XmlSchema schemaOfType;
- // see whether Schema type is in the same schema
- XmlSchemaType childSchemaType = schema.getTypeByName(targetQname.getLocalPart());
- if (childSchemaType == null) {
- schemaOfType = getXmlSchema(targetQname);
- childSchemaType = schemaOfType.getTypeByName(targetQname.getLocalPart());
- } else {
- schemaOfType = schema;
- }
- processSchemaType(childSchemaType, xmlNode, schemaOfType);
- }
- }
- }
-
-
- private void processSchemaType(XmlSchemaType xmlSchemaType , XmlNode parentNode , XmlSchema schema) throws AxisFault {
- if (xmlSchemaType instanceof XmlSchemaComplexType) {
- XmlSchemaComplexType complexType = (XmlSchemaComplexType)xmlSchemaType;
- XmlSchemaParticle particle = complexType.getParticle();
- if (particle instanceof XmlSchemaSequence) {
- XmlSchemaSequence sequence = (XmlSchemaSequence)particle;
- for (XmlSchemaSequenceMember member : sequence.getItems()) {
- if (member instanceof XmlSchemaElement) {
- processElement((XmlSchemaElement)member , parentNode , schema);
- }
- }
- }
- }else if (xmlSchemaType instanceof XmlSchemaSimpleType) {
- // nothing to do with simpleType
- }
- }
-
-
- private XmlSchema getXmlSchema(QName qName) {
- for (XmlSchema xmlSchema : xmlSchemaList) {
- if (xmlSchema.getTargetNamespace().equals(qName.getNamespaceURI())) {
- return xmlSchema;
- }
- }
- return null;
- }
-
- private void generateQueue(XmlNode node) {
- if (node.isArray()) {
- if (node.getChildrenList().size() > 0) {
- queue.add(new JsonObject(node.getName(), JSONType.NESTED_ARRAY, node.getValueType() , node.getNamespaceUri()));
- processXmlNodeChildren(node.getChildrenList());
- } else {
- queue.add(new JsonObject(node.getName(), JSONType.ARRAY , node.getValueType() , node.getNamespaceUri()));
- }
- } else {
- if (node.getChildrenList().size() > 0) {
- queue.add(new JsonObject(node.getName(), JSONType.NESTED_OBJECT, node.getValueType() , node.getNamespaceUri()));
- processXmlNodeChildren(node.getChildrenList());
- } else {
- queue.add(new JsonObject(node.getName(), JSONType.OBJECT , node.getValueType() , node.getNamespaceUri()));
- }
- }
- }
-
- private void processXmlNodeChildren(List<XmlNode> childrenNodes) {
- for (int i = 0; i < childrenNodes.size(); i++) {
- generateQueue(childrenNodes.get(i));
- }
- }
-
-
- public XmlNode getMainXmlNode() throws AxisFault {
- if (mainXmlNode == null) {
- try {
- processSchemaList();
- } catch (AxisFault axisFault) {
- throw new AxisFault("Error while creating intermeidate xml structure ", axisFault);
- }
- }
- return mainXmlNode;
- }
-
- public Queue<JsonObject> getQueue(XmlNode node) {
- generateQueue(node);
- return queue;
- }
-
-}
diff --git a/modules/json/src/org/apache/axis2/json/gson/rpc/JsonInOnlyRPCMessageReceiver.java b/modules/json/src/org/apache/axis2/json/gson/rpc/JsonInOnlyRPCMessageReceiver.java
index 6a68120..6a2c591 100644
--- a/modules/json/src/org/apache/axis2/json/gson/rpc/JsonInOnlyRPCMessageReceiver.java
+++ b/modules/json/src/org/apache/axis2/json/gson/rpc/JsonInOnlyRPCMessageReceiver.java
@@ -24,7 +24,7 @@
import org.apache.axis2.context.MessageContext;
import org.apache.axis2.description.AxisOperation;
import org.apache.axis2.json.gson.GsonXMLStreamReader;
-import org.apache.axis2.json.gson.factory.JsonConstant;
+import org.apache.axis2.json.factory.JsonConstant;
import org.apache.axis2.rpc.receivers.RPCInOnlyMessageReceiver;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
diff --git a/modules/json/src/org/apache/axis2/json/gson/rpc/JsonRpcMessageReceiver.java b/modules/json/src/org/apache/axis2/json/gson/rpc/JsonRpcMessageReceiver.java
index 7a4855c..7cd29e2 100644
--- a/modules/json/src/org/apache/axis2/json/gson/rpc/JsonRpcMessageReceiver.java
+++ b/modules/json/src/org/apache/axis2/json/gson/rpc/JsonRpcMessageReceiver.java
@@ -23,7 +23,7 @@
import org.apache.axis2.context.MessageContext;
import org.apache.axis2.description.AxisOperation;
import org.apache.axis2.json.gson.GsonXMLStreamReader;
-import org.apache.axis2.json.gson.factory.JsonConstant;
+import org.apache.axis2.json.factory.JsonConstant;
import org.apache.axis2.rpc.receivers.RPCMessageReceiver;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
diff --git a/modules/json/src/org/apache/axis2/json/moshi/JSONMessageHandler.java b/modules/json/src/org/apache/axis2/json/moshi/JSONMessageHandler.java
index 723c6d3..324a5ec 100644
--- a/modules/json/src/org/apache/axis2/json/moshi/JSONMessageHandler.java
+++ b/modules/json/src/org/apache/axis2/json/moshi/JSONMessageHandler.java
@@ -27,7 +27,7 @@
import org.apache.axis2.description.AxisOperation;
import org.apache.axis2.engine.MessageReceiver;
import org.apache.axis2.handlers.AbstractHandler;
-import org.apache.axis2.json.moshi.factory.JsonConstant;
+import org.apache.axis2.json.factory.JsonConstant;
import org.apache.axis2.json.moshi.rpc.JsonInOnlyRPCMessageReceiver;
import org.apache.axis2.json.moshi.rpc.JsonRpcMessageReceiver;
import org.apache.axis2.wsdl.WSDLConstants;
diff --git a/modules/json/src/org/apache/axis2/json/moshi/JsonBuilder.java b/modules/json/src/org/apache/axis2/json/moshi/JsonBuilder.java
index 9a76f00..f2fabe8 100644
--- a/modules/json/src/org/apache/axis2/json/moshi/JsonBuilder.java
+++ b/modules/json/src/org/apache/axis2/json/moshi/JsonBuilder.java
@@ -31,7 +31,7 @@
import org.apache.axis2.Constants;
import org.apache.axis2.builder.Builder;
import org.apache.axis2.context.MessageContext;
-import org.apache.axis2.json.moshi.factory.JsonConstant;
+import org.apache.axis2.json.factory.JsonConstant;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
diff --git a/modules/json/src/org/apache/axis2/json/moshi/JsonFormatter.java b/modules/json/src/org/apache/axis2/json/moshi/JsonFormatter.java
index c72904b..93870ea 100644
--- a/modules/json/src/org/apache/axis2/json/moshi/JsonFormatter.java
+++ b/modules/json/src/org/apache/axis2/json/moshi/JsonFormatter.java
@@ -31,7 +31,7 @@
import org.apache.axis2.AxisFault;
import org.apache.axis2.Constants;
import org.apache.axis2.context.MessageContext;
-import org.apache.axis2.json.moshi.factory.JsonConstant;
+import org.apache.axis2.json.factory.JsonConstant;
import org.apache.axis2.transport.MessageFormatter;
import org.apache.axis2.wsdl.WSDLConstants;
import org.apache.commons.logging.Log;
diff --git a/modules/json/src/org/apache/axis2/json/moshi/MoshiXMLStreamReader.java b/modules/json/src/org/apache/axis2/json/moshi/MoshiXMLStreamReader.java
index 6c34ba4..b3221a2 100644
--- a/modules/json/src/org/apache/axis2/json/moshi/MoshiXMLStreamReader.java
+++ b/modules/json/src/org/apache/axis2/json/moshi/MoshiXMLStreamReader.java
@@ -24,11 +24,11 @@
import org.apache.axis2.AxisFault;
import org.apache.axis2.context.ConfigurationContext;
-import org.apache.axis2.json.moshi.factory.JSONType;
-import org.apache.axis2.json.moshi.factory.JsonConstant;
-import org.apache.axis2.json.moshi.factory.JsonObject;
-import org.apache.axis2.json.moshi.factory.XmlNode;
-import org.apache.axis2.json.moshi.factory.XmlNodeGenerator;
+import org.apache.axis2.json.factory.JSONType;
+import org.apache.axis2.json.factory.JsonConstant;
+import org.apache.axis2.json.factory.JsonObject;
+import org.apache.axis2.json.factory.XmlNode;
+import org.apache.axis2.json.factory.XmlNodeGenerator;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.ws.commons.schema.XmlSchema;
diff --git a/modules/json/src/org/apache/axis2/json/moshi/MoshiXMLStreamWriter.java b/modules/json/src/org/apache/axis2/json/moshi/MoshiXMLStreamWriter.java
index 813ca40..f00caea 100644
--- a/modules/json/src/org/apache/axis2/json/moshi/MoshiXMLStreamWriter.java
+++ b/modules/json/src/org/apache/axis2/json/moshi/MoshiXMLStreamWriter.java
@@ -22,11 +22,11 @@
import com.squareup.moshi.JsonWriter;
import org.apache.axis2.context.ConfigurationContext;
-import org.apache.axis2.json.moshi.factory.JSONType;
-import org.apache.axis2.json.moshi.factory.JsonConstant;
-import org.apache.axis2.json.moshi.factory.JsonObject;
-import org.apache.axis2.json.moshi.factory.XmlNode;
-import org.apache.axis2.json.moshi.factory.XmlNodeGenerator;
+import org.apache.axis2.json.factory.JSONType;
+import org.apache.axis2.json.factory.JsonConstant;
+import org.apache.axis2.json.factory.JsonObject;
+import org.apache.axis2.json.factory.XmlNode;
+import org.apache.axis2.json.factory.XmlNodeGenerator;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.ws.commons.schema.XmlSchema;
diff --git a/modules/json/src/org/apache/axis2/json/moshi/factory/JSONType.java b/modules/json/src/org/apache/axis2/json/moshi/factory/JSONType.java
deleted file mode 100644
index e3cbef5..0000000
--- a/modules/json/src/org/apache/axis2/json/moshi/factory/JSONType.java
+++ /dev/null
@@ -1,27 +0,0 @@
-/*
- * 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.moshi.factory;
-
-public enum JSONType {
- ARRAY,
- NESTED_ARRAY,
- NESTED_OBJECT,
- OBJECT,
-}
diff --git a/modules/json/src/org/apache/axis2/json/moshi/factory/JsonObject.java b/modules/json/src/org/apache/axis2/json/moshi/factory/JsonObject.java
deleted file mode 100644
index 86b9569..0000000
--- a/modules/json/src/org/apache/axis2/json/moshi/factory/JsonObject.java
+++ /dev/null
@@ -1,51 +0,0 @@
-/*
- * 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.moshi.factory;
-
-
-public class JsonObject {
- private String name;
- private JSONType type;
- private String valueType;
- private String namespaceUri;
-
- public JsonObject(String name, JSONType type, String valueType , String namespaceUri) {
- this.name = name;
- this.type = type;
- this.valueType = valueType;
- this.namespaceUri = namespaceUri;
- }
-
- public String getName() {
- return name;
- }
-
- public JSONType getType() {
- return type;
- }
-
- public String getValueType() {
- return valueType;
- }
-
- public String getNamespaceUri() {
- return namespaceUri;
- }
-}
diff --git a/modules/json/src/org/apache/axis2/json/moshi/rpc/JsonInOnlyRPCMessageReceiver.java b/modules/json/src/org/apache/axis2/json/moshi/rpc/JsonInOnlyRPCMessageReceiver.java
index 62c3122..1959895 100644
--- a/modules/json/src/org/apache/axis2/json/moshi/rpc/JsonInOnlyRPCMessageReceiver.java
+++ b/modules/json/src/org/apache/axis2/json/moshi/rpc/JsonInOnlyRPCMessageReceiver.java
@@ -24,7 +24,7 @@
import org.apache.axis2.context.MessageContext;
import org.apache.axis2.description.AxisOperation;
import org.apache.axis2.json.moshi.MoshiXMLStreamReader;
-import org.apache.axis2.json.moshi.factory.JsonConstant;
+import org.apache.axis2.json.factory.JsonConstant;
import org.apache.axis2.rpc.receivers.RPCInOnlyMessageReceiver;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
diff --git a/modules/json/src/org/apache/axis2/json/moshi/rpc/JsonRpcMessageReceiver.java b/modules/json/src/org/apache/axis2/json/moshi/rpc/JsonRpcMessageReceiver.java
index 03d19d8..bf90f30 100644
--- a/modules/json/src/org/apache/axis2/json/moshi/rpc/JsonRpcMessageReceiver.java
+++ b/modules/json/src/org/apache/axis2/json/moshi/rpc/JsonRpcMessageReceiver.java
@@ -23,7 +23,7 @@
import org.apache.axis2.context.MessageContext;
import org.apache.axis2.description.AxisOperation;
import org.apache.axis2.json.moshi.MoshiXMLStreamReader;
-import org.apache.axis2.json.moshi.factory.JsonConstant;
+import org.apache.axis2.json.factory.JsonConstant;
import org.apache.axis2.rpc.receivers.RPCMessageReceiver;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
diff --git a/modules/json/test/org/apache/axis2/json/gson/factory/XmlNodeGeneratorTest.java b/modules/json/test/org/apache/axis2/json/factory/XmlNodeGeneratorTest.java
similarity index 98%
rename from modules/json/test/org/apache/axis2/json/gson/factory/XmlNodeGeneratorTest.java
rename to modules/json/test/org/apache/axis2/json/factory/XmlNodeGeneratorTest.java
index 30a4389..7797d7f 100644
--- a/modules/json/test/org/apache/axis2/json/gson/factory/XmlNodeGeneratorTest.java
+++ b/modules/json/test/org/apache/axis2/json/factory/XmlNodeGeneratorTest.java
@@ -17,7 +17,7 @@
* under the License.
*/
-package org.apache.axis2.json.gson.factory;
+package org.apache.axis2.json.factory;
import org.apache.ws.commons.schema.XmlSchema;
import org.apache.ws.commons.schema.XmlSchemaCollection;
diff --git a/modules/json/test/org/apache/axis2/json/gson/JSONMessageHandlerTest.java b/modules/json/test/org/apache/axis2/json/gson/JSONMessageHandlerTest.java
index 4bf79aa..4d924f0 100644
--- a/modules/json/test/org/apache/axis2/json/gson/JSONMessageHandlerTest.java
+++ b/modules/json/test/org/apache/axis2/json/gson/JSONMessageHandlerTest.java
@@ -33,7 +33,7 @@
import org.apache.axis2.description.AxisService;
import org.apache.axis2.engine.AxisConfiguration;
import org.apache.axis2.engine.MessageReceiver;
-import org.apache.axis2.json.gson.factory.JsonConstant;
+import org.apache.axis2.json.factory.JsonConstant;
import org.apache.axis2.json.gson.rpc.JsonRpcMessageReceiver;
import org.apache.axis2.rpc.receivers.RPCMessageReceiver;
import org.apache.axis2.wsdl.WSDLConstants;
diff --git a/modules/json/test/org/apache/axis2/json/gson/JsonBuilderTest.java b/modules/json/test/org/apache/axis2/json/gson/JsonBuilderTest.java
index 383ab8a..7ec94da 100644
--- a/modules/json/test/org/apache/axis2/json/gson/JsonBuilderTest.java
+++ b/modules/json/test/org/apache/axis2/json/gson/JsonBuilderTest.java
@@ -22,7 +22,7 @@
import com.google.gson.stream.JsonReader;
import org.apache.axis2.Constants;
import org.apache.axis2.context.MessageContext;
-import org.apache.axis2.json.gson.factory.JsonConstant;
+import org.apache.axis2.json.factory.JsonConstant;
import org.junit.Assert;
import org.junit.Test;
diff --git a/modules/json/test/org/apache/axis2/json/gson/JsonFormatterTest.java b/modules/json/test/org/apache/axis2/json/gson/JsonFormatterTest.java
index caf6c51..a0b234b 100644
--- a/modules/json/test/org/apache/axis2/json/gson/JsonFormatterTest.java
+++ b/modules/json/test/org/apache/axis2/json/gson/JsonFormatterTest.java
@@ -35,7 +35,7 @@
import org.apache.axis2.description.AxisOperationFactory;
import org.apache.axis2.description.AxisService;
import org.apache.axis2.engine.AxisConfiguration;
-import org.apache.axis2.json.gson.factory.JsonConstant;
+import org.apache.axis2.json.factory.JsonConstant;
import org.apache.axis2.wsdl.WSDLConstants;
import org.apache.ws.commons.schema.XmlSchema;
import org.apache.ws.commons.schema.XmlSchemaCollection;
diff --git a/modules/json/test/org/apache/axis2/json/moshi/JSONMessageHandlerTest.java b/modules/json/test/org/apache/axis2/json/moshi/JSONMessageHandlerTest.java
index b9371db..d995962 100644
--- a/modules/json/test/org/apache/axis2/json/moshi/JSONMessageHandlerTest.java
+++ b/modules/json/test/org/apache/axis2/json/moshi/JSONMessageHandlerTest.java
@@ -37,7 +37,7 @@
import org.apache.axis2.description.AxisService;
import org.apache.axis2.engine.AxisConfiguration;
import org.apache.axis2.engine.MessageReceiver;
-import org.apache.axis2.json.moshi.factory.JsonConstant;
+import org.apache.axis2.json.factory.JsonConstant;
import org.apache.axis2.json.moshi.rpc.JsonRpcMessageReceiver;
import org.apache.axis2.rpc.receivers.RPCMessageReceiver;
import org.apache.axis2.wsdl.WSDLConstants;
diff --git a/modules/json/test/org/apache/axis2/json/moshi/JsonBuilderTest.java b/modules/json/test/org/apache/axis2/json/moshi/JsonBuilderTest.java
index 4c25f25..2ed96e5 100644
--- a/modules/json/test/org/apache/axis2/json/moshi/JsonBuilderTest.java
+++ b/modules/json/test/org/apache/axis2/json/moshi/JsonBuilderTest.java
@@ -22,7 +22,7 @@
import com.squareup.moshi.JsonReader;
import org.apache.axis2.Constants;
import org.apache.axis2.context.MessageContext;
-import org.apache.axis2.json.moshi.factory.JsonConstant;
+import org.apache.axis2.json.factory.JsonConstant;
import org.junit.Assert;
import org.junit.Test;
diff --git a/modules/json/test/org/apache/axis2/json/moshi/JsonFormatterTest.java b/modules/json/test/org/apache/axis2/json/moshi/JsonFormatterTest.java
index 68870d0..728453d 100644
--- a/modules/json/test/org/apache/axis2/json/moshi/JsonFormatterTest.java
+++ b/modules/json/test/org/apache/axis2/json/moshi/JsonFormatterTest.java
@@ -39,7 +39,7 @@
import org.apache.axis2.description.AxisOperationFactory;
import org.apache.axis2.description.AxisService;
import org.apache.axis2.engine.AxisConfiguration;
-import org.apache.axis2.json.moshi.factory.JsonConstant;
+import org.apache.axis2.json.factory.JsonConstant;
import org.apache.axis2.wsdl.WSDLConstants;
import org.apache.ws.commons.schema.XmlSchema;
import org.apache.ws.commons.schema.XmlSchemaCollection;
diff --git a/modules/json/test/org/apache/axis2/json/moshi/factory/XmlNodeGeneratorTest.java b/modules/json/test/org/apache/axis2/json/moshi/factory/XmlNodeGeneratorTest.java
deleted file mode 100644
index d81221f..0000000
--- a/modules/json/test/org/apache/axis2/json/moshi/factory/XmlNodeGeneratorTest.java
+++ /dev/null
@@ -1,107 +0,0 @@
-/*
- * 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.moshi.factory;
-
-import org.apache.ws.commons.schema.XmlSchema;
-import org.apache.ws.commons.schema.XmlSchemaCollection;
-import org.junit.Assert;
-import org.junit.BeforeClass;
-import org.junit.Test;
-
-import javax.xml.namespace.QName;
-import javax.xml.transform.stream.StreamSource;
-import java.io.FileInputStream;
-import java.io.InputStream;
-import java.util.ArrayList;
-import java.util.List;
-
-
-public class XmlNodeGeneratorTest {
-
- static List<XmlSchema> schemaList = null;
- @Test
- public void testMainXMLNode() throws Exception {
- QName elementQName = new QName("http://test.json.axis2.apache.org" ,"echoPerson");
- XmlNodeGenerator xmlNodeGenerator = new XmlNodeGenerator(schemaList, elementQName);
- XmlNode mainXmlNode = xmlNodeGenerator.getMainXmlNode();
-
- Assert.assertNotNull(mainXmlNode);
- Assert.assertEquals("echoPerson", mainXmlNode.getName());
- Assert.assertEquals(1, mainXmlNode.getChildrenList().size());
- Assert.assertEquals("http://test.json.axis2.apache.org" , mainXmlNode.getNamespaceUri());
-
- Assert.assertEquals("arg0", mainXmlNode.getChildrenList().get(0).getName());
- Assert.assertEquals(3, mainXmlNode.getChildrenList().get(0).getChildrenList().size());
-
- Assert.assertEquals("name", mainXmlNode.getChildrenList().get(0).getChildrenList().get(0).getName());
- Assert.assertEquals(0, mainXmlNode.getChildrenList().get(0).getChildrenList().get(0).getChildrenList().size());
-
- Assert.assertEquals("age", mainXmlNode.getChildrenList().get(0).getChildrenList().get(1).getName());
- Assert.assertEquals(0, mainXmlNode.getChildrenList().get(0).getChildrenList().get(1).getChildrenList().size());
-
- Assert.assertEquals("gender", mainXmlNode.getChildrenList().get(0).getChildrenList().get(2).getName());
- Assert.assertEquals(0, mainXmlNode.getChildrenList().get(0).getChildrenList().get(2).getChildrenList().size());
- }
-
- @Test
- public void testXMLNodeGenWithRefElement() throws Exception {
- QName eleQName = new QName("http://test.json.axis2.apache.org", "Offices");
- XmlNodeGenerator xmlNodeGenerator = new XmlNodeGenerator(schemaList, eleQName);
- XmlNode mainXmlNode = xmlNodeGenerator.getMainXmlNode();
-
- Assert.assertNotNull(mainXmlNode);
- Assert.assertEquals(true, mainXmlNode.getChildrenList().get(0).isArray());
- Assert.assertEquals(5, mainXmlNode.getChildrenList().get(0).getChildrenList().size());
- Assert.assertEquals("Employees", mainXmlNode.getChildrenList().get(0).getChildrenList().get(2).getName());
- Assert.assertEquals(false, mainXmlNode.getChildrenList().get(0).getChildrenList().get(2).isArray());
- Assert.assertEquals("Employee", mainXmlNode.getChildrenList().get(0).getChildrenList().get(2).getChildrenList().get(0).getName());
- Assert.assertEquals(true, mainXmlNode.getChildrenList().get(0).getChildrenList().get(2).getChildrenList().get(0).isArray());
- Assert.assertEquals(3, mainXmlNode.getChildrenList().get(0).getChildrenList().get(2).getChildrenList().get(0).getChildrenList().size());
-
- }
-
- @BeforeClass
- public static void setUp() throws Exception {
- InputStream is2 = null;
- InputStream is3 = null;
- try {
- String testSchema2 = "test-resources/custom_schema/testSchema_2.xsd";
- String testSchema3 = "test-resources/custom_schema/testSchema_3.xsd";
- is2 = new FileInputStream(testSchema2);
- is3 = new FileInputStream(testSchema3);
- XmlSchemaCollection schemaCol = new XmlSchemaCollection();
- XmlSchema schema2 = schemaCol.read(new StreamSource(is2));
- XmlSchema schema3 = schemaCol.read(new StreamSource(is3));
-
- schemaList = new ArrayList<XmlSchema>();
- schemaList.add(schema2);
- schemaList.add(schema3);
- } finally {
- if (is2 != null) {
- is2.close();
- }
- if (is3 != null) {
- is3.close();
- }
- }
-
- }
-
-}