|
Oracle® Coherence Java API Reference Release 3.6.1.0 E18814-01 |
|||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object
com.tangosol.io.pof.ConfigurablePofContext
public class ConfigurablePofContext
This class implements the PofContext
interface using information provided in a configuration file (or in a passed XML configuration).
<pof-config> <user-type-list> .. <user-type> <type-id>53</type-id> <class-name>com.mycompany.data.Trade</class-name> <serializer> <class-name>com.tangosol.io.pof.PortableObjectSerializer</class-name> <init-params> <init-param> <param-type>int</param-type> <param-value>{type-id}</param-value> </init-param> </init-params> </serializer> </user-type> <user-type> <type-id>54</type-id> <class-name>com.mycompany.data.Position</class-name> </user-type> .. <include>file:/my-pof-config.xml</include> .. </user-type-list> <allow-interfaces>false</allow-interfaces> <allow-subclasses>false</allow-subclasses> </pof-config>
For each user type, a user-type element must exist inside the user-type-list element. The user-type-list element contains up to three elements, in the following order:
PortableObjectSerializer
implementation is used.If the init-params element is not present, then the ConfigurablePofContext attempts to construct the PofSerializer by searching for one of the following constructors in the same order as they appear here:
setConfig
method is invoked, and it is passed the parameter XML information, transposed as described by transformInitParams
, and as described in the pof-config.dtd file. Finally, if the PofSerializer implements the ClassLoaderAware interface and a ClassLoader has been specified, then the setContextClassLoader
method is invoked with the reference to the specified ClassLoader. Conceptually, the identity of a ConfigurablePofContext is a combination of a configuration locator and a ClassLoader. The ClassLoader is used to resolve and load the configuration details whose location is specified by the configuration locator, and to load all of the classes specified by the configuration. To achieve acceptable performance, and to limit the redundant use of resources, the ConfigurablePofContext maintains a WeakHashMap keyed by ClassLoader, whose corresponding values are each a SafeHashMap keyed by configuration locator, whose corresponding values contain the data necessary to efficiently perform the operations prescribed by the PofContext interface. Note: The configuration for the default constructor
can be specified using the tangosol.pof.config
system property.
Nested Class Summary | |
---|---|
protected static class |
ConfigurablePofContext.PofConfig The information related to the configuration of a particular PofContext for a specific URI and ClassLoader. |
Field Summary | |
---|---|
static java.lang.String |
DEFAULT_RESOURCE The name of the application resource that contains the default set of wire-format-to-object bindings. |
static java.lang.String |
PROPERTY_CONFIG The name of the system property ("tangosol.pof.config") that can be used to override the location of the default POF configuration file. |
Constructor Summary | |
---|---|
ConfigurablePofContext() Default constructor. |
|
ConfigurablePofContext(java.lang.String sLocator) Create a ConfigurablePofContext that will load configuration information from the specified locator. |
|
ConfigurablePofContext(XmlElement xml) Create a ConfigurablePofContext that will use the passed configuration information. |
Method Summary | |
---|---|
protected void |
appendDefaultSerializerToUserTypes(XmlElement xmlConfig) Process <default-serializer> element from the specified xml configuration and append information about the serializer to each <user-type> element within <user-type-list> unless user type already has a serializer specified. |
protected void |
checkNotInitialized() Verify that the ConfigurablePofContext has not already been initialized. |
protected ConfigurablePofContext.PofConfig |
createPofConfig() Create a PofConfig object based on a configuration that was either provided as XML, or can be loaded from the specified (or default) URI using the provided ClassLoader. |
java.lang.Object |
deserialize(ReadBuffer.BufferInput in) Deserialize an object from a ReadBuffer by reading its state using the specified BufferInput object. |
protected void |
ensureInitialized() Fully initialize the ConfigurablePofContext if it has not already been initialized. |
java.lang.Class |
getClass(int nTypeId) Determine the class associated with the given user type identifier. |
java.lang.String |
getClassName(int nTypeId) Determine the name of the class associated with the given user type identifier. |
XmlElement |
getConfig() Determine the current configuration of the object. Note that the configuration will not be available unless the ConfigurablePofContext was constructed with the configuration, the configuration was specified using the XmlConfigurable interface, or the ConfigurablePofContext has fully initialized itself (which does not occur until a ClassLoader is provided, or an attempt is made through the ConfigurablePofContext to serialize or deserialize a POF object, whichever comes first.) |
protected java.lang.String |
getConfigLocation() Obtain the location of the configuration that the ConfigurablePofContext used to configure itself. |
java.lang.ClassLoader |
getContextClassLoader() Retrieve the context ClassLoader for this object. |
protected int |
getInheritedUserTypeIdentifier(java.lang.Class clz) Helper method for determining the user type identifier associated with a given class that does not have a direct configured association. |
protected ConfigurablePofContext.PofConfig |
getPofConfig() Obtain the PofConfig that represents the initialized state of the ConfigurablePofContext. |
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. |
int |
getUserTypeIdentifier(java.lang.Class clz) Determine the user type identifier associated with the given class. |
int |
getUserTypeIdentifier(java.lang.Object o) Determine the user type identifier associated with the given object. |
int |
getUserTypeIdentifier(java.lang.String sClass) Determine the user type identifier associated with the given class name. |
protected int |
getUserTypeIdentifierInternal(java.lang.Class clz) Determine the user type identifier associated with the given class. |
protected int |
getUserTypeIdentifierInternal(java.lang.String sClass) Determine the user type identifier associated with the given class name. |
protected void |
initialize() Bind the ConfigurablePofContext to a ClassLoader, resolving all class names, etc. |
protected boolean |
isInitialized() Determine if the ConfigurablePofContext has completed its initialization. |
protected boolean |
isInterfaceAllowed() Determine if the ConfigurablePofContext supports the configuration of user types by specifying an interface (instead of a class) for the Java type. |
protected boolean |
isSubclassAllowed() Determine if the ConfigurablePofContext supports the serialization of an object that is an instance of a sub-class of a configured type, but not actually an instance of a class of a configured type. |
boolean |
isUserType(java.lang.Class clz) Determine if the given class is a user type known to this PofContext. |
boolean |
isUserType(java.lang.Object o) Determine if the given object is of a user type known to this PofContext. |
boolean |
isUserType(java.lang.String sClass) Determine if the class with the given name is a user type known to this PofContext. |
protected java.lang.Class |
loadClass(java.lang.String sClass) Find the specified class, return a Java Class object for it. |
protected java.lang.RuntimeException |
report(java.lang.String sURI, int nTypeId, java.lang.String sClass, java.lang.Throwable e, java.lang.String sText) Assemble and throw an informative exception based on the passed details. |
void |
serialize(WriteBuffer.BufferOutput out, java.lang.Object o) Serialize an object to a WriteBuffer by writing its state using the specified BufferOutput object. |
void |
setConfig(XmlElement xml) Specify the configuration for the object. Note that the configuration cannot be set after the ConfigurablePofContext is fully initialized. |
void |
setContextClassLoader(java.lang.ClassLoader loader) Specify the context ClassLoader for this object. Note that the ConfigurablePofContext will fully initialize when it is provided a ClassLoader. |
java.lang.String |
toString() Return a description of this ConfigurablePofContext. |
Field Detail |
---|
public static final java.lang.String PROPERTY_CONFIG
public static final java.lang.String DEFAULT_RESOURCE
tangosol.pof.config
system property.Constructor Detail |
---|
public ConfigurablePofContext()
DEFAULT_RESOURCE
.public ConfigurablePofContext(java.lang.String sLocator)
sLocator
- the locator that specifies the location of the PofContext configuration file; the locator is either a valid path or a URLpublic ConfigurablePofContext(XmlElement xml)
xml
- an XmlElement containing information in the format of a configuration file used by ConfigurablePofContextMethod Detail |
---|
public XmlElement getConfig()
XmlConfigurable
interface, or the ConfigurablePofContext has fully initialized itself (which does not occur until a ClassLoader is provided, or an attempt is made through the ConfigurablePofContext to serialize or deserialize a POF object, whichever comes first.)getConfig
in interface XmlConfigurable
public void setConfig(XmlElement xml)
setConfig
in interface XmlConfigurable
xml
- the XML configuration for the objectjava.lang.IllegalStateException
- if the ConfigurablePofContext is already fully initializedpublic java.lang.ClassLoader getContextClassLoader()
getContextClassLoader
in interface ClassLoaderAware
Thread.getContextClassLoader()
public void setContextClassLoader(java.lang.ClassLoader loader)
setContextClassLoader
in interface ClassLoaderAware
loader
- the context ClassLoader for this objectjava.lang.IllegalStateException
- if the ConfigurablePofContext is already fully initializedpublic void serialize(WriteBuffer.BufferOutput out, java.lang.Object o) throws java.io.IOException
serialize
in interface Serializer
out
- the BufferOutput with which to write the object's stateo
- the object to serializejava.io.IOException
- if an I/O error occurspublic java.lang.Object deserialize(ReadBuffer.BufferInput in) throws java.io.IOException
deserialize
in interface Serializer
in
- the BufferInput with which to read the object's statejava.io.IOException
- if an I/O error occurspublic PofSerializer getPofSerializer(int nTypeId)
getPofSerializer
in interface PofContext
nTypeId
- the type identifier of the user type that can be serialized and deserialized using the returned PofSerializer; must be non-negativepublic int getUserTypeIdentifier(java.lang.Object o)
getUserTypeIdentifier
in interface PofContext
o
- an instance of a user type; must not be nullpublic int getUserTypeIdentifier(java.lang.Class clz)
getUserTypeIdentifier
in interface PofContext
clz
- a user type class; must not be nullpublic int getUserTypeIdentifier(java.lang.String sClass)
getUserTypeIdentifier
in interface PofContext
sClass
- the name of a user type class; must not be nullpublic java.lang.String getClassName(int nTypeId)
getClassName
in interface PofContext
nTypeId
- the user type identifier; must be non-negativepublic java.lang.Class getClass(int nTypeId)
getClass
in interface PofContext
nTypeId
- the user type identifier; must be non-negativepublic boolean isUserType(java.lang.Object o)
isUserType
in interface PofContext
o
- the object to test; must not be nullpublic boolean isUserType(java.lang.Class clz)
isUserType
in interface PofContext
clz
- the class to test; must not be nullpublic boolean isUserType(java.lang.String sClass)
isUserType
in interface PofContext
sClass
- the name of the class to test; must not be nullprotected int getUserTypeIdentifierInternal(java.lang.Class clz)
clz
- a user type class; must not be nullprotected int getInheritedUserTypeIdentifier(java.lang.Class clz)
clz
- a user type class; must not be nullprotected int getUserTypeIdentifierInternal(java.lang.String sClass)
sClass
- the name of a user type class; must not be nullprotected boolean isInitialized()
protected java.lang.String getConfigLocation()
protected ConfigurablePofContext.PofConfig getPofConfig()
protected boolean isInterfaceAllowed()
protected boolean isSubclassAllowed()
public java.lang.String toString()
protected void checkNotInitialized()
java.lang.IllegalStateException
- if the ConfigurablePofContext is already fully initializedprotected void ensureInitialized()
protected void initialize()
protected ConfigurablePofContext.PofConfig createPofConfig()
protected java.lang.Class loadClass(java.lang.String sClass)
sClass
- the fully qualified class namejava.lang.RuntimeException
- a RuntimeException (or a subclass thereof) is thrown if the specified Class could not be loadedprotected java.lang.RuntimeException report(java.lang.String sURI, int nTypeId, java.lang.String sClass, java.lang.Throwable e, java.lang.String sText)
sURI
- the URI of the configurationnTypeId
- the type ID (if applicable and if known)sClass
- the user type class name (if applicable and if known)e
- the underlying exception, if anysText
- the detailed description of the problemjava.lang.IllegalStateException
- always thrownprotected void appendDefaultSerializerToUserTypes(XmlElement xmlConfig)
xmlConfig
- the XmlElement containing pof configuration
|
Oracle® Coherence Java API Reference Release 3.6.1.0 E18814-01 |
|||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |