public interface Marshaller
Marshaller
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.
Ignite provides the following Marshaller
implementations:
IgniteBinary
.JdkMarshaller
Below are examples of marshaller configuration, usage, and injection into tasks, jobs, and SPI's.
Marshaller
can be explicitly configured in code.
JdkMarshaller marshaller = new JdkMarshaller(); IgniteConfiguration cfg = new IgniteConfiguration(); // Override marshaller. cfg.setMarshaller(marshaller); // Starts grid. G.start(cfg);
<bean id="grid.custom.cfg" class="org.apache.ignite.configuration.IgniteConfiguration" singleton="true"> ... <property name="marshaller"> <bean class="org.apache.ignite.marshaller.jdk.JdkMarshaller"/> </property> ... </bean>
For information about Spring framework visit www.springframework.org
Modifier and Type | Method and Description |
---|---|
byte[] |
marshal(@Nullable Object obj)
Marshals object to byte array.
|
void |
marshal(@Nullable Object obj,
OutputStream out)
Marshals object to the output stream.
|
void |
setContext(MarshallerContext ctx)
Sets marshaller context.
|
<T> T |
unmarshal(byte[] arr,
@Nullable ClassLoader clsLdr)
Unmarshals object from byte array using given class loader.
|
<T> T |
unmarshal(InputStream in,
@Nullable ClassLoader clsLdr)
Unmarshals object from the input stream using given class loader.
|
void setContext(MarshallerContext ctx)
ctx
- Marshaller context.void marshal(@Nullable @Nullable Object obj, OutputStream out) throws IgniteCheckedException
obj
- Object to marshal. null
object will be marshaled to binary null
representation.out
- Output stream to marshal into.IgniteCheckedException
- If marshalling failed.byte[] marshal(@Nullable @Nullable Object obj) throws IgniteCheckedException
obj
- Object to marshal. null
object will be marshaled to binary null
representation.IgniteCheckedException
- If marshalling failed.<T> T unmarshal(InputStream in, @Nullable @Nullable ClassLoader clsLdr) throws IgniteCheckedException
T
- Type of unmarshalled object.in
- Input stream.clsLdr
- If not null
then given class loader will be used for unmarshal object.IgniteCheckedException
- If unmarshalling failed.<T> T unmarshal(byte[] arr, @Nullable @Nullable ClassLoader clsLdr) throws IgniteCheckedException
T
- Type of unmarshalled object.arr
- Byte array.clsLdr
- If not null
then given class loader will be used for unmarshal object.IgniteCheckedException
- If unmarshalling failed.
Follow @ApacheIgnite
Ignite Database and Caching Platform : ver. 2.16.0 Release Date : December 15 2023