|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object javax.jdo.JDOHelper
public class JDOHelper
This class can be used by a JDO-aware application to call the JDO behavior
of PersistenceCapable
instances without declaring them to be
PersistenceCapable
.
It is also used to acquire a PersistenceManagerFactory
via
various methods.
This helper class defines static methods that allow a JDO-aware
application to examine the runtime state of instances. For example,
an application can discover whether the instance is persistent,
transactional, dirty, new, deleted, or detached; and to get its associated
PersistenceManager
if it has one.
Field Summary |
---|
Constructor Summary | |
---|---|
JDOHelper()
Some applications might prefer to use instance methods instead of static methods. |
Method Summary | |
---|---|
protected static java.lang.String |
getClassNameFromURL(java.net.URL url)
Get a class name from a URL. |
protected static javax.xml.parsers.DocumentBuilderFactory |
getDefaultDocumentBuilderFactory()
|
protected static org.xml.sax.ErrorHandler |
getDefaultErrorHandler()
|
protected static javax.xml.parsers.DocumentBuilderFactory |
getDocumentBuilderFactory()
|
static JDOEnhancer |
getEnhancer()
Get a JDOEnhancer using the available enhancer(s) specified in
"META-INF/services/JDOEnhancer" using the context class loader. |
static JDOEnhancer |
getEnhancer(java.lang.ClassLoader loader)
Get a JDOEnhancer using the available enhancer(s) specified in
"META-INF/services/JDOEnhancer" |
protected static org.xml.sax.ErrorHandler |
getErrorHandler()
|
static JDOHelper |
getInstance()
Return the singleton instance of JDOHelper. |
protected static java.util.Map<java.lang.Object,java.lang.Object> |
getNamedPMFProperties(java.lang.String name,
java.lang.ClassLoader resourceLoader,
java.lang.String jdoconfigResourceName)
Find and return the named PersistenceManagerFactory 's properties,
or null if not found. |
static java.lang.Object |
getObjectId(java.lang.Object pc)
Return a copy of the JDO identity associated with the parameter instance. |
static java.util.Collection<java.lang.Object> |
getObjectIds(java.util.Collection<?> pcs)
Get object ids for a collection of instances. |
static java.lang.Object[] |
getObjectIds(java.lang.Object[] pcs)
Get object ids for an array of instances. |
static ObjectState |
getObjectState(java.lang.Object pc)
Accessor for the state of the passed object. |
static PersistenceManager |
getPersistenceManager(java.lang.Object pc)
Return the associated PersistenceManager if there is one. |
static PersistenceManagerFactory |
getPersistenceManagerFactory()
Get the anonymous PersistenceManagerFactory configured via
the standard configuration file resource "META-INF/jdoconfig.xml", using
the current thread's context class loader
to locate the configuration file resource(s). |
static PersistenceManagerFactory |
getPersistenceManagerFactory(java.lang.ClassLoader pmfClassLoader)
Get the anonymous PersistenceManagerFactory configured via
the standard configuration file resource "META-INF/jdoconfig.xml", using
the given class loader. |
static PersistenceManagerFactory |
getPersistenceManagerFactory(java.io.File propsFile)
Returns a PersistenceManagerFactory configured based
on the properties stored in the file at
propsFile . |
static PersistenceManagerFactory |
getPersistenceManagerFactory(java.io.File propsFile,
java.lang.ClassLoader loader)
Returns a PersistenceManagerFactory configured based
on the properties stored in the file at
propsFile . |
static PersistenceManagerFactory |
getPersistenceManagerFactory(java.io.InputStream stream)
Returns a PersistenceManagerFactory configured based
on the Properties stored in the input stream at
stream . |
static PersistenceManagerFactory |
getPersistenceManagerFactory(java.io.InputStream stream,
java.lang.ClassLoader loader)
Returns a PersistenceManagerFactory configured based
on the Properties stored in the input stream at
stream . |
static PersistenceManagerFactory |
getPersistenceManagerFactory(java.util.Map<?,?> props)
Get a PersistenceManagerFactory based on a Properties
instance, using the current thread's context class loader to locate the
PersistenceManagerFactory class. |
static PersistenceManagerFactory |
getPersistenceManagerFactory(java.util.Map<?,?> props,
java.lang.ClassLoader pmfClassLoader)
Get a PersistenceManagerFactory based on a
Map and a class loader. |
protected static PersistenceManagerFactory |
getPersistenceManagerFactory(java.util.Map<?,?> overrides,
java.util.Map<?,?> props,
java.lang.ClassLoader pmfClassLoader)
Get a PersistenceManagerFactory based on a
Map of overrides, a Map of
properties, and a class loader. |
static PersistenceManagerFactory |
getPersistenceManagerFactory(java.util.Map<?,?> overrides,
java.lang.String name)
Returns a named PersistenceManagerFactory or persistence
unit. |
static PersistenceManagerFactory |
getPersistenceManagerFactory(java.util.Map<?,?> overrides,
java.lang.String name,
java.lang.ClassLoader resourceLoader)
Returns a named PersistenceManagerFactory or persistence
unit. |
static PersistenceManagerFactory |
getPersistenceManagerFactory(java.util.Map<?,?> overrides,
java.lang.String name,
java.lang.ClassLoader resourceLoader,
java.lang.ClassLoader pmfLoader)
Returns a PersistenceManagerFactory configured based
on the properties stored in the resource at
name , or, if not found, returns a
PersistenceManagerFactory with the given
name or, if not found, returns a
javax.persistence.EntityManagerFactory cast to a
PersistenceManagerFactory . |
static PersistenceManagerFactory |
getPersistenceManagerFactory(java.lang.String name)
Returns a named PersistenceManagerFactory or persistence
unit. |
static PersistenceManagerFactory |
getPersistenceManagerFactory(java.lang.String name,
java.lang.ClassLoader loader)
Returns a named PersistenceManagerFactory or persistence
unit. |
static PersistenceManagerFactory |
getPersistenceManagerFactory(java.lang.String name,
java.lang.ClassLoader resourceLoader,
java.lang.ClassLoader pmfLoader)
Returns a named PersistenceManagerFactory or persistence
unit. |
static PersistenceManagerFactory |
getPersistenceManagerFactory(java.lang.String jndiLocation,
javax.naming.Context context)
Returns a PersistenceManagerFactory at the JNDI
location specified by jndiLocation in the context
context . |
static PersistenceManagerFactory |
getPersistenceManagerFactory(java.lang.String jndiLocation,
javax.naming.Context context,
java.lang.ClassLoader loader)
Returns a PersistenceManagerFactory at the JNDI
location specified by jndiLocation in the context
context . |
protected static java.util.Map<java.lang.Object,java.lang.Object> |
getPropertiesFromJdoconfig(java.lang.String name,
java.lang.ClassLoader resourceLoader)
|
protected static java.util.Enumeration<java.net.URL> |
getResources(java.lang.ClassLoader resourceLoader,
java.lang.String resourceName)
Get resources of the resource loader. |
static java.lang.Object |
getTransactionalObjectId(java.lang.Object pc)
Return a copy of the JDO identity associated with the parameter instance. |
static java.lang.Object |
getVersion(java.lang.Object pc)
Return the version of the instance. |
protected static PersistenceManagerFactory |
invokeGetPersistenceManagerFactoryOnImplementation(java.lang.String pmfClassName,
java.util.Map<?,?> overrides,
java.util.Map<?,?> properties,
java.lang.ClassLoader cl)
Invoke the getPersistenceManagerFactory method on the implementation. |
static boolean |
isDeleted(java.lang.Object pc)
Tests whether the parameter instance has been deleted. |
static boolean |
isDetached(java.lang.Object pc)
Tests whether the parameter instance has been detached. |
static boolean |
isDirty(java.lang.Object pc)
Tests whether the parameter instance is dirty. |
static boolean |
isNew(java.lang.Object pc)
Tests whether the parameter instance has been newly made persistent. |
protected static boolean |
isNullOrBlank(java.lang.String s)
|
static boolean |
isPersistent(java.lang.Object pc)
Tests whether the parameter instance is persistent. |
static boolean |
isTransactional(java.lang.Object pc)
Tests whether the parameter instance is transactional. |
protected static java.util.Map<java.lang.Object,java.lang.Object> |
loadPropertiesFromResource(java.lang.ClassLoader resourceLoader,
java.lang.String name)
Load a Properties instance by name from the class loader. |
static void |
makeDirty(java.lang.Object pc,
java.lang.String fieldName)
Explicitly mark the parameter instance and field dirty. |
protected static java.util.Map<java.lang.String,java.util.Map<java.lang.Object,java.lang.Object>> |
readNamedPMFProperties(java.net.URL url,
java.lang.String requestedPMFName,
javax.xml.parsers.DocumentBuilderFactory factory)
Reads JDO configuration file, creates a Map for each persistence-manager-factory, then returns the map. |
protected static java.util.Properties |
readPropertiesFromPMFElementAttributes(org.w3c.dom.Node pmfElement)
|
protected static java.util.Properties |
readPropertiesFromPMFSubelements(org.w3c.dom.Node pmfElement,
java.net.URL url)
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public JDOHelper()
Method Detail |
---|
public static JDOHelper getInstance()
public static PersistenceManager getPersistenceManager(java.lang.Object pc)
PersistenceManager
if there is one.
Transactional and persistent instances return the associated
PersistenceManager
.
Transient non-transactional instances and instances of classes
that do not implement PersistenceCapable
return
null
.
pc
- the PersistenceCapable
instance.
PersistenceManager
associated with the parameter
instance.PersistenceCapable.jdoGetPersistenceManager()
public static void makeDirty(java.lang.Object pc, java.lang.String fieldName)
PersistenceCapable
classes are able to detect
changes made to their fields. However, if a reference to an array is
given to a method outside the class, and the array is modified, then the
persistent instance is not aware of the change. This API allows the
application to notify the instance that a change was made to a field.
Transient instances and instances of classes
that do not implement PersistenceCapable
ignore this method.
pc
- the PersistenceCapable
instance.fieldName
- the name of the field to be marked dirty.PersistenceCapable.jdoMakeDirty(String fieldName)
public static java.lang.Object getObjectId(java.lang.Object pc)
Persistent instances of PersistenceCapable
classes have a
JDO identity managed by the PersistenceManager
. This method
returns a copy of the ObjectId that represents the JDO identity.
Transient instances and instances of classes that do not implement
PersistenceCapable
return null
.
The ObjectId may be serialized
and later restored, and used with a PersistenceManager
from
the same JDO implementation to locate a persistent instance with the same
data store identity.
If the JDO identity is managed by the application, then the ObjectId
may be used with a PersistenceManager
from any JDO
implementation that supports the PersistenceCapable
class.
If the JDO identity is not managed by the application or the data store, then the ObjectId returned is only valid within the current transaction.
pc
- the PersistenceCapable instance.
PersistenceManager.getObjectId(Object pc)
,
PersistenceCapable.jdoGetObjectId()
,
PersistenceManager.getObjectById(Object oid, boolean validate)
public static java.util.Collection<java.lang.Object> getObjectIds(java.util.Collection<?> pcs)
pcs
- the persistence-capable instances
getObjectId(Object pc)
,
getObjectIds(Object[] pcs)
public static java.lang.Object[] getObjectIds(java.lang.Object[] pcs)
pcs
- the persistence-capable instances
getObjectId(Object pc)
,
getObjectIds(Collection pcs)
public static java.lang.Object getTransactionalObjectId(java.lang.Object pc)
pc
- the PersistenceCapable
instance.
PersistenceCapable.jdoGetTransactionalObjectId()
,
PersistenceManager.getObjectById(Object oid, boolean validate)
public static java.lang.Object getVersion(java.lang.Object pc)
pc
- the instance
public static boolean isDirty(java.lang.Object pc)
true
.
Transient instances and instances of classes that do not implement
PersistenceCapable
return false
.
pc
- the PersistenceCapable
instance.
true
if the parameter instance has been modified in
the current transaction.StateManager.makeDirty(PersistenceCapable pc,
String fieldName)
,
PersistenceCapable.jdoIsDirty()
public static boolean isTransactional(java.lang.Object pc)
Transient instances and instances of classes that do not implement
PersistenceCapable
return false
.
pc
- the PersistenceCapable
instance.
true
if the parameter instance is transactional.PersistenceCapable.jdoIsTransactional()
public static boolean isPersistent(java.lang.Object pc)
true
.
Transient instances and instances of classes that do not implement
PersistenceCapable
return false
.
pc
- the PersistenceCapable
instance.
true
if the parameter instance is persistent.PersistenceManager.makePersistent(Object pc)
,
PersistenceCapable.jdoIsPersistent()
public static boolean isNew(java.lang.Object pc)
true
.
Transient instances and instances of classes that do not implement
PersistenceCapable
return false
.
pc
- the PersistenceCapable
instance.
true
if the parameter instance was made persistent
in the current transaction.PersistenceManager.makePersistent(Object pc)
,
PersistenceCapable.jdoIsNew()
public static boolean isDeleted(java.lang.Object pc)
true
.
Transient instances and instances of classes that do not implement
PersistenceCapable
return false
.
pc
- the PersistenceCapable
instance.
true
if the parameter instance was deleted
in the current transaction.PersistenceManager.deletePersistent(Object pc)
,
PersistenceCapable.jdoIsDeleted()
public static boolean isDetached(java.lang.Object pc)
Transient instances return false.
pc
- the instance
true
if this instance is detached.PersistenceCapable.jdoIsDetached()
public static ObjectState getObjectState(java.lang.Object pc)
pc
- The object
public static PersistenceManagerFactory getPersistenceManagerFactory()
PersistenceManagerFactory
configured via
the standard configuration file resource "META-INF/jdoconfig.xml", using
the current thread's context class loader
to locate the configuration file resource(s).
PersistenceManagerFactory
.getPersistenceManagerFactory(Map,String,ClassLoader,ClassLoader)
public static PersistenceManagerFactory getPersistenceManagerFactory(java.lang.ClassLoader pmfClassLoader)
PersistenceManagerFactory
configured via
the standard configuration file resource "META-INF/jdoconfig.xml", using
the given class loader.
pmfClassLoader
- the ClassLoader used to load resources and classes
PersistenceManagerFactory
.getPersistenceManagerFactory(Map,String,ClassLoader,ClassLoader)
public static PersistenceManagerFactory getPersistenceManagerFactory(java.util.Map<?,?> props)
PersistenceManagerFactory
based on a Properties
instance, using the current thread's context class loader to locate the
PersistenceManagerFactory
class.
props
- a Properties
instance with properties of the
PersistenceManagerFactory
.
PersistenceManagerFactory
.getPersistenceManagerFactory(java.util.Map,ClassLoader)
public static PersistenceManagerFactory getPersistenceManagerFactory(java.util.Map<?,?> props, java.lang.ClassLoader pmfClassLoader)
PersistenceManagerFactory
based on a
Map
and a class loader.
This method delegates to the getPersistenceManagerFactory
method that takes a Map of overrides and a Map of properties,
passing null as the overrides parameter.
props
- a Map
with properties of the
PersistenceManagerFactory
.pmfClassLoader
- the class loader used to load the
PersistenceManagerFactory
class
PersistenceManagerFactory
.getPersistenceManagerFactory(java.util.Map, java.util.Map, ClassLoader)
protected static PersistenceManagerFactory getPersistenceManagerFactory(java.util.Map<?,?> overrides, java.util.Map<?,?> props, java.lang.ClassLoader pmfClassLoader)
PersistenceManagerFactory
based on a
Map
of overrides, a Map
of
properties, and a class loader.
The following are standard key names:
"javax.jdo.PersistenceManagerFactoryClass"
"javax.jdo.option.Optimistic",
"javax.jdo.option.RetainValues",
"javax.jdo.option.RestoreValues",
"javax.jdo.option.IgnoreCache",
"javax.jdo.option.NontransactionalRead",
"javax.jdo.option.NontransactionalWrite",
"javax.jdo.option.Multithreaded",
"javax.jdo.option.ConnectionUserName",
"javax.jdo.option.ConnectionPassword",
"javax.jdo.option.ConnectionURL",
"javax.jdo.option.ConnectionFactoryName",
"javax.jdo.option.ConnectionFactory2Name",
"javax.jdo.option.Mapping",
"javax.jdo.mapping.Catalog",
"javax.jdo.mapping.Schema",
"javax.jdo.option.PersistenceUnitName",
"javax.jdo.option.DetachAllOnCommit",
"javax.jdo.option.CopyOnAttach",
"javax.jdo.option.ReadOnly",
"javax.jdo.option.TransactionIsolationLevel",
"javax.jdo.option.TransactionType",
"javax.jdo.option.ServerTimeZoneID",
"javax.jdo.option.DatastoreReadTimeoutMillis",
"javax.jdo.option.DatastoreWriteTimeoutMillis",
"javax.jdo.option.Name".
and properties of the form
javax.jdo.option.InstanceLifecycleListener.{listenerClass}[=[{pcClasses}]]
where {listenerClass}
is the fully qualified name of a
class that implements
InstanceLifecycleListener
, and
{pcClasses}
is an optional comma- or whitespace-delimited
list of persistence-capable classes to be observed; the absence of a
value for a property of this form means that instances of all
persistence-capable classes will be observed by an instance of the given
listener class.
JDO implementations
are permitted to define key values of their own. Any key values not
recognized by the implementation must be ignored. Key values that are
recognized but not supported by an implementation must result in a
JDOFatalUserException
thrown by the method.
The returned PersistenceManagerFactory
is not
configurable (the setXXX
methods will throw an
exception).
JDO implementations might manage a map of instantiated
PersistenceManagerFactory
instances based on specified
property key values, and return a previously instantiated
PersistenceManagerFactory
instance. In this case, the
properties of the returned instance must exactly match the requested
properties.
props
- a Properties
instance with properties of the
PersistenceManagerFactory
.pmfClassLoader
- the class loader to use to load the
PersistenceManagerFactory
class
PersistenceManagerFactory
.
JDOFatalUserException
- if
props
or system resources
(an entry in META-INF/services/javax.jdo.PersistenceManagerFactory); or
protected static java.lang.String getClassNameFromURL(java.net.URL url) throws java.io.IOException
url
- the URL of the services file
java.io.IOException
public static PersistenceManagerFactory getPersistenceManagerFactory(java.lang.String name)
PersistenceManagerFactory
or persistence
unit.
getPersistenceManagerFactory(Map,String,ClassLoader,ClassLoader)
public static PersistenceManagerFactory getPersistenceManagerFactory(java.lang.String name, java.lang.ClassLoader loader)
PersistenceManagerFactory
or persistence
unit.
getPersistenceManagerFactory(Map,String,ClassLoader,ClassLoader)
public static PersistenceManagerFactory getPersistenceManagerFactory(java.lang.String name, java.lang.ClassLoader resourceLoader, java.lang.ClassLoader pmfLoader)
PersistenceManagerFactory
or persistence
unit.
getPersistenceManagerFactory(Map,String,ClassLoader,ClassLoader)
public static PersistenceManagerFactory getPersistenceManagerFactory(java.util.Map<?,?> overrides, java.lang.String name)
PersistenceManagerFactory
or persistence
unit.
getPersistenceManagerFactory(Map,String,ClassLoader,ClassLoader)
public static PersistenceManagerFactory getPersistenceManagerFactory(java.util.Map<?,?> overrides, java.lang.String name, java.lang.ClassLoader resourceLoader)
PersistenceManagerFactory
or persistence
unit.
getPersistenceManagerFactory(Map,String,ClassLoader,ClassLoader)
public static PersistenceManagerFactory getPersistenceManagerFactory(java.util.Map<?,?> overrides, java.lang.String name, java.lang.ClassLoader resourceLoader, java.lang.ClassLoader pmfLoader)
PersistenceManagerFactory
configured based
on the properties stored in the resource at
name
, or, if not found, returns a
PersistenceManagerFactory
with the given
name or, if not found, returns a
javax.persistence.EntityManagerFactory
cast to a
PersistenceManagerFactory
. If the name given is null or consists
only of whitespace, it is interpreted as
Constants.ANONYMOUS_PERSISTENCE_MANAGER_FACTORY_NAME
.
The following are standard key names:
"javax.jdo.PersistenceManagerFactoryClass"
"javax.jdo.option.Optimistic",
"javax.jdo.option.RetainValues",
"javax.jdo.option.RestoreValues",
"javax.jdo.option.IgnoreCache",
"javax.jdo.option.NontransactionalRead",
"javax.jdo.option.NontransactionalWrite",
"javax.jdo.option.Multithreaded",
"javax.jdo.option.ConnectionUserName",
"javax.jdo.option.ConnectionPassword",
"javax.jdo.option.ConnectionURL",
"javax.jdo.option.ConnectionFactoryName",
"javax.jdo.option.ConnectionFactory2Name",
"javax.jdo.option.Mapping",
"javax.jdo.mapping.Catalog",
"javax.jdo.mapping.Schema",
"javax.jdo.option.PersistenceUnitName".
"javax.jdo.option.DetachAllOnCommit".
"javax.jdo.option.CopyOnAttach".
"javax.jdo.option.TransactionType".
"javax.jdo.option.ServerTimeZoneID".
"javax.jdo.option.DatastoreReadTimeoutMillis",
"javax.jdo.option.DatastoreWriteTimeoutMillis",
"javax.jdo.option.Name".
and properties of the form
javax.jdo.option.InstanceLifecycleListener.{listenerClass}[=[{pcClasses}]]
where {listenerClass}
is the fully qualified name of a
class that implements
InstanceLifecycleListener
, and
{pcClasses}
is an optional comma- or whitespace-delimited
list of persistence-capable classes to be observed; the absence of a
value for a property of this form means that instances of all
persistence-capable classes will be observed by an instance of the given
listener class.
JDO implementations
are permitted to define key values of their own. Any key values not
recognized by the implementation must be ignored. Key values that are
recognized but not supported by an implementation must result in a
JDOFatalUserException
thrown by the method.
The returned PersistenceManagerFactory
is not
configurable (the setXXX
methods will throw an
exception).
This method loads the properties found at name
, if any, via
resourceLoader
, and creates a PersistenceManagerFactory
with pmfLoader
. Any
exceptions thrown during resource loading will
be wrapped in a JDOFatalUserException
.
If multiple PMFs with the requested name are found, a
JDOFatalUserException
is thrown.
overrides
- a Map containing properties that override properties
defined in any resources loaded according to the "name" parametername
- interpreted as the name of the resource containing the PMF
properties, the name of the PMF, or the persistence unit name, in that
order; if name is null, blank or whitespace, it is interpreted as
indicating the anonymous PersistenceManagerFactory
.resourceLoader
- the class loader to use to load properties file
resources; must be non-null if name
is non-null or blankpmfLoader
- the class loader to use to load the
PersistenceManagerFactory
or
javax.persistence.EntityManagerFactory
classes
PersistenceManagerFactory
with properties in the
given resource, with the given name, or with the given persitence unit
nameConstants.ANONYMOUS_PERSISTENCE_MANAGER_FACTORY_NAME
protected static PersistenceManagerFactory invokeGetPersistenceManagerFactoryOnImplementation(java.lang.String pmfClassName, java.util.Map<?,?> overrides, java.util.Map<?,?> properties, java.lang.ClassLoader cl)
pmfClassName
- the name of the implementation factory classoverrides
- a Map of overridesproperties
- a Map of propertiescl
- the class loader to use to load the implementation class
protected static java.util.Map<java.lang.Object,java.lang.Object> loadPropertiesFromResource(java.lang.ClassLoader resourceLoader, java.lang.String name)
resourceLoader
- the class loader from which to load the propertiesname
- the name of the resource
protected static java.util.Map<java.lang.Object,java.lang.Object> getPropertiesFromJdoconfig(java.lang.String name, java.lang.ClassLoader resourceLoader)
getNamedPMFProperties(String,ClassLoader,String)
protected static java.util.Map<java.lang.Object,java.lang.Object> getNamedPMFProperties(java.lang.String name, java.lang.ClassLoader resourceLoader, java.lang.String jdoconfigResourceName)
PersistenceManagerFactory
's properties,
or null if not found.
If multiple named PMF property sets with
the given name are found (including anonymous ones), throw
JDOFatalUserException
.
This method is here only to facilitate testing; the parameter
"jdoconfigResourceName" in public usage should always have the value
given in the constant Constants.JDOCONFIG_RESOURCE_NAME
.
name
- The persistence unit name; null is disallowed.resourceLoader
- The ClassLoader used to load the standard JDO
configuration file.jdoconfigResourceName
- The name of the configuration file to read.
In public usage, this should always be the value of
Constants.JDOCONFIG_RESOURCE_NAME
.
PersistenceManagerFactory
properties if
found, null if not.
JDOFatalUserException
- if multiple named PMF property sets are
found with the given name, or any other exception is encountered.protected static javax.xml.parsers.DocumentBuilderFactory getDocumentBuilderFactory()
protected static javax.xml.parsers.DocumentBuilderFactory getDefaultDocumentBuilderFactory()
protected static org.xml.sax.ErrorHandler getErrorHandler()
protected static org.xml.sax.ErrorHandler getDefaultErrorHandler()
protected static java.util.Map<java.lang.String,java.util.Map<java.lang.Object,java.lang.Object>> readNamedPMFProperties(java.net.URL url, java.lang.String requestedPMFName, javax.xml.parsers.DocumentBuilderFactory factory)
url
- URL of a JDO configuration file compliant with
javax/jdo/jdoconfig.xsd.requestedPMFName
- The name of the requested
persistence unit (allows for fail-fast).factory
- The DocumentBuilderFactory
to use for XML
parsing.
protected static java.util.Properties readPropertiesFromPMFElementAttributes(org.w3c.dom.Node pmfElement)
protected static java.util.Properties readPropertiesFromPMFSubelements(org.w3c.dom.Node pmfElement, java.net.URL url)
protected static boolean isNullOrBlank(java.lang.String s)
public static PersistenceManagerFactory getPersistenceManagerFactory(java.io.File propsFile)
PersistenceManagerFactory
configured based
on the properties stored in the file at
propsFile
. This method is equivalent to
invoking getPersistenceManagerFactory(File,ClassLoader)
with
Thread.currentThread().getContextClassLoader()
as
the loader
argument.
propsFile
- the file containing the Properties
public static PersistenceManagerFactory getPersistenceManagerFactory(java.io.File propsFile, java.lang.ClassLoader loader)
PersistenceManagerFactory
configured based
on the properties stored in the file at
propsFile
. Creates a PersistenceManagerFactory
with loader
. Any
IOException
s or
FileNotFoundException
s thrown during resource
loading will be wrapped in a JDOFatalUserException
.
propsFile
- the file containing the Propertiesloader
- the class loader to use to load the
PersistenceManagerFactory
class
public static PersistenceManagerFactory getPersistenceManagerFactory(java.lang.String jndiLocation, javax.naming.Context context)
PersistenceManagerFactory
at the JNDI
location specified by jndiLocation
in the context
context
. If context
is
null
, new InitialContext()
will be
used. This method is equivalent to invoking getPersistenceManagerFactory(String,Context,ClassLoader)
with Thread.currentThread().getContextClassLoader()
as
the loader
argument.
jndiLocation
- the JNDI location containing the
PersistenceManagerFactorycontext
- the context in which to find the named
PersistenceManagerFactory
public static PersistenceManagerFactory getPersistenceManagerFactory(java.lang.String jndiLocation, javax.naming.Context context, java.lang.ClassLoader loader)
PersistenceManagerFactory
at the JNDI
location specified by jndiLocation
in the context
context
. If context
is
null
, new InitialContext()
will be
used. Creates a PersistenceManagerFactory
with
loader
. Any NamingException
s thrown
will be wrapped in a JDOFatalUserException
.
jndiLocation
- the JNDI location containing the
PersistenceManagerFactorycontext
- the context in which to find the named
PersistenceManagerFactoryloader
- the class loader to use to load the
PersistenceManagerFactory
class
public static PersistenceManagerFactory getPersistenceManagerFactory(java.io.InputStream stream)
PersistenceManagerFactory
configured based
on the Properties stored in the input stream at
stream
. This method is equivalent to
invoking getPersistenceManagerFactory(InputStream,ClassLoader)
with
Thread.currentThread().getContextClassLoader()
as
the loader
argument.
stream
- the stream containing the Properties
public static PersistenceManagerFactory getPersistenceManagerFactory(java.io.InputStream stream, java.lang.ClassLoader loader)
PersistenceManagerFactory
configured based
on the Properties stored in the input stream at
stream
. Creates a PersistenceManagerFactory
with loader
. Any
IOException
s thrown during resource
loading will be wrapped in a JDOFatalUserException
.
stream
- the stream containing the Propertiesloader
- the class loader to use to load the
PersistenceManagerFactory
class
public static JDOEnhancer getEnhancer()
JDOEnhancer
using the available enhancer(s) specified in
"META-INF/services/JDOEnhancer" using the context class loader.
JDOEnhancer
.
JDOFatalUserException
- if no available enhancerpublic static JDOEnhancer getEnhancer(java.lang.ClassLoader loader)
JDOEnhancer
using the available enhancer(s) specified in
"META-INF/services/JDOEnhancer"
loader
- the loader to use for loading the JDOEnhancer class (if any)
JDOEnhancer
.
JDOFatalUserException
- if no available enhancerprotected static java.util.Enumeration<java.net.URL> getResources(java.lang.ClassLoader resourceLoader, java.lang.String resourceName) throws java.io.IOException
resourceLoader
- resourceName
-
java.io.IOException
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |