Java Doc for LocalPersistenceManagerFactoryBean.java in  » J2EE » spring-framework-2.0.6 » org » springframework » orm » jdo » 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.jdo 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


java.lang.Object
   org.springframework.orm.jdo.LocalPersistenceManagerFactoryBean

LocalPersistenceManagerFactoryBean
public class LocalPersistenceManagerFactoryBean implements FactoryBean,InitializingBean,DisposableBean,PersistenceExceptionTranslator(Code)
org.springframework.beans.factory.FactoryBean that creates a JDO javax.jdo.PersistenceManagerFactory . This is the usual way to set up a shared JDO PersistenceManagerFactory in a Spring application context; the PersistenceManagerFactory can then be passed to JDO-based DAOs via dependency injection. Note that switching to a JNDI lookup or to a bean-style PersistenceManagerFactory instance is just a matter of configuration!

Configuration settings can either be read from a properties file, specified as "configLocation", or completely via this class. Properties specified as "jdoProperties" here will override any settings in a file.

This PersistenceManager handling strategy is most appropriate for applications which solely use JDO for data access. In this case, JdoTransactionManager is more convenient than setting up your JDO provider for JTA transactions (which might involve a JCA connector).

NOTE: This class is compatible with both JDO 1.0 and JDO 2.0, as far as possible. It uses reflection to adapt to the actual API present on the class path (concretely: for the getPersistenceManagerFactory method with either a Properties or a Map argument). Make sure that the JDO API jar on your class path matches the one that your JDO provider has been compiled against!

This class also implements the org.springframework.dao.support.PersistenceExceptionTranslator interface, as autodetected by Spring's org.springframework.dao.annotation.PersistenceExceptionTranslationPostProcessor , for AOP-based translation of native exceptions to Spring DataAccessExceptions. Hence, the presence of a LocalPersistenceManagerFactoryBean automatically enables a PersistenceExceptionTranslationPostProcessor to translate JDO exceptions.

Alternative: Configuration of a PersistenceManagerFactory provider bean

As alternative to the properties-driven approach that this FactoryBean offers (which is analogous to using the standard JDOHelper class with a Properties object that is populated with standard JDO properties), you can set up an instance of your PersistenceManagerFactory implementation class directly.

Like a DataSource, a PersistenceManagerFactory is encouraged to support bean-style configuration, which makes it very easy to set up as Spring-managed bean. The implementation class becomes the bean class; the remaining properties are applied as bean properties (starting with lower-case characters, in contrast to the corresponding JDO properties).

For example, in case of JPOX:

 <bean id="persistenceManagerFactory" class="org.jpox.PersistenceManagerFactoryImpl" destroy-method="close">
 <property name="connectionFactory" ref="dataSource"/>
 <property name="nontransactionalRead" value="true"/>
 </bean>
 

Note that such direct setup of a PersistenceManagerFactory implementation is the only way to pass an external connection factory (i.e. a JDBC DataSource) into a JDO PersistenceManagerFactory. With the standard properties-driven approach, you can only use an internal connection pool or a JNDI DataSource.

The close() method is standardized as of JDO 1.0.1; don't forget to specify it as "destroy-method" for any PersistenceManagerFactory instance. Note that this FactoryBean will automatically invoke close() for the PersistenceManagerFactory that it creates, without any special configuration.
author:
   Juergen Hoeller
since:
   03.06.2003
See Also:   JdoTemplate.setPersistenceManagerFactory
See Also:   JdoTransactionManager.setPersistenceManagerFactory
See Also:   org.springframework.jndi.JndiObjectFactoryBean
See Also:   javax.jdo.JDOHelper.getPersistenceManagerFactory
See Also:   javax.jdo.PersistenceManagerFactory.setConnectionFactory
See Also:   javax.jdo.PersistenceManagerFactory.close
See Also:   org.springframework.dao.annotation.PersistenceExceptionTranslationPostProcessor



Field Summary
final protected  Loglogger
    


Method Summary
public  voidafterPropertiesSet()
     Initialize the PersistenceManagerFactory for the given location.
public  voiddestroy()
     Close the PersistenceManagerFactory on bean factory shutdown.
public  PropertiesgetJdoProperties()
     Return the JDO properties, if any.
public  ObjectgetObject()
     Return the singleton PersistenceManagerFactory.
public  ClassgetObjectType()
    
public  booleanisSingleton()
    
protected  PersistenceManagerFactorynewPersistenceManagerFactory(Properties props)
     Subclasses can override this to perform custom initialization of the PersistenceManagerFactory instance, creating it via the given Properties that got prepared by this LocalPersistenceManagerFactoryBean.
public  voidsetConfigLocation(Resource configLocation)
     Set the location of the JDO properties config file, for example as classpath resource "classpath:kodo.properties".
public  voidsetJdoDialect(JdoDialect jdoDialect)
     Set the JDO dialect to use for the PersistenceExceptionTranslator functionality of this factory.
public  voidsetJdoProperties(Properties jdoProperties)
     Set JDO properties, such as"javax.jdo.PersistenceManagerFactoryClass".
public  DataAccessExceptiontranslateExceptionIfPossible(RuntimeException ex)
     Implementation of the PersistenceExceptionTranslator interface, as autodetected by Spring's PersistenceExceptionTranslationPostProcessor.

Converts the exception if it is a JDOException, preferably using a specified JdoDialect.


Field Detail
logger
final protected Log logger(Code)





Method Detail
afterPropertiesSet
public void afterPropertiesSet() throws IllegalArgumentException, IOException, JDOException(Code)
Initialize the PersistenceManagerFactory for the given location.
throws:
  IllegalArgumentException - in case of illegal property values
throws:
  IOException - if the properties could not be loaded from the given location
throws:
  JDOException - in case of JDO initialization errors



destroy
public void destroy()(Code)
Close the PersistenceManagerFactory on bean factory shutdown.



getJdoProperties
public Properties getJdoProperties()(Code)
Return the JDO properties, if any. Mainly available for configuration through property paths that specify individual keys.



getObject
public Object getObject()(Code)
Return the singleton PersistenceManagerFactory.



getObjectType
public Class getObjectType()(Code)



isSingleton
public boolean isSingleton()(Code)



newPersistenceManagerFactory
protected PersistenceManagerFactory newPersistenceManagerFactory(Properties props)(Code)
Subclasses can override this to perform custom initialization of the PersistenceManagerFactory instance, creating it via the given Properties that got prepared by this LocalPersistenceManagerFactoryBean.

The default implementation invokes JDOHelper's getPersistenceManagerFactory method. A custom implementation could prepare the instance in a specific way, or use a custom PersistenceManagerFactory implementation.

Implemented to work with either the JDO 1.0 getPersistenceManagerFactory(java.util.Properties) method or the JDO 2.0 getPersistenceManagerFactory(java.util.Map) method, detected through reflection.
Parameters:
  props - the merged Properties prepared by this LocalPersistenceManagerFactoryBean the PersistenceManagerFactory instance
See Also:   javax.jdo.JDOHelper.getPersistenceManagerFactory(java.util.Map)




setConfigLocation
public void setConfigLocation(Resource configLocation)(Code)
Set the location of the JDO properties config file, for example as classpath resource "classpath:kodo.properties".

Note: Can be omitted when all necessary properties are specified locally via this bean.




setJdoDialect
public void setJdoDialect(JdoDialect jdoDialect)(Code)
Set the JDO dialect to use for the PersistenceExceptionTranslator functionality of this factory.

Default is a DefaultJdoDialect based on the PersistenceManagerFactory's underlying DataSource, if any.
See Also:   JdoDialect.translateException
See Also:   LocalPersistenceManagerFactoryBean.translateExceptionIfPossible
See Also:   org.springframework.dao.support.PersistenceExceptionTranslator




setJdoProperties
public void setJdoProperties(Properties jdoProperties)(Code)
Set JDO properties, such as"javax.jdo.PersistenceManagerFactoryClass".

Can be used to override values in a JDO properties config file, or to specify all necessary properties locally.




translateExceptionIfPossible
public DataAccessException translateExceptionIfPossible(RuntimeException ex)(Code)
Implementation of the PersistenceExceptionTranslator interface, as autodetected by Spring's PersistenceExceptionTranslationPostProcessor.

Converts the exception if it is a JDOException, preferably using a specified JdoDialect. Else returns null to indicate an unknown exception.
See Also:   org.springframework.dao.annotation.PersistenceExceptionTranslationPostProcessor
See Also:   JdoDialect.translateException
See Also:   PersistenceManagerFactoryUtils.convertJdoAccessException




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.