Java Doc for LocalSessionFactory.java in  » J2EE » spring-framework-2.0.6 » org » springframework » orm » toplink » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » J2EE » spring framework 2.0.6 » org.springframework.orm.toplink 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


java.lang.Object
   org.springframework.orm.toplink.LocalSessionFactory

All known Subclasses:   org.springframework.orm.toplink.LocalSessionFactoryBean,
LocalSessionFactory
public class LocalSessionFactory (Code)
Convenient JavaBean-style factory for a TopLink SessionFactory instance. Loads a TopLink sessions.xml file from the class path, exposing a specific TopLink Session defined there (usually a ServerSession).

TopLink Session configuration is done using a sessions.xml file. The most convenient way to create the sessions.xml file is to use the Oracle TopLink SessionsEditor workbench. The sessions.xml file contains all runtime configuration and points to a second XML or Class resource from which to load the actual TopLink project metadata (which defines mappings).

LocalSessionFactory loads the sessions.xml file during initialization in order to bootstrap the specified TopLink (Server)Session. The name of the actual config resource and the name of the Session to be loaded, if different from sessions.xml and "Session", respectively, can be configured through bean properties.

All resources (sessions.xml and Mapping Workbench metadata) are loaded using ClassLoader.getResourceAsStream calls by TopLink, so users may need to configure a ClassLoader with appropriate visibility. This is particularly important in J2EE environments where the TopLink metadata might be deployed to a different location than the Spring configuration. The ClassLoader used to search for the TopLink metadata and to load the persistent classes defined there will default to the the context ClassLoader for the current Thread.

TopLink's debug logging can be redirected to Commons Logging by passing a CommonsLoggingSessionLog to the "sessionLog" bean property. Otherwise, TopLink uses it's own DefaultSessionLog, whose levels are configured in the sessions.xml file.

This class has been tested against both TopLink 9.0.4 and TopLink 10.1.3. It will automatically adapt to the TopLink version encountered: for example, using an XMLSessionConfigLoader on 10.1.3, but an XMLLoader on 9.0.4.

NOTE: When defining a TopLink SessionFactory in a Spring application context, you will usually define a bean of type LocalSessionFactoryBean. LocalSessionFactoryBean is a subclass of this factory, which will automatically expose the created TopLink SessionFactory instance as bean reference.
author:
   Juergen Hoeller
author:
   James Clark
since:
   1.2
See Also:   LocalSessionFactoryBean
See Also:   TopLinkTemplate.setSessionFactory
See Also:   TopLinkTransactionManager.setSessionFactory
See Also:   SingleSessionFactory
See Also:   ServerSessionFactory
See Also:   oracle.toplink.threetier.ServerSession
See Also:   oracle.toplink.tools.sessionconfiguration.XMLLoader
See Also:   oracle.toplink.tools.sessionconfiguration.XMLSessionConfigLoader



Field Summary
final public static  StringDEFAULT_SESSIONS_XML
     The default location of the sessions.xml TopLink configuration file: "sessions.xml" in the class path.
final public static  StringDEFAULT_SESSION_NAME
     The default session name to look for in the sessions.xml: "Session".
final protected  Loglogger
    


Method Summary
public  SessionFactorycreateSessionFactory()
     Create a TopLink SessionFactory according to the configuration settings.
public  MapgetLoginPropertyMap()
     Allow Map access to the TopLink login properties to be passed to the DatabaseLogin instance, with the option to add or override specific entries.
protected  SessionManagergetSessionManager()
     Return the TopLink SessionManager to use for loading DatabaseSessions.

The default implementation creates a new plain SessionManager instance, leading to completely independent TopLink Session instances.

protected  DatabaseSessionloadDatabaseSession(String configLocation, String sessionName, ClassLoader sessionClassLoader)
     Load the specified DatabaseSession from the TopLink sessions.xml configuration file.
protected  SessionFactorynewSessionFactory(DatabaseSession session)
     Create a new SessionFactory for the given TopLink DatabaseSession.
public  voidsetConfigLocation(String configLocation)
     Set the TopLink sessions.xml configuration file that defines TopLink Sessions, as class path resource location.
public  voidsetDataSource(DataSource dataSource)
     Specify a standard JDBC DataSource that TopLink should use as connection pool. This allows for using a shared DataSource definition instead of TopLink's own connection pool.

A passed-in DataSource will be wrapped in an appropriate TopLink Connector and registered with the TopLink DatabaseLogin instance (either the default instance or one passed in through the "databaseLogin" property).

public  voidsetDatabaseLogin(DatabaseLogin databaseLogin)
     Specify the DatabaseLogin instance that carries the TopLink database configuration to use.
protected  voidsetDatabaseLogin(DatabaseSession session, DatabaseLogin login)
     Handle differences between the Session.setLogin interface between TopLink 9.0.4 to 10.1.3.
public  voidsetDatabasePlatform(DatabasePlatform databasePlatform)
     Specify the TopLink DatabasePlatform instance that the Session should use: for example, HSQLPlatform.
public  voidsetLoginProperties(Properties loginProperties)
     Specify TopLink login properties, to be passed to the oracle.toplink.sessions.DatabaseLogin instance.
public  voidsetLoginPropertyMap(Map loginProperties)
     Specify TopLink login properties as a Map, to be passed to the oracle.toplink.sessions.DatabaseLogin instance.
public  voidsetSessionClassLoader(ClassLoader sessionClassLoader)
     Set the ClassLoader that should be used to lookup the config resources. If nothing is set here, then we will try to use the Thread context ClassLoader and the ClassLoader that loaded this factory class, in that order.

This ClassLoader will be used to load the TopLink configuration files and the project metadata.

public  voidsetSessionLog(SessionLog sessionLog)
     Specify a TopLink SessionLog instance to use for detailed logging of the Session's activities: for example, DefaultSessionLog (which logs to the console), JavaLog (which logs through JDK 1.4'S java.util.logging, available as of TopLink 10.1.3), or CommonsLoggingSessionLog / CommonsLoggingSessionLog904 (which logs through Commons Logging, on TopLink 10.1.3 and 9.0.4, respectively).

Note that detailed Session logging is usually only useful for debug logging, with adjustable detail level.

public  voidsetSessionName(String sessionName)
     Set the name of the TopLink Session, as defined in TopLink's sessions.xml configuration file.

Field Detail
DEFAULT_SESSIONS_XML
final public static String DEFAULT_SESSIONS_XML(Code)
The default location of the sessions.xml TopLink configuration file: "sessions.xml" in the class path.



DEFAULT_SESSION_NAME
final public static String DEFAULT_SESSION_NAME(Code)
The default session name to look for in the sessions.xml: "Session".



logger
final protected Log logger(Code)





Method Detail
createSessionFactory
public SessionFactory createSessionFactory() throws TopLinkException(Code)
Create a TopLink SessionFactory according to the configuration settings. the new TopLink SessionFactory
throws:
  TopLinkException - in case of errors



getLoginPropertyMap
public Map getLoginPropertyMap()(Code)
Allow Map access to the TopLink login properties to be passed to the DatabaseLogin instance, with the option to add or override specific entries.

Useful for specifying entries directly, for example via "loginPropertyMap[tableQualifier]".
See Also:   oracle.toplink.sessions.DatabaseLogin




getSessionManager
protected SessionManager getSessionManager()(Code)
Return the TopLink SessionManager to use for loading DatabaseSessions.

The default implementation creates a new plain SessionManager instance, leading to completely independent TopLink Session instances. Could be overridden to return a shared or pre-configured SessionManager. the TopLink SessionManager instance




loadDatabaseSession
protected DatabaseSession loadDatabaseSession(String configLocation, String sessionName, ClassLoader sessionClassLoader) throws TopLinkException(Code)
Load the specified DatabaseSession from the TopLink sessions.xml configuration file.
Parameters:
  configLocation - the class path location of the sessions.xml file
Parameters:
  sessionName - the name of the TopLink Session in the configuration file
Parameters:
  sessionClassLoader - the class loader to use the DatabaseSession instance
throws:
  TopLinkException - in case of errors



newSessionFactory
protected SessionFactory newSessionFactory(DatabaseSession session)(Code)
Create a new SessionFactory for the given TopLink DatabaseSession.

The default implementation creates a ServerSessionFactory for a ServerSession and a SingleSessionFactory for a plain DatabaseSession.
Parameters:
  session - the TopLink DatabaseSession to create a SessionFactory for the SessionFactory
throws:
  TopLinkException - in case of errors
See Also:   ServerSessionFactory
See Also:   SingleSessionFactory
See Also:   oracle.toplink.threetier.ServerSession
See Also:   oracle.toplink.sessions.DatabaseSession




setConfigLocation
public void setConfigLocation(String configLocation)(Code)
Set the TopLink sessions.xml configuration file that defines TopLink Sessions, as class path resource location.

The sessions.xml file will usually be placed in the META-INF directory or root path of a JAR file, or the WEB-INF/classes directory of a WAR file (specifying "META-INF/toplink-sessions.xml" or simply "toplink-sessions.xml" as config location, respectively).

The default config location is "sessions.xml" in the root of the class path.
Parameters:
  configLocation - the class path location of the sessions.xml file




setDataSource
public void setDataSource(DataSource dataSource)(Code)
Specify a standard JDBC DataSource that TopLink should use as connection pool. This allows for using a shared DataSource definition instead of TopLink's own connection pool.

A passed-in DataSource will be wrapped in an appropriate TopLink Connector and registered with the TopLink DatabaseLogin instance (either the default instance or one passed in through the "databaseLogin" property). The "usesExternalConnectionPooling" flag will automatically be set to "true".
See Also:   oracle.toplink.sessions.DatabaseLogin.setConnector(oracle.toplink.sessions.Connector)
See Also:   oracle.toplink.sessions.DatabaseLogin.setUsesExternalConnectionPooling(boolean)
See Also:   LocalSessionFactory.setDatabaseLogin(oracle.toplink.sessions.DatabaseLogin)




setDatabaseLogin
public void setDatabaseLogin(DatabaseLogin databaseLogin)(Code)
Specify the DatabaseLogin instance that carries the TopLink database configuration to use. This is an alternative to specifying that information in a <login> tag in the sessions.xml configuration file, allowing for configuring a DatabaseLogin instance as standard Spring bean definition (being able to leverage Spring's placeholder mechanism, etc).

The DatabaseLogin instance can either carry traditional JDBC config properties or hold a nested TopLink Connector instance, pointing to the connection pool to use. DatabaseLogin also holds the TopLink DatabasePlatform instance that defines the database product that TopLink is talking to (for example, HSQLPlatform).

WARNING: Overriding the Login instance has been reported to not work on TopLink 10.1.3.0 and 10.1.3.1. Specify LocalSessionFactory.setLoginProperties"loginProperties" or LocalSessionFactory.getLoginPropertyMap "loginPropertyMap[...]" entries instead, if you prefer to have the login configuration defined on the Spring LocalSessionFactory.




setDatabaseLogin
protected void setDatabaseLogin(DatabaseSession session, DatabaseLogin login)(Code)
Handle differences between the Session.setLogin interface between TopLink 9.0.4 to 10.1.3.

The Login interface was introduced in TopLink 10.1.3.
Parameters:
  session - the DatabaseSession being logged in
Parameters:
  login - the DatabaseLogin injected by Spring
See Also:   oracle.toplink.sessions.DatabaseSession.setLogin




setDatabasePlatform
public void setDatabasePlatform(DatabasePlatform databasePlatform)(Code)
Specify the TopLink DatabasePlatform instance that the Session should use: for example, HSQLPlatform. This is an alternative to specifying the platform in a <login> tag in the sessions.xml configuration file.

A passed-in DatabasePlatform will be registered with the TopLink DatabaseLogin instance (either the default instance or one passed in through the "databaseLogin" property).
See Also:   oracle.toplink.internal.databaseaccess.HSQLPlatform
See Also:   oracle.toplink.platform.database.HSQLPlatform




setLoginProperties
public void setLoginProperties(Properties loginProperties)(Code)
Specify TopLink login properties, to be passed to the oracle.toplink.sessions.DatabaseLogin instance.

Can be populated with a String "value" (parsed via PropertiesEditor) or a "props" element in XML bean definitions.
See Also:   oracle.toplink.sessions.DatabaseLogin




setLoginPropertyMap
public void setLoginPropertyMap(Map loginProperties)(Code)
Specify TopLink login properties as a Map, to be passed to the oracle.toplink.sessions.DatabaseLogin instance.

Can be populated with a "map" or "props" element in XML bean definitions.
See Also:   oracle.toplink.sessions.DatabaseLogin




setSessionClassLoader
public void setSessionClassLoader(ClassLoader sessionClassLoader)(Code)
Set the ClassLoader that should be used to lookup the config resources. If nothing is set here, then we will try to use the Thread context ClassLoader and the ClassLoader that loaded this factory class, in that order.

This ClassLoader will be used to load the TopLink configuration files and the project metadata. Furthermore, the TopLink ConversionManager will use this ClassLoader to load all TopLink entity classes. If the latter is not appropriate, users can configure a pre-login SessionEvent to alter the ConversionManager ClassLoader that TopLink will use at runtime.




setSessionLog
public void setSessionLog(SessionLog sessionLog)(Code)
Specify a TopLink SessionLog instance to use for detailed logging of the Session's activities: for example, DefaultSessionLog (which logs to the console), JavaLog (which logs through JDK 1.4'S java.util.logging, available as of TopLink 10.1.3), or CommonsLoggingSessionLog / CommonsLoggingSessionLog904 (which logs through Commons Logging, on TopLink 10.1.3 and 9.0.4, respectively).

Note that detailed Session logging is usually only useful for debug logging, with adjustable detail level. As of TopLink 10.1.3, TopLink also uses different log categories, which allows for fine-grained filtering of log messages. For standard execution, no SessionLog needs to be specified.
See Also:   oracle.toplink.sessions.DefaultSessionLog
See Also:   oracle.toplink.logging.DefaultSessionLog
See Also:   oracle.toplink.logging.JavaLog
See Also:   org.springframework.orm.toplink.support.CommonsLoggingSessionLog
See Also:   org.springframework.orm.toplink.support.CommonsLoggingSessionLog904




setSessionName
public void setSessionName(String sessionName)(Code)
Set the name of the TopLink Session, as defined in TopLink's sessions.xml configuration file. The default session name is "Session".



Methods inherited from java.lang.Object
native protected Object clone() throws CloneNotSupportedException(Code)(Java Doc)
public boolean equals(Object obj)(Code)(Java Doc)
protected void finalize() throws Throwable(Code)(Java Doc)
final native public Class getClass()(Code)(Java Doc)
native public int hashCode()(Code)(Java Doc)
final native public void notify()(Code)(Java Doc)
final native public void notifyAll()(Code)(Java Doc)
public String toString()(Code)(Java Doc)
final native public void wait(long timeout) throws InterruptedException(Code)(Java Doc)
final public void wait(long timeout, int nanos) throws InterruptedException(Code)(Java Doc)
final public void wait() throws InterruptedException(Code)(Java Doc)

www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.