org.caleigo.core
Class AbstractDataService

java.lang.Object
  extended byorg.caleigo.core.AbstractDataService
All Implemented Interfaces:
IDataService, IDistributable, ISecureService, IService, java.io.Serializable
Direct Known Subclasses:
CachedDataService, JDBCDataService, JDBCPreparedStatementDataService, MemoryDataService, TunneledDataService

public abstract class AbstractDataService
extends java.lang.Object
implements IDataService

AbstractDataService provides an abstract implementation of the IDataService interface that uses an abstract IDataTransaction to implement its function. Descendants only need to to implement the newTransaction() and ping() methods plus the commit() method of the internal AbstractDataTransaction class.

Version:
1.00
Author:
Dennis Zikovic
See Also:
Serialized Form

Nested Class Summary
static class AbstractDataService.AbstractDataTransaction
           
 
Field Summary
static int DEFAULT_TIMEOUT
           
 
Constructor Summary
AbstractDataService(java.lang.Object serviceType, java.lang.Object serviceIdentity, IDataSourceDescriptor dataSourceDescriptor)
          Default constructor for AbstractDataService.
 
Method Summary
protected  void checkEntityAsDeletable(IEntity entity)
          Checks if the entity is deletable else an exception is thrown.
protected  void checkEntityAsStorable(IEntity entity)
          Checks if the entity is storable else an exception is thrown.
 void delete(IEntity entity)
          Deletes a single entity object to the database.
 void finalizeService()
          This method is always called by the ServiceManager before the service is released.
 IProxyService getCustomProxyService(ITunnel tunnel)
          Returns an IProxyService that is responsible for handling remote invokations of this service.
 IDataSourceDescriptor getDataSourceDescriptor()
          This method provides access to the IDataSourceDescriptor that describes the entity meta structure of the information source that a specific data service provides access to.
 java.lang.Object getServiceIdentity()
          Returns the URI defining the a unique individual service.
 java.lang.Object getServiceInterface()
          Returns the service object that this service provides.
 java.lang.Class getServiceInterfaceClass()
          Returns the class object the defines the service interface that all services with the same type provides.
 java.lang.Object getServiceType()
          Returns a URI that defines the type of this service.
 int getTimeout()
           
 boolean hasCustomProxyService()
          If this method returns true then the method getCustomProxyService must not return null.
 void initializeService()
          This method is always called by the ServiceManager before any other method in the service is called.
 boolean isValidating()
           
 IEntity load(IEntityDescriptor entityDescriptor, Qualifier identitQualifier)
          The load method returnes a single entity object intentified by the provided indentity qualifier that must be able to uniquely identify a single entity instance.
 ISelection loadSelection(DataQuery dataQuery)
          Loads a selection of entities identyfied by the provided reusable dataQuery object.
 ISelection loadSelection(IEntityDescriptor entityDescriptor, Qualifier qualifier)
          Loads a selection of entities identyfied by the provided qualifier.
abstract  IDataTransaction newTransaction()
          Returns a new IDataTransaction object that can be used to batch data operations and wrap them in a transaction.
abstract  boolean ping()
          Should return true if the service is online and reponding to calls.
 void refresh(IEntity entity)
          Reloads a single entity object from the database.
protected  void setEntityData(IEntity entity, int j, java.lang.Object data)
          Help method that sets field data with better performance.
 void setTimeout(int timeout)
          Sets the timeout for asynchoniesly executed commits.
 void setValidating(boolean validating)
           
 void store(IEntity entity)
          Stores a single entity object to the database.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_TIMEOUT

public static final int DEFAULT_TIMEOUT
See Also:
Constant Field Values
Constructor Detail

AbstractDataService

public AbstractDataService(java.lang.Object serviceType,
                           java.lang.Object serviceIdentity,
                           IDataSourceDescriptor dataSourceDescriptor)
Default constructor for AbstractDataService.

Method Detail

newTransaction

public abstract IDataTransaction newTransaction()
Description copied from interface: IDataService
Returns a new IDataTransaction object that can be used to batch data operations and wrap them in a transaction.

Specified by:
newTransaction in interface IDataService

ping

public abstract boolean ping()
Should return true if the service is online and reponding to calls. Note that initializeService() must be called prior to this method.

Specified by:
ping in interface IService

getDataSourceDescriptor

public IDataSourceDescriptor getDataSourceDescriptor()
Description copied from interface: IDataService
This method provides access to the IDataSourceDescriptor that describes the entity meta structure of the information source that a specific data service provides access to.

Specified by:
getDataSourceDescriptor in interface IDataService

load

public IEntity load(IEntityDescriptor entityDescriptor,
                    Qualifier identitQualifier)
             throws DataServiceException
Description copied from interface: IDataService
The load method returnes a single entity object intentified by the provided indentity qualifier that must be able to uniquely identify a single entity instance.

Specified by:
load in interface IDataService
Throws:
DataServiceException

loadSelection

public ISelection loadSelection(IEntityDescriptor entityDescriptor,
                                Qualifier qualifier)
                         throws DataServiceException
Description copied from interface: IDataService
Loads a selection of entities identyfied by the provided qualifier.

Specified by:
loadSelection in interface IDataService
Throws:
DataServiceException

loadSelection

public ISelection loadSelection(DataQuery dataQuery)
                         throws DataServiceException
Description copied from interface: IDataService
Loads a selection of entities identyfied by the provided reusable dataQuery object.

Specified by:
loadSelection in interface IDataService
Throws:
DataServiceException

store

public void store(IEntity entity)
           throws DataServiceException
Description copied from interface: IDataService
Stores a single entity object to the database.

Specified by:
store in interface IDataService
Throws:
DataServiceException

delete

public void delete(IEntity entity)
            throws DataServiceException
Description copied from interface: IDataService
Deletes a single entity object to the database. Note that the emtity object can still be used and even stored again posssibly to another data source.

Specified by:
delete in interface IDataService
Throws:
DataServiceException

refresh

public void refresh(IEntity entity)
             throws DataServiceException
Description copied from interface: IDataService
Reloads a single entity object from the database.

Specified by:
refresh in interface IDataService
Throws:
DataServiceException

initializeService

public void initializeService()
This method is always called by the ServiceManager before any other method in the service is called.

Specified by:
initializeService in interface IService

finalizeService

public void finalizeService()
This method is always called by the ServiceManager before the service is released. No other method calls will then be performed on this instance of the service.

Specified by:
finalizeService in interface IService

getServiceInterface

public java.lang.Object getServiceInterface()
Returns the service object that this service provides. This object should always implement the interface defined by the service interface class.

Specified by:
getServiceInterface in interface IService

getServiceInterfaceClass

public java.lang.Class getServiceInterfaceClass()
Returns the class object the defines the service interface that all services with the same type provides.

Specified by:
getServiceInterfaceClass in interface IService

getServiceType

public java.lang.Object getServiceType()
Returns a URI that defines the type of this service. Note that there can be multiple services implementing the same service type but implementations of a given type must implement the same service interface.

Specified by:
getServiceType in interface IService

getServiceIdentity

public java.lang.Object getServiceIdentity()
Returns the URI defining the a unique individual service.

Specified by:
getServiceIdentity in interface IService

hasCustomProxyService

public boolean hasCustomProxyService()
If this method returns true then the method getCustomProxyService must not return null.

Specified by:
hasCustomProxyService in interface IService

getCustomProxyService

public IProxyService getCustomProxyService(ITunnel tunnel)
Returns an IProxyService that is responsible for handling remote invokations of this service.

Specified by:
getCustomProxyService in interface IService

isValidating

public boolean isValidating()

setValidating

public void setValidating(boolean validating)

setTimeout

public void setTimeout(int timeout)
Sets the timeout for asynchoniesly executed commits. It the timeout is set to 0, no timeout will be used.

Parameters:
timeout - the timeout in seconds.

getTimeout

public int getTimeout()

checkEntityAsStorable

protected void checkEntityAsStorable(IEntity entity)
                              throws DataServiceException
Checks if the entity is storable else an exception is thrown.

Throws:
DataServiceException

checkEntityAsDeletable

protected void checkEntityAsDeletable(IEntity entity)
                               throws DataServiceException
Checks if the entity is deletable else an exception is thrown.

Throws:
DataServiceException

setEntityData

protected void setEntityData(IEntity entity,
                             int j,
                             java.lang.Object data)
Help method that sets field data with better performance. The method does if possible avoid the setData method that has a considerable overhead in time and not least memory performance.



Copyright © 2005 Caleigo. All Rights Reserved.