Class BootstrapConnector<K>

  • All Implemented Interfaces:
    Connector, ConnectorCacheFactory<K,​BootstrapConnector.ClassLoaderCache<K>,​BrowseContext>

    public abstract class BootstrapConnector<K>
    extends Object
    implements Connector, ConnectorCacheFactory<K,​BootstrapConnector.ClassLoaderCache<K>,​BrowseContext>
    Connector base class which can be used to implement a Connector which downloads the actual service classes at runtime. The connector archive should include a subclass of this class which does not use any service specific classes. The subclass is responsible for downloading the service classes and constructing a new classloader including the service specific classes. Once this classloader has been created, it can be used to load the actual Connector implementation (this implementation can use any service specific classes it desires). The subclass of this class will delegate all the Connector method invocations to this delegate Connector implementation. The ClassLoader and delegate Connector will be cached in an instance of a ClassLoaderCache.

    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.

    • Constructor Detail

      • BootstrapConnector

        protected BootstrapConnector()
    • Method Detail

      • initialize

        public void initialize​(AtomContext newContext)
        Description copied from interface: Connector
        Does any startup initialization for this connector. This will be called exactly once (within external synchronization) after the Connector is instantiated and before any other methods are called on it.

        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.

        Specified by:
        initialize in interface Connector
        Parameters:
        newContext - the static atom context
      • createBrowser

        public Browser createBrowser​(BrowseContext browseContext)
        Returns a Browser for this connector. All connection fields from the connector's descriptor will be provided in 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.

        Specified by:
        createBrowser in interface Connector
        Parameters:
        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.
        Returns:
        a Browser for use when browsing this connector
      • createOperation

        public Operation createOperation​(OperationContext operationContext)
        Returns the actual Operation. All connection fields from the connector's descriptor will be provided in 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.

        Specified by:
        createOperation in interface Connector
        Parameters:
        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.
        Returns:
        an Operation for use when executing operations for this connector
      • loadConnectorDelegate

        protected Connector loadConnectorDelegate​(String implClassName,
                                                  ClassLoader cl)
                                           throws Exception
        Utility method which loads the delegate Connector implementation with the given implClassName from the given ClassLoader.
        Parameters:
        implClassName - the fully-qualified name of the service specific Connector implementation
        cl - the ClassLoader which contains all the necessary classes for accessing the service
        Returns:
        the service specific Connector implementation, initialized and ready to go
        Throws:
        Exception
      • createClassLoaderCacheKey

        protected abstract K createClassLoaderCacheKey​(BrowseContext browseContext)
        Returns the key which should be used to cache the ClassLoaderCache. The key should include whatever information is required to uniquely identify the ClassLoader information.
        Parameters:
        browseContext - current browse/operation context