Converting JSON Databinding implementation to 2.x

git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@820522 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
lresende 2009-10-01 03:58:49 +00:00
parent f178ddb849
commit d7631af738
5 changed files with 11 additions and 8 deletions

View file

@ -22,7 +22,7 @@
<parent>
<groupId>org.apache.tuscany.sca</groupId>
<artifactId>tuscany-modules</artifactId>
<version>1.6-SNAPSHOT</version>
<version>2.0-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<artifactId>tuscany-databinding-json</artifactId>
@ -32,12 +32,12 @@
<dependency>
<groupId>org.apache.tuscany.sca</groupId>
<artifactId>tuscany-core-spi</artifactId>
<version>1.6-SNAPSHOT</version>
<version>2.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.apache.tuscany.sca</groupId>
<artifactId>tuscany-databinding</artifactId>
<version>1.6-SNAPSHOT</version>
<version>2.0-SNAPSHOT</version>
</dependency>
<dependency>

View file

@ -29,6 +29,7 @@ import java.util.Collections;
import java.util.Comparator;
import org.apache.tuscany.sca.databinding.PullTransformer;
import org.apache.tuscany.sca.databinding.SimpleTypeMapper;
import org.apache.tuscany.sca.databinding.TransformationContext;
import org.apache.tuscany.sca.databinding.TransformationException;
import org.apache.tuscany.sca.databinding.impl.BaseTransformer;
@ -39,6 +40,8 @@ import org.codehaus.jettison.json.JSONArray;
import org.codehaus.jettison.json.JSONObject;
public class JavaBean2JSONObject extends BaseTransformer<Object, Object> implements PullTransformer<Object, Object> {
private static final SimpleTypeMapper SIMPLE_TYPE_MAPPER = new SimpleTypeMapperImpl();
private static final Comparator<PropertyDescriptor> COMPARATOR = new Comparator<PropertyDescriptor>() {
public int compare(PropertyDescriptor o1, PropertyDescriptor o2) {
return o1.getName().compareTo(o2.getName());
@ -52,7 +55,7 @@ public class JavaBean2JSONObject extends BaseTransformer<Object, Object> impleme
if (o == null) {
return null;
}
TypeInfo info = SimpleTypeMapperImpl.getXMLType(o.getClass());
TypeInfo info = SIMPLE_TYPE_MAPPER.getXMLType(o.getClass());
if (info != null) {
return MAPPER.toXMLLiteral(info.getQName(), o, null);
} else {
@ -61,7 +64,7 @@ public class JavaBean2JSONObject extends BaseTransformer<Object, Object> impleme
}
private static boolean isSimpleType(Class<?> javaType) {
return SimpleTypeMapperImpl.getXMLType(javaType) != null;
return SIMPLE_TYPE_MAPPER.getXMLType(javaType) != null;
}
public JavaBean2JSONObject() {

View file

@ -24,11 +24,11 @@ import java.io.StringWriter;
import javax.xml.stream.XMLStreamReader;
import javax.xml.stream.XMLStreamWriter;
import org.apache.tuscany.sca.common.xml.stax.impl.XMLStreamSerializer;
import org.apache.tuscany.sca.databinding.PullTransformer;
import org.apache.tuscany.sca.databinding.TransformationContext;
import org.apache.tuscany.sca.databinding.TransformationException;
import org.apache.tuscany.sca.databinding.impl.BaseTransformer;
import org.apache.tuscany.sca.databinding.xml.XMLStreamSerializer;
import org.codehaus.jettison.badgerfish.BadgerFishXMLStreamWriter;
/**

View file

@ -34,7 +34,7 @@ import org.apache.tuscany.sca.databinding.json.JSONHelper;
import org.apache.tuscany.sca.interfacedef.DataType;
import org.apache.tuscany.sca.interfacedef.util.XMLType;
import org.codehaus.jettison.json.JSONObject;
import org.osoa.sca.annotations.Service;
import org.oasisopen.sca.annotation.Service;
/**
* @version $Rev$ $Date$

View file

@ -32,10 +32,10 @@ import junit.framework.Assert;
import junit.framework.TestCase;
import org.apache.axiom.om.OMElement;
import org.apache.tuscany.sca.common.xml.stax.impl.XMLStreamSerializer;
import org.apache.tuscany.sca.databinding.TransformationContext;
import org.apache.tuscany.sca.databinding.impl.TransformationContextImpl;
import org.apache.tuscany.sca.databinding.json.axiom.JSON2OMElement;
import org.apache.tuscany.sca.databinding.xml.XMLStreamSerializer;
import org.apache.tuscany.sca.interfacedef.DataType;
import org.apache.tuscany.sca.interfacedef.impl.DataTypeImpl;
import org.apache.tuscany.sca.interfacedef.util.XMLType;