/**
* perseus/connector: this is an implementation of some JCA-related technologies
* (resource adapters and managers) for the ObjectWeb consortium.
* Copyright (C) 2001-2004 France Telecom R&D
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* Contact: speedo@objectweb.org
*
*/
package org.objectweb.speedo.jca.jdo;
import org.objectweb.util.monolog.api.BasicLevel;
import org.objectweb.util.monolog.api.Logger;
import org.objectweb.speedo.api.Debug;
import org.objectweb.speedo.api.SpeedoProperties;
import org.objectweb.speedo.jca.SpeedoManagedConnection;
import org.objectweb.speedo.jca.SpeedoConnection;
import org.objectweb.speedo.pm.jdo.api.JDOPOManagerItf;
import java.util.Collection;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.resource.ResourceException;
import javax.resource.cci.Connection;
import javax.resource.cci.ConnectionMetaData;
import javax.resource.cci.Interaction;
import javax.resource.cci.LocalTransaction;
import javax.resource.cci.ResultSetInfo;
import javax.transaction.Synchronization;
import javax.transaction.UserTransaction;
import javax.jdo.datastore.JDOConnection;
import javax.jdo.datastore.Sequence;
import javax.jdo.listener.InstanceLifecycleListener;
import javax.jdo.FetchPlan;
import javax.jdo.PersistenceManager;
import javax.jdo.JDOException;
import javax.jdo.Transaction;
import javax.jdo.Query;
import javax.jdo.Extent;
import javax.jdo.PersistenceManagerFactory;
/**
* @author P. Dechamboux
*/
public class JDOConnectionImpl extends SpeedoConnection
implements Connection, ConnectionMetaData, PersistenceManager, Transaction {
/**
* The logger into which traces about JDOConnectionImpl are produced.
*/
private Logger logger;
/**
* The name of this storage sub-system.
*/
private final static String EISPRODUCTNAME = "JDO Connector";
/**
* The ConnectionFactory that have requested the allocation of this
* Connection.
*/
private JDOConnectionFactory connectionFactory;
/**
* The LocalTransaction allocated by this connection if any.
*/
private LocalTransaction localTransaction = null;
/**
* The UserTransaction of JTA
*/
private UserTransaction userTransaction = null;
/**
* Constructs a JDOConnectionImpl.
* @param el The logger into which to produce Connection-related traces.
* @param fcf The ConnectionFactory that has requested the Connection
* creation.
*/
JDOConnectionImpl(Logger el, JDOConnectionFactory fcf) {
logger = el;
connectionFactory = fcf;
}
/**
* Initializes a Connection to be linked with a ManagedConnection.
* @param mc The ManagedConnection to be linked to.
*/
void initialize(SpeedoManagedConnection mc) {
managedConnection = mc;
}
// IMPLEMENTATION OF METHODS FROM THE (cci)Connection INTERFACE
/**
* No support for Interaction.
*/
public Interaction createInteraction() throws ResourceException {
throw new ResourceException("JDO Connector: no support for Interaction.");
}
public LocalTransaction getLocalTransaction() throws ResourceException {
if (managedConnection == null) {
throw new ResourceException("JDO Connector: cannot get a LocalTransaction with no associated ManagedConnection.");
}
localTransaction = managedConnection;
return managedConnection;
}
/**
* The JDOConnectionImpl manages the metadata on its own.
*/
public ConnectionMetaData getMetaData() throws ResourceException {
return this;
}
/**
* No support for ResultSet.
*/
public ResultSetInfo getResultSetInfo() throws ResourceException {
throw new ResourceException("JDO Connector: no support for ResultSet.");
}
/**
* Closes this Connection. Dissociates from the ManagedConnection to which
* it is linked.
*/
public void close() {
if (Debug.ON)
logger.log(BasicLevel.DEBUG, "Closes Connection: " + this);
if (managedConnection == null) {
// The connection is already closed
return;
}
if (localTransaction != null) {
if (!managedConnection.localTransactionTerminated()) {
throw new JDOException("JDO Connector: cannot close connection while a LocalTransaction is still active.");
}
}
try {
managedConnection.dissociateConnection(this);
} catch (ResourceException e) {
throw new JDOException("JDO Connector: problem while closing a connection.", e);
} finally {
localTransaction = null;
managedConnection = null;
}
}
/**
* Sets the connection to the relevant auto-commit mode.
*/
public void setAutoCommit(boolean b) throws ResourceException {
throw new ResourceException("No sense for a JDO connector.");
}
/**
* Gets the connection auto-commit mode.
*/
public boolean getAutoCommit() throws ResourceException {
throw new ResourceException("No sense for a JDO connector.");
}
// IMPLEMENTATION OF METHODS FROM THE (cci)ConnectionMetaData INTERFACE
/**
* Returns the name of this storage sub-system.
* @return The storage sub-system name.
*/
public String getEISProductName() throws ResourceException {
return EISPRODUCTNAME;
}
/**
* This is the same version number as the adapter.
* @return The storage sub-system version.
*/
public String getEISProductVersion() throws ResourceException {
return connectionFactory.getAdapterVersion();
}
/**
* No support for user name.
* @return The empty string.
*/
public String getUserName() throws ResourceException {
return "";
}
// IMPLEMENTATION OF METHODS FROM THE PersistenceManager INTERFACE
// Delegates execution to the associated ManagedConnection.
public boolean isClosed() {
return managedConnection == null;
}
public Transaction currentTransaction() {
if (managedConnection == null) {
throw new JDOException(NO_ACTIVE_CONNECTION);
}
//if transaction mode is not normal, return this
if (connectionFactory.getTransactionMode() != SpeedoProperties.TRANSACTION_BMODE_NORMAL) {
if(connectionFactory.getTransactionMode() == SpeedoProperties.TRANSACTION_BMODE_UT) {
try {
if (userTransaction == null) {
Context ic = new InitialContext();
userTransaction = (UserTransaction) ic.lookup("javax.transaction.UserTransaction");
}
logger.log(BasicLevel.DEBUG, "UserTransaction is used.");
} catch (Exception e) {
throw new JDOException("Error with JTA UserTransaction", e);
}
}
return this;
} else {
return ((JDOPOManagerItf) managedConnection.getPOManager()).currentTransaction();
}
}
public void evict(Object o) {
if (managedConnection == null) {
throw new JDOException(NO_ACTIVE_CONNECTION);
}
((JDOPOManagerItf) managedConnection.getPOManager()).evict(o);
}
public void evictAll(Object[] objects) {
if (managedConnection == null) {
throw new JDOException(NO_ACTIVE_CONNECTION);
}
((JDOPOManagerItf) managedConnection.getPOManager()).evictAll(objects);
}
public void evictAll(Collection collection) {
if (managedConnection == null) {
throw new JDOException(NO_ACTIVE_CONNECTION);
}
((JDOPOManagerItf) managedConnection.getPOManager()).evictAll(collection);
}
public void evictAll() {
if (managedConnection == null) {
throw new JDOException(NO_ACTIVE_CONNECTION);
}
((JDOPOManagerItf) managedConnection.getPOManager()).evictAll();
}
public void refresh(Object o) {
if (managedConnection == null) {
throw new JDOException(NO_ACTIVE_CONNECTION);
}
((JDOPOManagerItf) managedConnection.getPOManager()).refresh(o);
}
public void refreshAll(Object[] objects) {
if (managedConnection == null) {
throw new JDOException(NO_ACTIVE_CONNECTION);
}
((JDOPOManagerItf) managedConnection.getPOManager()).refreshAll(objects);
}
public void refreshAll(Collection collection) {
if (managedConnection == null) {
throw new JDOException(NO_ACTIVE_CONNECTION);
}
((JDOPOManagerItf) managedConnection.getPOManager()).refreshAll(collection);
}
public void refreshAll() {
if (managedConnection == null) {
throw new JDOException(NO_ACTIVE_CONNECTION);
}
((JDOPOManagerItf) managedConnection.getPOManager()).refreshAll();
}
public Query newQuery() {
if (managedConnection == null) {
throw new JDOException(NO_ACTIVE_CONNECTION);
}
return ((JDOPOManagerItf) managedConnection.getPOManager()).newQuery();
}
public Query newQuery(String q) {
if (managedConnection == null) {
throw new JDOException(NO_ACTIVE_CONNECTION);
}
return ((JDOPOManagerItf) managedConnection.getPOManager()).newQuery(q);
}
public Query newQuery(Object o) {
if (managedConnection == null) {
throw new JDOException(NO_ACTIVE_CONNECTION);
}
return ((JDOPOManagerItf) managedConnection.getPOManager()).newQuery(o);
}
public Query newQuery(String s, Object o) {
if (managedConnection == null) {
throw new JDOException(NO_ACTIVE_CONNECTION);
}
return ((JDOPOManagerItf) managedConnection.getPOManager()).newQuery(s, o);
}
public Query newQuery(Class aClass) {
if (managedConnection == null) {
throw new JDOException(NO_ACTIVE_CONNECTION);
}
return ((JDOPOManagerItf) managedConnection.getPOManager()).newQuery(aClass);
}
public Query newQuery(Extent extent) {
if (managedConnection == null) {
throw new JDOException(NO_ACTIVE_CONNECTION);
}
return ((JDOPOManagerItf) managedConnection.getPOManager()).newQuery(extent);
}
public Query newQuery(Class aClass, Collection collection) {
if (managedConnection == null) {
throw new JDOException(NO_ACTIVE_CONNECTION);
}
return ((JDOPOManagerItf) managedConnection.getPOManager()).newQuery(aClass, collection);
}
public Query newQuery(Class aClass, String s) {
if (managedConnection == null) {
throw new JDOException(NO_ACTIVE_CONNECTION);
}
return ((JDOPOManagerItf) managedConnection.getPOManager()).newQuery(aClass, s);
}
public Query newQuery(Class aClass, Collection collection, String s) {
if (managedConnection == null) {
throw new JDOException(NO_ACTIVE_CONNECTION);
}
return ((JDOPOManagerItf) managedConnection.getPOManager()).newQuery(aClass, collection, s);
}
public Query newQuery(Extent extent, String s) {
if (managedConnection == null) {
throw new JDOException(NO_ACTIVE_CONNECTION);
}
return ((JDOPOManagerItf) managedConnection.getPOManager()).newQuery(extent, s);
}
public Extent getExtent(Class aClass, boolean b) {
if (managedConnection == null) {
throw new JDOException(NO_ACTIVE_CONNECTION);
}
return ((JDOPOManagerItf) managedConnection.getPOManager()).getExtent(aClass, b);
}
public Object getObjectById(Object o, boolean b) {
if (managedConnection == null) {
throw new JDOException(NO_ACTIVE_CONNECTION);
}
return ((JDOPOManagerItf) managedConnection.getPOManager()).getObjectById(o, b);
}
public Collection getObjectsById(Collection arg0, boolean arg1) {
if (managedConnection == null) {
throw new JDOException(NO_ACTIVE_CONNECTION);
}
return ((JDOPOManagerItf) managedConnection.getPOManager()).getObjectsById(arg0, arg1);
}
public Collection getObjectsById(Collection arg0) {
if (managedConnection == null) {
throw new JDOException(NO_ACTIVE_CONNECTION);
}
return ((JDOPOManagerItf) managedConnection.getPOManager()).getObjectsById(arg0);
}
public Object[] getObjectsById(Object[] arg0, boolean arg1) {
if (managedConnection == null) {
throw new JDOException(NO_ACTIVE_CONNECTION);
}
return ((JDOPOManagerItf) managedConnection.getPOManager()).getObjectsById(arg0, arg1);
}
public Object[] getObjectsById(Object[] arg0) {
if (managedConnection == null) {
throw new JDOException(NO_ACTIVE_CONNECTION);
}
return ((JDOPOManagerItf) managedConnection.getPOManager()).getObjectsById(arg0);
}
public Sequence getSequence(String arg0) {
if (managedConnection == null) {
throw new JDOException(NO_ACTIVE_CONNECTION);
}
return ((JDOPOManagerItf) managedConnection.getPOManager()).getSequence(arg0);
}
public Object getUserObject(Object arg0) {
if (managedConnection == null) {
throw new JDOException(NO_ACTIVE_CONNECTION);
}
return ((JDOPOManagerItf) managedConnection.getPOManager()).getUserObject(arg0);
}
public Object newInstance(Class arg0) {
if (managedConnection == null) {
throw new JDOException(NO_ACTIVE_CONNECTION);
}
return ((JDOPOManagerItf) managedConnection.getPOManager()).newInstance(arg0);
}
public Object putUserObject(Object arg0, Object arg1) {
if (managedConnection == null) {
throw new JDOException(NO_ACTIVE_CONNECTION);
}
return ((JDOPOManagerItf) managedConnection.getPOManager()).putUserObject(arg0, arg1);
}
public Object removeUserObject(Object arg0) {
if (managedConnection == null) {
throw new JDOException(NO_ACTIVE_CONNECTION);
}
return ((JDOPOManagerItf) managedConnection.getPOManager()).removeUserObject(arg0);
}
public Object getObjectId(Object o) {
if (managedConnection == null) {
throw new JDOException(NO_ACTIVE_CONNECTION);
}
return ((JDOPOManagerItf) managedConnection.getPOManager()).getObjectId(o);
}
public Object getObjectById(Class clazz, Object o) {
if (managedConnection == null) {
throw new JDOException(NO_ACTIVE_CONNECTION);
}
return ((JDOPOManagerItf) managedConnection.getPOManager()).getObjectById(clazz, o);
}
public Object getObjectById(Object o) {
if (managedConnection == null) {
throw new JDOException(NO_ACTIVE_CONNECTION);
}
return ((JDOPOManagerItf) managedConnection.getPOManager()).getObjectById(o);
}
public Object getTransactionalObjectId(Object o) {
if (managedConnection == null) {
throw new JDOException(NO_ACTIVE_CONNECTION);
}
return ((JDOPOManagerItf) managedConnection.getPOManager()).getTransactionalObjectId(o);
}
public Object newObjectIdInstance(Class aClass, Object s) {
if (managedConnection == null) {
throw new JDOException(NO_ACTIVE_CONNECTION);
}
return ((JDOPOManagerItf) managedConnection.getPOManager()).newObjectIdInstance(aClass, s);
}
public Object makePersistent(Object o) {
if (managedConnection == null) {
throw new JDOException(NO_ACTIVE_CONNECTION);
}
return ((JDOPOManagerItf) managedConnection.getPOManager()).makePersistent(o);
}
public Object[] makePersistentAll(Object[] objects) {
if (managedConnection == null) {
throw new JDOException(NO_ACTIVE_CONNECTION);
}
return ((JDOPOManagerItf) managedConnection.getPOManager()).makePersistentAll(objects);
}
public Collection makePersistentAll(Collection collection) {
if (managedConnection == null) {
throw new JDOException(NO_ACTIVE_CONNECTION);
}
return ((JDOPOManagerItf) managedConnection.getPOManager()).makePersistentAll(collection);
}
public void deletePersistent(Object o) {
if (managedConnection == null) {
throw new JDOException(NO_ACTIVE_CONNECTION);
}
((JDOPOManagerItf) managedConnection.getPOManager()).deletePersistent(o);
}
public void deletePersistentAll(Object[] objects) {
if (managedConnection == null) {
throw new JDOException(NO_ACTIVE_CONNECTION);
}
((JDOPOManagerItf) managedConnection.getPOManager()).deletePersistentAll(objects);
}
public void deletePersistentAll(Collection collection) {
if (managedConnection == null) {
throw new JDOException(NO_ACTIVE_CONNECTION);
}
((JDOPOManagerItf) managedConnection.getPOManager()).deletePersistentAll(collection);
}
public void makeTransient(Object o) {
if (managedConnection == null) {
throw new JDOException(NO_ACTIVE_CONNECTION);
}
((JDOPOManagerItf) managedConnection.getPOManager()).makeTransient(o);
}
public void makeTransientAll(Object[] objects) {
if (managedConnection == null) {
throw new JDOException(NO_ACTIVE_CONNECTION);
}
((JDOPOManagerItf) managedConnection.getPOManager()).makeTransientAll(objects);
}
public void makeTransientAll(Collection collection) {
if (managedConnection == null) {
throw new JDOException(NO_ACTIVE_CONNECTION);
}
((JDOPOManagerItf) managedConnection.getPOManager()).makeTransientAll(collection);
}
public void makeTransactional(Object o) {
if (managedConnection == null) {
throw new JDOException(NO_ACTIVE_CONNECTION);
}
((JDOPOManagerItf) managedConnection.getPOManager()).makeTransactional(o);
}
public void makeTransactionalAll(Object[] objects) {
if (managedConnection == null) {
throw new JDOException(NO_ACTIVE_CONNECTION);
}
((JDOPOManagerItf) managedConnection.getPOManager()).makeTransactionalAll(objects);
}
public void makeTransactionalAll(Collection collection) {
if (managedConnection == null) {
throw new JDOException(NO_ACTIVE_CONNECTION);
}
((JDOPOManagerItf) managedConnection.getPOManager()).makeTransactionalAll(collection);
}
public void makeNontransactional(Object o) {
if (managedConnection == null) {
throw new JDOException(NO_ACTIVE_CONNECTION);
}
((JDOPOManagerItf) managedConnection.getPOManager()).makeNontransactional(o);
}
public void makeNontransactionalAll(Object[] objects) {
if (managedConnection == null) {
throw new JDOException(NO_ACTIVE_CONNECTION);
}
makeNontransactionalAll(objects);
}
public void makeNontransactionalAll(Collection collection) {
if (managedConnection == null) {
throw new JDOException(NO_ACTIVE_CONNECTION);
}
((JDOPOManagerItf) managedConnection.getPOManager()).makeNontransactionalAll(collection);
}
public void retrieve(Object o) {
if (managedConnection == null) {
throw new JDOException(NO_ACTIVE_CONNECTION);
}
((JDOPOManagerItf) managedConnection.getPOManager()).retrieve(o);
}
public void retrieveAll(Collection collection) {
if (managedConnection == null) {
throw new JDOException(NO_ACTIVE_CONNECTION);
}
((JDOPOManagerItf) managedConnection.getPOManager()).retrieveAll(collection);
}
public void retrieveAll(Object[] objects) {
if (managedConnection == null) {
throw new JDOException(NO_ACTIVE_CONNECTION);
}
((JDOPOManagerItf) managedConnection.getPOManager()).retrieveAll(objects);
}
public void retrieveAll(Collection collection, boolean b) {
if (managedConnection == null) {
throw new JDOException(NO_ACTIVE_CONNECTION);
}
((JDOPOManagerItf) managedConnection.getPOManager()).retrieveAll(collection, b);
}
public void retrieveAll(Object[] objects, boolean b) {
if (managedConnection == null) {
throw new JDOException(NO_ACTIVE_CONNECTION);
}
((JDOPOManagerItf) managedConnection.getPOManager()).retrieveAll(objects, b);
}
public void setUserObject(Object o) {
if (managedConnection == null) {
throw new JDOException(NO_ACTIVE_CONNECTION);
}
((JDOPOManagerItf) managedConnection.getPOManager()).setUserObject(o);
}
public Object getUserObject() {
if (managedConnection == null) {
throw new JDOException(NO_ACTIVE_CONNECTION);
}
return ((JDOPOManagerItf) managedConnection.getPOManager()).getUserObject();
}
public PersistenceManagerFactory getPersistenceManagerFactory() {
if (managedConnection == null) {
throw new JDOException(NO_ACTIVE_CONNECTION);
}
return ((JDOPOManagerItf) managedConnection.getPOManager()).getPersistenceManagerFactory();
}
public Class getObjectIdClass(Class aClass) {
if (managedConnection == null) {
throw new JDOException(NO_ACTIVE_CONNECTION);
}
return ((JDOPOManagerItf) managedConnection.getPOManager()).getObjectIdClass(aClass);
}
public void setMultithreaded(boolean b) {
if (managedConnection == null) {
throw new JDOException(NO_ACTIVE_CONNECTION);
}
((JDOPOManagerItf) managedConnection.getPOManager()).setMultithreaded(b);
}
public boolean getMultithreaded() {
if (managedConnection == null) {
throw new JDOException(NO_ACTIVE_CONNECTION);
}
return ((JDOPOManagerItf) managedConnection.getPOManager()).getMultithreaded();
}
public void setIgnoreCache(boolean b) {
if (managedConnection == null) {
throw new JDOException(NO_ACTIVE_CONNECTION);
}
((JDOPOManagerItf) managedConnection.getPOManager()).setIgnoreCache(b);
}
public boolean getIgnoreCache() {
if (managedConnection == null) {
throw new JDOException(NO_ACTIVE_CONNECTION);
}
return ((JDOPOManagerItf) managedConnection.getPOManager()).getIgnoreCache();
}
public void addInstanceLifecycleListener(InstanceLifecycleListener arg0, Class[] arg1) {
if (managedConnection == null) {
throw new JDOException(NO_ACTIVE_CONNECTION);
}
((JDOPOManagerItf) managedConnection.getPOManager()).addInstanceLifecycleListener(arg0, arg1);
}
public Object attachCopy(Object arg0, boolean arg1) {
if (managedConnection == null) {
throw new JDOException(NO_ACTIVE_CONNECTION);
}
return ((JDOPOManagerItf) managedConnection.getPOManager()).makePersistent(arg0);
}
public Collection attachCopyAll(Collection arg0, boolean arg1) {
if (managedConnection == null) {
throw new JDOException(NO_ACTIVE_CONNECTION);
}
return ((JDOPOManagerItf) managedConnection.getPOManager()).makePersistentAll(arg0);
}
public Object[] attachCopyAll(Object[] arg0, boolean arg1) {
if (managedConnection == null) {
throw new JDOException(NO_ACTIVE_CONNECTION);
}
return ((JDOPOManagerItf) managedConnection.getPOManager()).makePersistentAll(arg0);
}
public Object detachCopy(Object arg0) {
if (managedConnection == null) {
throw new JDOException(NO_ACTIVE_CONNECTION);
}
return ((JDOPOManagerItf) managedConnection.getPOManager()).detachCopy(arg0);
}
public Collection detachCopyAll(Collection arg0) {
if (managedConnection == null) {
throw new JDOException(NO_ACTIVE_CONNECTION);
}
return ((JDOPOManagerItf) managedConnection.getPOManager()).detachCopyAll(arg0);
}
public Object[] detachCopyAll(Object[] arg0) {
if (managedConnection == null) {
throw new JDOException(NO_ACTIVE_CONNECTION);
}
return ((JDOPOManagerItf) managedConnection.getPOManager()).detachCopyAll(arg0);
}
public void flush() {
if (managedConnection == null) {
throw new JDOException(NO_ACTIVE_CONNECTION);
}
((JDOPOManagerItf) managedConnection.getPOManager()).flush();
}
public void checkConsistency() {
if (managedConnection == null) {
throw new JDOException(NO_ACTIVE_CONNECTION);
}
((JDOPOManagerItf) managedConnection.getPOManager()).checkConsistency();
}
public JDOConnection getDataStoreConnection() {
if (managedConnection == null) {
throw new JDOException(NO_ACTIVE_CONNECTION);
}
return ((JDOPOManagerItf) managedConnection.getPOManager()).getDataStoreConnection();
}
public Extent getExtent(Class arg0) {
if (managedConnection == null) {
throw new JDOException(NO_ACTIVE_CONNECTION);
}
return ((JDOPOManagerItf) managedConnection.getPOManager()).getExtent(arg0);
}
public FetchPlan getFetchPlan() {
if (managedConnection == null) {
throw new JDOException(NO_ACTIVE_CONNECTION);
}
return ((JDOPOManagerItf) managedConnection.getPOManager()).getFetchPlan();
}
public Query newNamedQuery(Class arg0, String arg1) {
if (managedConnection == null) {
throw new JDOException(NO_ACTIVE_CONNECTION);
}
return ((JDOPOManagerItf) managedConnection.getPOManager()).newNamedQuery(arg0, arg1);
}
public void refreshAll(JDOException arg0) {
if (managedConnection == null) {
throw new JDOException(NO_ACTIVE_CONNECTION);
}
((JDOPOManagerItf) managedConnection.getPOManager()).refreshAll(arg0);
}
public void removeInstanceLifecycleListener(InstanceLifecycleListener arg0) {
if (managedConnection == null) {
throw new JDOException(NO_ACTIVE_CONNECTION);
}
((JDOPOManagerItf) managedConnection.getPOManager()).removeInstanceLifecycleListener(arg0);
}
//
// IMPLEMENTATION OF JDO.TRANSACTION INTERFACE
//
public void begin() {
if (connectionFactory.getTransactionMode() == SpeedoProperties.TRANSACTION_BMODE_UT) {
try {
userTransaction.begin();
} catch(Exception e) {
throw new JDOException("Error with JTA UserTransaction.begin().", e);
}
} else {
//do nothing
logger.log(BasicLevel.INFO, "Nothing is done on begin. The property ignoreJDOTransaction is activated.");
}
}
public void commit() {
if (connectionFactory.getTransactionMode() == SpeedoProperties.TRANSACTION_BMODE_UT) {
try {
userTransaction.commit();
logger.log(BasicLevel.DEBUG, "UserTransaction commit.");
} catch(Exception e) {
throw new JDOException("Error with JTA UserTransaction.commit().", e);
}
} else {
// do nothing
logger.log(BasicLevel.INFO, "Nothing is done on commit. The property ignoreJDOTransaction is activated.");
}
}
public void rollback() {
if (connectionFactory.getTransactionMode() == SpeedoProperties.TRANSACTION_BMODE_UT) {
try {
userTransaction.rollback();
} catch(Exception e) {
throw new JDOException("Error with JTA UserTransaction.rollback().", e);
}
} else {
// do nothing
logger.log(BasicLevel.INFO, "Nothing is done on rollback. The property ignoreJDOTransaction is activated.");
}
}
public boolean isActive() {
// delegate
if (managedConnection == null) {
throw new JDOException(NO_ACTIVE_CONNECTION);
}
return ((JDOPOManagerItf) managedConnection.getPOManager()).currentTransaction().isActive();
}
public boolean getRollbackOnly() {
//delegate
if (managedConnection == null) {
throw new JDOException(NO_ACTIVE_CONNECTION);
}
return ((JDOPOManagerItf) managedConnection.getPOManager()).currentTransaction().getRollbackOnly();
}
public void setRollbackOnly() {
//delegate
if (managedConnection == null) {
throw new JDOException(NO_ACTIVE_CONNECTION);
}
((JDOPOManagerItf) managedConnection.getPOManager()).currentTransaction().setRollbackOnly();
}
public void setNontransactionalRead(boolean nontransactionalRead) {
//delegate
if (managedConnection == null) {
throw new JDOException(NO_ACTIVE_CONNECTION);
}
((JDOPOManagerItf) managedConnection.getPOManager()).currentTransaction().setNontransactionalRead(nontransactionalRead);
}
public boolean getNontransactionalRead() {
//delegate
if (managedConnection == null) {
throw new JDOException(NO_ACTIVE_CONNECTION);
}
return ((JDOPOManagerItf) managedConnection.getPOManager()).currentTransaction().getNontransactionalRead();
}
public void setNontransactionalWrite(boolean nontransactionalWrite) {
//delegate
if (managedConnection == null) {
throw new JDOException(NO_ACTIVE_CONNECTION);
}
((JDOPOManagerItf) managedConnection.getPOManager()).currentTransaction().setNontransactionalWrite(nontransactionalWrite);
}
public boolean getNontransactionalWrite() {
//delegate
if (managedConnection == null) {
throw new JDOException(NO_ACTIVE_CONNECTION);
}
return ((JDOPOManagerItf) managedConnection.getPOManager()).currentTransaction().getNontransactionalWrite();
}
public void setRetainValues(boolean retainValues) {
//delegate
if (managedConnection == null) {
throw new JDOException(NO_ACTIVE_CONNECTION);
}
((JDOPOManagerItf) managedConnection.getPOManager()).currentTransaction().setRetainValues(retainValues);
}
public boolean getRetainValues() {
//delegate
if (managedConnection == null) {
throw new JDOException(NO_ACTIVE_CONNECTION);
}
return ((JDOPOManagerItf) managedConnection.getPOManager()).currentTransaction().getRetainValues();
}
public void setRestoreValues(boolean restoreValues) {
//delegate
if (managedConnection == null) {
throw new JDOException(NO_ACTIVE_CONNECTION);
}
((JDOPOManagerItf) managedConnection.getPOManager()).currentTransaction().setRestoreValues(restoreValues);
}
public boolean getRestoreValues() {
//delegate
if (managedConnection == null) {
throw new JDOException(NO_ACTIVE_CONNECTION);
}
return ((JDOPOManagerItf) managedConnection.getPOManager()).currentTransaction().getRestoreValues();
}
public void setOptimistic(boolean optimistic) {
//delegate
if (managedConnection == null) {
throw new JDOException(NO_ACTIVE_CONNECTION);
}
((JDOPOManagerItf) managedConnection.getPOManager()).currentTransaction().setOptimistic(optimistic);
}
public boolean getOptimistic() {
//delegate
if (managedConnection == null) {
throw new JDOException(NO_ACTIVE_CONNECTION);
}
return ((JDOPOManagerItf) managedConnection.getPOManager()).currentTransaction().getOptimistic();
}
public void setSynchronization(Synchronization sync) {
//delegate
if (managedConnection == null) {
throw new JDOException(NO_ACTIVE_CONNECTION);
}
((JDOPOManagerItf) managedConnection.getPOManager()).currentTransaction().setSynchronization(sync);
}
public Synchronization getSynchronization() {
//delegate
if (managedConnection == null) {
throw new JDOException(NO_ACTIVE_CONNECTION);
}
return ((JDOPOManagerItf) managedConnection.getPOManager()).currentTransaction().getSynchronization();
}
public PersistenceManager getPersistenceManager() {
//delegate
if (managedConnection == null) {
throw new JDOException(NO_ACTIVE_CONNECTION);
}
return ((JDOPOManagerItf) managedConnection.getPOManager()).currentTransaction().getPersistenceManager();
}
/* (non-Javadoc)
* @see javax.jdo.PersistenceManager#makeTransient(java.lang.Object, boolean)
*/
public void makeTransient(Object o, boolean useFetchPlan) {
if (!useFetchPlan) {
makeTransient(o);
} else {
//TODO: implement
}
}
/* (non-Javadoc)
* @see javax.jdo.PersistenceManager#makeTransientAll(java.lang.Object[], boolean)
*/
public void makeTransientAll(Object[] os, boolean useFetchPlan) {
if (!useFetchPlan) {
makeTransientAll(os);
} else {
//TODO: implement
}
}
/* (non-Javadoc)
* @see javax.jdo.PersistenceManager#makeTransientAll(java.util.Collection, boolean)
*/
public void makeTransientAll(Collection os, boolean useFetchPlan) {
if (!useFetchPlan) {
makeTransientAll(os);
} else {
//TODO: implement
}
}
/* (non-Javadoc)
* @see javax.jdo.PersistenceManager#retrieve(java.lang.Object, boolean)
*/
public void retrieve(Object o, boolean FGOnly) {
if (!FGOnly) {
retrieve(o);
} else {
//TODO: implement
}
}
/* (non-Javadoc)
* @see javax.jdo.PersistenceManager#getDetachAllOnCommit()
*/
public boolean getDetachAllOnCommit() {
// TODO Auto-generated method stub
return false;
}
/* (non-Javadoc)
* @see javax.jdo.PersistenceManager#setDetachAllOnCommit(boolean)
*/
public void setDetachAllOnCommit(boolean arg0) {
// TODO Auto-generated method stub
}
}