VMware GemFire Java API Reference
Package org.apache.geode
Class CanonicalInstantiator
- java.lang.Object
-
- org.apache.geode.Instantiator
-
- org.apache.geode.CanonicalInstantiator
-
public abstract class CanonicalInstantiator extends Instantiator
CanonicalInstantiatoris much like its parentInstantiatorexcept that instead of needing to implementnewInstance()you now must implementnewInstance(DataInput). The addition of theDataInputparameter 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 newCanonicalInstantiatorthat instantiates a given class.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description DataSerializablenewInstance()This method is not supported and if called will throw UnsupportedOperationException.abstract DataSerializablenewInstance(java.io.DataInput in)Creates a new "empty" instance of aDataSerializableclass whose state will be filled in by invoking itsfromDatamethod.-
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 newCanonicalInstantiatorthat instantiates a given class.- Parameters:
c- TheDataSerializableclass to register. This class must have a static initializer that registers thisInstantiator.classId- A unique id for classc. TheclassIdmust not be zero. This has been anintsince dsPhase1.- Throws:
java.lang.IllegalArgumentException- Ifcdoes not implementDataSerializable,classIdis less than or equal to zero.java.lang.NullPointerException- Ifcisnull
-
-
Method Detail
-
newInstance
public DataSerializable newInstance()
This method is not supported and if called will throw UnsupportedOperationException. UsenewInstance(DataInput)instead.- Specified by:
newInstancein classInstantiator- Returns:
- a new "empty" instance of a
DataSerializableclass - 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 aDataSerializableclass whose state will be filled in by invoking itsfromDatamethod.- 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 frominfails.- Since:
- GemFire 5.1
-
-