org.apache.jdo.impl.fostore
Class FOStoreConnectionFactory

java.lang.Object
  extended by org.apache.jdo.impl.fostore.FOStoreConnectionFactory
All Implemented Interfaces:
java.io.Serializable

public class FOStoreConnectionFactory
extends java.lang.Object
implements java.io.Serializable

A connection factory for FOStore. Allows both same- and remote-address space connections. For the same address space-connections, the URL must not include the Host (Server) parameter. For remote address space connections, the URL's protocol is ignored.

This class is public so that clients can create instances of it with new.

Author:
Dave Bristor
See Also:
Serialized Form

Field Summary
protected static java.util.HashMap CFpropsAccessors
          This table maps from names to CFAccessors.
 
Constructor Summary
FOStoreConnectionFactory()
          First time a FOStoreConnectionFactory is created, initialize accessors which are used to store/save instances via JNDI.
 
Method Summary
 void closeDatabase()
          Close the database.
 org.apache.jdo.impl.fostore.FOStoreClientConnection getConnection()
          Provides a connection to the database using the configured userName, password, and url.
 org.apache.jdo.impl.fostore.FOStoreClientConnection getConnection(java.lang.String user, java.lang.String password)
          Provides a connection to the database using the given userName and password.
 boolean getCreate()
          Returns whether to create the database.
 java.lang.String getDriverName()
          Provides name of driver used for connections
 int getLoginTimeout()
          Returns the number of seconds to wait for a new connection to be established to the data source
 java.io.PrintWriter getLogWriter()
          Returns the LogWriter to which messages should be sent
 int getMaxPool()
          Returns maximum number of connections in the connection pool
 int getMinPool()
          Returns minimum number of connections in the connection pool
 int getMsInterval()
          Returns the amount of time, in milliseconds, between the connection manager's attempts to get a pooled connection.
 int getMsWait()
          Returns the number of milliseconds to wait for an available connection from the connection pool before throwing an exception
 FOStorePMF getPMF()
          Provides PersistenceManagerFactory for connections
 java.lang.String getURL()
          Returns connection URL
 java.lang.String getUserName()
          Returns database user name
protected static void initPropsAccessors()
           
 boolean isConfigured()
          Returns true if this connection factory has been configured with a URL.
 void setCreate(boolean create)
          Sets whether to create the database.
 void setCreate(java.lang.String create)
          Sets whether to create the database.
 void setDriverName(java.lang.String driverName)
          Sets name of the driver for connections
 void setFromProperties(java.util.Properties p)
          Configures a FOStoreConnectionFactory from the given Properties.
 void setLoginTimeout(int loginTimeout)
          Sets the number of seconds to wait for a new connection to be established to the data source
 void setLogWriter(java.io.PrintWriter logWriter)
          Sets the LogWriter to which messages should be sent
 void setMaxPool(int maxPool)
          Sets maximum number of connections in the connection pool
 void setMinPool(int minPool)
          Sets minimum number of connections in the connection pool
 void setMsInterval(int msInterval)
          Sets the amount of time, in milliseconds, between the connection manager's attempts to get a pooled connection.
 void setMsWait(int msWait)
          Sets the number of milliseconds to wait for an available connection from the connection pool before throwing an exception
 void setPassword(java.lang.String password)
          Sets database user password
 void setPMF(FOStorePMF pmf)
          Sets PersistenceManagerFactory for connections
 void setURL(java.lang.String url)
          Sets connection URL
 void setUserName(java.lang.String userName)
          Sets database user
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

CFpropsAccessors

protected static java.util.HashMap CFpropsAccessors
This table maps from names to CFAccessors. The names are the same as the persistence manager factory's property names, but with org.apache.jdo.FOStoreConnectionFactory.option prepended.

Constructor Detail

FOStoreConnectionFactory

public FOStoreConnectionFactory()
First time a FOStoreConnectionFactory is created, initialize accessors which are used to store/save instances via JNDI.

Method Detail

getConnection

public org.apache.jdo.impl.fostore.FOStoreClientConnection getConnection(java.lang.String user,
                                                                         java.lang.String password)
Provides a connection to the database using the given userName and password. The first time a connection is made, the factory can no longer be configured.

Returns:
A FOStoreClientConnection

getConnection

public org.apache.jdo.impl.fostore.FOStoreClientConnection getConnection()
Provides a connection to the database using the configured userName, password, and url. The first time a connection is made, the factory can no longer be configured.

Returns:
A FOStoreClientConnection

closeDatabase

public void closeDatabase()
Close the database. This really means close all connections that have been opened. Closing the last connection on a database actually closes the database, whether local or remote.


setDriverName

public void setDriverName(java.lang.String driverName)
Sets name of the driver for connections

Parameters:
driverName - driver name

getPMF

public FOStorePMF getPMF()
Provides PersistenceManagerFactory for connections

Returns:
PMF

setPMF

public void setPMF(FOStorePMF pmf)
Sets PersistenceManagerFactory for connections

Parameters:
pmf - PersistenceManagerFactory

getDriverName

public java.lang.String getDriverName()
Provides name of driver used for connections

Returns:
driver name

setURL

public void setURL(java.lang.String url)
Sets connection URL

Parameters:
url - connection URL

getURL

public java.lang.String getURL()
Returns connection URL

Returns:
connection URL

setUserName

public void setUserName(java.lang.String userName)
Sets database user

Parameters:
userName - database user

getUserName

public java.lang.String getUserName()
Returns database user name

Returns:
current database user name

setPassword

public void setPassword(java.lang.String password)
Sets database user password

Parameters:
password - database user password

setMinPool

public void setMinPool(int minPool)
Sets minimum number of connections in the connection pool

Parameters:
minPool - minimum number of connections

getMinPool

public int getMinPool()
Returns minimum number of connections in the connection pool

Returns:
connection minPool

setMaxPool

public void setMaxPool(int maxPool)
Sets maximum number of connections in the connection pool

Parameters:
maxPool - maximum number of connections

getMaxPool

public int getMaxPool()
Returns maximum number of connections in the connection pool

Returns:
connection maxPool

setMsInterval

public void setMsInterval(int msInterval)
Sets the amount of time, in milliseconds, between the connection manager's attempts to get a pooled connection.

Parameters:
msInterval - the interval between attempts to get a database connection, in milliseconds.

getMsInterval

public int getMsInterval()
Returns the amount of time, in milliseconds, between the connection manager's attempts to get a pooled connection.

Returns:
the length of the interval between tries in milliseconds

setMsWait

public void setMsWait(int msWait)
Sets the number of milliseconds to wait for an available connection from the connection pool before throwing an exception

Parameters:
msWait - number in milliseconds

getMsWait

public int getMsWait()
Returns the number of milliseconds to wait for an available connection from the connection pool before throwing an exception

Returns:
number in milliseconds

setLogWriter

public void setLogWriter(java.io.PrintWriter logWriter)
Sets the LogWriter to which messages should be sent

Parameters:
logWriter - logWriter

getLogWriter

public java.io.PrintWriter getLogWriter()
Returns the LogWriter to which messages should be sent

Returns:
logWriter

setLoginTimeout

public void setLoginTimeout(int loginTimeout)
Sets the number of seconds to wait for a new connection to be established to the data source

Parameters:
loginTimeout - wait time in seconds

getLoginTimeout

public int getLoginTimeout()
Returns the number of seconds to wait for a new connection to be established to the data source

Returns:
wait time in seconds

setCreate

public void setCreate(boolean create)
Sets whether to create the database.

Parameters:
create - whether to create the database.

setCreate

public void setCreate(java.lang.String create)
Sets whether to create the database.

Parameters:
create - whether to create the database.

getCreate

public boolean getCreate()
Returns whether to create the database.

Returns:
whether to create the database

initPropsAccessors

protected static void initPropsAccessors()

setFromProperties

public void setFromProperties(java.util.Properties p)
Configures a FOStoreConnectionFactory from the given Properties. For each Accessor in the given HashMap, gets the corresponding value from the Properties and sets that value in the PMF. This is public so that a test program can create a FOSToreConnectionFactory, and configure it from a Properties object.


isConfigured

public boolean isConfigured()
Returns true if this connection factory has been configured with a URL.


toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object


Copyright © 2005-2012 Apache Software Foundation. All Rights Reserved.