Package com.tangosol.io.pof
Class SafeConfigurablePofContext
- java.lang.Object
-
- com.tangosol.io.pof.ConfigurablePofContext
-
- com.tangosol.io.pof.SafeConfigurablePofContext
-
- All Implemented Interfaces:
ClassLoaderAware,PofContext,Serializer,XmlConfigurable
@Named("safe-pof") public class SafeConfigurablePofContext extends ConfigurablePofContextSafeConfigurablePofContext is an extension of ConfigurablePofContext that can serialize and deserialize any valid POF user type, even those that have not been explicitly configured, as well as any Java serializable types (Serializable, Externalizable, or ExternalizableLite).Important note: this PofContext has the following limitations:
- SafeConfigurablePofContext is supported only for Java clients;
- its performance is less optimal than of the ConfigurablePofContext;
- the serialized form produced by the SafeConfigurablePofContext will not be recognized by POF aware ValueExtractors.
For user types that have been explicitly configured, the SafeConfigurablePofContext behaves identical to the ConfigurablePofContext.
- Since:
- Coherence 3.3
- Author:
- jh 2007.05.03
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description classSafeConfigurablePofContext.ExternalSerializerSerializer used for Serializable and ExternalizableLite objects.classSafeConfigurablePofContext.JavaPofSerializerDefault Java serializer.classSafeConfigurablePofContext.SafePofSerializerSerializer used for objects implementing the PortableObject interface.-
Nested classes/interfaces inherited from class com.tangosol.io.pof.ConfigurablePofContext
ConfigurablePofContext.PofConfig
-
-
Field Summary
Fields Modifier and Type Field Description static intTYPE_PORTABLEThe type identifier for objects that implement the PortableObject interface.static intTYPE_SERIALIZABLEThe type identifier for Java Serializable (including the ExternalizableLite format) objects.-
Fields inherited from class com.tangosol.io.pof.ConfigurablePofContext
DEFAULT_INDEX_FILE_NAME, DEFAULT_RESOURCE, PROPERTY_CONFIG, ROOT_LAMBDA_CLASS
-
-
Constructor Summary
Constructors Constructor Description SafeConfigurablePofContext()Default constructor.SafeConfigurablePofContext(Serializer serializer, ClassLoader loader)Create a SafeConfigurablePofContext that serializes instances of non-POF classes with specified serializer.SafeConfigurablePofContext(XmlElement xml)Create a SafeConfigurablePofContext that will use the passed configuration information.SafeConfigurablePofContext(String sLocator)Create a SafeConfigurablePofContext that will load configuration information from the specified locator.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ClassgetClass(int nTypeId)Determine the class associated with the given user type identifier.protected intgetGenericTypeId(Class clz)For user types that are not registered in the POF configuration used by this PofContext, determine if the user type can be serialized using POF, otherwise determine if the user type can be serialized using the traditional (pre-POF) Coherence Java Serialization format that supports Java Serializable and ExternalizableLite objects.StringgetName()Return the name of this serializer.PofSerializergetPofSerializer(int nTypeId)Return a PofSerializer that can be used to serialize and deserialize an object of the specified user type to and from a POF stream.intgetUserTypeIdentifier(Class clz)Determine the user type identifier associated with the given class.intgetUserTypeIdentifier(String sClass)Determine the user type identifier associated with the given class name.booleanisUserType(Class clz)Determine if the given class is a user type known to this PofContext.booleanisUserType(String sClass)Determine if the class with the given name is a user type known to this PofContext.-
Methods inherited from class com.tangosol.io.pof.ConfigurablePofContext
appendDefaultSerializerToUserTypes, checkNotInitialized, createPofConfig, deserialize, ensureInitialized, getClassName, getConfig, getConfigLocation, getContextClassLoader, getIndexFileName, getInheritedUserTypeIdentifier, getPofConfig, getUserTypeIdentifier, getUserTypeIdentifierInternal, getUserTypeIdentifierInternal, initialize, instantiateSerializer, instantiateSerializer, isInitialized, isInterfaceAllowed, isLambdaAllowed, isPreferJavaTime, isReferenceEnabled, isSubclassAllowed, isUserType, loadClass, mergeIncludes, report, serialize, setConfig, setContextClassLoader, setIndexFileName, setPreferJavaTime, setReferenceEnabled, toString
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface com.tangosol.io.Serializer
deserialize
-
-
-
-
Field Detail
-
TYPE_PORTABLE
public static final int TYPE_PORTABLE
The type identifier for objects that implement the PortableObject interface.- See Also:
- Constant Field Values
-
TYPE_SERIALIZABLE
public static final int TYPE_SERIALIZABLE
The type identifier for Java Serializable (including the ExternalizableLite format) objects.- See Also:
- Constant Field Values
-
-
Constructor Detail
-
SafeConfigurablePofContext
public SafeConfigurablePofContext()
Default constructor.Create a default SafeConfigurablePofContext that will load configuration information from the locator specified in
ConfigurablePofContext.DEFAULT_RESOURCE.
-
SafeConfigurablePofContext
public SafeConfigurablePofContext(String sLocator)
Create a SafeConfigurablePofContext that will load configuration information from the specified locator.- Parameters:
sLocator- the locator that specifies the location of the PofContext configuration file; the locator is either a valid path or a URL
-
SafeConfigurablePofContext
public SafeConfigurablePofContext(Serializer serializer, ClassLoader loader)
Create a SafeConfigurablePofContext that serializes instances of non-POF classes with specified serializer.- Parameters:
serializer- cache config specified serializer to use for non-POF typesloader- context classloader to use with serializer
-
SafeConfigurablePofContext
public SafeConfigurablePofContext(XmlElement xml)
Create a SafeConfigurablePofContext that will use the passed configuration information.- Parameters:
xml- an XmlElement containing information in the format of a configuration file used by SafeConfigurablePofContext
-
-
Method Detail
-
getName
public String getName()
Description copied from interface:SerializerReturn the name of this serializer.- Specified by:
getNamein interfaceSerializer- Overrides:
getNamein classConfigurablePofContext- Returns:
- the name of this serializer
-
getPofSerializer
public PofSerializer getPofSerializer(int nTypeId)
Return a PofSerializer that can be used to serialize and deserialize an object of the specified user type to and from a POF stream.- Specified by:
getPofSerializerin interfacePofContext- Overrides:
getPofSerializerin classConfigurablePofContext- Parameters:
nTypeId- the type identifier of the user type that can be serialized and deserialized using the returned PofSerializer; must be non-negative- Returns:
- a PofSerializer for the specified user type
-
getClass
public Class getClass(int nTypeId)
Determine the class associated with the given user type identifier.- Specified by:
getClassin interfacePofContext- Overrides:
getClassin classConfigurablePofContext- Parameters:
nTypeId- the user type identifier; must be non-negative- Returns:
- the class associated with the specified user type identifier
-
getUserTypeIdentifier
public int getUserTypeIdentifier(Class clz)
Determine the user type identifier associated with the given class.- Specified by:
getUserTypeIdentifierin interfacePofContext- Overrides:
getUserTypeIdentifierin classConfigurablePofContext- Parameters:
clz- a user type class; must not be null- Returns:
- the type identifier of the user type associated with the given class
-
getUserTypeIdentifier
public int getUserTypeIdentifier(String sClass)
Determine the user type identifier associated with the given class name.- Specified by:
getUserTypeIdentifierin interfacePofContext- Overrides:
getUserTypeIdentifierin classConfigurablePofContext- Parameters:
sClass- the name of a user type class; must not be null- Returns:
- the type identifier of the user type associated with the given class name
-
isUserType
public boolean isUserType(Class clz)
Determine if the given class is a user type known to this PofContext.- Specified by:
isUserTypein interfacePofContext- Overrides:
isUserTypein classConfigurablePofContext- Parameters:
clz- the class to test; must not be null- Returns:
- true iff the specified class is a valid user type
-
isUserType
public boolean isUserType(String sClass)
Determine if the class with the given name is a user type known to this PofContext.- Specified by:
isUserTypein interfacePofContext- Overrides:
isUserTypein classConfigurablePofContext- Parameters:
sClass- the name of the class to test; must not be null- Returns:
- true iff the class with the specified name is a valid user type
-
getGenericTypeId
protected int getGenericTypeId(Class clz)
For user types that are not registered in the POF configuration used by this PofContext, determine if the user type can be serialized using POF, otherwise determine if the user type can be serialized using the traditional (pre-POF) Coherence Java Serialization format that supports Java Serializable and ExternalizableLite objects.- Parameters:
clz- a user type class that is not configured in this PofContext- Returns:
- a special user type id that indicates that the user type is supported by "generic" POF serialization or traditional Java serialization embedded in a POF stream
-
-