Top Description Constructors Methods
org.eclipse.persistence.jpa.metadata

public Class XMLMetadataSource

extends MetadataSourceAdapter
Class Inheritance
Known Direct Subclasses
org.eclipse.persistence.internal.jpa.config.persistenceunit.MetadataSource
Imports
java.io.IOException, .InputStreamReader, .Reader, java.net.URL, java.util.Enumeration, .HashMap, .Map, .Properties, org.eclipse.persistence.internal.jpa.metadata.xml.XMLEntityMappingsReader, .XMLEntityMappings, org.eclipse.persistence.config.PersistenceUnitProperties, org.eclipse.persistence.exceptions.ValidationException, org.eclipse.persistence.logging.SessionLog

Purpose: Support reading metadata for a persistence unit in an XML format from a URL and if the property is undefined, it will look for a file.

Constructor Summary

AccessConstructor and Description
public
XMLMetadataSource()

Default constructor.

Method Summary

Modifier and TypeMethod and Description
public Object

Returns:

object for the given name, null if not found
getConfigPropertyLogDebug
(final String
property name
propertyName
,
Map<String, ?>
properties
properties
,
SessionLog
logger
log
)

Check the provided map for an object with the given name.

public XMLEntityMappings

Returns:

XMLEntityMappings - object representation of the EclipseLink-orm.xml for this repository
getEntityMappings
(Map<String, Object> properties, ClassLoader classLoader, SessionLog log)

Overrides org.eclipse.persistence.jpa.metadata.MetadataSourceAdapter.getEntityMappings.

Implements org.eclipse.persistence.jpa.metadata.MetadataSource.getEntityMappings.

This method is responsible for returning the object representation of the MetadataSource.
public Reader

Returns:

Reader - a InputStreamReader with data in the form of an EclipseLink-orm.xml
getEntityMappingsReader
(Map<String, Object> properties, ClassLoader classLoader, SessionLog
- SessionLog used for status messages.
log
)

This method returns a Reader for an EclipseLink-ORM.xml.

protected static URL
getFileURL(String fileName, ClassLoader classLoader, SessionLog log)

public Map<String, Object>
getPropertyOverrides(Map<String, Object> properties, ClassLoader classLoader, SessionLog log)

Implements org.eclipse.persistence.jpa.metadata.MetadataSource.getPropertyOverrides.

PUBLIC: This method is responsible for returning additional persistence unit property overrides.
public String

Returns:

String - repository name to store in the XMLEntityMappings returned from getEntityMappings
getRepositoryName
()

Used by getEntityMappings when creating the XMLEntityMappings as a way of describing where it was read from.

Constructor Detail

XMLMetadataSourceback to summary
public XMLMetadataSource()

Default constructor.

Method Detail

getConfigPropertyLogDebugback to summary
public Object getConfigPropertyLogDebug(final String propertyName, Map<String, ?> properties, SessionLog log)

Check the provided map for an object with the given name. If that object is not available, check the System properties. Log the value returned if logging is enabled

Parameters
propertyName:String

property name

properties:Map<String, ?>

properties

log:SessionLog

logger

Returns:Object

object for the given name, null if not found

getEntityMappingsback to summary
public XMLEntityMappings getEntityMappings(Map<String, Object> properties, ClassLoader classLoader, SessionLog log)

Overrides org.eclipse.persistence.jpa.metadata.MetadataSourceAdapter.getEntityMappings.

Implements org.eclipse.persistence.jpa.metadata.MetadataSource.getEntityMappings.

This method is responsible for returning the object representation of the MetadataSource. This implementation makes a call to getEntityMappingsReader to get a Reader which is passed to an XMLUnmarshaller, and closes the reader in a finally block.

Returns:XMLEntityMappings

XMLEntityMappings - object representation of the EclipseLink-orm.xml for this repository

Annotations
@Override
getEntityMappingsReaderback to summary
public Reader getEntityMappingsReader(Map<String, Object> properties, ClassLoader classLoader, SessionLog log)

This method returns a Reader for an EclipseLink-ORM.xml. It will use the PersistenceUnitProperties.METADATA_SOURCE_XML_URL property if available to create an InputStreamReader from a URL, and if not available, use the PersistenceUnitProperties.METADATA_SOURCE_XML_FILE property will be used to get a file resource from the classloader. It will throw a ValidationException if no reader can be returned.

Parameters
log:SessionLog

- SessionLog used for status messages.

Returns:Reader

Reader - a InputStreamReader with data in the form of an EclipseLink-orm.xml

See Also
getEntityMappings
getFileURLback to summary
protected static URL getFileURL(String fileName, ClassLoader classLoader, SessionLog log) throws IOException
getPropertyOverridesback to summary
public Map<String, Object> getPropertyOverrides(Map<String, Object> properties, ClassLoader classLoader, SessionLog log)

Implements org.eclipse.persistence.jpa.metadata.MetadataSource.getPropertyOverrides.

PUBLIC: This method is responsible for returning additional persistence unit property overrides. It is called on initial deployment of the persistence unit and when the persistence unit is reloaded to allow customization of the persistence unit above and beyond what is packaged in the persistence.xml and what is code into the application.

Important Note

Although any property can be changed using this approach it is important that users of this feature ensure compatible configurations are supplied. As an example; overriding an application to use RESOURCE_LOCAL when it was coded to use JTA would result in changes not be written to the database. PersistenceUnitProperties.METADATA_SOURCE_PROPERTIES_FILE property will be used to get a file resource from the classloader. Properties are read from the file. If the property either not specified or contains an empty string then returns null.

Annotations
@Override
Since
EclipseLink 2.4
getRepositoryNameback to summary
public String getRepositoryName()

Used by getEntityMappings when creating the XMLEntityMappings as a way of describing where it was read from. Currently returns the current class's simple name.

Returns:String

String - repository name to store in the XMLEntityMappings returned from getEntityMappings