Interface ConnectorRuntime

  • All Superinterfaces:
    ConnectorConstants, ResourceConstants
    All Known Implementing Classes:
    ConnectorRuntime

    @Contract
    public interface ConnectorRuntime
    extends ConnectorConstants
    This class is the entry point to connector backend module. It exposes different API's called by external entities like JPA, admin to perform various connector backend related operations. It delegates calls to various connetcor admin services and other connector services which actually implement the functionality. This is a delegating class.
    Author:
    Binod P.G, Srikanth P, Aditya Gore, Jagadish Ramu
    • Method Detail

      • createActiveResourceAdapter

        void createActiveResourceAdapter​(String sourcePath,
                                         String moduleName,
                                         ClassLoader loader)
                                  throws ConnectorRuntimeException
        Creates Active resource Adapter which abstracts the rar module. During the creation of ActiveResourceAdapter, default pools and resources also are created.
        Parameters:
        sourcePath - Directory where rar module is exploded.
        moduleName - Name of the module
        loader - Classloader used to load the .rar
        Throws:
        ConnectorRuntimeException - if creation fails.
      • createActiveResourceAdapterForEmbeddedRar

        void createActiveResourceAdapterForEmbeddedRar​(String moduleName)
                                                throws ConnectorRuntimeException
        Creates Active resource Adapter which abstracts the rar module. During the creation of ActiveResourceAdapter, default pools and resources also are created.
        Parameters:
        moduleName - Name of the module
        Throws:
        ConnectorRuntimeException - if creation fails.
      • destroyActiveResourceAdapter

        void destroyActiveResourceAdapter​(String moduleName)
                                   throws ConnectorRuntimeException
        Destroys/deletes the Active resource adapter object from the connector container. Active resource adapter abstracts the rar deployed.
        Parameters:
        moduleName - Name of the rarModule to destroy/delete
        Throws:
        ConnectorRuntimeException - if the deletion fails
      • cleanUpResourcesAndShutdownAllActiveRAs

        void cleanUpResourcesAndShutdownAllActiveRAs()
        Shut down all pools and active resource-adapters
      • shutdownAllActiveResourceAdapters

        void shutdownAllActiveResourceAdapters()
        Shut down all active resource adapters
      • createConnectorClassLoader

        ClassLoader createConnectorClassLoader​(String moduleDirectory,
                                               ClassLoader parent,
                                               String rarModuleName)
                                        throws ConnectorRuntimeException
        Given the module directory, creates a connector-class-finder (class-loader) for the module
        Parameters:
        moduleDirectory - rar module directory for which classloader is needed
        parent - parent classloader
        For standalone rars, pass null, as the parent should be common-class-loader that will be automatically taken care by ConnectorClassLoaderService.
        For embedded rars, parent is necessary
        Returns:
        classloader created for the module
        Throws:
        ConnectorRuntimeException - when unable to create classloader
      • lookupNonTxResource

        Object lookupNonTxResource​(String jndiName,
                                   boolean force)
                            throws NamingException
        Does lookup of non-tx-datasource. If found, it will be returned.

        If not found and force is true, this api will try to get a wrapper datasource specified by the jdbcjndi name. The motivation for having this API is to provide the CMP backend/ JPA-Java2DB a means of acquiring a connection during the codegen phase. If a user is trying to deploy an JPA-Java2DB app on a remote server, without this API, a resource reference has to be present both in the DAS and the server instance. This makes the deployment more complex for the user since a resource needs to be forcibly created in the DAS Too. This API will mitigate this need.

        Parameters:
        jndiName - jndi name of the resource
        force - provide the resource (in DAS) even if it is not enabled in DAS
        Returns:
        DataSource representing the resource.
        Throws:
        NamingException - when not able to get the datasource.
      • lookupPMResource

        Object lookupPMResource​(String jndiName,
                                boolean force)
                         throws NamingException
        Does lookup of "__pm" datasource. If found, it will be returned.

        If not found and force is true, this api will try to get a wrapper datasource specified by the jdbcjndi name. The motivation for having this API is to provide the CMP backend/ JPA-Java2DB a means of acquiring a connection during the codegen phase. If a user is trying to deploy an JPA-Java2DB app on a remote server, without this API, a resource reference has to be present both in the DAS and the server instance. This makes the deployment more complex for the user since a resource needs to be forcibly created in the DAS Too. This API will mitigate this need. When the resource is not enabled, datasource wrapper provided will not be of type "__pm"

        Parameters:
        jndiName - jndi name of the resource
        force - provide the resource (in DAS) even if it is not enabled in DAS
        Returns:
        DataSource representing the resource.
        Throws:
        NamingException - when not able to get the datasource.
      • lookupNonTxResource

        Object lookupNonTxResource​(ResourceInfo resourceInfo,
                                   boolean force)
                            throws NamingException
        Does lookup of non-tx-datasource. If found, it will be returned.

        If not found and force is true, this api will try to get a wrapper datasource specified by the jdbcjndi name. The motivation for having this API is to provide the CMP backend/ JPA-Java2DB a means of acquiring a connection during the codegen phase. If a user is trying to deploy an JPA-Java2DB app on a remote server, without this API, a resource reference has to be present both in the DAS and the server instance. This makes the deployment more complex for the user since a resource needs to be forcibly created in the DAS Too. This API will mitigate this need.

        Parameters:
        resourceInfo - jndi name of the resource
        force - provide the resource (in DAS) even if it is not enabled in DAS
        Returns:
        DataSource representing the resource.
        Throws:
        NamingException - when not able to get the datasource.
      • lookupPMResource

        Object lookupPMResource​(ResourceInfo resourceInfo,
                                boolean force)
                         throws NamingException
        Does lookup of "__pm" datasource. If found, it will be returned.

        If not found and force is true, this api will try to get a wrapper datasource specified by the jdbcjndi name. The motivation for having this API is to provide the CMP backend/ JPA-Java2DB a means of acquiring a connection during the codegen phase. If a user is trying to deploy an JPA-Java2DB app on a remote server, without this API, a resource reference has to be present both in the DAS and the server instance. This makes the deployment more complex for the user since a resource needs to be forcibly created in the DAS Too. This API will mitigate this need. When the resource is not enabled, datasource wrapper provided will not be of type "__pm"

        Parameters:
        resourceInfo - jndi name of the resource
        force - provide the resource (in DAS) even if it is not enabled in DAS
        Returns:
        DataSource representing the resource.
        Throws:
        NamingException - when not able to get the datasource.
      • registerConnectorNamingEventListener

        void registerConnectorNamingEventListener​(ConnectorNamingEventListener listener)
        register the connector naming event listener
        Parameters:
        listener - connector-naming-event-listener
      • unregisterConnectorNamingEventListener

        void unregisterConnectorNamingEventListener​(ConnectorNamingEventListener listener)
        unregister the connector naming event listner
        Parameters:
        listener - connector-naming-event-listener
      • getConnectionPoolConfig

        ResourcePool getConnectionPoolConfig​(PoolInfo poolInfo)
        Provide the configuration of the pool
        Parameters:
        PoolInfo - connection pool info
        Returns:
        ResourcePool connection pool configuration
      • pingConnectionPool

        boolean pingConnectionPool​(PoolInfo poolInfo)
                            throws jakarta.resource.ResourceException
        Tests whether the configuration for the pool is valid by making a connection.
        Parameters:
        PoolInfo - connection pool info.
        Returns:
        boolean indicating ping status
        Throws:
        jakarta.resource.ResourceException - when unable to ping
      • getTransactionManager

        JavaEETransactionManager getTransactionManager()
        provides the transactionManager
        Returns:
        TransactionManager
      • getInvocationManager

        InvocationManager getInvocationManager()
        provides the invocationManager
        Returns:
        InvocationManager
      • getResourceReferenceDescriptor

        Set getResourceReferenceDescriptor()
        get resource reference descriptors from current component's jndi environment
        Returns:
        set of resource-refs
      • obtainManagedConnectionFactory

        jakarta.resource.spi.ManagedConnectionFactory obtainManagedConnectionFactory​(PoolInfo poolInfo)
                                                                              throws ConnectorRuntimeException
        Returns the MCF instance. If the MCF is already created and present in connectorRegistry that instance is returned. Otherwise it is created explicitly and added to ConnectorRegistry.
        Parameters:
        PoolInfo - Name of the pool.MCF pertaining to this pool is created/returned.
        Returns:
        created/already present MCF instance
        Throws:
        ConnectorRuntimeException - if creation/retrieval of MCF fails
      • obtainManagedConnectionFactory

        jakarta.resource.spi.ManagedConnectionFactory obtainManagedConnectionFactory​(PoolInfo poolInfo,
                                                                                     Hashtable env)
                                                                              throws ConnectorRuntimeException
        provide the MCF of the pool (either retrieve or create)
        Parameters:
        poolName - connection pool name
        env - Environment entries to use for lookup
        Returns:
        ManagedConnectionFactory mcf of the pool
        Throws:
        ConnectorRuntimeException - when unable to provide the MCF
      • getEnvironment

        ProcessEnvironment.ProcessType getEnvironment()
        Indicates whether the execution environment is server or client
        Returns:
        ConnectorConstants.SERVER or ConnectorConstants.CLIENT
      • getCallbackHandler

        CallbackHandler getCallbackHandler()
        provides container's (application server's) callback handler
        Returns:
        container callback handler
      • isServer

        boolean isServer()
        Checks whether the executing environment is application server
        Returns:
        true if execution environment is server false if it is not server
      • isEmbedded

        boolean isEmbedded()
        Checks whether the executing environment is embedded runtime
        Returns:
        true if execution environment is embedded mode false if it non-embedded
      • getConnectorClassLoader

        ClassLoader getConnectorClassLoader()
        provides connector class loader
        Returns:
        ClassLoader
      • getConnectionDefinitionPropertiesAndDefaults

        Map<String,​Object> getConnectionDefinitionPropertiesAndDefaults​(String connectionDefinitionClassName,
                                                                              String resType)
        Gets the properties of the Java bean connection definition class that have setter methods defined and the default values as provided by the Connection Definition java bean developer. This method is used to get properties of jdbc-data-source
        To get Connection definition properties for Connector Connection Pool, use ConnectorRuntime.getMCFConfigProperties()
        When the connection definition class is not found, standard JDBC properties (of JDBC 3.0 Specification) will be returned.
        Parameters:
        connectionDefinitionClassName - The Connection Definition Java bean class for which overrideable properties are required.
        resType - resource-type
        Returns:
        Map String represents property name and Object is the defaultValue that is a primitive type or String
      • getBuiltInCustomResources

        Map<String,​String> getBuiltInCustomResources()
        Provides the list of built in custom resources by resource-type and factory-class-name pair.
        Returns:
        map of resource-type & factory-class-name
      • getSystemConnectorsAllowingPoolCreation

        String[] getSystemConnectorsAllowingPoolCreation()
        Returns the system RAR names that allow pool creation
        Returns:
        String array representing list of system-rars
      • getConnectionDefinitionNames

        String[] getConnectionDefinitionNames​(String rarName)
                                       throws ConnectorRuntimeException
        Obtains all the Connection definition names of a rar
        Parameters:
        rarName - rar moduleName
        Returns:
        Array of connection definition names.
        Throws:
        ConnectorRuntimeException - when unable to obtain connection definition from descriptor.
      • getSecurityPermissionSpec

        String getSecurityPermissionSpec​(String moduleName)
                                  throws ConnectorRuntimeException
        Obtains the Permission string that needs to be added to the to the security policy files. These are the security permissions needed by the resource adapter implementation classes. These strings are obtained by parsing the ra.xml and by processing annotations if any
        Parameters:
        moduleName - rar module Name
        Returns:
        security permission spec
        Throws:
        ConnectorRuntimeException - If rar.xml parsing or annotation processing fails.
      • getAdminObjectInterfaceNames

        String[] getAdminObjectInterfaceNames​(String rarName)
                                       throws ConnectorRuntimeException
        Obtains all the Admin object interface names of a rar
        Parameters:
        rarName - rar moduleName
        Returns:
        Array of admin object interface names.
        Throws:
        ConnectorRuntimeException - when unable to obtain admin object interface names
      • getAdminObjectClassNames

        String[] getAdminObjectClassNames​(String rarName,
                                          String intfName)
                                   throws ConnectorRuntimeException
        Obtains all the Admin object implementation class names of the admin-object-interface for a rar
        Parameters:
        rarName - rar moduleName
        intfName - admin-object-interface-name
        Returns:
        Array of admin object interface names.
        Throws:
        ConnectorRuntimeException - when unable to obtain admin object interface names
      • hasAdminObject

        boolean hasAdminObject​(String rarName,
                               String intfName,
                               String className)
                        throws ConnectorRuntimeException
        checks whether the specified intfName, className has presence in admin objects of the RAR
        Parameters:
        rarName - resource-adapter name
        intfName - admin object interface name
        className - admin object class name
        Returns:
        boolean indicating the presence of admin object
        Throws:
        ConnectorRuntimeException - when unable to determine the presence
      • getResourceAdapterConfigProps

        Map<String,​String> getResourceAdapterConfigProps​(String rarName)
                                                        throws ConnectorRuntimeException
        Retrieves the Resource adapter javabean properties with default values. The default values will the values present in the ra.xml. If the value is not present in ra.xxml, javabean is introspected to obtain the default value present, if any. If intrspection fails or null is the default value, empty string is returned. If ra.xml has only the property and no value, empty string is the value returned. If the Resource Adapter Java bean is annotated, properties will be the result of merging annotated config property and config-property of Resource Adapter bean in ra.xml
        Parameters:
        rarName - rar module name
        Returns:
        Resource adapter javabean properties with default values.
        Throws:
        ConnectorRuntimeException - if property retrieval fails.
      • getMCFConfigProps

        Map<String,​String> getMCFConfigProps​(String rarName,
                                                   String connectionDefName)
                                            throws ConnectorRuntimeException
        Retrieves the MCF javabean properties with default values. The default values will the values present in the ra.xml. If the value is not present in ra.xxml, javabean is introspected to obtain the default value present, if any. If intrspection fails or null is the default value, empty string is returned. If ra.xml has only the property and no value, empty string is the value returned. If the ManagedConnectionFactory Java bean is annotated, properties will be the result of merging annotated config property and config-property of MCF in ra.xml
        Parameters:
        rarName - rar module name
        connectionDefName - connection-definition-name
        Returns:
        managed connection factory javabean properties with default values.
        Throws:
        ConnectorRuntimeException - if property retrieval fails.
      • getAdminObjectConfigProps

        Map<String,​String> getAdminObjectConfigProps​(String rarName,
                                                           String adminObjectIntf)
                                                    throws ConnectorRuntimeException
        Retrieves the admin object javabean properties with default values. The default values will the values present in the ra.xml. If the value is not present in ra.xxml, javabean is introspected to obtain the default value present, if any. If intrspection fails or null is the default value, empty string is returned. If ra.xml has only the property and no value, empty string is the value returned. If the AdministeredObject Java bean is annotated, properties will be the result of merging annotated config property and config-property of AdministeredObject in ra.xml
        Parameters:
        rarName - rar module name
        adminObjectIntf - admin-object-interface name
        Returns:
        admin object javabean properties with default values.
        Throws:
        ConnectorRuntimeException - if property retrieval fails.
      • getAdminObjectConfigProps

        Map<String,​String> getAdminObjectConfigProps​(String rarName,
                                                           String adminObjectIntf,
                                                           String adminObjectClass)
                                                    throws ConnectorRuntimeException
        Retrieves the admin object javabean properties with default values. The default values will the values present in the ra.xml. If the value is not present in ra.xxml, javabean is introspected to obtain the default value present, if any. If intrspection fails or null is the default value, empty string is returned. If ra.xml has only the property and no value, empty string is the value returned. If the AdministeredObject Java bean is annotated, properties will be the result of merging annotated config property and config-property of AdministeredObject in ra.xml
        Parameters:
        rarName - rar module name
        adminObjectIntf - admin-object-interface name
        adminObjectClass - admin-object-class name
        Returns:
        admin object javabean properties with default values.
        Throws:
        ConnectorRuntimeException - if property retrieval fails.
      • getConnectorConfigJavaBeans

        Map<String,​String> getConnectorConfigJavaBeans​(String rarName,
                                                             String connectionDefName,
                                                             String type)
                                                      throws ConnectorRuntimeException
        Retrieves the XXX javabean properties with default values. The javabean to introspect/retrieve is specified by the type. The default values will be the values present in the ra.xml. If the value is not present in ra.xxml, javabean is introspected to obtain the default value present, if any. If intrspection fails or null is the default value, empty string is returned. If ra.xml has only the property and no value, empty string is the value returned.
        Parameters:
        rarName - rar module name
        connectionDefName - connection definition name
        type - JavaBean type to introspect
        Returns:
        admin object javabean properties with default values.
        Throws:
        ConnectorRuntimeException - if property retrieval fails.
      • getActivationSpecClass

        String getActivationSpecClass​(String rarName,
                                      String messageListenerType)
                               throws ConnectorRuntimeException
        Return the ActivationSpecClass name for given rar and messageListenerType
        Parameters:
        rarName - name of the rar module
        messageListenerType - MessageListener type
        Returns:
        activation-spec class
        Throws:
        ConnectorRuntimeException - If moduleDir is null. If corresponding rar is not deployed.
      • getMessageListenerTypes

        String[] getMessageListenerTypes​(String rarName)
                                  throws ConnectorRuntimeException
        Parses the ra.xml, processes the annotated rar artificats if any and returns all the Message listener types.
        Parameters:
        rarName - name of the rar module.
        Returns:
        Array of message listener types as strings.
        Throws:
        ConnectorRuntimeException - If moduleDir is null. If corresponding rar is not deployed.
      • getMessageListenerConfigProps

        Map<String,​String> getMessageListenerConfigProps​(String rarName,
                                                               String messageListenerType)
                                                        throws ConnectorRuntimeException
        Parses the ra.xml for the ActivationSpec javabean properties and processes annotations if any. The ActivationSpec to be parsed is identified by the moduleDir where ra.xml is present and the message listener type. message listener type will be unique in a given ra.xml. It throws ConnectorRuntimeException if either or both the parameters are null, if corresponding rar is not deployed, if message listener type mentioned as parameter is not found in ra.xml. If rar is deployed and message listener (type mentioned) is present but no properties are present for the corresponding message listener, null is returned.
        Parameters:
        rarName - name of the rar module.
        messageListenerType - message listener type.It is uniqie across all sub-elements in element in a given rar.
        Returns:
        Javabean properties with the property names and values of properties. The property values will be the values mentioned in ra.xml if present. Otherwise it will be the default values obtained by introspecting the javabean. In both the case if no value is present, empty String is returned as the value.
        Throws:
        ConnectorRuntimeException - if either of the parameters are null. If corresponding rar is not deployed i.e moduleDir is invalid. If messagelistener type is not found in ra.xml or could not be found in annotations if any
      • getMessageListenerConfigPropTypes

        Map<String,​String> getMessageListenerConfigPropTypes​(String rarName,
                                                                   String messageListenerType)
                                                            throws ConnectorRuntimeException
        Returns the Properties object consisting of propertyname as the key and datatype as the value.
        Parameters:
        rarName - name of the rar module.
        messageListenerType - message listener type.It is uniqie across all sub-elements in element in a given rar.
        Returns:
        Properties object with the property names(key) and datatype of property(as value).
        Throws:
        ConnectorRuntimeException - if either of the parameters are null. If corresponding rar is not deployed i.e moduleDir is invalid. If messagelistener type is not found in ra.xmlor could not be found in annotations if any
      • getWorkSecurityMap

        List<WorkSecurityMap> getWorkSecurityMap​(String raName)
        get work security maps for a resource-adapter-name
        Parameters:
        raName - resource-adapter name
        Returns:
        all work security maps of a resource-adapter
      • registerDataSourceDefinitions

        void registerDataSourceDefinitions​(Application application)
        Used to register data-source-definitions at an earlier stage of deployment (prepare phase). This is used to register "java:global" and "java:app" scoped DataSourceDefinitions which can be referred by JPA in persistence.xml
        Parameters:
        application - Application being deployed.
      • unRegisterDataSourceDefinitions

        void unRegisterDataSourceDefinitions​(Application application)
        Used to unRegister data-source-definitions at an later stage of undeploy operation. This is used to unRegister "java:global" and "java:app" scoped DataSourceDefinitions which can be referred by JPA in persistence.xml
        Parameters:
        application - Application being undeployed.
      • getJdbcDriverClassNames

        Set<String> getJdbcDriverClassNames​(String dbVendor,
                                            String resType)
        Fetch the DataSource/Driver implementation class names for a particular dbVendor and resource type. Sometimes an already stored datasource
        classname is used in this method.
        Parameters:
        dbVendor - database vendor name
        resType - resource-type
        (javax.sql.DataSource/javax.sql.ConnectionPoolDataSource/javax.sql.XADataSource/java.sql.Driver)
        Returns:
        set of implementation class names for the dbvendor.
      • getJdbcDriverClassNames

        Set<String> getJdbcDriverClassNames​(String dbVendor,
                                            String resType,
                                            boolean introspect)
        Fetch the DataSource/Driver implementation class names for a particular dbVendor and resource type. A pre-defined datasource or driver
        classname is returned by this method by default for common database vendors. When introspect is true, classnames are got by introspection of the jdbc driver jar.
        Parameters:
        dbVendor - database vendor name
        resType - resource-type
        introspect - (javax.sql.DataSource/javax.sql.ConnectionPoolDataSource/javax.sql.XADataSource/java.sql.Driver)
        Returns:
        set of implementation class names for the dbvendor.
      • getPingDuringPoolCreation

        boolean getPingDuringPoolCreation​(PoolInfo poolInfo)
        Check if Ping attribute is on during pool creation. This is used for pinging the pool for erroneous values during pool creation.
        Parameters:
        PoolInfo - connection pool info
        Returns:
        true if ping is on
      • getConnectorDescriptor

        ConnectorDescriptor getConnectorDescriptor​(String rarName)
                                            throws ConnectorRuntimeException
        given a resource-adapter name, retrieves the connector-descriptor either from runtime's registry or by reading the descriptor from deployment location.
        Parameters:
        rarName - resource-adapter-name
        Returns:
        ConnectorDescriptor of the .rar
        Throws:
        ConnectorRuntimeException - when unable to provide the descriptor
      • getDatabaseVendorNames

        Set<String> getDatabaseVendorNames()
        Get jdbc database vendor names list. This is used for getting a list of all common database vendor names.
        Returns:
        set of common database vendor names
      • associateResourceAdapter

        void associateResourceAdapter​(String rarName,
                                      jakarta.resource.spi.ResourceAdapterAssociation raa)
                               throws jakarta.resource.ResourceException
        associates the given instance of ResourceAdapterAssociation with the ResourceAdapter java-bean of the specified RAR
        Parameters:
        rarName - resource-adapter-name
        raa - Object that is an instance of ResourceAdapterAssociation
        Throws:
        jakarta.resource.ResourceException - when unable to associate the RA Bean with RAA instance.
      • getShutdownTimeout

        long getShutdownTimeout()
        Gets the shutdown-timeout attribute configured in connector-service
        Returns:
        long shutdown timeout (in milli-seconds)
      • getConfidentialProperties

        List<String> getConfidentialProperties​(String rarName,
                                               String type,
                                               String... keyFields)
                                        throws ConnectorRuntimeException
        Retrieve the "confidential" config properties of specified artifact from a resource-adapter
        Parameters:
        rarName - resource-adapter name
        type - indicates the artifact type. Valid values are : ConnectorConstants.AOR, RA, MCF, MSL
        keyFields - var-args list of key fields. eg: connection-definition-name when
        Returns:
        list of confidential properties
        Throws:
        ConnectorRuntimeException