- java.lang.Object
-
- org.eclipse.persistence.sdo.helper.SDOHelperContext
-
- All Implemented Interfaces:
HelperContext
- Direct Known Subclasses:
JAXBHelperContext
public class SDOHelperContext extends Object implements HelperContext
Purpose:- This class represents a local HelperContext. The global HelperContext can be accessed as HelperProvider.getDefaultContext().
- Provide access to instances of helper objects.
- Provide an OSGi compatible HelperContext (when the constructor that takes a ClassLoader is used).
- Since:
- Oracle TopLink 11.1.1.0.0
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interface
SDOHelperContext.HelperContextResolver
Strategy forHelperContext
creation.
-
Field Summary
Fields Modifier and Type Field Description protected CopyHelper
copyHelper
protected DataFactory
dataFactory
protected DataHelper
dataHelper
protected EqualityHelper
equalityHelper
static String
STRICT_TYPE_CHECKING_PROPERTY_NAME
Deprecated.protected TypeHelper
typeHelper
protected XMLHelper
xmlHelper
protected XSDHelper
xsdHelper
-
Constructor Summary
Constructors Constructor Description SDOHelperContext()
Create a local HelperContext.SDOHelperContext(ClassLoader aClassLoader)
Create a local HelperContext.SDOHelperContext(String identifier)
Create a local HelperContext with the given identifier.SDOHelperContext(String identifier, ClassLoader aClassLoader)
Create a local HelperContext with the given identifier.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static void
addAlias(String identifier, String alias)
Add an alias to identifier pair to the alias Map for the current application.ExternalizableDelegator.Resolvable
createResolvable()
Create and return a new ExternalizableDelegator.Resolvable instance based on this helper context.ExternalizableDelegator.Resolvable
createResolvable(Object target)
Create and return a new ExternalizableDelegator.Resolvable instance based on this helper context and a given target.CopyHelper
getCopyHelper()
Return the CopyHelper instance for this helper context.DataFactory
getDataFactory()
Return the DataFactory instance for this helper context.DataHelper
getDataHelper()
Return the DataHelper instance for this helper context.EqualityHelper
getEqualityHelper()
Return the EqualityHelper instance for this helper context.static HelperContext
getHelperContext()
INTERNAL: Return the helper context for a given key.static HelperContext
getHelperContext(String identifier)
Return the local helper context associated with the given identifier, or create one if it does not already exist.static HelperContext
getHelperContext(String identifier, ClassLoader classLoader)
Return the local helper context with the given identifier, or create one if it does not already exist.static SDOHelperContext.HelperContextResolver
getHelperContextResolver()
Getter for HelperContextResolverString
getIdentifier()
Return the unique label for this HelperContext.Object
getProperty(String name)
Return the value stored in the properties Map for a given name, or null if an entry for name does not exist.TypeHelper
getTypeHelper()
Return the TypeHelper instance for this helper context.static Map<SDOTypeHelperDelegate.SDOWrapperTypeId,SDOWrapperType>
getWrapperTypes()
Returns theSDOWrapperType
instances for current applicationXMLHelper
getXMLHelper()
Return the XMLHelper instance for this helper context.XSDHelper
getXSDHelper()
Return the XSDHelper instance for this helper context.static boolean
hasHelperContext(String identifier)
Return true if a HelperContext corresponding to this identifier or alias already exists, else false.protected void
initialize(ClassLoader aClassLoader)
The underlying helpers for this instance will be instantiated in this method.static boolean
isApplicationResolverSet()
Indicates if a call to setApplicationResolver has been made.boolean
isStrictTypeCheckingEnabled()
Indicates whether strict type checking is enabled.void
makeDefaultContext()
ADVANCED Promote this helper context to be the default or global one.static void
putHelperContext(HelperContext ctx)
Replaces the provided helper context in the map of identifiers to helper contexts for this application.static void
putHelperContext(ClassLoader key, HelperContext value)
INTERNAL: Put a ClassLoader/HelperContext key/value pair in the Thread HelperContext map.static Map<SDOTypeHelperDelegate.SDOWrapperTypeId,SDOWrapperType>
putWrapperTypes(Map<SDOTypeHelperDelegate.SDOWrapperTypeId,SDOWrapperType> wrapperTypes)
Replaces theSDOWrapperType
instances for current application with the ones passed as an argumentstatic void
removeHelerContextResolver()
Removes HelperContextResolver for the current application.static void
removeHelperContext(ClassLoader key)
INTERNAL: Remove a ClassLoader/HelperContext key/value pair from the Thread HelperContext map.static void
removeHelperContext(String identifier, ClassLoader key)
INTERNALvoid
reset()
Reset the Type,XML and XSD helper instances.static void
setApplicationResolver(ApplicationResolver aResolver)
ADVANCED: Used to set an ApplicationResolver instance that will be used to retrieve info pertaining to a given application, such as the application name, in the case where our logic fails.static void
setHelperContextResolver(Object helperContextResolver)
Method allows dynamically change HelperContext creation strategy.static void
setHelperContextResolver(SDOHelperContext.HelperContextResolver helperContextResolver)
Method allows dynamically change HelperContext creation strategy.void
setProperty(String name, Object value)
Add a name/value pair to the properties Map.void
setStrictTypeCheckingEnabled(boolean enabled)
Controls type checking strictness.
-
-
-
Field Detail
-
copyHelper
protected CopyHelper copyHelper
-
dataFactory
protected DataFactory dataFactory
-
dataHelper
protected DataHelper dataHelper
-
equalityHelper
protected EqualityHelper equalityHelper
-
xmlHelper
protected XMLHelper xmlHelper
-
typeHelper
protected TypeHelper typeHelper
-
xsdHelper
protected XSDHelper xsdHelper
-
STRICT_TYPE_CHECKING_PROPERTY_NAME
@Deprecated public static final String STRICT_TYPE_CHECKING_PROPERTY_NAME
Deprecated.Property controls strictness ofType.getInstanceClass()
type checking.See
isStrictTypeCheckingEnabled()
for more details. By this property, the initial value can be changed. Default value istrue
.- See Also:
Moved to . *
, Constant Field Values
-
-
Constructor Detail
-
SDOHelperContext
public SDOHelperContext()
Create a local HelperContext. The current thread's context ClassLoader will be used to find static instance classes. In OSGi environments the construct that takes a ClassLoader parameter should be used instead.
-
SDOHelperContext
public SDOHelperContext(String identifier)
Create a local HelperContext with the given identifier. The current thread's context ClassLoader will be used to find static instance classes. In OSGi environments the construct that takes a ClassLoader parameter should be used instead.- Parameters:
identifier
- The unique label for this HelperContext.
-
SDOHelperContext
public SDOHelperContext(ClassLoader aClassLoader)
Create a local HelperContext. This constructor should be used in OSGi environments.- Parameters:
aClassLoader
- This class loader will be used to find static instance classes.
-
SDOHelperContext
public SDOHelperContext(String identifier, ClassLoader aClassLoader)
Create a local HelperContext with the given identifier. This constructor should be used in OSGi environments.- Parameters:
identifier
- The unique label for this HelperContext.aClassLoader
- This class loader will be used to find static instance classes.
-
-
Method Detail
-
setApplicationResolver
public static void setApplicationResolver(ApplicationResolver aResolver)
ADVANCED: Used to set an ApplicationResolver instance that will be used to retrieve info pertaining to a given application, such as the application name, in the case where our logic fails. This method can be called once and only once per active server instance.- Parameters:
aResolver
- the ApplicationResolver instance that will be used to retrieve info pertaining to a given application. Note that null is considered a valid set operation.- Throws:
SDOException
- if more than one call is made to this method in an active server instance.
-
isApplicationResolverSet
public static boolean isApplicationResolverSet()
Indicates if a call to setApplicationResolver has been made.- Returns:
- true if a prior call to setApplicationResolver has been made, false otherwise
-
initialize
protected void initialize(ClassLoader aClassLoader)
The underlying helpers for this instance will be instantiated in this method.- Parameters:
aClassLoader
-
-
reset
public void reset()
Reset the Type,XML and XSD helper instances.
-
getCopyHelper
public CopyHelper getCopyHelper()
Return the CopyHelper instance for this helper context.- Specified by:
getCopyHelper
in interfaceHelperContext
- Returns:
- a CopyHelper object
-
getDataFactory
public DataFactory getDataFactory()
Return the DataFactory instance for this helper context.- Specified by:
getDataFactory
in interfaceHelperContext
- Returns:
- a DataFactory object
-
getDataHelper
public DataHelper getDataHelper()
Return the DataHelper instance for this helper context.- Specified by:
getDataHelper
in interfaceHelperContext
- Returns:
- a DataHelper object
-
getEqualityHelper
public EqualityHelper getEqualityHelper()
Return the EqualityHelper instance for this helper context.- Specified by:
getEqualityHelper
in interfaceHelperContext
- Returns:
- an EqualityHelper object
-
getTypeHelper
public TypeHelper getTypeHelper()
Return the TypeHelper instance for this helper context.- Specified by:
getTypeHelper
in interfaceHelperContext
- Returns:
- a TypeHelper object
-
getXMLHelper
public XMLHelper getXMLHelper()
Return the XMLHelper instance for this helper context.- Specified by:
getXMLHelper
in interfaceHelperContext
- Returns:
- an XMLHelper object
-
getXSDHelper
public XSDHelper getXSDHelper()
Return the XSDHelper instance for this helper context.- Specified by:
getXSDHelper
in interfaceHelperContext
- Returns:
- an XSDHelper object
-
createResolvable
public ExternalizableDelegator.Resolvable createResolvable()
Create and return a new ExternalizableDelegator.Resolvable instance based on this helper context.- Returns:
-
createResolvable
public ExternalizableDelegator.Resolvable createResolvable(Object target)
Create and return a new ExternalizableDelegator.Resolvable instance based on this helper context and a given target.- Parameters:
target
-- Returns:
-
putHelperContext
public static void putHelperContext(ClassLoader key, HelperContext value)
INTERNAL: Put a ClassLoader/HelperContext key/value pair in the Thread HelperContext map. If Thread.currentThread().getContextClassLoader() == key during getHelperContext() call then the HelperContext (value) will be returned. This method will overwrite an existing entry in the map with the same ClassLoader key.- Parameters:
key
- class loadervalue
- helper context
-
removeHelperContext
public static void removeHelperContext(ClassLoader key)
INTERNAL: Remove a ClassLoader/HelperContext key/value pair from the Thread HelperContext map. If there are multiple local helper contexts associated with this ClassLoader, they will all be removed from the map.- Parameters:
key
- class loader
-
removeHelperContext
public static void removeHelperContext(String identifier, ClassLoader key)
INTERNAL- Parameters:
identifier
- the specific identifier of the HelperContext to be removed. "" for a Global helperkey
- the ClassLoader associated with the HelperContext to be removed
-
getHelperContext
public static HelperContext getHelperContext()
INTERNAL: Return the helper context for a given key. The key will either be a ClassLoader or a String (representing an application name). A new context will be created and put in the map if none exists for the given key. The key is assumed to be non-null - getDelegateKey should always return either a string representing the application name (for WLS, WAS and JBoss if available) or a class loader. This is relevant since 'putIfAbsent' will throw a null pointer exception if the key is null.
-
getHelperContext
public static HelperContext getHelperContext(String identifier)
Return the local helper context associated with the given identifier, or create one if it does not already exist. If identifier is an alias, the value associated with it in the alias Map will be used as the identifier value.- Parameters:
identifier
- the identifier or alias to use for lookup/creation- Returns:
- HelperContext associated with identifier, or a new HelperContext keyed on identifier if none eixsts
-
getHelperContext
public static HelperContext getHelperContext(String identifier, ClassLoader classLoader)
Return the local helper context with the given identifier, or create one if it does not already exist.
-
putHelperContext
public static void putHelperContext(HelperContext ctx)
Replaces the provided helper context in the map of identifiers to helper contexts for this application. ctx.getIdentifier() will be used to obtain the identifier value. If identifier is a key in the the alias Map, i.e. was previously set as alias, the corresponding entry will be removed from the alias Map.- Parameters:
ctx
- the HelperContext to be added to the context Map for the current application
-
getHelperContextResolver
public static SDOHelperContext.HelperContextResolver getHelperContextResolver()
Getter for HelperContextResolver- Returns:
- actual strategy
-
setHelperContextResolver
public static void setHelperContextResolver(Object helperContextResolver)
Method allows dynamically change HelperContext creation strategy.- Parameters:
helperContextResolver
- on this objectSDOHelperContext.HelperContextResolver.getHelperContext(String, ClassLoader)
will be called. If it is null - then default strategy will be set.
-
setHelperContextResolver
public static void setHelperContextResolver(SDOHelperContext.HelperContextResolver helperContextResolver)
Method allows dynamically change HelperContext creation strategy.- Parameters:
helperContextResolver
- strategy to be used. If it is null - then default strategy will be set.
-
removeHelerContextResolver
public static void removeHelerContextResolver()
Removes HelperContextResolver for the current application. Application is resolved based on applicationName or classLoader.
-
makeDefaultContext
public void makeDefaultContext()
ADVANCED Promote this helper context to be the default or global one. This will completely replace the existing default context including all types and properties defined.
-
getIdentifier
public String getIdentifier()
Return the unique label for this HelperContext.- Returns:
- String representing the unique label for this HelperContext
-
hasHelperContext
public static boolean hasHelperContext(String identifier)
Return true if a HelperContext corresponding to this identifier or alias already exists, else false. If identifer is an alias, the corresponding value in the alias Map will be used as the identifier for the lookup.- Parameters:
identifier
- the alias or identifier used to lookup a helper context- Returns:
- true if an entry exists in the helper context map for identifier (or the associated identifier value if identifier is an alias), false otherwise.
-
addAlias
public static void addAlias(String identifier, String alias)
Add an alias to identifier pair to the alias Map for the current application.- Parameters:
identifier
- assumed to be a key in the helper context Mapalias
- the alias to be associated with identifier
-
setProperty
public void setProperty(String name, Object value)
Add a name/value pair to the properties Map. If name is null, nothing will be done. If value is null, the entry in the Map will be removed (if an entry exists for name).- Parameters:
name
- the name of the propertyvalue
- the value of the property
-
getProperty
public Object getProperty(String name)
Return the value stored in the properties Map for a given name, or null if an entry for name does not exist.- Parameters:
name
- the name of the property to be returned- Returns:
- the value associated with name, or null
-
isStrictTypeCheckingEnabled
public boolean isStrictTypeCheckingEnabled()
Indicates whether strict type checking is enabled.If strict type checking is enabled then
Type.getInstanceClass()
interface is checked whether it contains getters for all the properties of theType
upon initialization of theType
. If any getter is missing then the interface is ignored andType.getInstanceClass()
will returnnull
.The getters are not checked if the strict type checking is disabled.
- Returns:
- boolean value
-
setStrictTypeCheckingEnabled
public void setStrictTypeCheckingEnabled(boolean enabled)
Controls type checking strictness. SeeisStrictTypeCheckingEnabled()
for more details.- Parameters:
enabled
- new value (true
to enable the strict validation)
-
getWrapperTypes
public static Map<SDOTypeHelperDelegate.SDOWrapperTypeId,SDOWrapperType> getWrapperTypes()
Returns theSDOWrapperType
instances for current application
-
putWrapperTypes
public static Map<SDOTypeHelperDelegate.SDOWrapperTypeId,SDOWrapperType> putWrapperTypes(Map<SDOTypeHelperDelegate.SDOWrapperTypeId,SDOWrapperType> wrapperTypes)
Replaces theSDOWrapperType
instances for current application with the ones passed as an argument- Parameters:
wrapperTypes
- the SDOWrapperType instances to use for current application- Returns:
- SDOWrapperType instances configured for current application
-
-