activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From chir...@apache.org
Subject svn commit: r1132962 - /activemq/activemq-apollo/trunk/apollo-dto/src/main/java/org/apache/activemq/apollo/dto/JsonCodec.java
Date Tue, 07 Jun 2011 11:54:14 GMT
Author: chirino
Date: Tue Jun  7 11:54:14 2011
New Revision: 1132962

URL: http://svn.apache.org/viewvc?rev=1132962&view=rev
Log:
Set the context classloader so that the Json can get properly decoded.

Modified:
    activemq/activemq-apollo/trunk/apollo-dto/src/main/java/org/apache/activemq/apollo/dto/JsonCodec.java

Modified: activemq/activemq-apollo/trunk/apollo-dto/src/main/java/org/apache/activemq/apollo/dto/JsonCodec.java
URL: http://svn.apache.org/viewvc/activemq/activemq-apollo/trunk/apollo-dto/src/main/java/org/apache/activemq/apollo/dto/JsonCodec.java?rev=1132962&r1=1132961&r2=1132962&view=diff
==============================================================================
--- activemq/activemq-apollo/trunk/apollo-dto/src/main/java/org/apache/activemq/apollo/dto/JsonCodec.java
(original)
+++ activemq/activemq-apollo/trunk/apollo-dto/src/main/java/org/apache/activemq/apollo/dto/JsonCodec.java
Tue Jun  7 11:54:14 2011
@@ -16,17 +16,11 @@
  */
 package org.apache.activemq.apollo.dto;
 
-import org.codehaus.jackson.JsonParseException;
 import org.codehaus.jackson.map.ObjectMapper;
 import org.fusesource.hawtbuf.Buffer;
 import org.fusesource.hawtbuf.ByteArrayOutputStream;
 
-import javax.xml.bind.JAXBException;
-import javax.xml.stream.XMLStreamException;
 import java.io.IOException;
-import java.io.InputStream;
-import java.net.URL;
-import java.util.Properties;
 
 /**
  *
@@ -37,7 +31,13 @@ public class JsonCodec {
     private static ObjectMapper mapper = new ObjectMapper();
 
     static public <T> T decode(Buffer buffer, Class<T> type) throws IOException
{
-        return mapper.readValue(buffer.in(), type);
+        ClassLoader original = Thread.currentThread().getContextClassLoader();
+        Thread.currentThread().setContextClassLoader(JsonCodec.class.getClassLoader());
+        try {
+            return mapper.readValue(buffer.in(), type);
+        } finally {
+            Thread.currentThread().setContextClassLoader(original);
+        }
     }
 
     static public Buffer encode(Object value) throws IOException {



Mime
View raw message