Methods Summary |
---|
private void | assertConnectionWait()INTERNAL
Asserts that MsWait and MsInterval are properly configured
if ( connectionMsWait < 0 )
{
throw new JDOUserException(I18NHelper.getMessage(messages,
"connection.connectionmanager.mswaitvalue")); // NOI18N
}
else if ( connectionMsInterval < 0 ||
connectionMsInterval > connectionMsWait ||
(connectionMsWait > 0 && connectionMsInterval == 0) )
{
throw new JDOUserException(I18NHelper.getMessage(messages,
"connection.connectionmanager.msintervalvalue")); // NOI18N
}
|
private void | assertNotConfigured()INTERNAL
Asserts that change to the property is allowed
if ( pmFactory != null) {
throw new JDOUnsupportedOptionException(I18NHelper.getMessage(messages,
"persistencemanagerfactoryimpl.configured")); //NOI18N
}
|
private boolean | equalBooleanProperties(PersistenceManagerFactory pmf)Compares boolean setting on 2 PersistenceManagerFactory instances.
return (pmf.getOptimistic() == optimistic &&
pmf.getRetainValues() == retainValues &&
pmf.getNontransactionalRead() == nontransactionalRead &&
pmf.getIgnoreCache() == ignoreCache &&
pmf.getSupersedeDeletedInstance() == supersedeDeletedInstance &&
pmf.getRequireCopyObjectId() == requireCopyObjectId &&
pmf.getRequireTrackedSCO() == requireTrackedSCO
);
|
public boolean | equals(java.lang.Object obj)Determines whether obj is a PersistenceManagerFactoryImpl with the same configuration
if ((obj == null) || !(obj instanceof PersistenceManagerFactoryImpl)) {
return false;
}
PersistenceManagerFactoryImpl pmf = (PersistenceManagerFactoryImpl)obj;
if (pmf.providedConnectionFactory == this.providedConnectionFactory) {
if (pmf.providedConnectionFactory == SET_AS_CONNECTIONFACTORY) {
return (pmf.connectionFactory.equals(this.connectionFactory) &&
equalBooleanProperties(pmf));
} else if (pmf.providedConnectionFactory == SET_AS_DATASOURCE) {
return (pmf.dataSource.equals(this.dataSource) &&
equalBooleanProperties(pmf));
} else if (pmf.connectionFactoryName != null) {
return (pmf.connectionFactoryName.equals(this.connectionFactoryName) &&
equalBooleanProperties(pmf));
}
return (pmf.URL.equals(this.URL) && pmf.userName.equals(this.userName) &&
pmf.password.equals(this.password) &&
pmf.driverName.equals(this.driverName) &&
equalBooleanProperties(pmf));
}
return false;
|
public java.lang.String | getConnectionDriverName()Returns JDBC driver name
if (connectionFactory != null)
return connectionFactory.getDriverName();
return driverName;
|
public java.lang.Object | getConnectionFactory()Returns ConnectionFactory
if (dataSource != null)
return dataSource;
return connectionFactory;
|
public java.lang.String | getConnectionFactoryName()Returns ConnectionFactory name
return connectionFactoryName;
|
public java.io.PrintWriter | getConnectionLogWriter()Returns the LogWriter to which messages should be sent
return connectionLogWriter;
|
public int | getConnectionLoginTimeout()Returns the number of seconds to wait for a new connection to be
established to the data source
if (connectionFactory != null) {
return connectionFactory.getLoginTimeout();
/*
} else if (dataSource != null) {
return dataSource.getLoginTimeout();
*/
} else {
return connectionLoginTimeout;
}
|
public int | getConnectionMaxPool()Returns maximum number of connections in the connection pool
if (connectionFactory != null)
return connectionFactory.getMaxPool();
return connectionMaxPool;
|
public int | getConnectionMinPool()Returns minimum number of connections in the connection pool
if (connectionFactory != null)
return connectionFactory.getMinPool();
return connectionMinPool;
|
public int | getConnectionMsInterval()Returns the amount of time, in milliseconds, between the connection
manager's attempts to get a pooled connection.
if (connectionFactory != null)
return connectionFactory.getMsInterval();
return connectionMsInterval;
|
public int | getConnectionMsWait()Returns the number of milliseconds to wait for an available connection
from the connection pool before throwing an exception
if (connectionFactory != null)
return connectionFactory.getMsWait();
return connectionMsWait;
|
public int | getConnectionTransactionIsolation()Returns current transaction isolation level for connections of this PersistenceManagerFactory.
if (connectionFactory != null)
return connectionFactory.getTransactionIsolation();
return txIsolation;
|
public java.lang.String | getConnectionURL()Returns connection URL
if (connectionFactory != null)
return connectionFactory.getURL();
return URL;
|
public java.lang.String | getConnectionUserName()Returns database user name
if (connectionFactory != null)
return connectionFactory.getUserName();
return userName;
|
public java.lang.String | getIdentifier()Gets Identifier. An identifier is a string that user can use to identify
the PersistenceManagerFactory in a given environment. Identifier can be
particularly useful in an environment where multiple
PersistenceManagerFactories are initialized in a system.
return identifier;
|
public boolean | getIgnoreCache()Returns the boolean value for the flag that allows the user to request that queries
be optimized to return approximate results by ignoring changed values in the cache.
return ignoreCache;
|
public int | getMaxPool()Returns maximum number of PersistenceManager instances in the pool
return maxPool;
|
public int | getMinPool()Returns minimum number of PersistenceManager instances in the pool
return minPool;
|
public boolean | getNontransactionalRead()Returns the boolean value for the flag that allows non-transactional instances
to be managed in the cache.
return nontransactionalRead;
|
public boolean | getOptimistic()Returns the boolean value of the optimistic flag for all PersistenceManagers
return optimistic;
|
public PersistenceManager | getPersistenceManager()Creates new PersistenceManager without extra info
return getPersistenceManager(null, null);
|
public PersistenceManager | getPersistenceManager(java.lang.String username, java.lang.String passwd)Creates new PersistenceManager with specific
username and password. Used to call ConnectionFactory.getConnection(String, String)
synchronized (this) {
if (pmFactory == null) {
// Nothing there yet. Check and create
if (providedConnectionFactory == NOT_SET) {
if (connectionFactoryName == null) {
// Validate that MsWait/MsInterval are correct
assertConnectionWait();
// only PMFactory was configured
// Create a default ConnectionFactoryImpl and
// set all the parameters. With 1st connection
// which happens during configuration od SqlStore
// the actaul connectionManager will be created
connectionFactory = new ConnectionFactoryImpl();
connectionFactory.setURL(URL);
connectionFactory.setUserName(userName);
connectionFactory.setPassword(password);
connectionFactory.setDriverName(driverName);
connectionFactory.setMinPool(connectionMinPool);
connectionFactory.setMaxPool(connectionMaxPool);
// MsWait MUST be set BEFORE MsInterval
connectionFactory.setMsWait(this.connectionMsWait);
connectionFactory.setMsInterval(this.connectionMsInterval);
connectionFactory.setLogWriter(this.connectionLogWriter);
connectionFactory.setLoginTimeout(this.connectionLoginTimeout);
if (txIsolation > 0)
connectionFactory.setTransactionIsolation(txIsolation);
} else {
// Do JNDI lookup
try {
javax.naming.InitialContext ctx =
(javax.naming.InitialContext) Class.forName("javax.naming.InitialContext").newInstance(); //NOI18N
Object o = ctx.lookup(connectionFactoryName);
if (EJBHelper.isManaged() || (o instanceof DataSource))
dataSource = o;
else if (o instanceof ConnectionFactory)
connectionFactory = (ConnectionFactory) o;
else
throw new JDOUserException(I18NHelper.getMessage(
messages,
"persistencemanagerfactoryimpl.wrongtype")); //NOI18N
} catch (JDOException e) {
throw e; // rethrow it.
} catch (ClassNotFoundException e) {
throw new JDOUserException(I18NHelper.getMessage(messages,
"persistencemanagerfactoryimpl.initialcontext")); //NOI18N
} catch (Exception e) {
throw new JDOUserException(I18NHelper.getMessage(messages,
"persistencemanagerfactoryimpl.lookup"), e); //NOI18N
}
}
}
//If identifier is not yet set, set it to name of connection factory
if(getIdentifier() == null) {
setIdentifier(getConnectionFactoryName());
}
// create new
pmFactory = new SQLPersistenceManagerFactory(this);
// Check EJBHelper
pmFactory =
(SQLPersistenceManagerFactory)EJBHelper.replaceInternalPersistenceManagerFactory(pmFactory);
}
} // end synchronized (this)
// Should not be called
if (username != null && connectionFactory != null) {
throw new JDOUnsupportedOptionException(I18NHelper.getMessage(messages,
"persistencemanagerfactoryimpl.notsupported")); //NOI18N
}
return pmFactory.getPersistenceManager(username, passwd);
|
public java.util.Properties | getProperties()Returns non-operational properties to be available to the application via a Properties instance.
if (pmFactory != null)
{
return pmFactory.getProperties();
}
return RuntimeVersion.getVendorProperties(
"/com/sun/jdo/spi/persistence/support/sqlstore/sys.properties"); //NOI18N
|
public int | getQueryTimeout()Gets the number of seconds to wait for a query statement
to execute in the datastore associated with this PersistenceManagerFactory.
return queryTimeout;
|
public boolean | getRequireCopyObjectId()Returns the default value of the requireCopyObjectId flag
for this PersistenceManagerFactoryImpl. If set to false, the PersistenceManager
will not create a copy of an ObjectId for PersistenceManager.getObjectId(Object pc)
and PersistenceManager.getObjectById(Object oid) requests.
return requireCopyObjectId;
|
public boolean | getRequireTrackedSCO()Returns the boolean value of the requireTrackedSCO flag.
If set to false, by default the PersistenceManager will not create
tracked SCO instances for new persistent instances at commit with
retainValues set to true and while retrieving data from a datastore.
return requireTrackedSCO;
|
public boolean | getRetainValues()Returns the boolean value for the flag that will not cause the eviction of persistent
instances after transaction completion.
return retainValues;
|
public boolean | getSupersedeDeletedInstance()Returns the boolean value of the supersedeDeletedInstance flag
for all PersistenceManagers. If set to true, deleted instances are
allowed to be replaced with persistent-new instances with the equal
Object Id.
return supersedeDeletedInstance;
|
public int | getUpdateTimeout()Gets the number of seconds to wait for an update statement
to execute in the datastore associated with this PersistenceManagerFactory.
return updateTimeout;
|
public int | hashCode()Computes the hash code of this PersistenceManagerFactory.
if (providedConnectionFactory == SET_AS_CONNECTIONFACTORY) {
return connectionFactory.hashCode();
} else if (providedConnectionFactory == SET_AS_DATASOURCE) {
return dataSource.hashCode();
} else if (connectionFactoryName != null) {
return connectionFactoryName.hashCode();
}
return URL.hashCode() + userName.hashCode() + password.hashCode() + driverName.hashCode();
|
public void | setBooleanProperty(java.lang.String name, boolean value)Sets default value of a known boolean property.
// These if-else statements will be replaced by the JDO implementation...
if (name.equals("optimistic")) { // NOI18N
setOptimistic(value);
} else if (name.equals("retainValues")) { // NOI18N
setRetainValues(value);
} else if (name.equals("nontransactionalRead")) { // NOI18N
setNontransactionalRead(value);
} else if (name.equals("ignoreCache")) { // NOI18N
setIgnoreCache(value);
} else if (name.equals("supersedeDeletedInstance")) { // NOI18N
setSupersedeDeletedInstance(value);
} else if (name.equals("requireCopyObjectId")) { // NOI18N
setRequireCopyObjectId(value);
} else if (name.equals("requireTrackedSCO")) { // NOI18N
setRequireTrackedSCO(value);
} // else ignore it.
|
public void | setConnectionDriverName(java.lang.String driverName)Sets JDBC driver name
assertNotConfigured();
this.driverName = driverName;
|
public void | setConnectionFactory(java.lang.Object connectionFactory)Sets ConnectionFactory that can be one of two types:
ConnectionFactory or javax.sql.DataSource
assertNotConfigured();
if (connectionFactory == null) {
this.connectionFactory = null;
this.dataSource = null;
providedConnectionFactory = NOT_SET;
} else {
if (EJBHelper.isManaged() || (connectionFactory instanceof DataSource)) {
this.dataSource = connectionFactory;
providedConnectionFactory = SET_AS_DATASOURCE;
} else if (connectionFactory instanceof ConnectionFactory) {
this.connectionFactory = (ConnectionFactory)connectionFactory;
providedConnectionFactory = SET_AS_CONNECTIONFACTORY;
} else {
throw new JDOUserException(I18NHelper.getMessage( messages,
"persistencemanagerfactoryimpl.wrongtype")); //NOI18N
}
}
|
public void | setConnectionFactoryName(java.lang.String connectionFactoryName)Sets ConnectionFactory name
assertNotConfigured();
this.connectionFactoryName = connectionFactoryName;
|
public void | setConnectionLogWriter(java.io.PrintWriter pw)Sets the LogWriter to which messages should be sent
assertNotConfigured();
this.connectionLogWriter = pw;
|
public void | setConnectionLoginTimeout(int LoginTimeout)Sets the number of seconds to wait for a new connection to be
established to the data source
assertNotConfigured();
this.connectionLoginTimeout = LoginTimeout;
|
public void | setConnectionMaxPool(int MaxPool)Sets maximum number of connections in the connection pool
assertNotConfigured();
this.connectionMaxPool = MaxPool;
|
public void | setConnectionMinPool(int MinPool)Sets minimum number of connections in the connection pool
assertNotConfigured();
this.connectionMinPool = MinPool;
|
public void | setConnectionMsInterval(int MsInterval)Sets the amount of time, in milliseconds, between the connection
manager's attempts to get a pooled connection.
assertNotConfigured();
this.connectionMsInterval = MsInterval;
|
public void | setConnectionMsWait(int MsWait)Sets the number of milliseconds to wait for an available connection
from the connection pool before throwing an exception
assertNotConfigured();
this.connectionMsWait = MsWait;
|
public void | setConnectionPassword(java.lang.String password)Sets database user password
assertNotConfigured();
this.password = password;
|
public void | setConnectionTransactionIsolation(int level)Sets transaction isolation level for all connections of this PersistenceManagerFactory.
All validation is done by java.sql.Connection itself, so e.g. while Oracle
will not allow to set solation level to TRANSACTION_REPEATABLE_READ, this method
does not have any explicit restrictions
assertNotConfigured();
txIsolation = level;
|
public void | setConnectionURL(java.lang.String URL)Sets JDBC connection URL
assertNotConfigured();
this.URL = URL;
|
public void | setConnectionUserName(java.lang.String userName)Sets database user
assertNotConfigured();
this.userName = userName;
|
public void | setIdentifier(java.lang.String identifier)Sets Identifier. An identifier is a string that user can use to identify
the PersistenceManagerFactory in a given environment. Identifier can be
particularly useful in an environment where multiple
PersistenceManagerFactories are initialized in a system.
assertNotConfigured();
this.identifier = identifier;
|
public void | setIgnoreCache(java.lang.String flag)Sets the IgnoreCache flag for all PersistenceManagers
setIgnoreCache(Boolean.parseBoolean(flag));
|
public void | setIgnoreCache(boolean flag)Sets the flag that allows the user to request that queries be optimized to return
approximate results by ignoring changed values in the cache.
assertNotConfigured();
throw new JDOUnsupportedOptionException(I18NHelper.getMessage(messages,
"persistencemanagerfactoryimpl.notsupported")); //NOI18N
//ignoreCache = flag;
|
public void | setMaxPool(int MaxPool)Sets maximum number of PersistenceManager instances in the pool
assertNotConfigured();
this.maxPool = MaxPool;
|
public void | setMinPool(int MinPool)Sets minimum number of PersistenceManager instances in the pool
assertNotConfigured();
this.minPool = MinPool;
|
public void | setNontransactionalRead(java.lang.String flag)Sets the NontransactionalRead flag for all PersistenceManagers
setNontransactionalRead(Boolean.parseBoolean(flag));
|
public void | setNontransactionalRead(boolean flag)Sets the flag that allows non-transactional instances to be managed in the cache.
assertNotConfigured();
nontransactionalRead = flag;
// Adjust depending flags
if (flag == false)
{
retainValues = flag;
optimistic = flag;
}
|
public void | setOptimistic(java.lang.String flag)Sets the optimistic flag for all PersistenceManagers
setOptimistic(Boolean.parseBoolean(flag));
|
public void | setOptimistic(boolean flag)Sets the optimistic flag for all PersistenceManagers
assertNotConfigured();
optimistic = flag;
// Adjust depending flags
if (flag)
nontransactionalRead = flag;
|
public void | setQueryTimeout(java.lang.String timeout)Sets the queryTimeout for all PersistenceManagers
setQueryTimeout(Integer.parseInt(timeout));
|
public void | setQueryTimeout(int timeout)Sets the number of seconds to wait for a query statement
to execute in the datastore associated with this PersistenceManagerFactory.
assertNotConfigured();
this.queryTimeout = timeout;
|
public void | setRequireCopyObjectId(boolean flag)Sets the default value of the requireCopyObjectId flag.
If set to false, by default a PersistenceManager will not create a copy of
an ObjectId for PersistenceManager.getObjectId(Object pc)
and PersistenceManager.getObjectById(Object oid) requests.
assertNotConfigured();
requireCopyObjectId = flag;
|
public void | setRequireTrackedSCO(boolean flag)Sets the requireTrackedSCO flag for this PersistenceManagerFactory.
If set to false, by default the PersistenceManager will not create tracked
SCO instances for new persistent instances at commit with retainValues set to true
and while retrieving data from a datastore.
assertNotConfigured();
requireTrackedSCO = flag;
|
public void | setRetainValues(java.lang.String flag)Sets the RetainValues flag for all PersistenceManagers
setRetainValues(Boolean.parseBoolean(flag));
|
public void | setRetainValues(boolean flag)Sets flag that will not cause the eviction of persistent instances after transaction completion.
assertNotConfigured();
retainValues = flag;
// Adjust depending flags
if (flag) {
nontransactionalRead = flag;
}
|
public void | setSupersedeDeletedInstance(boolean flag)Sets the supersedeDeletedInstance flag for all PersistenceManagers.
assertNotConfigured();
supersedeDeletedInstance = flag;
|
public void | setUpdateTimeout(java.lang.String timeout)Sets the updateTimeout for all PersistenceManagers
setUpdateTimeout(Integer.parseInt(timeout));
|
public void | setUpdateTimeout(int timeout)Sets the number of seconds to wait for an update statement
to execute in the datastore associated with this PersistenceManagerFactory.
assertNotConfigured();
this.updateTimeout = timeout;
|