GridGain™ 2.1.0
Java API Specification

org.gridgain.grid.marshaller
Interface GridMarshaller

All Known Implementing Classes:
GridJBossMarshaller, GridJdkMarshaller, GridXstreamMarshaller

@Apache20LicenseCompatible
public interface GridMarshaller

GridMarshaller allows to marshal or unmarshal objects in grid. It provides serialization/deserialization mechanism for all instances that are sent across networks or are otherwise serialized.

Gridgain provides the following GridMarshaller implementations:

Below are examples of marshaller configuration, usage, and injection into tasks, jobs, and SPI's.

Java Example

GridMarshaller can be explicitely configured in code.
 GridJbossMarshaller marshaller = new GridJbossMarshaller();

 GridConfigurationAdapter cfg = new GridConfigurationAdapter();

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

 // Start grid.
 GridFactory.start(cfg);
 

Spring Example

GridMarshaller 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.jboss.GridJBossMarshaller"/>
     </property>
     ...
 </bean>
 


For information about Spring framework visit www.springframework.org

Injection Example

GridMarshaller can be injected in users task, job or SPI as following:
 public class MyGridJob implements GridJob {
     ...
     @GridMarshallerResource
     private GridMarshaller marshaller = null;

     public Serializable execute() {
         // Use marshaller to serialize/deserialize any object.
         ...
     }
 }
 
or
 public class MyGridJob implements GridJob {
     ...
     private GridMarshaller marshaller = null;
     ...
     @GridMarshallerResource
     public void setMarshaller(GridMarshaller marshaller) {
         this.marshaller = marshaller;
     }
     ...
 }
 




See Also:

  Documentation
  Email Support
  Online Forums
  Issue Tracking

Author:   2005-2008 Copyright © GridGain Systems. All Rights Reserved. ver. 2.1.0

 

Field Summary
static Class<?>[] EXCLUDED_GRID_CLASSES
          Excluded grid classes from serialization.
 
Method Summary
 void marshal(Object obj, OutputStream out)
          Marshals object to the output stream.
<T> T
unmarshal(InputStream in, ClassLoader clsLoader)
          Unmarshals object from the output stream using given class loader.
 

Field Detail

EXCLUDED_GRID_CLASSES

static final Class<?>[] EXCLUDED_GRID_CLASSES
Excluded grid classes from serialization. All marshallers must omit this classes. Fields of these typs should be serialized as null.

Method Detail

marshal

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

Throws:
GridException - If marshalling failed.
Parameters:
obj - Object to marshal.
out - Output stream to marshal into.

unmarshal

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

Throws:
GridException - If unmarshalling failed.
Type Parameters:
T - Type of unmarshalled object.
Parameters:
in - Input stream.
clsLoader - Class loader to use.
Returns:
Unmarshalled object.

GridGain™ 2.1.0
Java API Specification

GridGain™ - Grid Computing Made Simple, ver. 2.1.0.19122008
2005-2008 Copyright © GridGain Systems. All Rights Reserved.