Module is.codion.framework.db.core
Package is.codion.framework.db
Interface EntityConnectionProvider
-
- All Superinterfaces:
AutoCloseable
- All Known Subinterfaces:
HttpEntityConnectionProvider
,LocalEntityConnectionProvider
,RemoteEntityConnectionProvider
- All Known Implementing Classes:
AbstractEntityConnectionProvider
public interface EntityConnectionProvider extends AutoCloseable
Specifies a class responsible for providing a singleEntityConnection
instance.connection()
is guaranteed to return a healthy connection or throw an exception. A factory class for handing out EntityConnectionProviders according to system properties.
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static interface
EntityConnectionProvider.Builder<T extends EntityConnectionProvider,B extends EntityConnectionProvider.Builder<T,B>>
Builds aEntityConnectionProvider
instances
-
Field Summary
Fields Modifier and Type Field Description static PropertyValue<String>
CLIENT_CONNECTION_TYPE
Specifies whether the client should connect locally, via rmi or http, accepted values: local, remote, http
Value type: String
Default value: localstatic PropertyValue<String>
CLIENT_DOMAIN_CLASS
Specifies the name of the domain model class required for a client connection.
Value type: String
Default value: nullstatic String
CONNECTION_TYPE_HTTP
Indicates a http database connectionstatic String
CONNECTION_TYPE_LOCAL
Indicates a local database connectionstatic String
CONNECTION_TYPE_REMOTE
Indicates a remote database connection
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Modifier and Type Method Description void
addOnConnectListener(EventDataListener<EntityConnection> listener)
Adds a listener notified each time this connection provider establishes a connection to the databasestatic EntityConnectionProvider.Builder<?,?>
builder()
UUID
clientId()
String
clientTypeId()
Version
clientVersion()
void
close()
Logs out, disconnects and performs cleanup if requiredEntityConnection
connection()
Provides a EntityConnection object, is responsible for returning a healthy EntityConnection object, that is, it must reconnect an invalid connection whether remotely or locallyString
connectionType()
Returns a String specifying the type of connection provided by this connection providerString
description()
String
domainClassName()
Entities
entities()
Returns the domain entities this connection is based onboolean
isConnected()
boolean
isConnectionValid()
void
removeOnConnectListener(EventDataListener<EntityConnection> listener)
Removes the given listenerUser
user()
-
-
-
Field Detail
-
CONNECTION_TYPE_LOCAL
static final String CONNECTION_TYPE_LOCAL
Indicates a local database connection- See Also:
CLIENT_CONNECTION_TYPE
, Constant Field Values
-
CONNECTION_TYPE_REMOTE
static final String CONNECTION_TYPE_REMOTE
Indicates a remote database connection- See Also:
CLIENT_CONNECTION_TYPE
, Constant Field Values
-
CONNECTION_TYPE_HTTP
static final String CONNECTION_TYPE_HTTP
Indicates a http database connection- See Also:
CLIENT_CONNECTION_TYPE
, Constant Field Values
-
CLIENT_DOMAIN_CLASS
static final PropertyValue<String> CLIENT_DOMAIN_CLASS
Specifies the name of the domain model class required for a client connection.
Value type: String
Default value: null
-
CLIENT_CONNECTION_TYPE
static final PropertyValue<String> CLIENT_CONNECTION_TYPE
Specifies whether the client should connect locally, via rmi or http, accepted values: local, remote, http
Value type: String
Default value: local
-
-
Method Detail
-
entities
Entities entities()
Returns the domain entities this connection is based on- Returns:
- the underlying domain entities
-
connection
EntityConnection connection()
Provides a EntityConnection object, is responsible for returning a healthy EntityConnection object, that is, it must reconnect an invalid connection whether remotely or locally- Returns:
- a EntityConnection instance
-
connectionType
String connectionType()
Returns a String specifying the type of connection provided by this connection provider- Returns:
- a String specifying the type of connection, e.g. "local" or "remote"
-
description
String description()
- Returns:
- a short description of the database provider
-
isConnected
boolean isConnected()
- Returns:
- true if a connection has been established, note that this does not check if the actual connection is valid, only that one has been established.
- See Also:
isConnectionValid()
-
isConnectionValid
boolean isConnectionValid()
- Returns:
- true if a connection has been establised and the connection is in a valid state
-
addOnConnectListener
void addOnConnectListener(EventDataListener<EntityConnection> listener)
Adds a listener notified each time this connection provider establishes a connection to the database- Parameters:
listener
- a listener notified when a connection is established
-
removeOnConnectListener
void removeOnConnectListener(EventDataListener<EntityConnection> listener)
Removes the given listener- Parameters:
listener
- the listener to remove
-
close
void close()
Logs out, disconnects and performs cleanup if required- Specified by:
close
in interfaceAutoCloseable
-
user
User user()
- Returns:
- the user used by this connection provider
-
domainClassName
String domainClassName()
- Returns:
- the domain model classname
-
clientId
UUID clientId()
- Returns:
- the UUID identifying this client connection
-
clientTypeId
String clientTypeId()
- Returns:
- the String identifying the client type for this connection provider
-
clientVersion
Version clientVersion()
- Returns:
- the client version
-
builder
static EntityConnectionProvider.Builder<?,?> builder()
- Returns:
- a unconfigured
EntityConnectionProvider.Builder
instance, based onCLIENT_CONNECTION_TYPE
configuration value - See Also:
CLIENT_CONNECTION_TYPE
-
-