C
- the generic type of the connections to be handledpublic interface ConnectionProvider<C>
Connection
type, which are created from a
configuration object of the generic type Config
.
Providers centralize the logic and parametrization to provision and release connection, while remaining abstracted from the concerns of actually manage those connections.
Implementations are expected to be reusable and thread-safe.
It is valid for implementations to implement any of the lifecycle interfaces or to request external dependencies through any of the JSR-330 annotations. However, implementations are not propagate lifecycle or to perform dependency injection into the generated connections. The runtime will do that automatically at the proper time.
Modifier and Type | Method and Description |
---|---|
C |
connect()
Creates a new connection.
|
void |
disconnect(C connection)
Disposes the given
connection , freeing all its allocated resources |
ConnectionValidationResult |
validate(C connection)
Validates the given
C . |
C connect() throws ConnectionException
The returned connection is expected to be ready to use
Connection
ConnectionException
void disconnect(C connection)
connection
, freeing all its allocated resourcesconnection
- a non null
Connection
.ConnectionValidationResult validate(C connection)
C
.
In invalid connection case, the ConnectionValidationResult
should also return a valid
message ConnectionValidationResult.getMessage()
, exception ConnectionValidationResult.getException()
and code ConnectionValidationResult.getErrorType()
connection
- a non null
C
.ConnectionValidationResult
indicating if the connection
is valid or not.Copyright © 2018. All rights reserved.