Module is.codion.framework.db.core
Package is.codion.framework.db
Interface EntityConnectionProvider
- All Superinterfaces:
AutoCloseable
- All Known Implementing Classes:
AbstractEntityConnectionProvider
Specifies a class responsible for providing a single
EntityConnection 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 ClassesModifier and TypeInterfaceDescriptionstatic interfaceEntityConnectionProvider.Builder<T extends EntityConnectionProvider,B extends EntityConnectionProvider.Builder<T, B>> Builds aEntityConnectionProviderinstances -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final is.codion.common.property.PropertyValue<String>Specifies whether the client should connect locally, via rmi or http, accepted values: local, remote, http
Value type: String
Default value:CONNECTION_TYPE_LOCALstatic final is.codion.common.property.PropertyValue<is.codion.framework.domain.DomainType>Specifies the domain type required for a client connection.
Value type: is.codion.framework.domain.DomainType
Default value: nullstatic final StringIndicates a http database connectionstatic final StringIndicates a local database connectionstatic final StringIndicates a remote database connection -
Method Summary
Modifier and TypeMethodDescriptionvoidaddOnConnectListener(Consumer<EntityConnection> listener) Adds a listener notified each time this connection provider establishes a connection to the databasestatic EntityConnectionProvider.Builder<?,?> builder()clientId()is.codion.common.version.Versionvoidclose()Closes the underlying connection and performs cleanup if required<T extends EntityConnection>
TProvides a EntityConnection object, is responsible for returning a healthy EntityConnection object, that is, it must reconnect an invalid connection whether remotely or locallyReturns a String specifying the type of connection provided by this connection providerbooleanis.codion.framework.domain.DomainTypeis.codion.framework.domain.entity.Entitiesentities()Returns the domain entities this connection is based onvoidremoveOnConnectListener(Consumer<EntityConnection> listener) Removes the given listeneris.codion.common.user.Useruser()
-
Field Details
-
CONNECTION_TYPE_LOCAL
Indicates a local database connection- See Also:
-
CONNECTION_TYPE_REMOTE
Indicates a remote database connection- See Also:
-
CONNECTION_TYPE_HTTP
Indicates a http database connection- See Also:
-
CLIENT_DOMAIN_TYPE
static final is.codion.common.property.PropertyValue<is.codion.framework.domain.DomainType> CLIENT_DOMAIN_TYPESpecifies the domain type required for a client connection.
Value type: is.codion.framework.domain.DomainType
Default value: null -
CLIENT_CONNECTION_TYPE
Specifies whether the client should connect locally, via rmi or http, accepted values: local, remote, http
Value type: String
Default value:CONNECTION_TYPE_LOCAL
-
-
Method Details
-
entities
is.codion.framework.domain.entity.Entities entities()Returns the domain entities this connection is based on- Returns:
- the underlying domain entities
-
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- Type Parameters:
T- the expected EntityConnection type- 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
-
connectionValid
boolean connectionValid()- Returns:
- true if a connection has been establised and the connection is in a valid state
-
addOnConnectListener
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
Removes the given listener- Parameters:
listener- the listener to remove
-
close
void close()Closes the underlying connection and performs cleanup if required- Specified by:
closein interfaceAutoCloseable- See Also:
-
user
is.codion.common.user.User user()- Returns:
- the user used by this connection provider
-
domainType
is.codion.framework.domain.DomainType domainType()- Returns:
- the domain type
-
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
is.codion.common.version.Version clientVersion()- Returns:
- the client version
-
builder
- Returns:
- a unconfigured
EntityConnectionProvider.Builderinstance, based onCLIENT_CONNECTION_TYPEconfiguration value - See Also:
-