com.intersys.objects
Interface Database


public interface Database

Interface Database provides access to actual connection with Cache. The normal way to obtain this connection is by calling one of methods getDatabase() in CacheDatabase class. This connection can be implemented in different ways Currently we have 2 implementations:

In future we also consider other implementations.

Because the connection is very implementation specific Database interface is totally opaque. Classes which implement it hold some information, but only implementation knows how to use it. Users are discouraged to use any methods of those classes not defined in this interface.

In applications working with Cache Database Java classes, generated from Cache classes are usually present. Objects of those classes held references to Database server. All generated classes have com.intersys.classes.CacheRootObject as their superclass.

See Also:
CacheRootObject, ObjectHandle

Field Summary
static int RET_NONE
           
static int RET_OBJECT
           
static int RET_PRIM
           
 
Method Summary
 boolean addListener(EventListener listener)
          Adds another listener for messages from server.
 Map close()
          Closes connection to Database.
 void closeAllObjects()
          Closes all objects, opened by client.
 void closeObject(int oref)
          Closes an object with given object reference.
 void closeObject(Object zref)
          Closes an object with given object reference.
 void createObjects(String cacheClassName, Collection objects)
          Saves a collection of previously created new objects in Cache Database.
 Statement createStatement()
          Creates SQL statement to be run through this connection.
 boolean equals(Object obj)
          Checks whether two databases refer to the same Cache server connection.
 CacheClass getCacheClass(String typeName)
          Returns Cache Class corresponding to given type name.
 int getCacheType()
          Returns type of client side data cache.
 String getConnectionString()
          Returns connection string for Database.
 int getNumberOfOpenObjects()
          Returns number of objects opened by client.
 int getNumberOfServerCalls()
          Returns number of all calls from client to Cache server from Database object creation.
 int getNumberOfServerCalls(int i)
          Returns number of calls from client to Cache server from Database object creation while profile i was on (between calls to setProfileOn(i) and setProfileOff(i)).
 ObjectServerInfo getServerInfo()
          Returns information about Cache Database server.
 long getServerTime()
          Returns commulative time elapsed during waiting for server response in all calls to Cache server.
 long getServerTime(int i)
          Returns commulative time elapsed during waiting for server response in calls to Cache server while profile i was on (between calls to setProfileOn(i) and setProfileOff(i)).
 boolean isLightConnection()
          Returns information about Cache Database server.
 boolean isLowLevelConnectionClosed()
          Checks whether a JDBC (or ODBC) driver level connection to Cache Server, which had been used by this Database object is closed.
 Iterator openByQuery(String query)
          Opens all objects othat satisfy given SQL query.
 Iterator openByQuery(String query, Object[] args)
          Opens all objects othat satisfy given SQL query.
 Iterator openByQuery(String cacheClassName, String condition)
          Opens all objects of given class that satisfy given simple condition, specified in SQL syntax.
 Iterator openByQuery(String cacheClassName, String condition, Object[] args)
          Opens all objects of given class that satisfy given simple condition, specified in SQL syntax.
 int parseStatus(com.intersys.cache.Dataholder dh)
          Parses status, returned by Cache routine.
 int parseStatus(StatusCode sc)
          Parses status, returned by Cache routine.
 CallableStatement prepareCall(String statement)
          Prepares SQL stored procedure to be called.
 PreparedStatement prepareStatement(String statement)
          Prepares SQL statement to be run through this connection.
 void printStatistics()
          Prints statistics of cache usage to standard out.
 void printStatistics(PrintStream out)
          Prints statistics of cache usage.
 void registerSensitiveObject(CacheServerSensitive obj)
          Registers an object which will be informed of any call to Cache Database which changes any of proxy objects in this client.
 void registerSensitiveObject(CacheServerSensitive obj, int ref)
          Registers an object which will be informed of any call to Cache Database which changes a particular proxy object in this client.
 void registerSensitiveObject(CacheServerSensitive obj, ObjectHandle ref)
          Registers an object which will be informed of any call to Cache Database which changes a particular proxy object in this client.
 void registerSensitiveObject(CacheServerSensitive obj, Set refSet)
          Registers an object which will be informed of any call to Cache Database which changes some particular proxy objects in this client.
 boolean removeListener(EventListener listener)
          Removes a listener for messages from server.
 com.intersys.cache.Dataholder runClassMethod(String className, String methodName, com.intersys.cache.Dataholder[] argv, int retType)
          Runs static (also known as class) method in cache.
 com.intersys.cache.Dataholder[] runClassMethod(String className, String methodName, int[] refs, com.intersys.cache.Dataholder[] argv, int retType)
          Runs static (also known as class) method in cache.
 void saveObjects(String cacheClassName, Collection objects)
          Saves changes in objects to Cache Database.
 void setClassLoader(ClassLoader newLoader)
          Sets custom class loader for loading Java projections of Cache classes.
 void setConsoleOutput(PrintStream out)
          Sets the stream used for console output by Cache server-side methods.
 void setProfileOff(int i)
          Disables gathering profile information for cell i.
 void setProfileOn(int i)
          Enables gathering profile information for cell i.
 void transactionCommit()
          Commits the transaction
 void transactionRollback()
          Roll the transaction back
 void transactionStart()
          Starts a transaction
 boolean unRegisterSensitiveObject(CacheServerSensitive obj)
          Unregisters object, previously registered with method registerSensitiveObject.
 DatabaseUtilities utilities()
          Returns an utility object which can import class into Cache, generate Java class from Cache class and do a number of other operations.
 

Field Detail

RET_OBJECT

public static final int RET_OBJECT
See Also:
Constant Field Values

RET_PRIM

public static final int RET_PRIM
See Also:
Constant Field Values

RET_NONE

public static final int RET_NONE
See Also:
Constant Field Values
Method Detail

runClassMethod

public com.intersys.cache.Dataholder[] runClassMethod(String className,
                                                      String methodName,
                                                      int[] refs,
                                                      com.intersys.cache.Dataholder[] argv,
                                                      int retType)
                                               throws CacheException
Runs static (also known as class) method in cache.

The first element (index 0) of returned array contains return value. If the method is void first element has undefined value. Elements starting with the second (index 1) contain values for parameters passed by reference. Note, that even if the method is void, values for references start from the second, not the first element of array.

Parameters:
className - Name of the Cache class.
methodName - Name of static method in the class.
refs - Array containing indexes (in array argv) for parameters passed by reference. If there are no parameters passed by reference it is a zero length array.
argv - Arguments to the method. If there are no arguments, it is a zero length array.
retType - Can have 3 possible values: Database.RET_OBJECT if method returns an object, Database.RET_PRIM if method returns a value of primitive type or Database.RET_NONE if method does not return a value.
Returns:
Array containing return value of the method if method is not void and values of paramters passed by reference.
Throws:
CacheException

runClassMethod

public com.intersys.cache.Dataholder runClassMethod(String className,
                                                    String methodName,
                                                    com.intersys.cache.Dataholder[] argv,
                                                    int retType)
                                             throws CacheException
Runs static (also known as class) method in cache.

Wrapper method to run class method when no arguments are passed by reference.

Parameters:
className - Name of the Cache class.
methodName - Name of static method in the class.
argv - Arguments to the method. If there are no arguments, it is a zero length array.
retType - Can have 3 possible values: Database.RET_OBJECT if method returns an object, Database.RET_PRIM if method returns a value of primitive type or Database.RET_NONE if method does not return a value.
Returns:
Return value of method, represented as Dataholder.
Throws:
CacheException

getCacheClass

public CacheClass getCacheClass(String typeName)
                         throws CacheException
Returns Cache Class corresponding to given type name. Can be used for dynamic binding or other use of reflection api.

Parameters:
typeName - Name of the type
Returns:
Cache Class represented as CacheClass object.
Throws:
CacheException
See Also:
com.intersys.objects.reflect

printStatistics

public void printStatistics()
Prints statistics of cache usage to standard out. For each object the following information is printed: Statistics for static calls (class methods) is printed under object reference -1


printStatistics

public void printStatistics(PrintStream out)
Prints statistics of cache usage. For each object the following information is printed: Statistics for static calls (class methods) is printed under object reference -1

Parameters:
out - java.io.PrintStream to print output to.

equals

public boolean equals(Object obj)
Checks whether two databases refer to the same Cache server connection.

Parameters:
obj - Object which should be an instance of Database.
Returns:
true if obj is an instance of Database and it referes to the same Cache server connection. Otherwise returns false.

getConnectionString

public String getConnectionString()
Returns connection string for Database. Connection string is of the form of jdbc URL for JDBC connection or Data Source for ODBC connection.

Returns:
String, representing connection to Cache Server via DBC driver.

createStatement

public Statement createStatement()
                          throws CacheException
Creates SQL statement to be run through this connection.

A set of convenience methods: createStatement, prepareStatement, prepareCall are provided here for simple queries and some update operations on the database. They are intended to use in applications which mostly use Object Java Projection with Cache but also need simple SQL functionality.

For full JDBC functioanlity you should use package java.sql. In this case it is convenient first to establish a JDBC connection to Cache and then obtain an instance of Database interface using method CacheDatabase.getDatabase(java.sql.Connection).

Returns:
Statement represented as java.sql.Statement.
Throws:
CacheException - if an error occured during preparation.
See Also:
Connection.createStatement(), prepareStatement(java.lang.String), prepareCall(java.lang.String), CacheDatabase.getDatabase(java.sql.Connection)

prepareStatement

public PreparedStatement prepareStatement(String statement)
                                   throws CacheException
Prepares SQL statement to be run through this connection. A set of convenience methods: createStatement, prepareStatement, prepareCall are provided here for simple queries and some update operations on the database. They are intended to use in applications which mostly use Object Java Projection with Cache but also need simple SQL functionality.

For full JDBC functioanlity you should use package java.sql. In this case it is convenient first to establish a JDBC connection to Cache and then obtain an instance of Database interface using method CacheDatabase.getDatabase(java.sql.Connection).

Parameters:
statement - SQL query string
Returns:
Prepared statement represented as java.sql.PreparedStatement.
Throws:
CacheException - if an error occured during preparation.
See Also:
Connection.prepareStatement(java.lang.String), createStatement(), prepareCall(java.lang.String), CacheDatabase.getDatabase(java.sql.Connection)

prepareCall

public CallableStatement prepareCall(String statement)
                              throws CacheException
Prepares SQL stored procedure to be called. A set of convenience methods: createStatement, prepareStatement, prepareCall are provided here for simple queries and some update operations on the database. They are intended to use in applications which mostly use Object Java Projection with Cache but also need simple SQL functionality.

For full JDBC functioanlity you should use package java.sql. In this case it is convenient first to establish a JDBC connection to Cache and then obtain an instance of Database interface using method CacheDatabase.getDatabase(java.sql.Connection).

Parameters:
statement - Statement representing call to an SQL procedure.
Returns:
Prepared statement represented as java.sql.PreparedStatement.
Throws:
CacheException - if SQL stored procedure was not found or any other error occured during preparation.
See Also:
Connection.prepareCall(java.lang.String), prepareStatement(java.lang.String), CacheDatabase.getDatabase(java.sql.Connection)

closeObject

public void closeObject(int oref)
                 throws CacheException
Closes an object with given object reference. After that all Java objects which refer to this Cache object may become invalid. The exact behaviour in case when such Java object is used is not yet defined.

Parameters:
oref - Object reference of object to close.
Throws:
CacheException

closeObject

public void closeObject(Object zref)
                 throws CacheException
Closes an object with given object reference. After that all Java objects which refer to this Cache object may become invalid. The exact behaviour in case when such Java object is used is not yet defined.

Parameters:
zref - Object reference of object to close. Returned by getZRef() method of ObjectHandle interface.
Throws:
CacheException
See Also:
ObjectHandle.getZRef()

close

public Map close()
          throws CacheException
Closes connection to Database. After that all Java objects which were created with this connection become invalid.

Returns:
In debug mode: Map, containing all objects which remained open when Databased was closed. The key of each Map entry is oref of the object and the value is its class name. In no-debug mode the Map is always empty.
Throws:
CacheException

closeAllObjects

public void closeAllObjects()
                     throws CacheException
Closes all objects, opened by client. Any changes that were made to any of these objects without subsequent save will be lost.

Database object can be used after call to this method but it will have to load again any previously loaded objects. No other resources will be released. It is still advisable to call close() method to release all remaining resources.

Throws:
CacheException

isLowLevelConnectionClosed

public boolean isLowLevelConnectionClosed()
                                   throws CacheException
Checks whether a JDBC (or ODBC) driver level connection to Cache Server, which had been used by this Database object is closed. In case of JDBC it queries java.sql.Connection object. Note, that though a driver level connection can be still open, database connection maybe already closed. Generally this method can be useful in connection pooling situation.

Returns:
true if Database driver has closed connection to Database server, false otherwise.
Throws:
CacheException
See Also:
Connection

getServerInfo

public ObjectServerInfo getServerInfo()
                               throws CacheException
Returns information about Cache Database server.

Returns:
Server information as ObjectServerInfo object.
Throws:
CacheException - if information is unavailable, e.g. if connection is not open.

isLightConnection

public boolean isLightConnection()
Returns information about Cache Database server.

Returns:
true if the connection was initiated by calling getLightDatabase() method. Light connection has some limitations.

parseStatus

public int parseStatus(com.intersys.cache.Dataholder dh)
                throws CacheException
Parses status, returned by Cache routine. In case status indicates success, this method normally returns. In case status indicates an error it throws an exception, containing error code and error text from status object. Normally application programmer should not call ths routine, it will be invoked automatically if Cache routine returns %Library.Status.

Parameters:
dh - Status object embedded in Dataholder. Dataholder is an internal way of trepresenting data passed and received from Cache Server.
Throws:
CacheException - in 2 cases: First in case when Status indicates error and second when communication error occured, attempting to connect to Cache Server.

parseStatus

public int parseStatus(StatusCode sc)
                throws CacheException
Parses status, returned by Cache routine. In case status indicates success, this method normally returns. In case status indicates an error it throws an exception, containing error code and error text from status object. Normally application programmer should not call ths routine, it will be invoked automatically if Cache routine returns %Library.Status.

Parameters:
sc - Status object represented as com.intersys.objects.StatusCode.
Throws:
CacheException - in 2 cases: First in case when Status indicates error and second when communication error occured, attempting to connect to Cache Server.

openByQuery

public Iterator openByQuery(String cacheClassName,
                            String condition,
                            Object[] args)
                     throws CacheException
Opens all objects of given class that satisfy given simple condition, specified in SQL syntax.

If actual object belongs to subclasses of cacheClassName, it will be opened correctly. However in case when there are many such objects that can degrade performance significantly.

Condition in this method only can be a simple condition that refers only to properties of a single object (single row in one SQL table). For example, for class Sample.Person valid conditions can be "Name %STARTSWITH ?", "Home_City = ?" or "ID BETWEEN ? AND ?". It can also include "ORDER BY" clause, for example: "Home_City = ? ORDER BY Name". If a particular ordering was specified in SQL statement, the ordering is preserved by Itetrator.

In case when a more complex condition is required, method openByQuery(String,Object[]) should be used.

Parameters:
cacheClassName - Name of Cache class to which (or its subclasses) objects belong. It must me a fully qualified class name including package name.
condition - Simple condition on objects, in SQL syntax. It can refer only to properties of a single object.
args - Parameters to replace "?" in condition. If there are no parameters in condition may be null or empty array.
Returns:
Iterator in the form of java.util.Iterator, that iterates over all opened objects in specified order.
Throws:
CacheException
See Also:
openByQuery(java.lang.String,java.lang.Object[]), openByQuery(java.lang.String,java.lang.String)

openByQuery

public Iterator openByQuery(String cacheClassName,
                            String condition)
                     throws CacheException
Opens all objects of given class that satisfy given simple condition, specified in SQL syntax.

If actual object belongs to subclasses of cacheClassName, it will be opened correctly. However in case when there are many such objects that can degrade performance significantly.

Condition in this method only can be a simple condition that refers only to properties of a single object (single row in one SQL table). For example, for class Sample.Person valid conditions can be "Name %STARTSWITH 'A'", "Home_City = 'BOSTON'" or "ID BETWEEN 1000 AND 2000". It can also include "ORDER BY" clause, for example: "Home_City = 'BOSTON' ORDER BY Name". If a particular ordering was specified in SQL statement, the ordering is preserved by Itetrator.

If similar queries with different values of parameters are used then method openByQuery(java.lang.String,java.lang.String,java.lang.Object[]) gives better perfromance. In case when a more complex condition is required, method openByQuery(String,Object[]) should be used.

Parameters:
cacheClassName - Name of Cache class to which (or its subclasses) objects belong. It must me a fully qualified class name including package name.
condition - Simple condition on objects, in SQL syntax. It can refer only to properties of a single object and can not have parameters.
Returns:
Iterator in the form of java.util.Iterator, that iterates over all opened objects in specified order.
Throws:
CacheException
See Also:
openByQuery(java.lang.String,java.lang.String,java.lang.Object[]), openByQuery(java.lang.String,java.lang.Object[])

openByQuery

public Iterator openByQuery(String query,
                            Object[] args)
                     throws CacheException
Opens all objects othat satisfy given SQL query. SQL statement must satisfy the following additional requirments:
  1. The first returned column should be fully qualified %ID column for some table. For instance, when openeing Sample.Person objects, the first coulmn should be "Sample.Person.%ID".
  2. If particular ordering is required then columns in "ORDER BY" clause should be specified by names, not by numbers.

Example of valid SQL statement for the purpose of opening objects of class Sample.Employee is:

SELECT Sample.Employee.%ID, Sample.Employee.Name, Sample.Company.Name FROM Sample.Employee, Sample.Company WHERE Revenue > ? AND Company = Sample.Company.ID Order by Sample.Company.Name, Sample.Employee.Name

If actual objects belong to subclasses of the class specified by the first column of SQL statement, they will be opened correctly. However in case when there are many such objects performance can be significantly degraded.

Parameters:
query - A valid SQL statement, satisfying additional requirments, described above.
args - Parameters to replace "?" in query. If there are no parameters in condition may be null or empty array.
Returns:
Iterator in the form of java.util.Iterator, that iterates over all opened objects in specified order.
Throws:
CacheException
See Also:
openByQuery(java.lang.String,java.lang.String,java.lang.Object[])

openByQuery

public Iterator openByQuery(String query)
                     throws CacheException
Opens all objects othat satisfy given SQL query. SQL statement must satisfy the following additional requirments:
  1. The first returned column should be fully qualified %ID column for some table. For instance, when openeing Sample.Person objects, the first coulmn should be "Sample.Person.%ID".
  2. If particular ordering is required then columns in "ORDER BY" clause should be specified by names, not by numbers.

Example of valid SQL statement for the purpose of opening objects of class Sample.Employee is:

SELECT Sample.Employee.%ID, Sample.Employee.Name, Sample.Company.Name FROM Sample.Employee, Sample.Company WHERE Revenue > 2100 AND Company = Sample.Company.ID Order by Sample.Company.Name, Sample.Employee.Name

If actual objects belong to subclasses of the class specified by the first column of SQL statement, they will be opened correctly. However in case when there are many such objects performance can be significantly degraded.

If similar queries with different values of parameters are used then method openByQuery(java.lang.String,java.lang.Object[]) gives better perfromance.

Parameters:
query - A valid SQL statement, satisfying additional requirments, described above.
Returns:
Iterator in the form of java.util.Iterator, that iterates over all opened objects in specified order.
Throws:
CacheException
See Also:
openByQuery(java.lang.String,java.lang.String,java.lang.Object[]), openByQuery(java.lang.String,java.lang.Object[])

createObjects

public void createObjects(String cacheClassName,
                          Collection objects)
                   throws CacheException
Saves a collection of previously created new objects in Cache Database. No object in collection could been saved before. All objects must be of the same given class and not of its subclasses. To save changes in objects that already exist in the database use saveObjects method or instance method save on the object itself.

Parameters:
cacheClassName - Name of the Cache class, to which all objects in given collection belong. Cache class should be a subclass of %Library.Persistent.
objects - A collection of newly created objects. None of the objects in the collection may already exist in database.
Throws:
CacheException
See Also:
saveObjects(java.lang.String, java.util.Collection), Persistent.save()

saveObjects

public void saveObjects(String cacheClassName,
                        Collection objects)
                 throws CacheException
Saves changes in objects to Cache Database. All object in collection must already exist in database. All objects must be of the same given class and not of its subclasses. To save changes in newly created objects use createObjects method or instance method save on the object itself.

Parameters:
cacheClassName - Name of the Cache class, to which all objects in given collection belong. Cache class should be a subclass of %Library.Persistent.
objects - A collection of existing objects. Any object in collection must already exist in database.
Throws:
CacheException
See Also:
createObjects(java.lang.String, java.util.Collection), Persistent.save()

utilities

public DatabaseUtilities utilities()
Returns an utility object which can import class into Cache, generate Java class from Cache class and do a number of other operations.

Returns:
instance of DatabaseUtilities associated with this Database.

registerSensitiveObject

public void registerSensitiveObject(CacheServerSensitive obj)
                             throws CacheException
Registers an object which will be informed of any call to Cache Database which changes any of proxy objects in this client. If such call occur, method onServerCall() of registered object will be called.

Parameters:
obj - an object, implementing com.intersys.CacheServerSensitive interface.
Throws:
CacheException - if registration fails for any reason.
See Also:
registerSensitiveObject(CacheServerSensitive,ObjectHandle), registerSensitiveObject(CacheServerSensitive,java.util.Set), unRegisterSensitiveObject(com.intersys.objects.CacheServerSensitive)

registerSensitiveObject

public void registerSensitiveObject(CacheServerSensitive obj,
                                    ObjectHandle ref)
                             throws CacheException
Registers an object which will be informed of any call to Cache Database which changes a particular proxy object in this client. If such call occur, method onServerCall() of registered object will be called.

Parameters:
obj - an object, implementing com.intersys.CacheServerSensitive interface.
ref - a proxy object, in which registering object is interested.
Throws:
CacheException - if registration fails for any reason.
See Also:
registerSensitiveObject(CacheServerSensitive), registerSensitiveObject(CacheServerSensitive,java.util.Set), unRegisterSensitiveObject(com.intersys.objects.CacheServerSensitive)

registerSensitiveObject

public void registerSensitiveObject(CacheServerSensitive obj,
                                    int ref)
                             throws CacheException
Registers an object which will be informed of any call to Cache Database which changes a particular proxy object in this client. If such call occur, method onServerCall() of registered object will be called.

Parameters:
obj - an object, implementing com.intersys.CacheServerSensitive interface.
ref - an oref of the object in which this object is interested.
Throws:
CacheException - if registration fails for any reason.
See Also:
registerSensitiveObject(CacheServerSensitive), registerSensitiveObject(CacheServerSensitive,java.util.Set), unRegisterSensitiveObject(com.intersys.objects.CacheServerSensitive)

registerSensitiveObject

public void registerSensitiveObject(CacheServerSensitive obj,
                                    Set refSet)
                             throws CacheException
Registers an object which will be informed of any call to Cache Database which changes some particular proxy objects in this client. If such call occur, method onServerCall() of registered object will be called.

Parameters:
obj - an object, implementing com.intersys.CacheServerSensitive interface.
refSet - Set of proxy objects, in which registering object is interested. All elements of this set must be assignable to com.intersys.cklasses.ObjectHandle.
Throws:
CacheException - if registration fails for any reason.
See Also:
registerSensitiveObject(CacheServerSensitive), registerSensitiveObject(CacheServerSensitive,ObjectHandle), unRegisterSensitiveObject(com.intersys.objects.CacheServerSensitive)

unRegisterSensitiveObject

public boolean unRegisterSensitiveObject(CacheServerSensitive obj)
                                  throws CacheException
Unregisters object, previously registered with method registerSensitiveObject.

Parameters:
obj - an object, implementing com.intersys.CacheServerSensitive interface.
Returns:
true if object has been previously registered, false if it was not registred.
Throws:
CacheException - if deregistration fails for any reason.
See Also:
registerSensitiveObject(CacheServerSensitive), registerSensitiveObject(CacheServerSensitive,ObjectHandle), registerSensitiveObject(CacheServerSensitive,java.util.Set)

transactionStart

public void transactionStart()
                      throws CacheException
Starts a transaction

Throws:
CacheException

transactionCommit

public void transactionCommit()
                       throws CacheException
Commits the transaction

Throws:
CacheException

transactionRollback

public void transactionRollback()
                         throws CacheException
Roll the transaction back

Throws:
CacheException

getCacheType

public int getCacheType()
                 throws CacheException
Returns type of client side data cache.

Returns:
type of client side cache, represented as int. In current implementation meaningful is only whether return value is 0 (means no client side caching) or greater than 0 (indicates presense of client side cache).
Throws:
CacheException

getNumberOfOpenObjects

public int getNumberOfOpenObjects()
Returns number of objects opened by client. This number can be changed by garbbage collector in a separate thread, so 2 calls to this method can return different results. This number may be only used as an approximate number for profiling purposes and must not be relied upon.

Returns:
Number of objects opened by this client.

getServerTime

public long getServerTime()
                   throws CacheException
Returns commulative time elapsed during waiting for server response in all calls to Cache server.

Returns:
cummulative server time in milliseconds.
Throws:
CacheException
See Also:
getNumberOfServerCalls(), getServerTime(int)

getNumberOfServerCalls

public int getNumberOfServerCalls()
                           throws CacheException
Returns number of all calls from client to Cache server from Database object creation.

Returns:
number of all calls from client to Cache server.
Throws:
CacheException
See Also:
getNumberOfServerCalls(int), getServerTime()

getServerTime

public long getServerTime(int i)
                   throws CacheException
Returns commulative time elapsed during waiting for server response in calls to Cache server while profile i was on (between calls to setProfileOn(i) and setProfileOff(i)).

Parameters:
i - Profiling cell number.
Returns:
cummulative server time in milliseconds while profile i was on.
Throws:
CacheException
See Also:
getNumberOfServerCalls(int), getServerTime(), setProfileOn(int), setProfileOff(int), CacheDatabase.setNumberOfProfiles(int), CacheDatabase.getNumberOfProfiles()

getNumberOfServerCalls

public int getNumberOfServerCalls(int i)
                           throws CacheException
Returns number of calls from client to Cache server from Database object creation while profile i was on (between calls to setProfileOn(i) and setProfileOff(i)).

Parameters:
i - Profiling cell number.
Returns:
number of calls from client to Cache server while profile i was on.
Throws:
CacheException
See Also:
getNumberOfServerCalls(int), getServerTime(), setProfileOn(int), setProfileOff(int), CacheDatabase.setNumberOfProfiles(int), CacheDatabase.getNumberOfProfiles()

setProfileOn

public void setProfileOn(int i)
                  throws CacheException
Enables gathering profile information for cell i.

Parameters:
i - Profiling cell number.
Throws:
CacheException
See Also:
getNumberOfServerCalls(int), getServerTime(int), setProfileOff(int), CacheDatabase.setNumberOfProfiles(int), CacheDatabase.getNumberOfProfiles()

setProfileOff

public void setProfileOff(int i)
                   throws CacheException
Disables gathering profile information for cell i.

Parameters:
i - Profiling cell number.
Throws:
CacheException
See Also:
getNumberOfServerCalls(int), getServerTime(int), setProfileOn(int), CacheDatabase.setNumberOfProfiles(int), CacheDatabase.getNumberOfProfiles()

setClassLoader

public void setClassLoader(ClassLoader newLoader)
Sets custom class loader for loading Java projections of Cache classes. Notes, that setting another class loader will not affect normal class loading and is used only for classes for objects, received from Cache server.

The primary intention for this method is to facilitate work inside application servers, which use their own class loaders which may differ from the class loader for Database object, which by default would be used to load all classes for Cache proxy objects.

Another possible application of this method is to generate Java projections of Cache classes "on the fly", i.e. at the moment they are required by the application. This is rather limited use, because generation of classes happen at runtime, not at compilation time. To achieve automatic generation and compilation this method should be used in the special form: setClassLoader(new com.intersys.cache.CacheClassLoder("scratch directory path", db));, where db is reference to this database object.

Parameters:
newLoader - the class loader to use.

setConsoleOutput

public void setConsoleOutput(PrintStream out)
Sets the stream used for console output by Cache server-side methods. If any methods attempts to write to a console (or standard output), e.g. by using "Write command the output is redirected to specified stream. By default it is System.out.

Setting output stream to null will suppress output.

Parameters:
out - Stream to be used for console output. If null, then output will be suppressed.

addListener

public boolean addListener(EventListener listener)
Adds another listener for messages from server. In current implementation the only type of messages is writing to console output.

Returns:
true if lsitener was added, false if it was already added before.
See Also:
setConsoleOutput(java.io.PrintStream)

removeListener

public boolean removeListener(EventListener listener)
Removes a listener for messages from server. In current implementation the only type of messages is writing to console output.

Returns:
true if lsitener was removed, false if listener was never added before.
See Also:
setConsoleOutput(java.io.PrintStream)