org.jminor.framework.db.provider
Class AbstractEntityConnectionProvider

java.lang.Object
  extended by org.jminor.framework.db.provider.AbstractEntityConnectionProvider
All Implemented Interfaces:
EntityConnectionProvider
Direct Known Subclasses:
LocalEntityConnectionProvider, RemoteEntityConnectionProvider

public abstract class AbstractEntityConnectionProvider
extends Object
implements EntityConnectionProvider

An abstract EntityConnectionProvider implementation.


Constructor Summary
AbstractEntityConnectionProvider(User user)
          Instantiates a new AbstractEntityConnectionProvider.
 
Method Summary
protected abstract  EntityConnection connect()
           
 StateObserver getConnectedState()
          
 EntityConnection getConnection()
          Provides a EntityConnection object, is responsible for returning a healthy EntityConnection object, that is, it must reconnect an invalid connection whether remotely or locally
protected  EntityConnection getConnectionInternal()
           
 User getUser()
          
 boolean isConnected()
          
protected abstract  boolean isConnectionValid()
           
protected  void setConnection(EntityConnection entityConnection)
           
 void setUser(User user)
          Sets the user for this db provider, this invalidates and disconnects the previous connection if any.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.jminor.framework.db.provider.EntityConnectionProvider
disconnect, getDescription
 

Constructor Detail

AbstractEntityConnectionProvider

public AbstractEntityConnectionProvider(User user)
Instantiates a new AbstractEntityConnectionProvider.

Parameters:
user - the user to base the db provider on
Method Detail

getUser

public final User getUser()

Specified by:
getUser in interface EntityConnectionProvider
Returns:
the user used by this db provider

setUser

public final void setUser(User user)
Sets the user for this db provider, this invalidates and disconnects the previous connection if any.

Specified by:
setUser in interface EntityConnectionProvider
Parameters:
user - the user

isConnected

public final boolean isConnected()

Specified by:
isConnected in interface EntityConnectionProvider
Returns:
true if a connection has been established

getConnectedState

public final StateObserver getConnectedState()

Specified by:
getConnectedState in interface EntityConnectionProvider
Returns:
a state active when this provider is connected

getConnection

public final EntityConnection getConnection()
Provides a EntityConnection object, is responsible for returning a healthy EntityConnection object, that is, it must reconnect an invalid connection whether remotely or locally

Specified by:
getConnection in interface EntityConnectionProvider
Returns:
a EntityConnection instance

isConnectionValid

protected abstract boolean isConnectionValid()
Returns:
true if the connection is valid

connect

protected abstract EntityConnection connect()
Returns:
an established connection

getConnectionInternal

protected final EntityConnection getConnectionInternal()

setConnection

protected final void setConnection(EntityConnection entityConnection)