You are viewing a plain text version of this content. The canonical link for it is here.
Posted to ojb-dev@db.apache.org by ar...@apache.org on 2004/05/20 13:13:10 UTC
cvs commit: db-ojb/src/java/org/apache/ojb/odmg ImplementationImpl.java ImplementationJTAImpl.java DatabaseImpl.java ImplementationDefaultImpl.java
arminw 2004/05/20 04:13:10
Modified: src/test/org/apache/ojb OJB.properties
src/java/org/apache/ojb/odmg ImplementationJTAImpl.java
DatabaseImpl.java
Added: src/java/org/apache/ojb/odmg ImplementationImpl.java
Removed: src/java/org/apache/ojb/odmg ImplementationDefaultImpl.java
Log:
rename ImplementationDefaultImpl to ImplementationImpl to be
backward compatible
Revision Changes Path
1.68 +2 -2 db-ojb/src/test/org/apache/ojb/OJB.properties
Index: OJB.properties
===================================================================
RCS file: /home/cvs/db-ojb/src/test/org/apache/ojb/OJB.properties,v
retrieving revision 1.67
retrieving revision 1.68
diff -u -r1.67 -r1.68
--- OJB.properties 9 May 2004 11:10:33 -0000 1.67
+++ OJB.properties 20 May 2004 11:13:10 -0000 1.68
@@ -325,7 +325,7 @@
# - ImplementationJTAImpl is for use in managed environments like J2EE conform
# Application Server
#
-ImplementationClass=org.apache.ojb.odmg.ImplementationDefaultImpl
+ImplementationClass=org.apache.ojb.odmg.ImplementationImpl
#ImplementationClass=org.apache.ojb.odmg.ImplementationJTAImpl
#
#
1.2 +2 -2 db-ojb/src/java/org/apache/ojb/odmg/ImplementationJTAImpl.java
Index: ImplementationJTAImpl.java
===================================================================
RCS file: /home/cvs/db-ojb/src/java/org/apache/ojb/odmg/ImplementationJTAImpl.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- ImplementationJTAImpl.java 3 May 2004 23:05:56 -0000 1.1
+++ ImplementationJTAImpl.java 20 May 2004 11:13:10 -0000 1.2
@@ -35,7 +35,7 @@
*
* @version $Id$
*/
-public class ImplementationJTAImpl extends ImplementationDefaultImpl
+public class ImplementationJTAImpl extends ImplementationImpl
{
private Logger log = LoggerFactory.getLogger(ImplementationJTAImpl.class);
1.26 +4 -4 db-ojb/src/java/org/apache/ojb/odmg/DatabaseImpl.java
Index: DatabaseImpl.java
===================================================================
RCS file: /home/cvs/db-ojb/src/java/org/apache/ojb/odmg/DatabaseImpl.java,v
retrieving revision 1.25
retrieving revision 1.26
diff -u -r1.25 -r1.26
--- DatabaseImpl.java 3 May 2004 23:05:56 -0000 1.25
+++ DatabaseImpl.java 20 May 2004 11:13:10 -0000 1.26
@@ -47,14 +47,14 @@
private PBKey pbKey;
private boolean isOpen;
- private ImplementationDefaultImpl ojb;
+ private ImplementationImpl ojb;
/**
* the broker instance for persistence operations
* the named roots map;
*/
private NamedRootsMap nrm;
- public DatabaseImpl(ImplementationDefaultImpl ojb)
+ public DatabaseImpl(ImplementationImpl ojb)
{
nrm = NamedRootsMap.getInstance();
isOpen = false;
@@ -79,7 +79,7 @@
return pbKey;
}
- public ImplementationDefaultImpl getAssociatedImplementation()
+ public ImplementationImpl getAssociatedImplementation()
{
return ojb;
}
1.1 db-ojb/src/java/org/apache/ojb/odmg/ImplementationImpl.java
Index: ImplementationImpl.java
===================================================================
package org.apache.ojb.odmg;
/* Copyright 2002-2004 The Apache Software Foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import org.apache.ojb.broker.Identity;
import org.apache.ojb.broker.PBKey;
import org.apache.ojb.broker.PersistenceBroker;
import org.apache.ojb.broker.PersistenceBrokerFactory;
import org.apache.ojb.broker.util.configuration.ConfigurationException;
import org.apache.ojb.broker.util.configuration.Configurator;
import org.apache.ojb.broker.util.logging.Logger;
import org.apache.ojb.broker.util.logging.LoggerFactory;
import org.apache.ojb.odmg.collections.DCollectionFactory;
import org.apache.ojb.odmg.oql.EnhancedOQLQuery;
import org.apache.ojb.odmg.oql.OQLQueryImpl;
import org.odmg.DArray;
import org.odmg.DBag;
import org.odmg.DList;
import org.odmg.DMap;
import org.odmg.DSet;
import org.odmg.Database;
import org.odmg.DatabaseClosedException;
import org.odmg.Implementation;
import org.odmg.ODMGRuntimeException;
import org.odmg.Transaction;
import java.util.ArrayList;
import java.util.List;
/**
* Default implementation of the {@link Implementation} interface.
*
* @author <a href="mailto:thma@apache.org">Thomas Mahler<a>
* @author <a href="mailto:mattbaird@yahoo.com">Matthew Baird</a>
* @author <a href="mailto:armin@codeAuLait.de">Armin Waibel</a>
*
* @version $Id: ImplementationImpl.java,v 1.1 2004/05/20 11:13:10 arminw Exp $
*/
public class ImplementationImpl extends Object implements Implementation
{
private Logger log = LoggerFactory.getLogger(ImplementationImpl.class);
private List usedDatabases = new ArrayList();
private DatabaseImpl currentDatabase;
private Configurator configurator;
private OJBTxManager ojbTxManager;
/**
* private Constructor: use static factory method
* getInstance() to obtain an instance
*/
protected ImplementationImpl()
{
ojbTxManager = TxManagerFactory.instance();
setConfigurator(PersistenceBrokerFactory.getConfigurator());
}
/**
* Method declaration
* @param curDB
*/
protected synchronized void setCurrentDatabase(DatabaseImpl curDB)
{
currentDatabase = curDB;
}
public DatabaseImpl getCurrentDatabase()
{
return currentDatabase;
}
public PBKey getCurrentPBKey()
{
return currentDatabase.getPBKey();
}
/**
* Gets the configurator.
* @return Returns a Configurator
*/
public Configurator getConfigurator()
{
return configurator;
}
/**
* Sets the configurator.
* @param configurator The configurator to set
*/
public void setConfigurator(Configurator configurator)
{
this.configurator = configurator;
}
/**
* Create a <code>Transaction</code> object and associate it with the current thread.
* @return The newly created <code>Transaction</code> instance.
* @see Transaction
*/
public Transaction newTransaction()
{
if ((getCurrentDatabase() == null))
{
throw new DatabaseClosedException("Database is NULL, must have a DB in order to create a transaction");
}
TransactionImpl tx = new TransactionImpl(getCurrentDatabase());
try
{
getConfigurator().configure(tx);
}
catch (ConfigurationException e)
{
throw new ODMGRuntimeException("Error in configuration of TransactionImpl instance: " + e.getMessage());
}
return tx;
}
/**
* Get the current <code>Transaction</code> for the thread.
* @return The current <code>Transaction</code> object or null if there is none.
* @see Transaction
*/
public Transaction currentTransaction()
{
if ((getCurrentDatabase() == null))
{
throw new DatabaseClosedException("Database is NULL, must have a DB in order to create a transaction");
}
return ojbTxManager.getTransaction();
}
/**
* Create a new <code>Database</code> object.
* @return The new <code>Database</code> object.
* @see Database
*/
public Database newDatabase()
{
return new DatabaseImpl(this);
}
/**
* Create a new <code>OQLQuery</code> object.
* @return The new <code>OQLQuery</code> object.
* @see org.odmg.OQLQuery
*/
public EnhancedOQLQuery newOQLQuery()
{
if ((getCurrentDatabase() == null) || !getCurrentDatabase().isOpen())
{
throw new DatabaseClosedException("Database is not open");
}
OQLQueryImpl query = new OQLQueryImpl(this.getCurrentPBKey());
try
{
getConfigurator().configure(query);
}
catch (ConfigurationException e)
{
throw new ODMGRuntimeException("Error in configuration of OQLQueryImpl instance: " + e.getMessage());
}
return query;
}
/**
* Create a new <code>DList</code> object.
* @return The new <code>DList</code> object.
* @see DList
*/
public DList newDList()
{
if ((getCurrentDatabase() == null))
{
throw new DatabaseClosedException("Database is NULL, cannot create a DList with a null database.");
}
return DCollectionFactory.getInstance().createDList(getCurrentPBKey());
}
/**
* Create a new <code>DBag</code> object.
* @return The new <code>DBag</code> object.
* @see DBag
*/
public DBag newDBag()
{
if ((getCurrentDatabase() == null))
{
throw new DatabaseClosedException("Database is NULL, cannot create a DBag with a null database.");
}
return DCollectionFactory.getInstance().createDBag(getCurrentPBKey());
}
/**
* Create a new <code>DSet</code> object.
* @return The new <code>DSet</code> object.
* @see DSet
*/
public DSet newDSet()
{
if ((getCurrentDatabase() == null))
{
throw new DatabaseClosedException("Database is NULL, cannot create a DSet with a null database.");
}
return DCollectionFactory.getInstance().createDSet(getCurrentPBKey());
}
/**
* Create a new <code>DArray</code> object.
* @return The new <code>DArray</code> object.
* @see DArray
*/
public DArray newDArray()
{
if ((getCurrentDatabase() == null))
{
throw new DatabaseClosedException("Database is NULL, cannot create a DArray with a null database.");
}
return DCollectionFactory.getInstance().createDArray(getCurrentPBKey());
}
/**
* Create a new <code>DMap</code> object.
* @return The new <code>DMap</code> object.
* @see DMap
*/
public DMap newDMap()
{
if ((getCurrentDatabase() == null))
{
throw new DatabaseClosedException("Database is NULL, cannot create a DMap with a null database.");
}
return DCollectionFactory.getInstance().createDMap(getCurrentPBKey());
}
/**
* Get a <code>String</code> representation of the object's identifier.
* OJB returns the serialized Identity of the object.
* @param obj The object whose identifier is being accessed.
* @return The object's identifier in the form of a String
*/
public String getObjectId(Object obj)
{
Identity oid = null;
PersistenceBroker broker;
if (getCurrentDatabase() != null)
{
/**
* is there an open database we are calling getObjectId against? if yes, use it
*/
broker = PersistenceBrokerFactory.createPersistenceBroker(getCurrentDatabase().getPBKey());
}
else
{
/**
* otherwise, use default.
*/
broker = PersistenceBrokerFactory.defaultPersistenceBroker();
}
oid = new Identity(obj, broker);
return new String(oid.serialize());
}
/**
* Returns the current used database or null.
*/
public Database getDatabase(Object obj)
{
/* @todo enhance functionality */
return getCurrentDatabase();
}
/**
* Register opened database via the PBKey.
*/
protected synchronized void registerOpenDatabase(DatabaseImpl newDB)
{
DatabaseImpl old_db = getCurrentDatabase();
if (old_db != null)
{
try
{
if (old_db.isOpen())
{
log.warn("## There is still an opened database, close old one ##");
old_db.close();
}
}
catch (Throwable t)
{
//ignore
}
}
if (log.isDebugEnabled()) log.debug("Set current database " + newDB + " PBKey was " + newDB.getPBKey());
setCurrentDatabase(newDB);
usedDatabases.add(newDB.getPBKey());
}
/**
* This method can be used to activate or deactivate the implicit
* locking mechanism for the current transaction.
* turning of implicit locking may improve performance but requires
* additional care to make sure all changed objects are properly
* registered to the transaction.
* @param value if set to true implicit locking is enabled,
* if false, implicit locking is disabled.
**/
public void setImplicitLocking(boolean value)
{
((TransactionExt)currentTransaction()).setImplicitLocking(value);
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-dev-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-dev-help@db.apache.org