com.j256.ormlite.spring
Class DatabaseTypeFactory

java.lang.Object
  extended by com.j256.ormlite.spring.DatabaseTypeFactory

public class DatabaseTypeFactory
extends Object

Factory class suitable for Spring injections of the database type classes.

NOTE: If you are using the Spring type wiring in Java, initialize() should be called after all of the set methods. In Spring XML, init-method="initialize" should be used.

Here is an example of spring wiring. It expects the database URL to be in ${database.url}.

 <!-- our database type factory-bean -->
 <bean id="databaseTypeFactory" class="com.j256.ormlite.db.DatabaseTypeFactory" init-method="initialize">
        <property name="databaseUrl" value="${database.url}" />
 </bean>
 <bean id="databaseType" class="com.j256.ormlite.db.DatabaseType" factory-bean="databaseTypeFactory"
        factory-method="getDatabaseType" />
 <bean id="driverClassName" class="java.lang.String" factory-bean="databaseTypeFactory"
        factory-method="getDriverClassName" />
 

Author:
graywatson

Constructor Summary
DatabaseTypeFactory()
           
 
Method Summary
 DatabaseType getDatabaseType()
          Return the database type we got from the URL.
 String getDatabaseUrl()
          Return the wired in database URL.
 String getDriverClassName()
          Return the class name of the database driver that was determined from the URL.
 void initialize()
          If you are using the Spring type wiring, this should be called after all of the set methods.
 void setDatabaseUrl(String databaseUrl)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DatabaseTypeFactory

public DatabaseTypeFactory()
Method Detail

initialize

public void initialize()
                throws Exception
If you are using the Spring type wiring, this should be called after all of the set methods.

Throws:
Exception

getDriverClassName

public String getDriverClassName()
Return the class name of the database driver that was determined from the URL.


getDatabaseUrl

public String getDatabaseUrl()
Return the wired in database URL.


setDatabaseUrl

public void setDatabaseUrl(String databaseUrl)

getDatabaseType

public DatabaseType getDatabaseType()
Return the database type we got from the URL.



Copyright © 2010. All Rights Reserved.