ojb.broker.server
Class PersistenceBrokerClient

java.lang.Object
  |
  +--ojb.broker.server.PersistenceBrokerClient
All Implemented Interfaces:
PersistenceBroker, java.io.Serializable, ServerAdministration

public class PersistenceBrokerClient
extends java.lang.Object
implements PersistenceBroker, java.io.Serializable, ServerAdministration

See Also:
Serialized Form

Constructor Summary
PersistenceBrokerClient(ServerEntry server)
           
PersistenceBrokerClient(ServerPool serverpool)
           
 
Method Summary
 void abortTransaction()
          Abort and close the transaction.
 void beginTransaction()
          begin a transaction against the underlying RDBMS.
 void clearCache()
          clears the brokers internal cache.
 boolean close()
          close connection to last opened repository.
 void commitTransaction()
          Commit and close the transaction.
 void delete(java.lang.Object obj)
          deletes the objects obj concrete representation in the underlying persistence system.
 ClassDescriptor getClassDescriptor(java.lang.Class clazz)
          returns a ClassDescriptor for the persistence capable class clazz.
 ManageableCollection getCollectionByQuery(java.lang.Class collectionClass, Query query)
          retrieve a userdefined Collection that implements the interface Manageable collection that contains all Objects matching the Query query.
 java.util.Collection getCollectionByQuery(Query query)
          retrieve a collection of itemClass Objects matching the Query query.
 int getCount(Query query)
          returns the count of elements a given query will return.
 java.lang.Class getExtentClass(java.lang.Class clazz)
          returns the Extent to which the class clazz belongs.
 java.util.Iterator getIteratorByQuery(Query query)
          returns an Iterator that iterates Objects of class c if calling the .next() method.
 java.lang.Object getObjectByIdentity(Identity id)
          retrieve an Object by its Identity.
 java.lang.Object getObjectByQuery(Query query)
          retrieve an Object by query.
 java.util.Enumeration getPKEnumerationByQuery(java.lang.Class primaryKeyClass, Query query)
          returns an Enumeration of PrimaryKey Objects for objects of class DataClass.
 java.util.Iterator getReportQueryIteratorByQuery(Query query)
          returns an Iterator that iterates Object[] calling the .next() method.
 int getUniqueId(java.lang.Class extent, java.lang.String attribute)
          returns a unique int for class extent and field attribute.
 long getUniqueLong(java.lang.Class extent, java.lang.String attribute)
          returns a unique long for class extent and field attribute.
 java.lang.Object getUniqueObject(java.lang.Class extent, java.lang.String attribute)
          returns a unique Object for class extent and field attribute.
 java.lang.String getUniqueString(java.lang.Class extent, java.lang.String attribute)
          returns a unique String for class extent and field attribute.
 boolean hasNext(int iteratorId)
           
 void invalidate(Identity oid)
          removes the objects obj from the brokers internal cache and inform other caches in OJB cluster about invalidation.
 boolean isInTransaction()
          returns true if the broker performs a transaction.
 java.lang.Object next(int iteratorId)
           
 boolean open(java.lang.String repository, java.lang.String user, java.lang.String passwd)
          open a repository. returns true if successfull, else false.
 void ping()
          ping the server
 void releaseDbResources(int iteratorId)
           
 void removeFromCache(java.lang.Object obj)
          removes the objects obj from the brokers internal cache.
 void setClassDescriptor(ClassDescriptor modifiedOrNewDescriptor)
          adds a new or replaces an existing ClassDescriptor to the DescriptorRepository.
 void store(java.lang.Object obj)
          make object obj persistent in the underlying persistence system.
 void store(java.lang.Object obj, ObjectModification modification)
          makes object obj persistent in the underlying persistence system.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PersistenceBrokerClient

public PersistenceBrokerClient(ServerPool serverpool)

PersistenceBrokerClient

public PersistenceBrokerClient(ServerEntry server)
Method Detail

delete

public void delete(java.lang.Object obj)
            throws PersistenceBrokerException
Description copied from interface: PersistenceBroker
deletes the objects obj concrete representation in the underlying persistence system. E.G. by DELETE FROM ... WHERE ... in an RDBMS

Specified by:
delete in interface PersistenceBroker
PersistenceBrokerException

store

public void store(java.lang.Object obj)
           throws PersistenceBrokerException
Description copied from interface: PersistenceBroker
make object obj persistent in the underlying persistence system. E.G. by INSERT INTO ... or UPDATE ... in an RDBMS

Specified by:
store in interface PersistenceBroker
PersistenceBrokerException

abortTransaction

public void abortTransaction()
                      throws TransactionNotInProgressException
Description copied from interface: PersistenceBroker
Abort and close the transaction. Calling abort abandons all persistent object modifications and releases the associated locks. If transaction is not in progress a TransactionNotInProgressException is thrown

Specified by:
abortTransaction in interface PersistenceBroker
TransactionNotInProgressException

beginTransaction

public void beginTransaction()
                      throws TransactionInProgressException,
                             TransactionAbortedException
Description copied from interface: PersistenceBroker
begin a transaction against the underlying RDBMS. Calling beginTransaction multiple times, without an intervening call to commitTransaction or abortTransaction, causes the exception TransactionInProgressException to be thrown on the second and subsequent calls.

Specified by:
beginTransaction in interface PersistenceBroker
TransactionInProgressException
TransactionAbortedException

commitTransaction

public void commitTransaction()
                       throws TransactionNotInProgressException,
                              TransactionAbortedException
Description copied from interface: PersistenceBroker
Commit and close the transaction. Calling commit commits to the database all UPDATE, INSERT and DELETE statements called within the transaction and releases any locks held by the transaction. If beginTransaction() has not been called before a TransactionNotInProgressException exception is thrown. If the transaction cannot be commited a TransactionAbortedException exception is thrown.

Specified by:
commitTransaction in interface PersistenceBroker
TransactionNotInProgressException
TransactionAbortedException

getCollectionByQuery

public java.util.Collection getCollectionByQuery(Query query)
                                          throws PersistenceBrokerException
Description copied from interface: PersistenceBroker
retrieve a collection of itemClass Objects matching the Query query. if the Query has no criteria no WHERE-clause is generated, i.e. ALL table rows are selected.

Specified by:
getCollectionByQuery in interface PersistenceBroker
PersistenceBrokerException

getCollectionByQuery

public ManageableCollection getCollectionByQuery(java.lang.Class collectionClass,
                                                 Query query)
                                          throws PersistenceBrokerException
Description copied from interface: PersistenceBroker
retrieve a userdefined Collection that implements the interface Manageable collection that contains all Objects matching the Query query. If query has no criteria no WHERE-clause is generated, i.e. ALL table rows are selected.

Specified by:
getCollectionByQuery in interface PersistenceBroker
PersistenceBrokerException

getIteratorByQuery

public java.util.Iterator getIteratorByQuery(Query query)
                                      throws PersistenceBrokerException
Description copied from interface: PersistenceBroker
returns an Iterator that iterates Objects of class c if calling the .next() method. The Elements returned come from a SELECT ... WHERE Statement that is defined by the Query query. If itemProxy is null, no proxies are used. NOT YET AWARE OF EXTENTS !

Specified by:
getIteratorByQuery in interface PersistenceBroker
PersistenceBrokerException

getObjectByIdentity

public java.lang.Object getObjectByIdentity(Identity id)
                                     throws PersistenceBrokerException
Description copied from interface: PersistenceBroker
retrieve an Object by its Identity. Application Developers are encouraged to use getObjectByQuery(). This method is mainly used for internal performant handling of materialization by OID (e.g. in Proxies)

Specified by:
getObjectByIdentity in interface PersistenceBroker
PersistenceBrokerException

getObjectByQuery

public java.lang.Object getObjectByQuery(Query query)
                                  throws PersistenceBrokerException
Description copied from interface: PersistenceBroker
retrieve an Object by query. I.e perform a SELECT ... FROM ... WHERE ... in an RDBMS

Specified by:
getObjectByQuery in interface PersistenceBroker
PersistenceBrokerException

getPKEnumerationByQuery

public java.util.Enumeration getPKEnumerationByQuery(java.lang.Class primaryKeyClass,
                                                     Query query)
                                              throws PersistenceBrokerException
Description copied from interface: PersistenceBroker
returns an Enumeration of PrimaryKey Objects for objects of class DataClass. The Elements returned come from a SELECT ... WHERE Statement that is defined by the fields and their coresponding values of vecFields and vecValues. Useful for EJB Finder Methods... NOT YET AWARE OF EXTENTS !

Specified by:
getPKEnumerationByQuery in interface PersistenceBroker
Parameters:
primaryKeyClass - the pk class for the searched objects
query - the query
PersistenceBrokerException

store

public void store(java.lang.Object obj,
                  ObjectModification modification)
           throws PersistenceBrokerException
Description copied from interface: PersistenceBroker
makes object obj persistent in the underlying persistence system. E.G. by INSERT INTO ... or UPDATE ... in an RDBMS. The ObjectModification parameter can be used to generate optimized SQL code (decide whether insert or update is needed. And for updates only generate code for modified columns)

Specified by:
store in interface PersistenceBroker
PersistenceBrokerException

ping

public void ping()
Description copied from interface: ServerAdministration
ping the server

Specified by:
ping in interface ServerAdministration

getUniqueId

public int getUniqueId(java.lang.Class extent,
                       java.lang.String attribute)
                throws PersistenceBrokerException
Description copied from interface: PersistenceBroker
returns a unique int for class extent and field attribute. the returned uid is unique accross all tables in the extent of class extent.

Specified by:
getUniqueId in interface PersistenceBroker
PersistenceBrokerException

getUniqueString

public java.lang.String getUniqueString(java.lang.Class extent,
                                        java.lang.String attribute)
                                 throws PersistenceBrokerException
Description copied from interface: PersistenceBroker
returns a unique String for class extent and field attribute. the returned String is unique accross all tables in the extent of class extent.

Specified by:
getUniqueString in interface PersistenceBroker
PersistenceBrokerException

hasNext

public boolean hasNext(int iteratorId)
                throws PersistenceBrokerException
PersistenceBrokerException

next

public java.lang.Object next(int iteratorId)
                      throws PersistenceBrokerException
PersistenceBrokerException

releaseDbResources

public void releaseDbResources(int iteratorId)

removeFromCache

public void removeFromCache(java.lang.Object obj)
                     throws PersistenceBrokerException
removes the objects obj from the brokers internal cache. removing is recursive. That is referenced Objects are also removed from the cache, if the auto-retrieve flag is set for obj.getClass() in the metadata repository.

Specified by:
removeFromCache in interface PersistenceBroker
PersistenceBrokerException

getUniqueObject

public java.lang.Object getUniqueObject(java.lang.Class extent,
                                        java.lang.String attribute)
                                 throws PersistenceBrokerException
returns a unique Object for class extent and field attribute. the returned Object is unique accross all tables in the extent of class extent.

Specified by:
getUniqueObject in interface PersistenceBroker
PersistenceBrokerException

getClassDescriptor

public ClassDescriptor getClassDescriptor(java.lang.Class clazz)
                                   throws PersistenceBrokerException
returns a ClassDescriptor for the persistence capable class clazz. throws a PersistenceBrokerException if clazz is not persistence capable, i.e. if clazz is not defined in the DescriptorRepository.

Specified by:
getClassDescriptor in interface PersistenceBroker
PersistenceBrokerException

clearCache

public void clearCache()
                throws PersistenceBrokerException
clears the brokers internal cache. removing is recursive. That is referenced Objects are also removed from the cache, if the auto-retrieve flag is set for obj.getClass() in the metadata repository.

Specified by:
clearCache in interface PersistenceBroker
PersistenceBrokerException

setClassDescriptor

public void setClassDescriptor(ClassDescriptor modifiedOrNewDescriptor)
                        throws PersistenceBrokerException
adds a new or replaces an existing ClassDescriptor to the DescriptorRepository.

Specified by:
setClassDescriptor in interface PersistenceBroker
PersistenceBrokerException

getExtentClass

public java.lang.Class getExtentClass(java.lang.Class clazz)
                               throws PersistenceBrokerException
returns the Extent to which the class clazz belongs. This may be a baseclass,an interface or clazz itself, if no Extent is defined. throws a PersistenceBrokerException if clazz is not persistence capable, i.e. if clazz is not defined in the DescriptorRepository.

Specified by:
getExtentClass in interface PersistenceBroker
PersistenceBrokerException

invalidate

public void invalidate(Identity oid)
                throws PersistenceBrokerException
removes the objects obj from the brokers internal cache and inform other caches in OJB cluster about invalidation.

Specified by:
invalidate in interface PersistenceBroker
PersistenceBrokerException

getUniqueLong

public long getUniqueLong(java.lang.Class extent,
                          java.lang.String attribute)
                   throws PersistenceBrokerException
returns a unique long for class extent and field attribute. the returned number is unique accross all tables in the extent of class extent.

Specified by:
getUniqueLong in interface PersistenceBroker
PersistenceBrokerException

getCount

public int getCount(Query query)
             throws PersistenceBrokerException
Description copied from interface: PersistenceBroker
returns the count of elements a given query will return.

Specified by:
getCount in interface PersistenceBroker
PersistenceBrokerException

getReportQueryIteratorByQuery

public java.util.Iterator getReportQueryIteratorByQuery(Query query)
                                                 throws PersistenceBrokerException
Description copied from interface: PersistenceBroker
returns an Iterator that iterates Object[] calling the .next() method. The Elements returned come from a SELECT ... WHERE sqlStatement The Class c is only used to provide the associated JDBC Connection

Specified by:
getReportQueryIteratorByQuery in interface PersistenceBroker
PersistenceBrokerException

close

public boolean close()
Description copied from interface: PersistenceBroker
close connection to last opened repository.

Specified by:
close in interface PersistenceBroker
Returns:
true if successful

isInTransaction

public boolean isInTransaction()
                        throws PersistenceBrokerException
Description copied from interface: PersistenceBroker
returns true if the broker performs a transaction. returns false if broker is not in a transaction.

Specified by:
isInTransaction in interface PersistenceBroker
PersistenceBrokerException

open

public boolean open(java.lang.String repository,
                    java.lang.String user,
                    java.lang.String passwd)
             throws PersistenceBrokerException
Description copied from interface: PersistenceBroker
open a repository. returns true if successfull, else false.

Specified by:
open in interface PersistenceBroker
Parameters:
repository - name of the repository
user - user name, if left null username is taken from repository.
passwd - password, if left null password is taken from repository.
Returns:
true if successful, else false.
PersistenceBrokerException


Authors: Thomas Mahler and others. (C) 2000, 2001.
All rights reserved. Published under the Gnu Public License.
http://objectbridge.sourceforge.net
Version: 0.8.375, 2002-04-04