GridGain™ 3.6.0e
Enterprise Edition

org.gridgain.grid.marshaller.xstream
Class GridXstreamMarshaller

java.lang.Object
  extended by org.gridgain.grid.marshaller.xstream.GridXstreamMarshaller
All Implemented Interfaces:
GridMarshaller

public class GridXstreamMarshaller
extends Object
implements GridMarshaller

Implementation of GridMarshaller based on XStream. This marshaller does not require objects to implement Serializable.

Configuration

Mandatory

This marshaller has no mandatory configuration parameters.

Java Example

GridXstreamMarshaller has to be explicitly configured to override default GridOptimizedMarshaller.
 GridXstreamMarshaller marshaller = new GridXstreamMarshaller();

 GridConfigurationAdapter cfg = new GridConfigurationAdapter();

 // Override marshaller.
 cfg.setMarshaller(marshaller);

 // Starts grid.
 G.start(cfg);
 

Spring Example

GridXstreamMarshaller can be configured from Spring XML configuration file:
 <bean id="grid.custom.cfg" class="org.gridgain.grid.GridConfigurationAdapter" singleton="true">
     ...
     <property name="marshaller">
         <bean class="org.gridgain.grid.marshaller.xstream.GridXstreamMarshaller"/>
     </property>
     ...
 </bean>
 


For information about Spring framework visit www.springframework.org

Injection Example

GridXstreamMarshaller can be injected in users task, job or SPI as following:
 public class MyGridJob implements GridJob {
     ...
     @GridMarshallerResource
     private GridMarshaller marshaller;
     ...
 }
 
or
 public class MyGridJob implements GridJob {
     ...
     private GridMarshaller marshaller;
     ...
     @GridMarshallerResource
     public void setMarshaller(GridMarshaller marshaller) {
         this.marshaller = marshaller;
     }
     ...
 }
 

Wiki & Forum:


Wiki
Forum

 

Constructor Summary
GridXstreamMarshaller()
          Initializes XStream marshaller.
 
Method Summary
 void marshal(Object obj, OutputStream out)
          Marshals object to the output stream.
 String toString()
          
<T> T
unmarshal(InputStream in, ClassLoader clsLdr)
          Unmarshalls object from the output stream using given class loader.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

GridXstreamMarshaller

public GridXstreamMarshaller()
Initializes XStream marshaller.

Method Detail

marshal

public void marshal(@Nullable
                    Object obj,
                    OutputStream out)
             throws GridException
Marshals object to the output stream. This method should not close given output stream.

Specified by:
marshal in interface GridMarshaller
Throws:
GridException - If marshalling failed.
Parameters:
obj - Object to marshal.
out - Output stream to marshal into.

unmarshal

public <T> T unmarshal(InputStream in,
                       @Nullable
                       ClassLoader clsLdr)
            throws GridException
Unmarshalls object from the output stream using given class loader. This method should not close given input stream.

Specified by:
unmarshal in interface GridMarshaller
Throws:
GridException - If unmarshalling failed.
Type Parameters:
T - Type of unmarshalled object.
Parameters:
in - Input stream.
clsLdr - Class loader to use.
Returns:
Unmarshalled object.

toString

public String toString()

Overrides:
toString in class Object

GridGain™ 3.6.0e
Enterprise Edition

GridGain - Real Time Big Data
Enterprise Edition, ver. 3.6.0e.13012012
2012 Copyright © GridGain Systems
Follow us:   Follow GridGain on Github Follow GridGain on Facebook Join GridGain User Group Follow GridGain on Twitter Follow GridGain on YouTube