Class AbstractResourceAdapterDeployer


  • public abstract class AbstractResourceAdapterDeployer
    extends Object
    An abstract resource adapter deployer which contains common functionality for all resource adapter archive based deployers.
    Author:
    Jesper Pedersen
    • Field Detail

      • validateClasses

        protected final boolean validateClasses
        boolean to set if validation is needed at class level or it should be considered already valid (IOW object put in repository at previous steps have been already validated at class level
    • Constructor Detail

      • AbstractResourceAdapterDeployer

        public AbstractResourceAdapterDeployer​(boolean validateClasses)
        Create a new AbstractResourceAdapterDeployer.
        Parameters:
        validateClasses - validateClasses validateClasses boolean to express if this instance will apply validation on classes structure
    • Method Detail

      • setConfiguration

        public void setConfiguration​(Configuration value)
        Set the configuration
        Parameters:
        value - value value The value
      • getConfiguration

        public Configuration getConfiguration()
        Get the configuration
        Returns:
        The value
      • validateArchive

        public Set<Failure> validateArchive​(URL url,
                                            List<Validate> archiveValidation,
                                            Set<Failure> failures)
        validate archive
        Parameters:
        url - url url of the archive
        archiveValidation - archiveValidation archiveValidation classes and/or to validate.
        failures - failures failures original list of failures
        Returns:
        The list of failures gotten with all new failures added. Null in case of no failures or if validation is not run according to Configuration.getArchiveValidation() Setting. It returns null also if the concrete implementation of this class set validateClasses instance variable to flase and the list of archiveValidation contains one or more instance of ValidateClass type
      • printFailuresLog

        public String printFailuresLog​(String urlFileName,
                                       Validator validator,
                                       Collection<Failure> failures,
                                       File reportDirectory,
                                       FailureHelper... fhInput)
        print Failures into Log files.
        Parameters:
        urlFileName - urlFileName urlFileName filename Of deployed rar
        validator - validator validator validator instance used to run validation rules
        failures - failures failures the list of Failures to be printed
        reportDirectory - reportDirectory reportDirectory where to put various logs
        fhInput - fhInput fhInput optional parameter. Normally used only for test or in case of FailureHelper already present in context
        Returns:
        the error Text
      • hasFailuresLevel

        protected boolean hasFailuresLevel​(Collection<Failure> failures,
                                           int severity)
        Cehck for failures at a certain level
        Parameters:
        failures - failures failures The failures
        severity - severity severity The level
        Returns:
        True if a failure is found with the specified severity; otherwise false
      • startContext

        protected void startContext​(jakarta.resource.spi.ResourceAdapter resourceAdapter,
                                    String bootstrapContextIdentifier,
                                    String bootstrapContextName,
                                    Callback cb)
                             throws DeployException
        Start the resource adapter
        Parameters:
        resourceAdapter - The resource adapter
        bootstrapContextIdentifier - The bootstrap context identifier
        bootstrapContextName - The bootstrap context name; may be null
        cb - The callback
        Throws:
        DeployException - DeployException Thrown if the resource adapter cant be started
      • setCallbackSecurity

        protected void setCallbackSecurity​(WorkManager workManager,
                                           Callback cb)
        Sets the call back security info in this rar work manager before starting the resource adapter.
        Parameters:
        workManager - the work manager that will be used by the resource adapter
        cb - the security callback
      • associateResourceAdapter

        protected void associateResourceAdapter​(jakarta.resource.spi.ResourceAdapter resourceAdapter,
                                                Object object)
                                         throws DeployException
        Associate resource adapter with ojects if they implement ResourceAdapterAssociation
        Parameters:
        resourceAdapter - resourceAdapter resourceAdapter The resource adapter
        object - object object The of possible association object
        Throws:
        DeployException - DeployException Thrown if the resource adapter cant be started
      • findConnectionDefinitions

        protected Set<ConnectionDefinition> findConnectionDefinitions​(String clz,
                                                                      Set<String> mcfs,
                                                                      List<ConnectionDefinition> defs,
                                                                      ClassLoader cl)
                                                               throws DeployException
        Find the metadata for a managed connection factory
        Parameters:
        clz - The fully quilified class name for the managed connection factory
        mcfs - The managed connection facotries
        defs - The connection definitions
        cl - The class loader
        Returns:
        The metadata; null if none could be found
        Throws:
        DeployException - Thrown in case of configuration error
      • findAdminObjects

        protected Set<AdminObject> findAdminObjects​(String clz,
                                                    Set<String> aos,
                                                    List<AdminObject> defs)
                                             throws DeployException
        Find the metadata for an admin object
        Parameters:
        clz - The fully quilified class name for the admin object
        aos - The admin object classes
        defs - The admin object definitions
        Returns:
        The metadata; null if none could be found
        Throws:
        DeployException - Thrown in case of configuration error
      • createPoolConfiguration

        protected PoolConfiguration createPoolConfiguration​(Pool pp,
                                                            TimeOut tp,
                                                            Validation vp)
        Create an instance of the pool configuration based on the input
        Parameters:
        pp - The pool parameters
        tp - The timeout parameters
        vp - The validation parameters
        Returns:
        The configuration
      • start

        public void start()
        Start
      • initActivationSpec

        protected Set<Failure> initActivationSpec​(ClassLoader cl,
                                                  Connector cmd,
                                                  jakarta.resource.spi.ResourceAdapter resourceAdapter,
                                                  List<Validate> archiveValidationObjects,
                                                  List<Object> beanValidationObjects,
                                                  Set<Failure> failures,
                                                  URL url,
                                                  boolean activateDeployment)
                                           throws DeployException
        init the acrtivation spec
        Parameters:
        cl - cl
        cmd - cmd
        resourceAdapter - resourceAdapter
        archiveValidationObjects - archiveValidationObjects
        beanValidationObjects - beanValidationObjects
        failures - falures to be updated during implemented operations
        url - url
        activateDeployment - activateDeployment
        Returns:
        failures updated after implemented operations
        Throws:
        DeployException - DeployException in case of error
      • initAdminObject

        protected Set<Failure> initAdminObject​(Connector cmd,
                                               ClassLoader cl,
                                               List<Validate> archiveValidationObjects,
                                               List<Object> beanValidationObjects,
                                               Set<Failure> failures,
                                               URL url,
                                               String deploymentName,
                                               boolean activateDeployment,
                                               jakarta.resource.spi.ResourceAdapter resourceAdapter,
                                               List<AdminObject> aosAct,
                                               List<Object> aos,
                                               List<String> aoJndiNames,
                                               Connector mgtConnector)
                                        throws DeployException
        init an Admin Object
        Parameters:
        cmd - cmd
        cl - cl
        archiveValidationObjects - archiveValidationObjects
        beanValidationObjects - beanValidationObjects
        failures - falures to be updated during implemented operations
        url - url
        deploymentName - The deployment name
        activateDeployment - activateDeployment
        resourceAdapter - The resource adapter instance
        aosAct - Admin object definitions from activation
        aos - The resulting array of admin objects
        aoJndiNames - The resulting array of JNDI names
        mgtConnector - The management view of the connector
        Returns:
        failures updated after implemented operations
        Throws:
        DeployException - DeployException in case of errors
      • buildJndiName

        protected String buildJndiName​(String jndiName,
                                       Boolean javaContext)
        Build the jndi name
        Parameters:
        jndiName - The jndi name
        javaContext - The java context
        Returns:
        The value
      • requireExplicitJndiBindings

        protected boolean requireExplicitJndiBindings()
        Require explicit JNDI bindings
        Returns:
        True if explicit JNDI bindings are required; otherwise false
      • getSubjectFactory

        protected abstract SubjectFactory getSubjectFactory​(SecurityMetadata securityMetadata,
                                                            String jndiName)
                                                     throws DeployException
        Get a subject factory
        Parameters:
        securityMetadata - The security metadata: contains the security domain and any other necessary information for returning the subject factory
        jndiName - optionally used for authentication context matching
        Returns:
        The subject factory; must return null if security domain isn't defined
        Throws:
        DeployException - Thrown if the security domain can't be resolved
      • createSubject

        protected Subject createSubject​(SubjectFactory subjectFactory,
                                        String securityDomain,
                                        jakarta.resource.spi.ManagedConnectionFactory mcf)
        Create a subject
        Parameters:
        subjectFactory - The subject factory
        securityDomain - The security domain
        mcf - The managed connection factory
        Returns:
        The subject; null in case of an error
      • getBeanValidation

        protected BeanValidation getBeanValidation()
        Get the bean validation module
        Returns:
        The module
      • getCachedConnectionManager

        protected abstract CachedConnectionManager getCachedConnectionManager()
        Get the cached connection manager
        Returns:
        The handle
      • createCallback

        protected Callback createCallback​(WorkManagerSecurity ws)
        Get a callback implementation
        Parameters:
        ws - The WorkManager security settings
        Returns:
        The value
      • applyCapacity

        protected void applyCapacity​(ConnectionDefinition connectionDefinition,
                                     Pool pool,
                                     boolean isCRI)
        Apply capacity
        Parameters:
        connectionDefinition - The connection definition
        pool - The pool
        isCRI - Is the pool going to be CRI based
      • scanArchive

        protected boolean scanArchive​(Connector cmd)
        Should the archive be scanned for annotations
        Parameters:
        cmd - The metadata
        Returns:
        True if scan is needed; otherwise false
      • getReportDirectory

        protected abstract File getReportDirectory()
        get The directory where write error reports
        Returns:
        the directory as File
      • registerResourceAdapterToMDR

        protected abstract void registerResourceAdapterToMDR​(URL url,
                                                             File root,
                                                             Connector cmd,
                                                             Activation activation)
                                                      throws AlreadyExistsException
        Register the ResourceAdapter to the MDR. Implementer should provide the implementation to get MDR and do the registration
        Parameters:
        url - url
        root - root
        cmd - cmd
        activation - activation
        Throws:
        AlreadyExistsException - AlreadyExistsException
      • registerResourceAdapterToResourceAdapterRepository

        protected abstract String registerResourceAdapterToResourceAdapterRepository​(jakarta.resource.spi.ResourceAdapter instance)
        Register the ResourceAdapter to the ResourceAdapterRepository. Implementer should provide the implementation to get repository and do the registration
        Parameters:
        instance - the instance
        Returns:
        The key
      • setRecoveryForResourceAdapterInResourceAdapterRepository

        protected abstract void setRecoveryForResourceAdapterInResourceAdapterRepository​(String key,
                                                                                         boolean isXA)
        Set recovery mode for a resource adapter in the ResourceAdapterRepository
        Parameters:
        key - The key for the resource adapter
        isXA - Is the resource adapter XA capable
      • getTransactionManager

        protected abstract jakarta.transaction.TransactionManager getTransactionManager()
        Get the transaction Manager. Implementers have to provide right implementation to find and get it
        Returns:
        The value
      • getTransactionIntegration

        protected abstract TransactionIntegration getTransactionIntegration()
        Get the transaction integration. Implementers have to provide right implementation to find and get it
        Returns:
        The value
      • getLogPrintWriter

        protected abstract PrintWriter getLogPrintWriter()
        get a PrintWriter where logger will put its output
        Returns:
        the printWriter for Logger
      • bindConnectionFactory

        protected abstract String[] bindConnectionFactory​(URL url,
                                                          String deploymentName,
                                                          Object cf)
                                                   throws Throwable
        Bind connection factory into JNDI
        Parameters:
        url - The deployment URL
        deploymentName - The deployment name
        cf - The connection factory
        Returns:
        The JNDI names bound
        Throws:
        Throwable - Thrown if an error occurs
      • bindConnectionFactory

        protected abstract String[] bindConnectionFactory​(URL url,
                                                          String deploymentName,
                                                          Object cf,
                                                          String jndiName)
                                                   throws Throwable
        Bind connection factory into JNDI
        Parameters:
        url - The deployment URL
        deploymentName - The deployment name
        cf - The connection factory
        jndiName - The JNDI name
        Returns:
        The JNDI names bound
        Throws:
        Throwable - Thrown if an error occurs
      • bindAdminObject

        protected abstract String[] bindAdminObject​(URL url,
                                                    String deploymentName,
                                                    Object ao)
                                             throws Throwable
        Bind admin object into JNDI
        Parameters:
        url - The deployment URL
        deploymentName - The deployment name
        ao - The admin object
        Returns:
        The JNDI names bound
        Throws:
        Throwable - Thrown if an error occurs
      • bindAdminObject

        protected abstract String[] bindAdminObject​(URL url,
                                                    String deploymentName,
                                                    Object ao,
                                                    String jndiName)
                                             throws Throwable
        Bind admin object into JNDI
        Parameters:
        url - The deployment URL
        deploymentName - The deployment name
        ao - The admin object
        jndiName - The JNDI name
        Returns:
        The JNDI names bound
        Throws:
        Throwable - Thrown if an error occurs
      • checkConfigurationIsValid

        protected abstract boolean checkConfigurationIsValid()
        check if the configuration for this deployer has been set to a valid value
        Returns:
        false if configuration is not valid
      • checkActivation

        protected abstract boolean checkActivation​(Connector cmd,
                                                   Activation activation)
        Check if the resource adapter should be activated based on the ironjacamar.xml input
        Parameters:
        cmd - cmd cmd The connector metadata
        activation - The activation metadata
        Returns:
        True if the deployment should be activated; otherwise false
      • initAndInject

        protected abstract Object initAndInject​(String value,
                                                List<? extends ConfigProperty> cpm,
                                                ClassLoader cl)
                                         throws DeployException
        Initialize and inject configuration properties into container
        Parameters:
        value - value
        cpm - confi properties
        cl - The class loader
        Returns:
        The object
        Throws:
        DeployException - DeployException Thrown if the object cant be initialized
      • getLogger

        protected abstract DeployersLogger getLogger()
        Get the logger
        Returns:
        The value