org.jboss.jca.deployers.common
Class AbstractResourceAdapterDeployer

java.lang.Object
  extended by org.jboss.jca.deployers.common.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 Summary
protected  org.jboss.logging.Logger log
          the logger
protected  boolean trace
          trace boolean check
protected  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 Summary
AbstractResourceAdapterDeployer(boolean validateClasses, org.jboss.logging.Logger log)
          Create a new AbstractResourceAdapterDeployer.
 
Method Summary
protected  void associateResourceAdapter(javax.resource.spi.ResourceAdapter resourceAdapter, Object object)
          Associate resource adapter with ojects if they implement ResourceAdapterAssociation
protected abstract  String[] bindConnectionFactory(URL url, String deploymentName, Object cf)
          Bind connection factory into JNDI
protected abstract  String[] bindConnectionFactory(URL url, String deploymentName, Object cf, String jndiName)
          Bind connection factory into JNDI
protected abstract  boolean checkActivation(org.jboss.jca.common.api.metadata.ra.Connector cmd, org.jboss.jca.common.api.metadata.ironjacamar.IronJacamar ijmd)
          Check if the resource adapter should be activated based on the ironjacamar.xml input
protected abstract  boolean checkConfigurationIsValid()
          check if the configuration for this deployer has been set to a valid value
protected  CommonDeployment createObjectsAndInjectValue(URL url, String deploymentName, File root, ClassLoader cl, org.jboss.jca.common.api.metadata.ra.Connector cmd, org.jboss.jca.common.api.metadata.ironjacamar.IronJacamar ijmd)
          create objects and inject value for this depployment.
protected  org.jboss.jca.core.connectionmanager.pool.api.PoolConfiguration createPoolConfiguration(org.jboss.jca.common.api.metadata.common.CommonPool pp, org.jboss.jca.common.api.metadata.common.CommonTimeOut tp, org.jboss.jca.common.api.metadata.common.CommonValidation vp)
          Create an instance of the pool configuration based on the input
protected  org.jboss.jca.common.api.metadata.common.CommonConnDef findConnectionDefinition(String clz, List<org.jboss.jca.common.api.metadata.common.CommonConnDef> defs)
          Find the connection factory for a managed connection factory
 Configuration getConfiguration()
          Get the configuration
protected abstract  PrintWriter getLogPrintWriter()
          get a PrintWriter where logger will put its output
protected abstract  File getReportDirectory()
          get The directory where write error reports
protected abstract  TransactionManager getTransactionManager()
          get The transaction Manager.
protected  boolean hasFailuresLevel(Collection<org.jboss.jca.validator.Failure> failures, int severity)
          Cehck for failures at a certain level
protected  Set<org.jboss.jca.validator.Failure> initActivationSpec(ClassLoader cl, org.jboss.jca.common.api.metadata.ra.Connector cmd, javax.resource.spi.ResourceAdapter resourceAdapter, List<org.jboss.jca.validator.Validate> archiveValidationObjects, List<Object> beanValidationObjects, Set<org.jboss.jca.validator.Failure> failures, URL url, boolean activateDeployment)
          init the acrtivation spec
protected  Set<org.jboss.jca.validator.Failure> initAdminObject(org.jboss.jca.common.api.metadata.ra.Connector cmd, ClassLoader cl, List<org.jboss.jca.validator.Validate> archiveValidationObjects, List<Object> beanValidationObjects, Set<org.jboss.jca.validator.Failure> failures, URL url, boolean activateDeployment)
          init an Admin Object
protected abstract  Object initAndInject(String value, List<? extends org.jboss.jca.common.api.metadata.ra.ConfigProperty> cpm, ClassLoader cl)
          Initialize and inject configuration properties into container
 String printFailuresLog(String urlFileName, org.jboss.jca.validator.Validator validator, Collection<org.jboss.jca.validator.Failure> failures, File reportDirectory, org.jboss.jca.validator.FailureHelper... fhInput)
          print Failures into Log files.
protected abstract  void registerResourceAdapterToMDR(URL url, File root, org.jboss.jca.common.api.metadata.ra.Connector cmd, org.jboss.jca.common.api.metadata.ironjacamar.IronJacamar ijmd)
          Register the ResourceAdapter to the MDR.
 void setConfiguration(Configuration value)
          Set the configuration
 void start()
          Start
protected  void startContext(javax.resource.spi.ResourceAdapter resourceAdapter, String bootstrapIdentifier)
          Start the resource adapter
 Set<org.jboss.jca.validator.Failure> validateArchive(URL url, List<org.jboss.jca.validator.Validate> archiveValidation, Set<org.jboss.jca.validator.Failure> failures)
          validate archive
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

log

protected final org.jboss.logging.Logger log
the logger


trace

protected final boolean trace
trace boolean check


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,
                                       org.jboss.logging.Logger log)
Create a new AbstractResourceAdapterDeployer.

Parameters:
validateClasses - validateClasses validateClasses boolean to express if this instance will apply validation on classes structure
log - the right log where put messages
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<org.jboss.jca.validator.Failure> validateArchive(URL url,
                                                            List<org.jboss.jca.validator.Validate> archiveValidation,
                                                            Set<org.jboss.jca.validator.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 #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,
                               org.jboss.jca.validator.Validator validator,
                               Collection<org.jboss.jca.validator.Failure> failures,
                               File reportDirectory,
                               org.jboss.jca.validator.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<org.jboss.jca.validator.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(javax.resource.spi.ResourceAdapter resourceAdapter,
                            String bootstrapIdentifier)
                     throws DeployException
Start the resource adapter

Parameters:
resourceAdapter - resourceAdapter resourceAdapter The resource adapter
bootstrapIdentifier - bootstrapIdentifier bootstrapIdentifier The bootstrap context identifier; may be null
Throws:
DeployException - DeployException Thrown if the resource adapter cant be started

associateResourceAdapter

protected void associateResourceAdapter(javax.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

findConnectionDefinition

protected org.jboss.jca.common.api.metadata.common.CommonConnDef findConnectionDefinition(String clz,
                                                                                          List<org.jboss.jca.common.api.metadata.common.CommonConnDef> defs)
Find the connection factory for a managed connection factory

Parameters:
clz - clz clz The fully quilified class name for the managed connection factory
defs - defs defs The connection definitions
Returns:
The connection definiton; null if none could be found

createPoolConfiguration

protected org.jboss.jca.core.connectionmanager.pool.api.PoolConfiguration createPoolConfiguration(org.jboss.jca.common.api.metadata.common.CommonPool pp,
                                                                                                  org.jboss.jca.common.api.metadata.common.CommonTimeOut tp,
                                                                                                  org.jboss.jca.common.api.metadata.common.CommonValidation vp)
Create an instance of the pool configuration based on the input

Parameters:
pp - pp pp The pool parameters
tp - tp tp The timeout parameters
vp - vp vp The validation parameters
Returns:
The configuration

start

public void start()
Start


initActivationSpec

protected Set<org.jboss.jca.validator.Failure> initActivationSpec(ClassLoader cl,
                                                                  org.jboss.jca.common.api.metadata.ra.Connector cmd,
                                                                  javax.resource.spi.ResourceAdapter resourceAdapter,
                                                                  List<org.jboss.jca.validator.Validate> archiveValidationObjects,
                                                                  List<Object> beanValidationObjects,
                                                                  Set<org.jboss.jca.validator.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<org.jboss.jca.validator.Failure> initAdminObject(org.jboss.jca.common.api.metadata.ra.Connector cmd,
                                                               ClassLoader cl,
                                                               List<org.jboss.jca.validator.Validate> archiveValidationObjects,
                                                               List<Object> beanValidationObjects,
                                                               Set<org.jboss.jca.validator.Failure> failures,
                                                               URL url,
                                                               boolean activateDeployment)
                                                        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
activateDeployment - activateDeployment
Returns:
failures updated after implemented operations
Throws:
DeployException - DeployException in case of errors

checkActivation

protected abstract boolean checkActivation(org.jboss.jca.common.api.metadata.ra.Connector cmd,
                                           org.jboss.jca.common.api.metadata.ironjacamar.IronJacamar ijmd)
Check if the resource adapter should be activated based on the ironjacamar.xml input

Parameters:
cmd - cmd cmd The connector metadata
ijmd - ijmd ijmd The IronJacamar metadata
Returns:
True if the deployment should be activated; otherwise false

initAndInject

protected abstract Object initAndInject(String value,
                                        List<? extends org.jboss.jca.common.api.metadata.ra.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

createObjectsAndInjectValue

protected CommonDeployment createObjectsAndInjectValue(URL url,
                                                       String deploymentName,
                                                       File root,
                                                       ClassLoader cl,
                                                       org.jboss.jca.common.api.metadata.ra.Connector cmd,
                                                       org.jboss.jca.common.api.metadata.ironjacamar.IronJacamar ijmd)
                                                throws DeployException,
                                                       javax.resource.ResourceException,
                                                       org.jboss.jca.validator.ValidatorException,
                                                       org.jboss.jca.core.spi.mdr.AlreadyExistsException,
                                                       ClassNotFoundException,
                                                       Throwable
create objects and inject value for this depployment. it is a general method returning a CommonDeployment to be used to exchange objects needed to real injection in the container

Parameters:
url - url
deploymentName - deploymentName
root - root
cl - cl
cmd - connector md
ijmd - ironjacamar md
Returns:
return the exchange POJO with value useful for injection in the container (fungal or AS)
Throws:
DeployException - DeployException
javax.resource.ResourceException - ResourceException
org.jboss.jca.validator.ValidatorException - ValidatorException
org.jboss.jca.core.spi.mdr.AlreadyExistsException - AlreadyExistsException
ClassNotFoundException - ClassNotFoundException
Throwable - Throwable

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,
                                                     org.jboss.jca.common.api.metadata.ra.Connector cmd,
                                                     org.jboss.jca.common.api.metadata.ironjacamar.IronJacamar ijmd)
                                              throws org.jboss.jca.core.spi.mdr.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
ijmd - ijmd
Throws:
org.jboss.jca.core.spi.mdr.AlreadyExistsException - AlreadyExistsException

getTransactionManager

protected abstract TransactionManager getTransactionManager()
get The transaction Manager. Implementers have to provide right implementation to find and get it

Returns:
the transaction manager to be used

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

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


Copyright © 2008 Red Hat Middleware LLC (http://www.jboss.com/)