LEONARDI Application Composer - 8.9.0.40 by W4 S.A.

leon.peer
Class LyTransactionManager

java.lang.Object
  extended by leon.peer.LyTransactionManager

public class LyTransactionManager
extends java.lang.Object

This class is used to manage transactions in an application.

See Also:
LyDataProvider, LyRequestEncoder, LyConnection, LyTransaction

Field Summary
static java.lang.String __VERSION
           
 
Constructor Summary
LyTransactionManager(LyApplication application)
          Constructs a transaction manager.
 
Method Summary
 void abort(LyDataProvider provider)
          Abort all pending transactions (rollback) for a data provider.
 void abort(LyDataSession session)
          Abort all pending transactions (rollback) for a session.
 LyTransaction begin()
          To begin a new transaction.
 LyResponse createObject(LyDataSource dataSource, java.lang.Object peer, LyResponseListener listener, LyClassBinding classBinding)
          Create a new object on the specified data source.
 LyResponse deleteObject(LyDataSource dataSource, java.lang.Object peer, LyResponseListener listener, LyClassBinding classBinding)
          Delete an object on the specified data source.
 LyResponse deleteObjects(LyDataSource dataSource, java.util.Vector<java.lang.Object> peers, LyResponseListener listener, LyClassBinding classBinding)
          Delete a list of objects on the specified data source.
 boolean end(LyTransaction transaction)
          To end a transaction. if an error has occured during the transaction, do a rollback else do a commit.
 boolean end(LyTransaction transaction, boolean commit)
          To end a transaction.
 LyConnection getConnection(LyDataProvider provider)
          Accessor to a connection instance from the connection pool of the specified data provider.
 int getSize(LyDataSource dataSource, LyFilter peerFilter, LyClassBinding classBinding)
          Return the number of objects within the specified data source matching the given filter.
 LyTransaction getTransaction(LyDataProvider provider)
          To get the last open transaction on the current session associated with a data provider.
 LyTransaction getTransaction(LyDataSession session)
          To get the last open transaction on a session.
 LyResponse loadObject(LyDataSource dataSource, LyObjectId peerId, java.util.Vector<LyField> peerFields, LyResponseListener listener, LyClassBinding classBinding)
          Method to load an object from its id on the specified data source.
 LyResponse loadObjects(LyDataSource dataSource, java.util.Vector<LyField> peerFields, LySort peerSort, LyFilter peerFilter, int n, LyResponseListener listener, LyClassBinding classBinding)
          Method for loading objects on the specified data source.
 void releaseConnection(LyConnection connection, LyDataProvider provider)
          Return a connection instance to the connection pool of the specified data provider.
 LyResponse setObject(LyDataSource dataSource, java.lang.Object peer, LyResponseListener listener, LyClassBinding classBinding)
          Set an object on the specified data source.
 LyResponse setObjects(LyDataSource dataSource, java.util.Vector<java.lang.Object> peers, LyResponseListener listener, LyClassBinding classBinding)
          Set a list of objects on the specified data source.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

__VERSION

public static final java.lang.String __VERSION
See Also:
Constant Field Values
Constructor Detail

LyTransactionManager

public LyTransactionManager(LyApplication application)
Constructs a transaction manager. Initialization is done with the init method.

Parameters:
application - Current application instance
Method Detail

begin

public LyTransaction begin()
To begin a new transaction. The new transaction is associated with the current user session.

Returns:
the new created transaction.

end

public boolean end(LyTransaction transaction)
To end a transaction. if an error has occured during the transaction, do a rollback else do a commit.

Parameters:
transaction - The transaction to end
Returns:
true if all operations in the transactions are OK and false if an error occured. WARNING : operations may be completed successfully but the current transaction may be merged in another transactions. If one of the operations in this transaction is in error, all operations of all transactions are rollbacked. When the ended transaction is not the last begin transaction for the current user session (interlaced transactions).

end

public boolean end(LyTransaction transaction,
                   boolean commit)
To end a transaction.

Parameters:
transaction - The transaction to end
commit - Specifiy if the transaction must be committed (true) or aborted (false).
Returns:
true if all operations in the transactions are OK and false if an error occured. WARNING : operations may be completed successfully but the current transaction may be merged in another transactions. If one of the operations in this transaction is in error, all operations of all transactions are rollbacked. When the ended transaction is not the last begin transaction for the current user session (interlaced transactions).

abort

public void abort(LyDataSession session)
Abort all pending transactions (rollback) for a session.

Parameters:
session - the session

abort

public void abort(LyDataProvider provider)
Abort all pending transactions (rollback) for a data provider.

Parameters:
session - the session

getConnection

public LyConnection getConnection(LyDataProvider provider)
Accessor to a connection instance from the connection pool of the specified data provider.

If no connection is available currently, this method will block until a connection is released and available.

Important ! The connection MUST be released after usage so it's available for the connection pool. Invoke releaseConnection when the connection is no longer needed.

Parameters:
provider - the data provider from which we want to get a connection.
Returns:
a connection instance from the connection pool of the specified data provider. The connection instance must be released (releaseConnection) after usage.
See Also:
releaseConnection(leon.peer.LyConnection, leon.peer.LyDataProvider)

releaseConnection

public void releaseConnection(LyConnection connection,
                              LyDataProvider provider)
Return a connection instance to the connection pool of the specified data provider.

The connection reference was obtained by getConnection()

Important ! The connection MUST be released after usage so it's available for the connection pool. Invoke releaseConnection when the connection is no longer needed.

Parameters:
connection - a connection instance from the connection pool of the specified data provider.
provider - the provider to return the connection.
See Also:
releaseConnection(leon.peer.LyConnection, leon.peer.LyDataProvider)

getTransaction

public LyTransaction getTransaction(LyDataProvider provider)
To get the last open transaction on the current session associated with a data provider. If there is a transaction without any associated provider, it returns it. For internal use only.

Parameters:
provider - the associated provider of the search transaction.
Returns:
the last open transaction associated with the specified provider if exists, else null.

getTransaction

public LyTransaction getTransaction(LyDataSession session)
To get the last open transaction on a session.

Parameters:
session - the session
Returns:
the last open transaction on the specified session if exists, else null.

loadObject

public LyResponse loadObject(LyDataSource dataSource,
                             LyObjectId peerId,
                             java.util.Vector<LyField> peerFields,
                             LyResponseListener listener,
                             LyClassBinding classBinding)
Method to load an object from its id on the specified data source. Load fields of an object from a given object id.

Parameters:
dataSource - The data source for loading the object.
peerId - Object identifier corresponding to the object to load.
peerFields - Fields to load (null means all fields).
listener - Listener of the response.
classBinding - binding between logical class and physical class This binding may contain extra information required for encoding the request.
Returns:
Response to the loading.
See Also:
LyDataSource.loadObject(leon.data.LyObjectId, java.util.Vector, leon.data.LyResponseListener, leon.info.binding.LyClassBinding)

loadObjects

public LyResponse loadObjects(LyDataSource dataSource,
                              java.util.Vector<LyField> peerFields,
                              LySort peerSort,
                              LyFilter peerFilter,
                              int n,
                              LyResponseListener listener,
                              LyClassBinding classBinding)
Method for loading objects on the specified data source. Load fields of a specified number of objects sorted by a given sort and that match a given filter.

Parameters:
dataSource - The data source for loading the objects.
peerFields - Fields to load (null means all fields).
peerSort - Gives sort criteria, or null if there is no sort (the order is the one of the physical layer).
peerFilter - Gives filter criteria, or null if there is no filter (all objects).
n - Indicates the number of objects to load (-1 means no limit).
listener - Listener of the response.
classBinding - binding between logical class and physical class This binding may contain extra information required for encoding the request.
Returns:
Response to the loading.
See Also:
LyDataSource.loadObjects(java.util.Vector, leon.info.LySort, leon.info.LyFilter, int, leon.data.LyResponseListener, leon.info.binding.LyClassBinding)

getSize

public int getSize(LyDataSource dataSource,
                   LyFilter peerFilter,
                   LyClassBinding classBinding)
Return the number of objects within the specified data source matching the given filter.

Parameters:
dataSource - The data source for getting the number of objects.
peerFilter - Filter applied on objects for counting.
classBinding - Binding between logical class and physical class. This binding may contain extra information required for encoding the request (such as extra filter).
Returns:
Number of objects matching the given filter in this data source.
See Also:
LyDataSource.getSize()

deleteObject

public LyResponse deleteObject(LyDataSource dataSource,
                               java.lang.Object peer,
                               LyResponseListener listener,
                               LyClassBinding classBinding)
Delete an object on the specified data source.

Parameters:
dataSource - The data source for deleting the object.
peer - Object to delete.
listener - Listener of the response.
classBinding - Binding between logical class and physical class This binding may contain extra information required for encoding the request.
Returns:
Response to the deletion.
See Also:
LyDataSource.deleteObject(java.lang.Object, leon.data.LyResponseListener, leon.info.binding.LyClassBinding)

deleteObjects

public LyResponse deleteObjects(LyDataSource dataSource,
                                java.util.Vector<java.lang.Object> peers,
                                LyResponseListener listener,
                                LyClassBinding classBinding)
Delete a list of objects on the specified data source.

Parameters:
dataSource - The data source for deleting the objects.
peers - List of objects to delete.
listener - Listener of the response.
classBinding - Binding between logical class and physical class This binding may contain extra information required for encoding the request.
Returns:
Response to the deletion.
See Also:
LyDataSource.deleteObjects(java.util.Vector, leon.data.LyResponseListener, leon.info.binding.LyClassBinding)

createObject

public LyResponse createObject(LyDataSource dataSource,
                               java.lang.Object peer,
                               LyResponseListener listener,
                               LyClassBinding classBinding)
Create a new object on the specified data source.

Parameters:
dataSource - The data source for creating the object.
peer - Object to create.
listener - Listener of the response.
classBinding - Binding between logical class and physical class. This binding may contain extra information required for encoding the request.
Returns:
Response to the creation.
See Also:
LyDataSource.createObject(java.lang.Object, leon.data.LyResponseListener, leon.info.binding.LyClassBinding)

setObject

public LyResponse setObject(LyDataSource dataSource,
                            java.lang.Object peer,
                            LyResponseListener listener,
                            LyClassBinding classBinding)
Set an object on the specified data source.

Parameters:
dataSource - The data source for setting the object.
peer - Object to modify.
listener - Listener of the response.
classBinding - Binding between logical class and physical class This binding may contain extra information required for encoding the request.
Returns:
Response to the modification.
See Also:
LyDataSource.setObject(java.lang.Object, leon.data.LyResponseListener, leon.info.binding.LyClassBinding)

setObjects

public LyResponse setObjects(LyDataSource dataSource,
                             java.util.Vector<java.lang.Object> peers,
                             LyResponseListener listener,
                             LyClassBinding classBinding)
Set a list of objects on the specified data source.

Parameters:
dataSource - The data source for setting the objects.
peers - List of objects to modify.
listener - Listener of the response.
classBinding - Binding between logical class and physical class This binding may contain extra information required for encoding the request.
Returns:
Response to the modification.
See Also:
LyDataSource.setObjects(java.util.Vector, leon.data.LyResponseListener, leon.info.binding.LyClassBinding)

(c) January 2013 - W4 S.A.

Website: W4 S.A., contact us: support@w4global.com