You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-dev@axis.apache.org by th...@apache.org on 2007/02/23 08:23:57 UTC
svn commit: r510858 - in /webservices/axis2/trunk/java/modules/json:
src/org/apache/axis2/json/JSONBadgerfishOMBuilder.java
src/org/apache/axis2/json/JSONOMBuilder.java test-resources/axis2.xml
Author: thilina
Date: Thu Feb 22 23:23:57 2007
New Revision: 510858
URL: http://svn.apache.org/viewvc?view=rev&rev=510858
Log:
Reflecting the moving of OMBuilder to Axis2..
Making JSONOMBuilder stateless..
Modified:
webservices/axis2/trunk/java/modules/json/src/org/apache/axis2/json/JSONBadgerfishOMBuilder.java
webservices/axis2/trunk/java/modules/json/src/org/apache/axis2/json/JSONOMBuilder.java
webservices/axis2/trunk/java/modules/json/test-resources/axis2.xml
Modified: webservices/axis2/trunk/java/modules/json/src/org/apache/axis2/json/JSONBadgerfishOMBuilder.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/json/src/org/apache/axis2/json/JSONBadgerfishOMBuilder.java?view=diff&rev=510858&r1=510857&r2=510858
==============================================================================
--- webservices/axis2/trunk/java/modules/json/src/org/apache/axis2/json/JSONBadgerfishOMBuilder.java (original)
+++ webservices/axis2/trunk/java/modules/json/src/org/apache/axis2/json/JSONBadgerfishOMBuilder.java Thu Feb 22 23:23:57 2007
@@ -16,10 +16,12 @@
package org.apache.axis2.json;
+import java.io.InputStream;
+
public class JSONBadgerfishOMBuilder extends JSONOMBuilder{
- protected JSONDataSource getDataSource(){
- return new JSONBadgerfishDataSource(this.jsonInputStream, "\"" + prefix + localName + "\"");
+ protected JSONDataSource getDataSource(InputStream jsonInputStream,String prefix, String localName){
+ return new JSONBadgerfishDataSource(jsonInputStream, "\"" + prefix + localName + "\"");
}
}
Modified: webservices/axis2/trunk/java/modules/json/src/org/apache/axis2/json/JSONOMBuilder.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/json/src/org/apache/axis2/json/JSONOMBuilder.java?view=diff&rev=510858&r1=510857&r2=510858
==============================================================================
--- webservices/axis2/trunk/java/modules/json/src/org/apache/axis2/json/JSONOMBuilder.java (original)
+++ webservices/axis2/trunk/java/modules/json/src/org/apache/axis2/json/JSONOMBuilder.java Thu Feb 22 23:23:57 2007
@@ -21,51 +21,37 @@
import org.apache.axiom.om.*;
import org.apache.axiom.om.impl.OMNamespaceImpl;
-import org.apache.axiom.om.impl.builder.OMBuilder;
import org.apache.axiom.om.impl.llom.OMSourcedElementImpl;
import org.apache.axiom.om.impl.llom.factory.OMLinkedListImplFactory;
+import org.apache.axis2.AxisFault;
+import org.apache.axis2.builder.OMBuilder;
+import org.apache.axis2.context.MessageContext;
/**
* Makes the OMSourcedElementImpl object with the JSONDataSource inside.
*/
public class JSONOMBuilder implements OMBuilder {
- InputStream jsonInputStream = null;
- String localName = null;
- String prefix = "";
+
+
public JSONOMBuilder() {
}
- public void init(InputStream inputStream, String chatSetEncoding, String url, String contentType) {
- this.jsonInputStream = inputStream;
-
- }
-
//returns the OMSourcedElementImpl with JSONDataSource inside
- public OMElement getDocumentElement() {
- OMFactory factory = OMAbstractFactory.getOMFactory();
+ public OMElement processDocument(InputStream inputStream, MessageContext messageContext) throws AxisFault {
+ String localName="";
+ String prefix = "";
OMNamespace ns = new OMNamespaceImpl("", "");
- if (localName == null) {
- localName = getLocalName();
- }
- JSONDataSource jsonDataSource = getDataSource();
- return new OMSourcedElementImpl(localName, ns, factory, jsonDataSource);
- }
-
- protected JSONDataSource getDataSource() {
- return new JSONDataSource(this.jsonInputStream, "\"" + prefix + localName + "\"");
- }
-
- private String getLocalName() {
- String localName = "";
+
+ OMFactory factory = OMAbstractFactory.getOMFactory();
try {
- char temp = (char) jsonInputStream.read();
+ char temp = (char) inputStream.read();
while (temp != ':') {
if (temp != ' ' && temp != '{') {
localName += temp;
}
- temp = (char) jsonInputStream.read();
+ temp = (char) inputStream.read();
}
if (localName.charAt(0) == '"') {
@@ -74,24 +60,24 @@
} else {
prefix = localName.substring(1, localName.length()) + ":";
localName = "";
- temp = (char) jsonInputStream.read();
+ temp = (char) inputStream.read();
while (temp != ':') {
if (temp != ' ') {
localName += temp;
}
- temp = (char) jsonInputStream.read();
+ temp = (char) inputStream.read();
}
localName = localName.substring(0, localName.length() - 1);
}
}
} catch (IOException e) {
- throw new OMException(e);
+ throw new AxisFault(e);
}
- return localName;
+ JSONDataSource jsonDataSource = getDataSource(inputStream,prefix,localName);
+ return new OMSourcedElementImpl(localName, ns, factory, jsonDataSource);
}
- public String getCharsetEncoding() {
- return "UTF-8";
+ protected JSONDataSource getDataSource(InputStream jsonInputStream,String prefix,String localName) {
+ return new JSONDataSource(jsonInputStream, "\"" + prefix + localName + "\"");
}
-
}
Modified: webservices/axis2/trunk/java/modules/json/test-resources/axis2.xml
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/json/test-resources/axis2.xml?view=diff&rev=510858&r1=510857&r2=510858
==============================================================================
--- webservices/axis2/trunk/java/modules/json/test-resources/axis2.xml (original)
+++ webservices/axis2/trunk/java/modules/json/test-resources/axis2.xml Thu Feb 22 23:23:57 2007
@@ -132,8 +132,6 @@
class="org.apache.axis2.json.JSONBadgerfishOMBuilder"/>
<messageBuilder contentType="text/javascript"
class="org.apache.axis2.json.JSONOMBuilder"/>
- <messageBuilder contentType="application/soap+xml"
- class="org.apache.axiom.soap.impl.builder.StAXSOAPModelBuilder"/>
</messageBuilders>
<!-- ================================================= -->
---------------------------------------------------------------------
To unsubscribe, e-mail: axis-cvs-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-cvs-help@ws.apache.org