org.apache.slide.common
Class AbstractServiceBase

java.lang.Object
  extended byorg.apache.slide.common.AbstractServiceBase
All Implemented Interfaces:
Service, javax.transaction.xa.XAResource
Direct Known Subclasses:
AbstractService, AbstractSimpleService, AbstractXAService

public abstract class AbstractServiceBase
extends java.lang.Object
implements Service

Slide Service abstract implementation.

Version:
$Revision: 1.12 $

Field Summary
protected  java.lang.String LOG_CHANNEL
           
protected  Namespace namespace
          Namespace.
protected  Scope scope
           
 
Fields inherited from interface javax.transaction.xa.XAResource
TMENDRSCAN, TMFAIL, TMJOIN, TMNOFLAGS, TMONEPHASE, TMRESUME, TMSTARTRSCAN, TMSUCCESS, TMSUSPEND, XA_OK, XA_RDONLY
 
Constructor Summary
AbstractServiceBase()
           
 
Method Summary
 boolean cacheResults()
          Indicates whether or not the objects managed by this service should be cached.
abstract  void connect()
          Connects to the underlying data source (if any is needed).
 void connect(CredentialsToken crdtoken)
          Connects to the underlying data source (if any is needed).
 boolean connectIfNeeded()
          Connects to the service, if we were not previously connected.
 boolean connectIfNeeded(CredentialsToken token)
          Connects to the service, if we were not previously connected.
abstract  void disconnect()
          Disconnects from the underlying data source.
 Logger getLogger()
          Logger accessor.
 void initialize(NamespaceAccessToken token)
          Initializes service.
abstract  boolean isConnected()
          This function tells whether or not the service is connected.
abstract  void reset()
          Deletes service underlying data source, if possible (and meaningful).
 void setNamespace(Namespace namespace)
          Namespace setter.
abstract  void setParameters(java.util.Hashtable parameters)
          Initializes the service with a set of parameters.
 void setScope(Scope scope)
          Set the scope of the store as specified in domain.xml.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface javax.transaction.xa.XAResource
commit, end, forget, getTransactionTimeout, isSameRM, prepare, recover, rollback, setTransactionTimeout, start
 

Field Detail

LOG_CHANNEL

protected java.lang.String LOG_CHANNEL

namespace

protected Namespace namespace
Namespace.


scope

protected Scope scope
Constructor Detail

AbstractServiceBase

public AbstractServiceBase()
Method Detail

setScope

public void setScope(Scope scope)
Set the scope of the store as specified in domain.xml.

Specified by:
setScope in interface Service

setNamespace

public void setNamespace(Namespace namespace)
Namespace setter.

Specified by:
setNamespace in interface Service

getLogger

public Logger getLogger()
Logger accessor.

Specified by:
getLogger in interface Service
Returns:
The logger if one has been set for the associated namespace, or the Domain logger otherwise

setParameters

public abstract void setParameters(java.util.Hashtable parameters)
                            throws ServiceParameterErrorException,
                                   ServiceParameterMissingException
Initializes the service with a set of parameters. Those could be :
  • User name, login info
  • Host name on which to connect
  • Remote port
  • JDBC driver whoich is to be used :-)
  • Anything else ...

    Specified by:
    setParameters in interface Service
    Parameters:
    parameters - Hashtable containing the parameters' names and associated values
    Throws:
    ServiceParameterErrorException - Incorrect service parameter
    ServiceParameterMissingException - Service parameter missing

  • connect

    public void connect(CredentialsToken crdtoken)
                 throws ServiceConnectionFailedException
    Connects to the underlying data source (if any is needed). Compatibility implementation for the previous store implementations

    Specified by:
    connect in interface Service
    Parameters:
    crdtoken - the slide token containing e.g. the credential
    Throws:
    ServiceConnectionFailedException - Connection failed

    connect

    public abstract void connect()
                          throws ServiceConnectionFailedException
    Connects to the underlying data source (if any is needed).

    Specified by:
    connect in interface Service
    Throws:
    ServiceConnectionFailedException - Connection failed

    disconnect

    public abstract void disconnect()
                             throws ServiceDisconnectionFailedException
    Disconnects from the underlying data source.

    Specified by:
    disconnect in interface Service
    Throws:
    ServiceDisconnectionFailedException - Disconnection failed

    initialize

    public void initialize(NamespaceAccessToken token)
                    throws ServiceInitializationFailedException
    Initializes service.

    Specified by:
    initialize in interface Service
    Parameters:
    token - Namespace access token, needed if the service needs to access objects or data within the namespace during its initialization
    Throws:
    ServiceInitializationFailedException - May throw an exception if the service has already been initialized before

    reset

    public abstract void reset()
                        throws ServiceResetFailedException
    Deletes service underlying data source, if possible (and meaningful).

    Specified by:
    reset in interface Service
    Throws:
    ServiceResetFailedException - Reset failed

    isConnected

    public abstract boolean isConnected()
                                 throws ServiceAccessException
    This function tells whether or not the service is connected.

    Specified by:
    isConnected in interface Service
    Returns:
    boolean true if we are connected
    Throws:
    ServiceAccessException - Service access error

    connectIfNeeded

    public boolean connectIfNeeded(CredentialsToken token)
                            throws ServiceConnectionFailedException,
                                   ServiceAccessException
    Connects to the service, if we were not previously connected.

    Specified by:
    connectIfNeeded in interface Service
    Parameters:
    token - the Credeantials token containing e.g. the credential
    Returns:
    boolean true if we were not already connected
    Throws:
    ServiceAccessException - Unspecified service access error
    ServiceConnectionFailedException - Connection failed

    connectIfNeeded

    public boolean connectIfNeeded()
                            throws ServiceConnectionFailedException,
                                   ServiceAccessException
    Connects to the service, if we were not previously connected.

    Specified by:
    connectIfNeeded in interface Service
    Returns:
    boolean true if we were not already connected
    Throws:
    ServiceAccessException - Unspecified service access error
    ServiceConnectionFailedException - Connection failed

    cacheResults

    public boolean cacheResults()
    Indicates whether or not the objects managed by this service should be cached. Caching is enabled by default.

    Specified by:
    cacheResults in interface Service
    Returns:
    boolean True if results should be cached