public class PortableMarshaller extends AbstractMarshaller
Marshaller that lets to serialize and deserialize all objects
in the portable format.
PortableMarshaller is tested only on Java HotSpot VM on other VMs it could yield unexpected results.
PortableMarshaller marshaller = new PortableMarshaller(); 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.internal.portable.api.PortableMarshaller">
...
</bean>
</property>
...
</bean>
For information about Spring framework visit www.springframework.org
| Modifier and Type | Field and Description |
|---|---|
static PortableProtocolVersion |
DFLT_PORTABLE_PROTO_VER
Default portable protocol version.
|
ctx, DFLT_BUFFER_SIZE| Constructor and Description |
|---|
PortableMarshaller() |
| Modifier and Type | Method and Description |
|---|---|
Collection<String> |
getClassNames()
Gets class names.
|
MarshallerContext |
getContext()
Returns currently set
MarshallerContext. |
PortableIdMapper |
getIdMapper()
Gets ID mapper.
|
PortableProtocolVersion |
getProtocolVersion()
Gets portable protocol version.
|
PortableSerializer |
getSerializer()
Gets serializer.
|
Collection<PortableTypeConfiguration> |
getTypeConfigurations()
Gets types configuration.
|
boolean |
isConvertStringToBytes()
Gets strings must be converted to or from bytes using UTF-8 encoding.
|
boolean |
isKeepDeserialized()
If
true, PortableObject will cache deserialized instance after
PortableObject.deserialize() is called. |
boolean |
isMetaDataEnabled()
If
true, meta data will be collected or all types. |
boolean |
isUseTimestamp()
If
true then date values converted to Timestamp on deserialization. |
byte[] |
marshal(Object obj)
Marshals object to byte array.
|
void |
marshal(Object obj,
OutputStream out)
Marshals object to the output stream.
|
void |
setClassNames(Collection<String> clsNames)
Sets class names of portable objects explicitly.
|
void |
setConvertStringToBytes(boolean convertString)
Sets strings must be converted to or from bytes using UTF-8 encoding.
|
void |
setIdMapper(PortableIdMapper idMapper)
Sets ID mapper.
|
void |
setKeepDeserialized(boolean keepDeserialized) |
void |
setMetaDataEnabled(boolean metaDataEnabled) |
void |
setProtocolVersion(PortableProtocolVersion protoVer)
Sets portable protocol version.
|
void |
setSerializer(PortableSerializer serializer)
Sets serializer.
|
void |
setTypeConfigurations(Collection<PortableTypeConfiguration> typeCfgs)
Sets type configurations.
|
void |
setUseTimestamp(boolean useTs) |
<T> T |
unmarshal(byte[] bytes,
ClassLoader clsLdr)
Unmarshals object from byte array using given class loader.
|
<T> T |
unmarshal(InputStream in,
ClassLoader clsLdr)
Unmarshals object from the output stream using given class loader.
|
setContextpublic static final PortableProtocolVersion DFLT_PORTABLE_PROTO_VER
public Collection<String> getClassNames()
public void setClassNames(Collection<String> clsNames)
clsNames - Class names.public PortableIdMapper getIdMapper()
public void setIdMapper(PortableIdMapper idMapper)
idMapper - ID mapper.public PortableSerializer getSerializer()
public void setSerializer(PortableSerializer serializer)
serializer - Serializer.public Collection<PortableTypeConfiguration> getTypeConfigurations()
public void setTypeConfigurations(Collection<PortableTypeConfiguration> typeCfgs)
typeCfgs - Type configurations.public boolean isUseTimestamp()
Timestamp during unmarshalling.public void setUseTimestamp(boolean useTs)
useTs - Flag indicating whether date values converted to Timestamp during unmarshalling.public boolean isConvertStringToBytes()
Default value is true.
public void setConvertStringToBytes(boolean convertString)
Default value is true.
convertString - Flag indicating whether string must be converted to byte array using UTF-8 encoding.public boolean isMetaDataEnabled()
true, meta data will be collected or all types. If you need to override this behaviour for
some specific type, use PortableTypeConfiguration.setMetaDataEnabled(Boolean) method.
Default value if true.
public void setMetaDataEnabled(boolean metaDataEnabled)
metaDataEnabled - Whether meta data is collected.public boolean isKeepDeserialized()
true, PortableObject will cache deserialized instance after
PortableObject.deserialize() is called. All consequent calls of this
method on the same instance of PortableObject will return that cached
value without actually deserializing portable object. If you need to override this
behaviour for some specific type, use PortableTypeConfiguration.setKeepDeserialized(Boolean)
method.
Default value if true.
public void setKeepDeserialized(boolean keepDeserialized)
keepDeserialized - Whether deserialized value is kept.public PortableProtocolVersion getProtocolVersion()
Defaults to DFLT_PORTABLE_PROTO_VER.
public void setProtocolVersion(PortableProtocolVersion protoVer)
Defaults to DFLT_PORTABLE_PROTO_VER.
protoVer - Portable protocol version.public MarshallerContext getContext()
MarshallerContext.public byte[] marshal(@Nullable Object obj) throws IgniteCheckedException
marshal in interface Marshallermarshal in class AbstractMarshallerobj - Object to marshal.IgniteCheckedException - If marshalling failed.public void marshal(@Nullable Object obj, OutputStream out) throws IgniteCheckedException
obj - Object to marshal.out - Output stream to marshal into.IgniteCheckedException - If marshalling failed.public <T> T unmarshal(byte[] bytes,
@Nullable
ClassLoader clsLdr)
throws IgniteCheckedException
unmarshal in interface Marshallerunmarshal in class AbstractMarshallerT - Type of unmarshalled object.bytes - Byte array.clsLdr - Class loader to use.IgniteCheckedException - If unmarshalling failed.public <T> T unmarshal(InputStream in, @Nullable ClassLoader clsLdr) throws IgniteCheckedException
T - Type of unmarshalled object.in - Input stream.clsLdr - Class loader to use.IgniteCheckedException - If unmarshalling failed.
Follow @ApacheIgnite
Ignite Fabric : ver. 1.4.0 Release Date : September 24 2015