org.apache.camel.component.jackson
Class JacksonDataFormat

java.lang.Object
  extended by org.apache.camel.support.ServiceSupport
      extended by org.apache.camel.component.jackson.JacksonDataFormat
All Implemented Interfaces:
org.apache.camel.Service, org.apache.camel.ShutdownableService, org.apache.camel.spi.DataFormat, org.apache.camel.StatefulService, org.apache.camel.SuspendableService

public class JacksonDataFormat
extends org.apache.camel.support.ServiceSupport
implements org.apache.camel.spi.DataFormat

A data format (DataFormat) using Jackson to marshal to and from JSON.


Field Summary
 
Fields inherited from class org.apache.camel.support.ServiceSupport
shutdown, shuttingdown, started, starting, stopped, stopping, suspended, suspending
 
Constructor Summary
JacksonDataFormat()
          Use the default Jackson ObjectMapper and Map
JacksonDataFormat(Class<?> unmarshalType)
          Use the default Jackson ObjectMapper and with a custom unmarshal type
JacksonDataFormat(Class<?> unmarshalType, Class<?> jsonView)
          Use the default Jackson ObjectMapper and with a custom unmarshal type and JSON view
JacksonDataFormat(com.fasterxml.jackson.databind.ObjectMapper mapper, Class<?> unmarshalType)
          Use a custom Jackson mapper and and unmarshal type
JacksonDataFormat(com.fasterxml.jackson.databind.ObjectMapper mapper, Class<?> unmarshalType, Class<?> jsonView)
          Use a custom Jackson mapper, unmarshal type and JSON view
 
Method Summary
protected  void doStart()
           
protected  void doStop()
           
 String getInclude()
           
 Class<?> getJsonView()
           
 com.fasterxml.jackson.databind.ObjectMapper getObjectMapper()
           
 Class<?> getUnmarshalType()
           
 void marshal(org.apache.camel.Exchange exchange, Object graph, OutputStream stream)
           
 void setInclude(String include)
           
 void setJsonView(Class<?> jsonView)
           
 void setUnmarshalType(Class<?> unmarshalType)
           
 Object unmarshal(org.apache.camel.Exchange exchange, InputStream stream)
           
 
Methods inherited from class org.apache.camel.support.ServiceSupport
doResume, doShutdown, doSuspend, getStatus, getVersion, isRunAllowed, isStarted, isStarting, isStopped, isStopping, isStoppingOrStopped, isSuspended, isSuspending, resume, shutdown, start, stop, suspend
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JacksonDataFormat

public JacksonDataFormat()
Use the default Jackson ObjectMapper and Map


JacksonDataFormat

public JacksonDataFormat(Class<?> unmarshalType)
Use the default Jackson ObjectMapper and with a custom unmarshal type

Parameters:
unmarshalType - the custom unmarshal type

JacksonDataFormat

public JacksonDataFormat(Class<?> unmarshalType,
                         Class<?> jsonView)
Use the default Jackson ObjectMapper and with a custom unmarshal type and JSON view

Parameters:
unmarshalType - the custom unmarshal type
jsonView - marker class to specifiy properties to be included during marshalling. See also http://wiki.fasterxml.com/JacksonJsonViews

JacksonDataFormat

public JacksonDataFormat(com.fasterxml.jackson.databind.ObjectMapper mapper,
                         Class<?> unmarshalType)
Use a custom Jackson mapper and and unmarshal type

Parameters:
mapper - the custom mapper
unmarshalType - the custom unmarshal type

JacksonDataFormat

public JacksonDataFormat(com.fasterxml.jackson.databind.ObjectMapper mapper,
                         Class<?> unmarshalType,
                         Class<?> jsonView)
Use a custom Jackson mapper, unmarshal type and JSON view

Parameters:
mapper - the custom mapper
unmarshalType - the custom unmarshal type
jsonView - marker class to specifiy properties to be included during marshalling. See also http://wiki.fasterxml.com/JacksonJsonViews
Method Detail

marshal

public void marshal(org.apache.camel.Exchange exchange,
                    Object graph,
                    OutputStream stream)
             throws Exception
Specified by:
marshal in interface org.apache.camel.spi.DataFormat
Throws:
Exception

unmarshal

public Object unmarshal(org.apache.camel.Exchange exchange,
                        InputStream stream)
                 throws Exception
Specified by:
unmarshal in interface org.apache.camel.spi.DataFormat
Throws:
Exception

getUnmarshalType

public Class<?> getUnmarshalType()

setUnmarshalType

public void setUnmarshalType(Class<?> unmarshalType)

getJsonView

public Class<?> getJsonView()

setJsonView

public void setJsonView(Class<?> jsonView)

getObjectMapper

public com.fasterxml.jackson.databind.ObjectMapper getObjectMapper()

getInclude

public String getInclude()

setInclude

public void setInclude(String include)

doStart

protected void doStart()
                throws Exception
Specified by:
doStart in class org.apache.camel.support.ServiceSupport
Throws:
Exception

doStop

protected void doStop()
               throws Exception
Specified by:
doStop in class org.apache.camel.support.ServiceSupport
Throws:
Exception


Apache Camel