Skip to content
Commits on Source (19)
......@@ -43,19 +43,31 @@
<fail unless="password" message="Must define -Dpassword" />
<!-- uploads done using webdav, need to register -->
<!--
<artifact:install-provider artifactId="wagon-webdav" version="1.0-beta-1" />
-->
<echo message="(authenticating as user '${user}')" />
<artifact:remoteRepository id="repo.release"
<!--
url="dav:https://dav.codehaus.org/repository/jackson"
url="https://nexus.codehaus.org/service/local/staging/deploy/maven2/"
url="https://oss.sonatype.org/service/local/staging/deploy/maven2/"
-->
<artifact:remoteRepository id="repo.release"
url="https://oss.sonatype.org/service/local/staging/deploy/maven2/"
>
<authentication username="${user}" password="${password}" />
<releases enabled="true"/>
<snapshots enabled="false"/>
</artifact:remoteRepository>
<artifact:remoteRepository id="repo.snapshot"
<!--
url="dav:https://dav.codehaus.org/snapshots.repository/jackson"
url="https://nexus.codehaus.org/content/repositories/snapshots/"
url="https://oss.sonatype.org/content/repositories/snapshots"
-->
<artifact:remoteRepository id="repo.snapshot"
url="https://oss.sonatype.org/content/repositories/snapshots"
>
<authentication username="${user}" password="${password}" />
<releases enabled="false"/>
......@@ -163,56 +175,96 @@
file="${dir.dist}/jackson-core-asl-${IMPL_VERSION}.jar"
>
<remoteRepository refid="repo.release" />
<attach file="${dir.dist}/jackson-core-asl-${IMPL_VERSION}.jar.asc" type="jar.asc" />
<attach file="${dir.dist}/jackson-core-asl-${IMPL_VERSION}.pom.asc" type="pom.asc" />
<attach file="${dir.dist}/jackson-core-asl-${IMPL_VERSION}-sources.jar" type="jar" classifier="sources" />
<attach file="${dir.dist}/jackson-core-asl-${IMPL_VERSION}-sources.jar.asc" type="jar.asc" classifier="sources" />
<attach file="${dir.dist}/jackson-core-asl-${IMPL_VERSION}-javadoc.jar" type="jar" classifier="javadoc" />
<attach file="${dir.dist}/jackson-core-asl-${IMPL_VERSION}-javadoc.jar.asc" type="jar.asc" classifier="javadoc" />
</artifact:deploy>
<artifact:deploy pomRefId="pom.asl.mapper" uniqueVersion="false"
file="${dir.dist}/jackson-mapper-asl-${IMPL_VERSION}.jar"
>
<remoteRepository refid="repo.release" />
<attach file="${dir.dist}/jackson-mapper-asl-${IMPL_VERSION}.jar.asc" type="jar.asc" />
<attach file="${dir.dist}/jackson-mapper-asl-${IMPL_VERSION}.pom.asc" type="pom.asc" />
<attach file="${dir.dist}/jackson-mapper-asl-${IMPL_VERSION}-sources.jar" type="jar" classifier="sources" />
<attach file="${dir.dist}/jackson-mapper-asl-${IMPL_VERSION}-sources.jar.asc" type="jar.asc" classifier="sources" />
<attach file="${dir.dist}/jackson-mapper-asl-${IMPL_VERSION}-javadoc.jar" type="jar" classifier="javadoc" />
<attach file="${dir.dist}/jackson-mapper-asl-${IMPL_VERSION}-javadoc.jar.asc" type="jar.asc" classifier="javadoc" />
</artifact:deploy>
<artifact:deploy pomRefId="pom.lgpl.core" uniqueVersion="false"
file="${dir.dist}/jackson-core-lgpl-${IMPL_VERSION}.jar"
>
<remoteRepository refid="repo.release" />
<attach file="${dir.dist}/jackson-core-lgpl-${IMPL_VERSION}.jar.asc" type="jar.asc" />
<attach file="${dir.dist}/jackson-core-lgpl-${IMPL_VERSION}.pom.asc" type="pom.asc" />
<attach file="${dir.dist}/jackson-core-lgpl-${IMPL_VERSION}-sources.jar" type="jar" classifier="sources" />
<attach file="${dir.dist}/jackson-core-lgpl-${IMPL_VERSION}-sources.jar.asc" type="jar.asc" classifier="sources" />
<attach file="${dir.dist}/jackson-core-lgpl-${IMPL_VERSION}-javadoc.jar" type="jar" classifier="javadoc" />
<attach file="${dir.dist}/jackson-core-lgpl-${IMPL_VERSION}-javadoc.jar.asc" type="jar.asc" classifier="javadoc" />
</artifact:deploy>
<artifact:deploy pomRefId="pom.lgpl.mapper" uniqueVersion="false"
file="${dir.dist}/jackson-mapper-lgpl-${IMPL_VERSION}.jar"
>
<remoteRepository refid="repo.release" />
<attach file="${dir.dist}/jackson-mapper-lgpl-${IMPL_VERSION}.jar.asc" type="jar.asc" />
<attach file="${dir.dist}/jackson-mapper-lgpl-${IMPL_VERSION}.pom.asc" type="pom.asc" />
<attach file="${dir.dist}/jackson-mapper-lgpl-${IMPL_VERSION}-sources.jar" type="jar" classifier="sources" />
<attach file="${dir.dist}/jackson-mapper-lgpl-${IMPL_VERSION}-sources.jar.asc" type="jar.asc" classifier="sources" />
<attach file="${dir.dist}/jackson-mapper-lgpl-${IMPL_VERSION}-javadoc.jar" type="jar" classifier="javadoc" />
<attach file="${dir.dist}/jackson-mapper-lgpl-${IMPL_VERSION}-javadoc.jar.asc" type="jar.asc" classifier="javadoc" />
</artifact:deploy>
<artifact:deploy pomRefId="pom.jaxrs" uniqueVersion="false"
file="${dir.dist}/jackson-jaxrs-${IMPL_VERSION}.jar"
>
<remoteRepository refid="repo.release" />
<attach file="${dir.dist}/jackson-jaxrs-${IMPL_VERSION}.jar.asc" type="jar.asc" />
<attach file="${dir.dist}/jackson-jaxrs-${IMPL_VERSION}.pom.asc" type="pom.asc" />
<attach file="${dir.dist}/jackson-jaxrs-${IMPL_VERSION}-sources.jar" type="jar" classifier="sources" />
<attach file="${dir.dist}/jackson-jaxrs-${IMPL_VERSION}-sources.jar.asc" type="jar.asc" classifier="sources" />
<attach file="${dir.dist}/jackson-jaxrs-${IMPL_VERSION}-javadoc.jar" type="jar" classifier="javadoc" />
<attach file="${dir.dist}/jackson-jaxrs-${IMPL_VERSION}-javadoc.jar.asc" type="jar.asc" classifier="javadoc" />
</artifact:deploy>
<artifact:deploy pomRefId="pom.xc" uniqueVersion="false"
file="${dir.dist}/jackson-xc-${IMPL_VERSION}.jar"
>
<remoteRepository refid="repo.release" />
<attach file="${dir.dist}/jackson-xc-${IMPL_VERSION}.jar.asc" type="jar.asc" />
<attach file="${dir.dist}/jackson-xc-${IMPL_VERSION}.pom.asc" type="pom.asc" />
<attach file="${dir.dist}/jackson-xc-${IMPL_VERSION}-sources.jar" type="jar" classifier="sources" />
<attach file="${dir.dist}/jackson-xc-${IMPL_VERSION}-sources.jar.asc" type="jar.asc" classifier="sources" />
<attach file="${dir.dist}/jackson-xc-${IMPL_VERSION}-javadoc.jar" type="jar" classifier="javadoc" />
<attach file="${dir.dist}/jackson-xc-${IMPL_VERSION}-javadoc.jar.asc" type="jar.asc" classifier="javadoc" />
</artifact:deploy>
<artifact:deploy pomRefId="pom.smile" uniqueVersion="false"
file="${dir.dist}/jackson-smile-${IMPL_VERSION}.jar"
>
<remoteRepository refid="repo.release" />
<attach file="${dir.dist}/jackson-smile-${IMPL_VERSION}.jar.asc" type="jar.asc" />
<attach file="${dir.dist}/jackson-smile-${IMPL_VERSION}.pom.asc" type="pom.asc" />
<attach file="${dir.dist}/jackson-smile-${IMPL_VERSION}-sources.jar" type="jar" classifier="sources" />
<attach file="${dir.dist}/jackson-smile-${IMPL_VERSION}-sources.jar.asc" type="jar.asc" classifier="sources" />
<attach file="${dir.dist}/jackson-smile-${IMPL_VERSION}-javadoc.jar" type="jar" classifier="javadoc" />
<attach file="${dir.dist}/jackson-smile-${IMPL_VERSION}-javadoc.jar.asc" type="jar.asc" classifier="javadoc" />
</artifact:deploy>
<artifact:deploy pomRefId="pom.mrbean" uniqueVersion="false"
file="${dir.dist}/jackson-mrbean-${IMPL_VERSION}.jar"
>
<remoteRepository refid="repo.release" />
<attach file="${dir.dist}/jackson-mrbean-${IMPL_VERSION}.jar.asc" type="jar.asc" />
<attach file="${dir.dist}/jackson-mrbean-${IMPL_VERSION}.pom.asc" type="pom.asc" />
<attach file="${dir.dist}/jackson-mrbean-${IMPL_VERSION}-sources.jar" type="jar" classifier="sources" />
<attach file="${dir.dist}/jackson-mrbean-${IMPL_VERSION}-sources.jar.asc" type="jar.asc" classifier="sources" />
<attach file="${dir.dist}/jackson-mrbean-${IMPL_VERSION}-javadoc.jar" type="jar" classifier="javadoc" />
<attach file="${dir.dist}/jackson-mrbean-${IMPL_VERSION}-javadoc.jar.asc" type="jar.asc" classifier="javadoc" />
</artifact:deploy>
</target>
......
......@@ -98,6 +98,7 @@ org.codehaus.jackson.map.deser;version=${IMPL_VERSION},
org.codehaus.jackson.map.deser.impl;version=${IMPL_VERSION},
org.codehaus.jackson.map.deser.std;version=${IMPL_VERSION},
org.codehaus.jackson.map.exc;version=${IMPL_VERSION},
org.codehaus.jackson.map.ext;version=${IMPL_VERSION},
org.codehaus.jackson.map.introspect;version=${IMPL_VERSION},
org.codehaus.jackson.map.jsontype;version=${IMPL_VERSION},
org.codehaus.jackson.map.jsontype.impl;version=${IMPL_VERSION},
......@@ -198,6 +199,7 @@ org.codehaus.jackson.map.deser;version=${IMPL_VERSION},
org.codehaus.jackson.map.deser.impl;version=${IMPL_VERSION},
org.codehaus.jackson.map.deser.std;version=${IMPL_VERSION},
org.codehaus.jackson.map.exc;version=${IMPL_VERSION},
org.codehaus.jackson.map.ext;version=${IMPL_VERSION},
org.codehaus.jackson.map.introspect;version=${IMPL_VERSION},
org.codehaus.jackson.map.jsontype;version=${IMPL_VERSION},
org.codehaus.jackson.map.jsontype.impl;version=${IMPL_VERSION},
......
......@@ -178,6 +178,7 @@ test.run.interop, test.run.jaxrs, test.run.failing, test.run.versions"
<!-- failing tests run during dev, disabled for maintenance versions -->
<target name="test.run.failing" depends="test.compile">
<!--
<junit fork="no" printsummary="yes" haltonfailure="no" showoutput="yes">
<batchtest fork="no" todir="${dir.test.xmlresults}">
<fileset dir="${dir.test.classes}">
......@@ -200,6 +201,7 @@ test.run.interop, test.run.jaxrs, test.run.failing, test.run.versions"
</fileset>
</classpath>
</junit>
-->
</target>
<target name="test.run.versions" depends="test.compile">
......
#!/bin/sh
java -Xmx48m -server -cp build/classes/perf:build/classes/core\
:build/classes/mapper:lib/perf/\* \
-XX:CompileThreshold=2000 \
-Xrunhprof:cpu=samples,depth=10,verbose=n,interval=2 \
TestJsonPerf \
$*
#!/bin/sh
java -Xmx16m -server \
-cp build/classes/perf:perflib/\* \
-XX:CompileThreshold=2000 \
-Xrunhprof:cpu=samples,depth=10,verbose=n,interval=2 \
TestReadPerf $*
#!/bin/sh
java -Xmx48m -server -cp build/classes \
TestCopyPerf $*
#!/bin/sh
java -Xmx48m -server -cp build/classes/perf:build/classes/core\
:build/classes/mapper:lib/perf/\* \
TestJsonPerf \
$*
#!/bin/sh
java -Xmx16m -server \
-cp build/classes/perf:perflib/\* \
TestReadPerf $*
#!/bin/sh
java -Xmx48m -server -cp build/classes/perf:build/classes/core\
:build/classes/mapper:lib/perf/\* \
TestSerPerf \
$*
......@@ -50,7 +50,7 @@
<property name="IMPL_TITLE_SMILE" value="Jackson Binary format (aka Smile) handling functionality" />
<property name="IMPL_TITLE_MRBEAN" value="Jackson Bean Materializer (aka Mr. Bean)" />
<property name="IMPL_VERSION" value="1.9.2" />
<property name="IMPL_VERSION" value="1.9.13" />
<property name="IMPL_VENDOR" value="http://fasterxml.com" />
<patternset id="dist-all-source-files">
......@@ -357,7 +357,7 @@ compile.smile, compile.mrbean" />
<!-- Joda time... -->
<link href="http://joda-time.sourceforge.net/api-release" />
<!-- Regular JDK 6 classes -->
<link href="http://java.sun.com/javase/6/docs/api" />
<link href="http://docs.oracle.com/javase/6/docs/api" />
<!-- And JAX-RS (jsr-311) as well -->
<link href="http://jackson.codehaus.org/javadoc/jax-rs/1.0" />
......@@ -481,9 +481,33 @@ compile.smile, compile.mrbean" />
<jar destfile="${dir.dist}/jackson-core-asl-${IMPL_VERSION}-javadoc.jar"
filesonly="true" compress="true" basedir="${dir.javadoc}" includes="**/*"
/>
<jar destfile="${dir.dist}/jackson-core-lgpl-${IMPL_VERSION}-javadoc.jar"
filesonly="true" compress="true" basedir="${dir.javadoc}" includes="**/*"
/>
<jar destfile="${dir.dist}/jackson-mapper-asl-${IMPL_VERSION}-javadoc.jar"
filesonly="true" compress="true" basedir="${dir.javadoc}" includes="**/*"
/>
<jar destfile="${dir.dist}/jackson-mapper-lgpl-${IMPL_VERSION}-javadoc.jar"
filesonly="true" compress="true" basedir="${dir.javadoc}" includes="**/*"
/>
<jar destfile="${dir.dist}/jackson-jaxrs-${IMPL_VERSION}-javadoc.jar"
filesonly="true" compress="true" basedir="${dir.javadoc}"
includes="org/codehaus/jackson/jaxrs/**/*"
/>
<jar destfile="${dir.dist}/jackson-mrbean-${IMPL_VERSION}-javadoc.jar"
filesonly="true" compress="true" basedir="${dir.javadoc}"
includes="org/codehaus/jackson/mrbean/**/*"
/>
<jar destfile="${dir.dist}/jackson-smile-${IMPL_VERSION}-javadoc.jar"
filesonly="true" compress="true" basedir="${dir.javadoc}"
includes="org/codehaus/jackson/smile/**/*"
/>
<jar destfile="${dir.dist}/jackson-xc-${IMPL_VERSION}-javadoc.jar"
filesonly="true" compress="true" basedir="${dir.javadoc}">
<include name="org/codehaus/jackson/xc/**" />
<include name="org/codehaus/jackson/xml/**" />
</jar>
<!-- Then copy javadocs -->
<copy todir="${dir.dist}">
......
package org.codehaus.jackson.map.deser;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import org.objectweb.asm.ClassWriter;
import org.objectweb.asm.FieldVisitor;
import org.objectweb.asm.MethodVisitor;
import org.objectweb.asm.Opcodes;
public class BeanHelper implements Opcodes {
public static class BeanBuilder {
protected Map<String, Class> properties = new LinkedHashMap<String, Class>();
protected Map<String, ThrowMethodType> throwMethods = new LinkedHashMap<String, ThrowMethodType>();
protected List<Class> implementing = new ArrayList<Class>();
protected String className;
protected String internalClass;
public BeanBuilder(String className) {
this.className = className;
this.internalClass = getInternalClassName(className);
}
public BeanBuilder implement(Class parent) {
this.implementing.add(parent);
for (Method m : parent.getMethods()) {
if (m.getName().startsWith("get")
|| m.getName().startsWith("set")) {
String name = getFieldName(m.getName());
Class propType = m.getName().startsWith("get") ? m
.getReturnType() : m.getParameterTypes()[0];
if (this.properties.containsKey(name)
&& !this.properties.get(name).equals(propType)) {
throw new IllegalArgumentException("Duplicate property");
}
addProperty(name, propType);
} else {
addThrow(m.getName(), m.getParameterTypes(), m
.getReturnType(),
UnsupportedOperationException.class);
}
}
return this;
}
public BeanBuilder addProperty(String name, Class type) {
properties.put(name, type);
return this;
}
public BeanBuilder addThrow(String name, Class[] paramTypes,
Class returnType, Class exceptionType) {
this.throwMethods.put(name, new ThrowMethodType(name, paramTypes,
returnType, exceptionType));
return this;
}
public Class load() {
ClassWriter cw = new ClassWriter(0);
String[] parents = new String[implementing.size()];
for (int i = 0; i < implementing.size(); i++) {
parents[i] = getInternalClassName(implementing.get(i).getName());
}
cw.visit(V1_2, ACC_PUBLIC + ACC_SUPER, internalClass, null,
"java/lang/Object", parents);
cw.visitSource(className + ".java", null);
BeanHelper.generateDefaultConstructor(cw);
for (Map.Entry<String, Class> propEntry : this.properties
.entrySet()) {
String propName = propEntry.getKey();
Class propClass = propEntry.getValue();
BeanHelper.createField(cw, propName, propClass);
BeanHelper.createGetter(cw, internalClass, propName, propClass);
BeanHelper.createSetter(cw, internalClass, propName, propClass);
}
for (Map.Entry<String, ThrowMethodType> throwEntry : this.throwMethods
.entrySet()) {
ThrowMethodType thr = throwEntry.getValue();
BeanHelper.createThrow(cw, this.internalClass, throwEntry
.getKey(), thr.paramTypes, thr.returnType,
thr.exceptionType);
}
cw.visitEnd();
return loadClass(className, cw.toByteArray());
}
}
private static void generateDefaultConstructor(ClassWriter cw) {
MethodVisitor mv = cw.visitMethod(ACC_PUBLIC, "<init>", "()V", null,
null);
mv.visitCode();
mv.visitVarInsn(ALOAD, 0);
mv.visitMethodInsn(INVOKESPECIAL, "java/lang/Object", "<init>", "()V");
mv.visitInsn(RETURN);
mv.visitMaxs(1, 1);
mv.visitEnd();
}
private static void createField(ClassWriter cw, String fieldName,
Class fieldType) {
String javaType = getLValue(fieldType);
FieldVisitor fv = cw.visitField(0, fieldName, javaType, null, null);
fv.visitEnd();
}
private static void createSetter(ClassWriter cw, String internalClassName,
String fieldName, Class fieldType) {
String methodName = getSetterName(fieldName);
String returnType = getLValue(fieldType);
MethodVisitor mv = cw.visitMethod(ACC_PUBLIC, methodName, "("
+ returnType + ")V", null, null);
mv.visitVarInsn(ALOAD, 0);
mv.visitVarInsn(ALOAD, 1);
mv.visitFieldInsn(PUTFIELD, internalClassName, fieldName, returnType);
mv.visitInsn(RETURN);
mv.visitMaxs(2, 2);
mv.visitEnd();
}
private static void createGetter(ClassWriter cw, String internalClassName,
String fieldName, Class fieldType) {
String methodName = getGetterName(fieldName);
String returnType = getLValue(fieldType);
MethodVisitor mv = cw.visitMethod(ACC_PUBLIC, methodName, "()"
+ returnType, null, null);
mv.visitVarInsn(ALOAD, 0);
mv.visitFieldInsn(GETFIELD, internalClassName, fieldName, returnType);
mv.visitInsn(ARETURN);
mv.visitMaxs(1, 1);
mv.visitEnd();
}
private static void createThrow(ClassWriter cw, String internalClassName,
String methodName, Class[] inTypes, Class returnType,
Class exceptionType) {
String rTypeName = getLValue(returnType);
String exceptionName = getInternalClassName(exceptionType.getName());
String sig = "(" + getArgumentsType(inTypes) + ")" + rTypeName;
MethodVisitor mv = cw.visitMethod(ACC_PUBLIC, methodName, sig, null,
null);
mv.visitTypeInsn(NEW, exceptionName);
mv.visitInsn(DUP);
mv.visitMethodInsn(INVOKESPECIAL, exceptionName, "<init>", "()V");
mv.visitInsn(ATHROW);
mv.visitMaxs(2, 1 + inTypes.length);
mv.visitEnd();
}
private static Class loadClass(String className, byte[] b) {
// override classDefine (as it is protected) and define the class.
Class clazz = null;
try {
ClassLoader loader = ClassLoader.getSystemClassLoader();
Class cls = Class.forName("java.lang.ClassLoader");
java.lang.reflect.Method method = cls.getDeclaredMethod(
"defineClass", new Class[] { String.class, byte[].class,
int.class, int.class });
// protected method invocaton
method.setAccessible(true);
try {
Object[] args = new Object[] { className, b, new Integer(0),
new Integer(b.length) };
clazz = (Class) method.invoke(loader, args);
} finally {
method.setAccessible(false);
}
} catch (Exception e) {
e.printStackTrace();
System.exit(1);
}
return clazz;
}
private static String getInternalClassName(String className) {
return className.replace(".", "/");
}
private static String getFieldName(String getterMethodName) {
char[] name = getterMethodName.substring(3).toCharArray();
name[0] = Character.toLowerCase(name[0]);
final String propName = new String(name);
return propName;
}
private static String getLValue(Class fieldType) {
if (fieldType == null || fieldType.equals(void.class)) {
return "V";
}
String plainR = fieldType.getName();
String rType = getInternalClassName(plainR);
String javaType = "L" + rType + ";";
return javaType;
}
private static String getGetterName(String fieldName) {
return "get" + fieldName.substring(0, 1).toUpperCase()
+ fieldName.substring(1);
}
private static String getSetterName(String fieldName) {
return "set" + fieldName.substring(0, 1).toUpperCase()
+ fieldName.substring(1);
}
private static String getArgumentsType(Class[] inTypes) {
StringBuilder list = new StringBuilder();
for (Class clazz : inTypes) {
list.append(getLValue(clazz));
}
return list.toString();
}
private static class ThrowMethodType {
public final String name;
public final Class[] paramTypes;
public final Class returnType;
public final Class exceptionType;
public ThrowMethodType(String name, Class[] paramTypes,
Class returnType, Class exceptionType) {
this.name = name;
this.paramTypes = paramTypes;
this.returnType = returnType;
this.exceptionType = exceptionType;
}
}
}
/**
* 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.codehaus.jackson.map.deser;
import java.lang.reflect.Method;
import org.codehaus.jackson.map.DeserializationConfig;
import org.codehaus.jackson.map.DeserializerProvider;
import org.codehaus.jackson.map.JsonDeserializer;
import org.codehaus.jackson.map.JsonMappingException;
import org.codehaus.jackson.map.type.TypeFactory;
import org.codehaus.jackson.type.JavaType;
/**
* A very basic Jackson deserializer factory that extends the BeanSerializer
* factory to allow deserialization using interfaces.
*/
public class MaterializingDeserializerFactory extends BeanDeserializerFactory {
public MaterializingDeserializerFactory() {
super();
}
@Override
public JsonDeserializer<Object> createBeanDeserializer(
DeserializationConfig config, JavaType type, DeserializerProvider p)
throws JsonMappingException {
if (type.isInterface()) {
String className = "$org.codehaus.jackson.generated$"
+ type.getRawClass().getName();
BeanHelper.BeanBuilder builder = new BeanHelper.BeanBuilder(
className);
builder.implement(type.getRawClass());
return new BeanDeserializerProxyImpl(TypeFactory.fromClass(builder
.load()));
}
return super.createBeanDeserializer(config, type, p);
}
protected static class BeanDeserializerProxyImpl extends BeanDeserializer {
public BeanDeserializerProxyImpl(JavaType type) {
super(type);
try {
this.setDefaultConstructor(type.getRawClass().getConstructor());
} catch (Exception e) {
throw new RuntimeException(e);
}
try {
populateSetters(type);
} catch (NoSuchMethodException e) {
throw new RuntimeException(e);
}
}
private void populateSetters(JavaType type)
throws NoSuchMethodException {
Class clazz = type.getRawClass();
for (Method m : clazz.getMethods()) {
String methodName = m.getName();
if (methodName.startsWith("set")
&& m.getParameterTypes() != null
&& m.getParameterTypes().length == 1) {
Class fieldClass = m.getParameterTypes()[0];
JavaType fieldType = TypeFactory.fromClass(fieldClass);
Method setterMethod = getSetterMethod(clazz, methodName,
fieldClass);
this.addProperty(new SettableBeanProperty.MethodProperty(
getFieldName(methodName), fieldType,
setterMethod));
}
}
}
private Method getSetterMethod(Class clazz, String methodName,
Class returnType) throws NoSuchMethodException {
return clazz.getMethod("set" + methodName.substring(3), returnType);
}
}
private static String getFieldName(String getterMethodName) {
char[] name = getterMethodName.substring(3).toCharArray();
name[0] = Character.toLowerCase(name[0]);
final String propName = new String(name);
System.out.println(propName);
return propName;
}
}
Work in progress for "materialized interface" extension, contributed by Sunny Gleason.
Exciting stuff, real source at GitHub (see [http://github.com/sunnygleason/g414-jackson]), but temporarily also cached here for convenience.
/**
* 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.example;
import java.io.StringWriter;
import junit.framework.TestCase;
import org.codehaus.jackson.map.ObjectMapper;
import org.codehaus.jackson.map.deser.MaterializingDeserializerFactory;
import org.codehaus.jackson.map.deser.StdDeserializerProvider;
import com.g414.jackson.proxy.ProxySerializerFactory;
/**
* Exercise the deserializer...
*/
public class TestMaterializingDeserializer extends TestCase {
public void testExample() throws Exception {
ExampleImpl impl = new ExampleImpl();
ObjectMapper mapper = new ObjectMapper();
mapper.setSerializerFactory(new ProxySerializerFactory());
MaterializingDeserializerFactory df = new MaterializingDeserializerFactory();
StdDeserializerProvider dp = new StdDeserializerProvider(df);
mapper.setDeserializerProvider(dp);
// Testing Example1
StringWriter w1 = new StringWriter();
mapper.writeValue(w1, impl.asExample1());
String w1Value = w1.toString();
Example1 w1in = mapper.readValue(w1Value, Example1.class);
assertEquals("4660", w1in.getA().toString());
assertEquals("Foo", w1in.getB().toString());
// Testing Example2 ...
StringWriter w2 = new StringWriter();
mapper.writeValue(w2, impl.asExample2());
String w2Value = w2.toString();
Example2 w2in = mapper.readValue(w2Value, Example2.class);
assertEquals("305419896", w2in.getC().toString());
}
}
......@@ -40,8 +40,6 @@
<!-- Need to link to regular JDK 6 classes -->
<link href="/usr/share/doc/default-jdk-doc/api" />
<!-- And JAX-RS (jsr-311) as well -->
<link href="/usr/share/doc/libjsr311-java/api" />
<!-- And Joda time... -->
<link href="http://joda-time.sourceforge.net/api-release" />
......
libjackson-json-java (1.9.13-1) unstable; urgency=medium
* Team upload.
* New upstream release
- Updated the path to the artifacts installed by mh_install
* Depend on libjaxrs-api-java instead of libjsr311-api-java
* Standards-Version updated to 4.3.0
* Use salsa.debian.org Vcs-* URLs
* Added the watch file
* Converted debian/copyright to the Copyright Format 1.0
-- Emmanuel Bourg <ebourg@apache.org> Sun, 30 Dec 2018 23:28:06 +0100
libjackson-json-java (1.9.2-10) unstable; urgency=medium
* Team upload.
......
......@@ -14,21 +14,20 @@ Build-Depends:
libasm-java (>= 5.0),
libjarjar-java,
libjaxb-java,
libjaxrs-api-java,
libjoda-time-java,
libjsr311-api-java,
libjsr311-api-java-doc,
maven-repo-helper (>= 1.5~),
libnet-luminis-build-plugin-java (>= 0.2.0-3)
Standards-Version: 4.2.1
Vcs-Git: https://anonscm.debian.org/git/pkg-java/libjackson-json-java.git
Vcs-Browser: https://anonscm.debian.org/cgit/pkg-java/libjackson-json-java.git
Standards-Version: 4.3.0
Vcs-Git: https://salsa.debian.org/java-team/libjackson-json-java.git
Vcs-Browser: https://salsa.debian.org/java-team/libjackson-json-java
Homepage: https://github.com/FasterXML/jackson
Package: libjackson-json-java
Architecture: all
Depends:
libjoda-time-java,
libjsr311-api-java,
libjaxrs-api-java,
${misc:Depends}
Suggests: libjackson-json-java-doc
Description: streaming fast powerful standard conformant json processor in java
......@@ -51,7 +50,7 @@ Package: libjackson-json-java-doc
Architecture: all
Section: doc
Depends: ${misc:Depends}
Recommends: default-jdk-doc, libjsr311-api-java-doc
Recommends: default-jdk-doc
Description: standard conformant json processor in java - API documentation
Jackson is a Java-based JSON-processing package that contains:
.
......
This package was Debianised by Thomas Koch <thomas.koch@ymc.ch> on
Tue, 21 Apr 2010 11:11:05 +0200
This package was downloaded from
http://jackson.codehaus.org
Upstream Author: FasterXML, LLC, Seattle, USA <info@fasterxml.com>
The packaging is Copyright 2010 Thomas Koch <thomas.koch@ymc.ch>, 2011 James
Page <james.page@ubuntu.com>, 2013 Markus Koschany <apo@gambaru.de> and is
licenced under the terms of the Apache-2.0 licence.
The software is released dual licensed under the
* Apache License 2.0 (AL 2.0)
* Lesser/Library General Public License (LGPL 2.1)
On Debian systems the texts of these licenses can be found in the files
/usr/share/common-licenses/Apache-2.0
/usr/share/common-licenses/LGPL-2.1
The file
debian/bnd_plugin/net/luminis/build/plugin/bnd/BuildTask.java
was downloaded from:
https://opensource.luminis.net/svn/BUNDLES/trunk/build-plugin/src/net/luminis/build/plugin/bnd/BuildTask.java
as SVN Revision 628, Tue Apr 06 2010
More information on this file:
http://opensource.luminis.net/wiki/display/SITE/OSGi+Bundle+Ant+Task
It's copyright header says:
Copyright (c) 2006, 2007 luminis
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
- Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
- Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
- Neither the name of the Luminis nor the names of its contributors may be
used to endorse or promote products derived from this software without
specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/
Upstream-Name: Jackson
Source: https://github.com/FasterXML/jackson-1
Files-Excluded: *.jar
Files: *
Copyright: 2009-2013, FasterXML
License: Apache-2.0 or LGPL-2.1
Files: debian/*
Copyright: 2010, Thomas Koch <thomas.koch@ymc.ch>
2011, James Page <james.page@ubuntu.com>
2013-2018, Markus Koschany <apo@debian.org>
2015-2018, Emmanuel Bourg <ebourg@apache.org>
License: Apache-2.0
License: Apache-2.0
On Debian systems, the full text of the Apache-2.0 license
can be found in the file '/usr/share/common-licenses/Apache-2.0'
License: LGPL-2.1
On Debian systems, the full text of the LGPL-2.1 license
can be found in the file '/usr/share/common-licenses/LGPL-2.1'
dist/jackson-core-asl-1.9.2.pom --artifact=build/jackson-core-asl-1.9.2.jar --java-lib
dist/jackson-core-lgpl-1.9.2.pom --artifact=build/jackson-core-lgpl-1.9.2.jar --java-lib
dist/jackson-jaxrs-1.9.2.pom --artifact=build/jackson-jaxrs-1.9.2.jar --java-lib
dist/jackson-mapper-asl-1.9.2.pom --artifact=build/jackson-mapper-asl-1.9.2.jar --java-lib
dist/jackson-mapper-lgpl-1.9.2.pom --artifact=build/jackson-mapper-lgpl-1.9.2.jar --java-lib
dist/jackson-mrbean-1.9.2.pom --artifact=build/jackson-mrbean-1.9.2.jar --java-lib
dist/jackson-smile-1.9.2.pom --artifact=build/jackson-smile-1.9.2.jar --java-lib
dist/jackson-xc-1.9.2.pom --artifact=build/jackson-xc-1.9.2.jar --java-lib
dist/jackson-core-asl-1.9.13.pom --java-lib --artifact=build/jackson-core-asl-1.9.13.jar
dist/jackson-core-lgpl-1.9.13.pom --java-lib --artifact=build/jackson-core-lgpl-1.9.13.jar
dist/jackson-jaxrs-1.9.13.pom --java-lib --artifact=build/jackson-jaxrs-1.9.13.jar
dist/jackson-mapper-asl-1.9.13.pom --java-lib --artifact=build/jackson-mapper-asl-1.9.13.jar
dist/jackson-mapper-lgpl-1.9.13.pom --java-lib --artifact=build/jackson-mapper-lgpl-1.9.13.jar
dist/jackson-mrbean-1.9.13.pom --java-lib --artifact=build/jackson-mrbean-1.9.13.jar
dist/jackson-smile-1.9.13.pom --java-lib --artifact=build/jackson-smile-1.9.13.jar
dist/jackson-xc-1.9.13.pom --java-lib --artifact=build/jackson-xc-1.9.13.jar
......@@ -5,7 +5,7 @@
override_dh_auto_build: mklibdirs
ln -s /usr/share/java/joda-time.jar lib/ext/joda-time.jar || true
ln -s /usr/share/java/jsr311-api.jar lib/jaxrs/jsr311-api.jar || true
ln -s /usr/share/java/jaxrs-api.jar lib/jaxrs/jsr311-api.jar || true
ln -s /usr/share/java/asm.jar lib/ext/asm/asm-3.3.jar || true
ln -s /usr/share/java/jarjar.jar lib/ext/jarjar/jarjar-1.0.jar || true
ln -s /usr/share/java/jaxb-impl.jar lib/jaxb/jaxb-impl.jar || true
......