LEONARDI Application Composer - 8.9.0.40 by W4 S.A.

leon.peer
Class LyDataProvider

java.lang.Object
  extended by leon.peer.LyDataProvider
Direct Known Subclasses:
LyExtendDataProvider, LyInfoProvider, LyLocalDataProvider, LyPeerDataProvider, LyUnionDataProvider

public abstract class LyDataProvider
extends java.lang.Object

This class is used by DataSources to transmit their requests to an instance of RequestEncoder.

The LyDataProvider class implements the connector. Every instance of LyDataSource is associated to an instance of LyDataProvider.

The services of the LyDataProvider classes are :
- Manage instances of the LyConnection (connection to the information system : RDBMS, files, application server, corba connection ...).
- Create the description of physical data in memory and make the link with the logical layer.
- Create instances of LyRequestEncoder, associated to the LyDataSource instances : the encoder implements the communication between the dataSource and the connection. (Request encoding, connection service calls ...)
- Accessors to valid LyConnection instances for the LyRequestEncoder instances.

LyDataProvider implements a connection pool to manage multiple connections as a connection stack. The number of connection in the pool is a parameter (default is 1 single connection).

Remark : current implementation only uses a number of connection pool for SQL data providers, or programmatically in the code of a specific data provider.

See Also:
LyRequestEncoder, LyConnection

Field Summary
static java.lang.String __VERSION
           
 
Constructor Summary
LyDataProvider(LyApplication application, LyLocation location)
          Constructs a data provider.
LyDataProvider(LyApplication application, java.lang.String id)
          Deprecated. should use LyDataProvider(LyApplication application, LyLocation location) instead of this constructor.
 
Method Summary
 boolean canBeFullyLoaded(LyClass aClass)
          Indicates if this data provider can be fully loaded.
 boolean close()
          Closes all connections from the connection pool.
 void dumpConnections()
           
 LyApplication getApplication()
          Accessor to the application instance.
 LyConnection getConnection()
          Accessor to a connection instance from the connection pool.
 LyEnvironment getEnvironment()
          Accessor to the environment instance.
 LyEventNotifier getEventNotifier()
          Accessor to the notification service added to this data-provider.
 java.lang.String getId()
          Accessor to the id of the provider.
 LyLocation getLocation()
          Accessor to the location of the provider.
 int getNbAvailableConnection()
          Accessor to the number of connections available in the connection pool.
 int getNbConnection()
          Accessor to the max number of connections available in the connection pool.
abstract  LyRequestEncoder getRequestEncoder(LyDataSource dataSource)
          Create a specific request encoder for the specified dataSource.
 boolean hasLostConnection()
          Tests if the connection with the physical layer has been lost or not.
 boolean isConnectionReady()
          Tests if the data connection is ready or not.
 boolean isModified()
          Checks if this provider was modified.
 boolean isModified(LyClass modifiedClass)
          Checks if the given class was modified for this provider.
 boolean isNotifierReady()
          Tests if the notifier is ready or not.
 boolean isXASupported()
          Tests if this data provider supports the XA protocol or not.
 void releaseConnection(LyConnection connection)
          Return a connection instance to the connection pool.
 boolean save()
          To save data managed by this provider.
 void setEventNotifier(LyEventNotifier notifier)
          Modifier of the notification service added to this data-provider.
 void setLocation(LyLocation location)
          Sets location on provider.
 void setModified(boolean modified, LyClass modifiedClass, java.lang.Object object)
          Sets the given class as modified on this provider.
 void setNbConnection(int nbConnection)
          Sets the number of connection available in the connection pool.
 void sleep()
          This method is called when the application is going on sleeping mode.
 boolean validate()
          This method is used to build all the class peers for all the classInfo.
 boolean validate(LyInfoList<LyClassInfo> classInfos)
          This method is used to build all the class peers for all the classInfo.
 boolean validateNotifier(LyInfoList<LyClassInfo> classInfos)
          Validate the associated event notifier if exists.
 boolean wakeUp()
          This method is called when the application is going out of sleeping mode Default implementation call create the connection pool and wakes up the notifier.
 
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

LyDataProvider

public LyDataProvider(LyApplication application,
                      LyLocation location)
Constructs a data provider. Initialization is done with the init method.

Parameters:
application - Current application instance
location - This value is obtained from the location parameter in the meta model.

LyDataProvider

public LyDataProvider(LyApplication application,
                      java.lang.String id)
Deprecated. should use LyDataProvider(LyApplication application, LyLocation location) instead of this constructor.

Constructs a data provider. Initialization is done with the init method.

Parameters:
application - Current application instance
id - Identifier of this dataProvider. This value is obtained from the location parameter in the meta model.
Method Detail

isConnectionReady

public boolean isConnectionReady()
Tests if the data connection is ready or not.

Returns:
true if the data connection is ready, false otherwise.

isNotifierReady

public boolean isNotifierReady()
Tests if the notifier is ready or not.

Returns:
true if notifier is ready, false otherwise.

hasLostConnection

public boolean hasLostConnection()
Tests if the connection with the physical layer has been lost or not.

Returns:
true if the connection with the physical layer has been detected lost, false otherwise.

setLocation

public void setLocation(LyLocation location)
Sets location on provider.

Parameters:
location - New location for the provider.

getApplication

public final LyApplication getApplication()
Accessor to the application instance.

Returns:
the reference to the application

getLocation

public final LyLocation getLocation()
Accessor to the location of the provider.

Returns:
Location of this provider.

getId

public final java.lang.String getId()
Accessor to the id of the provider.

Returns:
Id of this provider.

getEnvironment

public final LyEnvironment getEnvironment()
Accessor to the environment instance.

Returns:
the reference to the environment

getEventNotifier

public final LyEventNotifier getEventNotifier()
Accessor to the notification service added to this data-provider. A notification service is used to post / receive data changes such as creation / deletion / modification. (For example JMS, Bus...) This may be null if no notification service is required.

Returns:
The notification service associated to this data provider.

getNbConnection

public final int getNbConnection()
Accessor to the max number of connections available in the connection pool.

Returns:
number of connection available. If <= 1 , one connection should be used.

setNbConnection

public void setNbConnection(int nbConnection)
Sets the number of connection available in the connection pool.

Parameters:
nbConnection - number of connection available. If <= 1 , one connection is used.

getNbAvailableConnection

public final int getNbAvailableConnection()
Accessor to the number of connections available in the connection pool.

Returns:
number of connection available. If <= 1 , one connection should be used.

setEventNotifier

public void setEventNotifier(LyEventNotifier notifier)
Modifier of the notification service added to this data-provider. A notification service is used to post / receive data changes such as creation / deletion / modification. (For example JMS, Bus...) This may be null if no notification service is required.

Parameters:
notifier - the notification service to associate with this data provider.

validate

public boolean validate()
This method is used to build all the class peers for all the classInfo.

Returns:
true if the valaitation was successful.

validate

public boolean validate(LyInfoList<LyClassInfo> classInfos)
This method is used to build all the class peers for all the classInfo. It must be specialized by subclasses. Basically, this method associates the dataProvider with local classes. A class is local if there is no binding.

Parameters:
classInfos - Classes to validate.
Returns:
true if the validation was successful.

validateNotifier

public boolean validateNotifier(LyInfoList<LyClassInfo> classInfos)
Validate the associated event notifier if exists.

Parameters:
classInfos - Classes to validate.
Returns:
true if the validation was successful.

sleep

public void sleep()
This method is called when the application is going on sleeping mode. Default implementation call close method and set the notifier into sleeping mode. (untill a further call to wakeUp()

Application will restart after calling wakeUp()

See Also:
close(), wakeUp()

wakeUp

public boolean wakeUp()
This method is called when the application is going out of sleeping mode Default implementation call create the connection pool and wakes up the notifier.

See Also:
sleep()

close

public boolean close()
Closes all connections from the connection pool.

Returns:
true if the request completed successfully.
See Also:
createConnections(int)

save

public final boolean save()
To save data managed by this provider.

Returns:
true if all is all right, else false.

getConnection

public final LyConnection getConnection()
Accessor to a connection instance from the connection pool.

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.

Returns:
a connection instance from the connection pool. The connection instance must be released (releaseConnection) after usage.
See Also:
releaseConnection(leon.peer.LyConnection)

releaseConnection

public final void releaseConnection(LyConnection connection)
Return a connection instance to the connection pool.

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.
See Also:
releaseConnection(leon.peer.LyConnection)

getRequestEncoder

public abstract LyRequestEncoder getRequestEncoder(LyDataSource dataSource)
Create a specific request encoder for the specified dataSource.

This method is used internally, but subclasses should override this method and create an instance of their own (specific) request encoder.

Default returns a LyRequestEncoder instance.

Parameters:
dataSource - reference to the dataSource associated to this request encoder.
Returns:
the specific LyRequestEncoder for the specified dataSource.

isXASupported

public boolean isXASupported()
Tests if this data provider supports the XA protocol or not. Subclasses may override this method. The default implementation is to return false.

Returns:
true if this provider supports the XA protocol, false otherwise.

canBeFullyLoaded

public boolean canBeFullyLoaded(LyClass aClass)
Indicates if this data provider can be fully loaded.

Returns:
true if the provider can load all objects. False otherwise.

dumpConnections

public void dumpConnections()

setModified

public void setModified(boolean modified,
                        LyClass modifiedClass,
                        java.lang.Object object)
Sets the given class as modified on this provider.

Parameters:
modified - True if modified, false otherwise.
modifiedClass - Class that was modified.
object - Modified instance(s) (may be null).

isModified

public boolean isModified()
Checks if this provider was modified.

Returns:
True if modified, false otherwise.

isModified

public boolean isModified(LyClass modifiedClass)
Checks if the given class was modified for this provider.

Parameters:
modifiedClass - Class that is checked.
Returns:
True if modified, false otherwise.

(c) January 2013 - W4 S.A.

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