public abstract class BootstrapConnector<K> extends Object implements Connector, ConnectorCacheFactory<K,BootstrapConnector.ClassLoaderCache<K>,BrowseContext>
The ClassLoader information will be cached indefinitely by default. If the service classes will be periodically
updated, the ClassLoaderCache can be subclassed and the ConnectorCache.isValid()
method overridden to handle
periodic checks for updates or whatever other logic is necessary.
As with a normal Connector implementation, all methods must be thread-safe. To make that easier, the
createCache(K, com.boomi.connector.api.BrowseContext)
method is synchronized.
Modifier and Type | Class and Description |
---|---|
static class |
BootstrapConnector.ClassLoaderCache<K>
ConnectorCache implementation used to cache a service specific ClassLoader and Connector implementation.
|
Modifier | Constructor and Description |
---|---|
protected |
BootstrapConnector() |
Modifier and Type | Method and Description |
---|---|
Browser |
createBrowser(BrowseContext browseContext)
Returns a Browser for this connector.
|
BootstrapConnector.ClassLoaderCache<K> |
createCache(K key,
BrowseContext browseContext)
Returns a new instance of a ConnectorCache for the given key and context.
|
protected abstract BootstrapConnector.ClassLoaderCache<K> |
createClassLoaderCache(K key,
BrowseContext browseContext)
Returns a new ClassLoaderCache instance.
|
protected abstract K |
createClassLoaderCacheKey(BrowseContext browseContext)
Returns the key which should be used to cache the ClassLoaderCache.
|
Operation |
createOperation(OperationContext operationContext)
Returns the actual Operation.
|
void |
initialize(AtomContext newContext)
Does any startup initialization for this connector.
|
protected Connector |
loadConnectorDelegate(String implClassName,
ClassLoader cl)
Utility method which loads the delegate Connector implementation with the given implClassName from the given
ClassLoader.
|
public void initialize(AtomContext newContext)
Connector
This call may do expensive things like open connections or other resources which will be used throughout the
Connector's lifecycle. Connectors are never explicitly closed, so explicit resource cleanup (if necessary) should
be managed through garbage-collector hooks (e.g. reference objects or finalize). Note that any resources cached
at the Connector level should not be account specific. The preferred resource cache is the one returned by
a call to ConnectorContext.getConnectorCache()
as it is Boomi account specific and therefore may be used to
cache account specific information.
initialize
in interface Connector
newContext
- the static atom contextpublic Browser createBrowser(BrowseContext browseContext)
ConnectorContext.getConnectionProperties()
if the configuration is marked "requireConnectionForBrowse" and all
operation fields marked "includeInBrowse will be provided in BrowseContext.getOperationProperties()
(where
the keys will be the relevant field's "id" and the values will be of the appropriate Java type for the relevant
field's "type").
This call should be relatively cheap as Browsers are only ever created for a single invocation. Any resource
caching should be handled at the Connector level or via the ConnectorContext.getConnectorCache()
.
This implementation loads a valid instance of ClassLoaderCache and delegates the createBrowser()
call to
the referenced delegate Connector.
createBrowser
in interface Connector
browseContext
- the context for this browse operation. this context is considered to be owned by the Browser after
this call and may be held by the Browser for use in subsequent method calls.public Operation createOperation(OperationContext operationContext)
ConnectorContext.getConnectionProperties()
and operation all fields will be provided in
BrowseContext.getOperationProperties()
(where the keys will be the relevant field's "id" and the values
will be of the appropriate Java type for the relevant field's "type").
This call should be relatively cheap as Operations are only ever created for a single invocation. Any resource
caching should be handled at the Connector level or via the ConnectorContext.getConnectorCache()
.
This implementation loads a valid instance of ClassLoaderCache and delegates the createOperation()
call
to the referenced delegate Connector.
createOperation
in interface Connector
operationContext
- the context for this connector operation. this context is considered to be owned by the Operation
after this call and may be held by the Operation for use in subsequent method calls.public final BootstrapConnector.ClassLoaderCache<K> createCache(K key, BrowseContext browseContext)
Creates a ClassLoaderCache instance by calling createClassLoaderCache(K, com.boomi.connector.api.BrowseContext)
and returns it. This method is
synchronized in order to simplify implementing this method in a thread-safe manner.
createCache
in interface ConnectorCacheFactory<K,BootstrapConnector.ClassLoaderCache<K>,BrowseContext>
key
- the key by which this ConnectorCache will be cached in the connector cachebrowseContext
- the current connector context. Note, this context should not be held by the ConnectorCache
instance, but may be used to retrieve connection properties.protected Connector loadConnectorDelegate(String implClassName, ClassLoader cl) throws Exception
implClassName
- the fully-qualified name of the service specific Connector implementationcl
- the ClassLoader which contains all the necessary classes for accessing the serviceException
protected abstract K createClassLoaderCacheKey(BrowseContext browseContext)
browseContext
- current browse/operation contextprotected abstract BootstrapConnector.ClassLoaderCache<K> createClassLoaderCache(K key, BrowseContext browseContext) throws Exception
loadConnectorDelegate(java.lang.String, java.lang.ClassLoader)
).key
- key returned from a call to createClassLoaderCacheKey(com.boomi.connector.api.BrowseContext)
browseContext
- current browse/operation contextException