Gemfire JavaDocs
Package org.apache.geode
Class CanonicalInstantiator
- java.lang.Object
-
- org.apache.geode.Instantiator
-
- org.apache.geode.CanonicalInstantiator
-
public abstract class CanonicalInstantiator extends Instantiator
CanonicalInstantiator
is much like its parentInstantiator
except that instead of needing to implementnewInstance()
you now must implementnewInstance(DataInput)
. The addition of theDataInput
parameter allows the instance creator to optionally read data from the data input stream and use it to decide the instance to create. This allows a value that represents a canonical instance to be written by a class'sDataSerializer.toData(java.lang.Object, java.io.DataOutput)
and then be read bynewInstance(DataInput)
and map it back to a canonical instance.Note that
DataSerializer.fromData(java.io.DataInput)
is always called on the instance returned fromnewInstance(DataInput)
.- Since:
- GemFire 5.1
-
-
Constructor Summary
Constructors Constructor Description CanonicalInstantiator(java.lang.Class<? extends DataSerializable> c, int classId)
Creates a newCanonicalInstantiator
that instantiates a given class.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description DataSerializable
newInstance()
This method is not supported and if called will throw UnsupportedOperationException.abstract DataSerializable
newInstance(java.io.DataInput in)
Creates a new "empty" instance of aDataSerializable
class whose state will be filled in by invoking itsfromData
method.-
Methods inherited from class org.apache.geode.Instantiator
getContext, getEventId, getId, getInstantiatedClass, register, register, setContext, setEventId
-
-
-
-
Constructor Detail
-
CanonicalInstantiator
public CanonicalInstantiator(java.lang.Class<? extends DataSerializable> c, int classId)
Creates a newCanonicalInstantiator
that instantiates a given class.- Parameters:
c
- TheDataSerializable
class to register. This class must have a static initializer that registers thisInstantiator
.classId
- A unique id for classc
. TheclassId
must not be zero. This has been anint
since dsPhase1.- Throws:
java.lang.IllegalArgumentException
- Ifc
does not implementDataSerializable
,classId
is less than or equal to zero.java.lang.NullPointerException
- Ifc
isnull
-
-
Method Detail
-
newInstance
public DataSerializable newInstance()
This method is not supported and if called will throw UnsupportedOperationException. UsenewInstance(DataInput)
instead.- Specified by:
newInstance
in classInstantiator
- Returns:
- a new "empty" instance of a
DataSerializable
class - Throws:
java.lang.UnsupportedOperationException
- in all cases- See Also:
DataSerializer.readObject(java.io.DataInput)
-
newInstance
public abstract DataSerializable newInstance(java.io.DataInput in) throws java.io.IOException
Creates a new "empty" instance of aDataSerializable
class whose state will be filled in by invoking itsfromData
method.- Parameters:
in
- the data input that can be read to decide what instance to create.- Returns:
- the new "empty" instance.
- Throws:
java.io.IOException
- if a read fromin
fails.- Since:
- GemFire 5.1
-
-