Package net.sf.basedb.util.uri
Class ConnectionManagerUtil
java.lang.Object
net.sf.basedb.util.uri.ConnectionManagerUtil
Collects utility methods related to connection managers.
Connection manager factories should be registered as
extensions to the
net.sf.basedb.core.uri.connection-manager
extension point. The methods in this class can then be used to
get information about installed connection manager factories and
to use them for retreiving external file data and information.- Since:
- 3.0
- Author:
- Nicklas
- Last modified
- $Date: 2019-02-26 11:10:15 +0100 (tis, 26 feb. 2019) $
-
Field Summary
Modifier and TypeFieldDescriptionstatic final String
The ID of the connection manager extension point. -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprivate static ConnectionManagerFactory
autoDetect
(ExtensionsInvoker<ConnectionManagerFactory> invoker, URI uri) Use auto-detection and return the first factory that can handle the given uri.static ConnectionManager
createConnectionManager
(URI uri, ConnectionParameters parameters) Utility method for creating a connection manager.static ConnectionManager
createConnectionManager
(File file, ConnectionParameters parameters) Utility method for creating a connection manager for a file item.static ConnectionManagerFactory
findFactory
(URI uri) Find a factory for the given URI.static List<ConnectionManagerFactory>
Get a list with all connection manager factories.static ConnectionManagerFactory
getFactory
(String id) Get the connection manager factory with the given extension id.private static ConnectionManagerFactory
Get the first factory returned by the invoker.private static ExtensionsInvoker<ConnectionManagerFactory>
getInvoker
(ClientContext context, ExtensionsFilter filter) Get an invoker for using the connection manager factory extensions.
-
Field Details
-
EXTENSION_POINT_ID
The ID of the connection manager extension point.- See Also:
-
-
Constructor Details
-
ConnectionManagerUtil
public ConnectionManagerUtil()
-
-
Method Details
-
getFactories
Get a list with all connection manager factories. No context information will be available to the action factories that creates the connection manager factories.- Returns:
- A list with the factories
-
getFactory
Get the connection manager factory with the given extension id. No context information will be available to the factory when it is created.- Parameters:
id
- The ID of the factory- Returns:
- A factory instance or null if not found
-
findFactory
Find a factory for the given URI. This method will iterate the registered factories in their priority/index order and callConnectionManagerFactory.supports(URI)
for all factories that supports auto-detection. The first one that gives a successful response is returned. If no factory supports the given URI, null is returned.Note to extension developers: The given uri is available to the action factory as "uri" attribute of the context.
- Parameters:
uri
- The URI (null is not allowed)- Returns:
- An UriHandlerFactory or null if no factory was found
-
createConnectionManager
Utility method for creating a connection manager. If a specific factory is specified in the connection parameters, that factory is used, otherwisefindFactory(URI)
is used for auto-detection. If no factory is found an exception is thrown, otherwise a connection manger is created by the factory method:ConnectionManagerFactory.createConnectionManager(URI, ConnectionParameters)
- Parameters:
uri
- The URI (required)parameters
- Connection parameters, such as user login/password, etc. (optional)- Returns:
- A connection manager
-
createConnectionManager
Utility method for creating a connection manager for a file item. If a specific factory is specified in the connection parameters, that factory is used, otherwise auto-detection is used. The auto-detection is similar to thefindFactory(URI)
method but this time the context information for the action factory contains the file object and connection parameters.- Parameters:
file
- The (external) file (required)parameters
- Connection parameters, such as user login/password, etc. (optional)- Returns:
- A connection manager
-
getInvoker
private static ExtensionsInvoker<ConnectionManagerFactory> getInvoker(ClientContext context, ExtensionsFilter filter) Get an invoker for using the connection manager factory extensions. -
getFirst
private static ConnectionManagerFactory getFirst(ExtensionsInvoker<ConnectionManagerFactory> invoker) Get the first factory returned by the invoker. -
autoDetect
private static ConnectionManagerFactory autoDetect(ExtensionsInvoker<ConnectionManagerFactory> invoker, URI uri) Use auto-detection and return the first factory that can handle the given uri.
-