Top Description Inners Fields Constructors Methods
org.eclipse.persistence.sessions.factories

public Class XMLSessionConfigLoader

extends Object
Class Inheritance
Imports
java.io.File, java.net.URL, java.util.Map, .Vector, org.eclipse.persistence.exceptions.SessionLoaderException, .ValidationException, org.eclipse.persistence.internal.helper.ConversionManager, org.eclipse.persistence.internal.localization.ExceptionLocalization, org.eclipse.persistence.internal.sessions.factories.PersistenceEntityResolver, .SessionsFactory, .XMLSessionConfigProject_11_1_1, .XMLSessionConfigToplinkProject, org.eclipse.persistence.internal.sessions.factories.model.SessionConfigs, org.eclipse.persistence.oxm.XMLContext, .XMLUnmarshaller, org.eclipse.persistence.platform.xml.XMLParser, .XMLPlatform, .XMLPlatformFactory, org.eclipse.persistence.sessions.Project, .Session, org.w3c.dom.Document, org.xml.sax.ErrorHandler, .SAXException, .SAXParseException

Provide a mechanism for loading Session configuration XML files. This is used by the SessionManager to define how to find and load a Session from a sessions XML file. The sessions XML file is typically deployed in the applications jar (ejb-jar) and named sessions.xml in the /META-INF directory. Several loading options are provided,
Author
Guy Pelletier
Since
TopLink 10.1.3

Nested and Inner Type Summary

Modifier and TypeClass and Description
public class
XMLSessionConfigLoader.XMLSessionConfigLoaderErrorHandler

INTERNAL:

Purpose: Provide a mechanism to swallow all parsing errors

Field Summary

Modifier and TypeField and Description
protected ClassLoader
classLoader

Define the class loader that should be used to find the resource.

protected static final String
protected static final String
protected PersistenceEntityResolver
entityResolver

Used to store the entity resolver to validate the XML schema when parsing.

protected Vector<Throwable>
exceptionStore

Stores any exceptions that occurred to provide all the exceptions up front if the load fails.

protected static final Project
project

Cache the creation and initialization of the Session XML mapping project.

protected String
protected String
resourcePath

Stores the resource path to provide a better error message if the load fails.

protected String
sessionName

Stores the name of the Session in the sessions XML file desired to be loaded.

protected boolean
shouldCheckClassLoader

Defines if the session will be refreshed from the file if the class loader requesting the load is different than the loaded session's class loader.

protected boolean
shouldLogin

Define if the loaded session should be connected, default true.

protected boolean
shouldRefresh

Define if the loaded session should be refreshed from the file.

Constructor Summary

AccessConstructor and Description
public
XMLSessionConfigLoader()

PUBLIC: This constructor is used when the file resource named 'sessions.xml' will be parsed for configuration.

public
XMLSessionConfigLoader(String resourceName)

PUBLIC: This constructor is used when passing in the resource name of the configuration file that should be parsed

Method Summary

Modifier and TypeMethod and Description
private boolean
buildSessionConfigs(SessionManager sessionManager, ClassLoader loader, Document document, Project project)

public ClassLoader
getClassLoader()

PUBLIC: Return the class loader that should be used to find the resource.

public Vector<Throwable>
getExceptionStore()

INTERNAL:

protected static Project
getProject()

Cache the creation and initialization of the Session XML mapping project.

public String
getResourceName()

PUBLIC: Returns the resource name we are trying to load.

public String
getResourcePath()

INTERNAL: Will return the the resource name with full path of the resource file.

public String
getSessionName()

PUBLIC: Returns the name of the Session in the sessions XML file desired to be loaded.

public boolean
load(SessionManager sessionManager, ClassLoader loader)

INTERNAL: This method instantiates the parser and builds the document based on the schema.

public SessionConfigs
loadConfigsForMappingWorkbench(ClassLoader loader)

INTERNAL: This method is to be used to load config objects for the Mapping Workbench only.

public SessionConfigs
loadConfigsForMappingWorkbench(ClassLoader loader, boolean validate)

INTERNAL: This method is to be used to load config objects for the Mapping Workbench only.

protected Document
loadDocument(ClassLoader loader)

INTERNAL: Load a session.xml document.

protected Document
loadDocument(ClassLoader loader, boolean validate)

INTERNAL: Load a session.xml document.

public void
setClassLoader(ClassLoader classLoader)

PUBLIC: Set the class loader that should be used to find the resource.

public void
setResourceName(String resourceName)

PUBLIC: Set the resource name we are trying to load.

public void
setSessionName(String sessionName)

PUBLIC: Set the name of the Session in the sessions XML file desired to be loaded.

public void
setShouldCheckClassLoader(boolean shouldCheckClassLoader)

PUBLIC: Set if the session will be refreshed from the file if the class loader requesting the load is different than the loaded session's class loader.

public void
setShouldLogin(boolean shouldLogin)

PUBLIC: Set if the loaded session should be connected.

public void
setShouldRefresh(boolean shouldRefresh)

PUBLIC: Set if the loaded session should be refreshed from the file.

public boolean
shouldCheckClassLoader()

PUBLIC: Return if the session will be refreshed from the file if the class loader requesting the load is different than the loaded session's class loader.

public boolean
shouldLogin()

PUBLIC: Return if the loaded session should be connected.

public boolean
shouldRefresh()

PUBLIC: Return if the loaded session should be refreshed from the file.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

classLoaderback to summary
protected ClassLoader classLoader

Define the class loader that should be used to find the resource.

DEFAULT_RESOURCE_NAMEback to summary
protected static final String DEFAULT_RESOURCE_NAME
DEFAULT_RESOURCE_NAME_IN_META_INFback to summary
protected static final String DEFAULT_RESOURCE_NAME_IN_META_INF
entityResolverback to summary
protected PersistenceEntityResolver entityResolver

Used to store the entity resolver to validate the XML schema when parsing.

exceptionStoreback to summary
protected Vector<Throwable> exceptionStore

Stores any exceptions that occurred to provide all the exceptions up front if the load fails.

projectback to summary
protected static final Project project

Cache the creation and initialization of the Session XML mapping project.

resourceNameback to summary
protected String resourceName
resourcePathback to summary
protected String resourcePath

Stores the resource path to provide a better error message if the load fails.

sessionNameback to summary
protected String sessionName

Stores the name of the Session in the sessions XML file desired to be loaded.

shouldCheckClassLoaderback to summary
protected boolean shouldCheckClassLoader

Defines if the session will be refreshed from the file if the class loader requesting the load is different than the loaded session's class loader.

shouldLoginback to summary
protected boolean shouldLogin

Define if the loaded session should be connected, default true.

shouldRefreshback to summary
protected boolean shouldRefresh

Define if the loaded session should be refreshed from the file.

Constructor Detail

XMLSessionConfigLoaderback to summary
public XMLSessionConfigLoader()

PUBLIC: This constructor is used when the file resource named 'sessions.xml' will be parsed for configuration.

XMLSessionConfigLoaderback to summary
public XMLSessionConfigLoader(String resourceName)

PUBLIC: This constructor is used when passing in the resource name of the configuration file that should be parsed

Method Detail

buildSessionConfigsback to summary
private boolean buildSessionConfigs(SessionManager sessionManager, ClassLoader loader, Document document, Project project)
getClassLoaderback to summary
public ClassLoader getClassLoader()

PUBLIC: Return the class loader that should be used to find the resource.

getExceptionStoreback to summary
public Vector<Throwable> getExceptionStore()

INTERNAL:

getProjectback to summary
protected static Project getProject()

Cache the creation and initialization of the Session XML mapping project.

getResourceNameback to summary
public String getResourceName()

PUBLIC: Returns the resource name we are trying to load.

getResourcePathback to summary
public String getResourcePath()

INTERNAL: Will return the the resource name with full path of the resource file.

getSessionNameback to summary
public String getSessionName()

PUBLIC: Returns the name of the Session in the sessions XML file desired to be loaded.

loadback to summary
public boolean load(SessionManager sessionManager, ClassLoader loader)

INTERNAL: This method instantiates the parser and builds the document based on the schema. If the document is loaded without errors, then the configs are converted to sessions and stored on the session manager and true is returned to indicate success.

loadConfigsForMappingWorkbenchback to summary
public SessionConfigs loadConfigsForMappingWorkbench(ClassLoader loader)

INTERNAL: This method is to be used to load config objects for the Mapping Workbench only. Do not call this method.

loadConfigsForMappingWorkbenchback to summary
public SessionConfigs loadConfigsForMappingWorkbench(ClassLoader loader, boolean validate)

INTERNAL: This method is to be used to load config objects for the Mapping Workbench only. Do not call this method.

loadDocumentback to summary
protected Document loadDocument(ClassLoader loader)

INTERNAL: Load a session.xml document. The error handler will capture all the errors and allow for a document to be returned.

loadDocumentback to summary
protected Document loadDocument(ClassLoader loader, boolean validate)

INTERNAL: Load a session.xml document. The error handler will capture all the errors and allow for a document to be returned.

setClassLoaderback to summary
public void setClassLoader(ClassLoader classLoader)

PUBLIC: Set the class loader that should be used to find the resource.

setResourceNameback to summary
public void setResourceName(String resourceName)

PUBLIC: Set the resource name we are trying to load.

setSessionNameback to summary
public void setSessionName(String sessionName)

PUBLIC: Set the name of the Session in the sessions XML file desired to be loaded.

setShouldCheckClassLoaderback to summary
public void setShouldCheckClassLoader(boolean shouldCheckClassLoader)

PUBLIC: Set if the session will be refreshed from the file if the class loader requesting the load is different than the loaded session's class loader.

setShouldLoginback to summary
public void setShouldLogin(boolean shouldLogin)

PUBLIC: Set if the loaded session should be connected.

setShouldRefreshback to summary
public void setShouldRefresh(boolean shouldRefresh)

PUBLIC: Set if the loaded session should be refreshed from the file.

shouldCheckClassLoaderback to summary
public boolean shouldCheckClassLoader()

PUBLIC: Return if the session will be refreshed from the file if the class loader requesting the load is different than the loaded session's class loader.

shouldLoginback to summary
public boolean shouldLogin()

PUBLIC: Return if the loaded session should be connected.

shouldRefreshback to summary
public boolean shouldRefresh()

PUBLIC: Return if the loaded session should be refreshed from the file.

org.eclipse.persistence.sessions.factories back to summary

public Class XMLSessionConfigLoader.XMLSessionConfigLoaderErrorHandler

extends Object
implements ErrorHandler
Class Inheritance
  • java.lang.Object
  • org.eclipse.persistence.sessions.factories.XMLSessionConfigLoader.XMLSessionConfigLoaderErrorHandler
All Implemented Interfaces
org.xml.sax.ErrorHandler

INTERNAL:

Purpose: Provide a mechanism to swallow all parsing errors

Author
Guy Pelletier
Since
TopLink 10.1.3
See Also
ErrorHandler

Constructor Summary

AccessConstructor and Description
public
XMLSessionConfigLoaderErrorHandler()

Default constructor.

Method Summary

Modifier and TypeMethod and Description
public void
error(SAXParseException
The error information encapsulated in a SAX parse exception.
e
)

Implements org.xml.sax.ErrorHandler.error.

Receive notification of a recoverable error.
public void
fatalError(SAXParseException
The error information encapsulated in a SAXParseException.
e
)

Implements org.xml.sax.ErrorHandler.fatalError.

Receive notification of a non-recoverable, fatal error.
public void
warning(SAXParseException
The warning information encapsulated in a SAX parse exception.
e
)

Implements org.xml.sax.ErrorHandler.warning.

Receive notification of a warning.
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Constructor Detail

XMLSessionConfigLoaderErrorHandlerback to summary
public XMLSessionConfigLoaderErrorHandler()

Default constructor.

Method Detail

errorback to summary
public void error(SAXParseException e) throws SAXException

Implements org.xml.sax.ErrorHandler.error.

Doc from org.xml.sax.ErrorHandler.error.

Receive notification of a recoverable error.

This corresponds to the definition of "error" in section 1.2 of the W3C XML 1.0 Recommendation. For example, a validating parser would use this callback to report the violation of a validity constraint. The default behaviour is to take no action.

The SAX parser must continue to provide normal parsing events after invoking this method: it should still be possible for the application to process the document through to the end. If the application cannot do so, then the parser should report a fatal error even if the XML recommendation does not require it to do so.

Filters may use this method to report other, non-XML errors as well.

Parameters
e:SAXParseException

The error information encapsulated in a SAX parse exception.

Annotations
@Override
Exceptions
SAXException:
Any SAX exception, possibly wrapping another exception.
fatalErrorback to summary
public void fatalError(SAXParseException e) throws SAXException

Implements org.xml.sax.ErrorHandler.fatalError.

Doc from org.xml.sax.ErrorHandler.fatalError.

Receive notification of a non-recoverable, fatal error.

As defined in section 1.2 of the W3C XML 1.0 Recommendation, fatal errors are those that would make it impossible for a parser to continue normal processing. These include violation of a well-formedness constraint, invalid encoding, and forbidden structural errors as described in the W3C XML 1.0 Recommendation.

Parameters
e:SAXParseException

The error information encapsulated in a SAXParseException.

Annotations
@Override
Exceptions
SAXException:
if the application chooses to discontinue the parsing
warningback to summary
public void warning(SAXParseException e) throws SAXException

Implements org.xml.sax.ErrorHandler.warning.

Doc from org.xml.sax.ErrorHandler.warning.

Receive notification of a warning.

SAX parsers will use this method to report conditions that are not errors or fatal errors as defined by the XML recommendation. The default behaviour is to take no action.

The SAX parser must continue to provide normal parsing events after invoking this method: it should still be possible for the application to process the document through to the end.

Filters may use this method to report other, non-XML warnings as well.

Parameters
e:SAXParseException

The warning information encapsulated in a SAX parse exception.

Annotations
@Override
Exceptions
SAXException:
Any SAX exception, possibly wrapping another exception.