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.jca.deployers.DeployersLogger 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)
          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[] bindAdminObject(URL url, String deploymentName, Object ao)
          Bind admin object into JNDI
protected abstract  String[] bindAdminObject(URL url, String deploymentName, Object ao, String jndiName)
          Bind admin object into JNDI
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  String buildJndiName(String jndiName, Boolean javaContext)
          Build the jndi name
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  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, org.jboss.jca.common.api.metadata.resourceadapter.ResourceAdapter raxml)
          create objects and inject value for this depployment.
protected  org.jboss.jca.core.api.connectionmanager.pool.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  Subject createSubject(org.jboss.security.SubjectFactory subjectFactory, String securityDomain, javax.resource.spi.ManagedConnectionFactory mcf)
          Create a subject
protected  org.jboss.jca.common.api.metadata.common.CommonAdminObject findAdminObject(String clz, List<String> aos, List<org.jboss.jca.common.api.metadata.common.CommonAdminObject> defs)
          Find the metadata for an admin object
protected  org.jboss.jca.common.api.metadata.common.CommonConnDef findConnectionDefinition(String clz, List<String> mcfs, List<org.jboss.jca.common.api.metadata.common.CommonConnDef> defs)
          Find the metadata for a managed connection factory
protected abstract  org.jboss.jca.core.api.connectionmanager.ccm.CachedConnectionManager getCachedConnectionManager()
          Get the cached connection manager
 Configuration getConfiguration()
          Get the configuration
protected abstract  org.jboss.jca.deployers.DeployersLogger getLogger()
          Get the logger
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  org.jboss.security.SubjectFactory getSubjectFactory(String securityDomain)
          Get a subject factory
protected abstract  org.jboss.jca.core.spi.transaction.TransactionIntegration getTransactionIntegration()
          Get the transaction integration.
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, String deploymentName, boolean activateDeployment, List<org.jboss.jca.common.api.metadata.common.CommonAdminObject> aosRaXml, List<org.jboss.jca.common.api.metadata.common.CommonAdminObject> aosIronJacamar, List<Object> aos, List<String> aoJndiNames, org.jboss.jca.core.api.management.Connector mgtConnector)
          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.
protected abstract  String registerResourceAdapterToResourceAdapterRepository(javax.resource.spi.ResourceAdapter instance)
          Register the ResourceAdapter to the ResourceAdapterRepository.
 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.jca.deployers.DeployersLogger 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)
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<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<String> mcfs,
                                                                                          List<org.jboss.jca.common.api.metadata.common.CommonConnDef> defs)
                                                                                   throws Exception
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
Returns:
The metadata; null if none could be found
Throws:
Exception - Thrown if the deployment shouldn't be activated

findAdminObject

protected org.jboss.jca.common.api.metadata.common.CommonAdminObject findAdminObject(String clz,
                                                                                     List<String> aos,
                                                                                     List<org.jboss.jca.common.api.metadata.common.CommonAdminObject> defs)
                                                                              throws Exception
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:
Exception - Thrown if the deployment shouldn't be activated

createPoolConfiguration

protected org.jboss.jca.core.api.connectionmanager.pool.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,
                                                               String deploymentName,
                                                               boolean activateDeployment,
                                                               List<org.jboss.jca.common.api.metadata.common.CommonAdminObject> aosRaXml,
                                                               List<org.jboss.jca.common.api.metadata.common.CommonAdminObject> aosIronJacamar,
                                                               List<Object> aos,
                                                               List<String> aoJndiNames,
                                                               org.jboss.jca.core.api.management.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
aosRaXml - Admin object definitions from -ra.xml
aosIronJacamar - Admin object definitions from ironjacamar.xml
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

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

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,
                                                       org.jboss.jca.common.api.metadata.resourceadapter.ResourceAdapter raxml)
                                                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
raxml - Resource Adapter from -ra.xml definition
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

buildJndiName

protected String buildJndiName(String jndiName,
                               Boolean javaContext)
Build the jndi name

Parameters:
jndiName - The jndi name
javaContext - The java context
Returns:
The value

getSubjectFactory

protected abstract org.jboss.security.SubjectFactory getSubjectFactory(String securityDomain)
                                                                throws DeployException
Get a subject factory

Parameters:
securityDomain - The security domain
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(org.jboss.security.SubjectFactory subjectFactory,
                                String securityDomain,
                                javax.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

getCachedConnectionManager

protected abstract org.jboss.jca.core.api.connectionmanager.ccm.CachedConnectionManager getCachedConnectionManager()
Get the cached connection manager

Returns:
The handle

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

registerResourceAdapterToResourceAdapterRepository

protected abstract String registerResourceAdapterToResourceAdapterRepository(javax.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

getTransactionManager

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

Returns:
The value

getTransactionIntegration

protected abstract org.jboss.jca.core.spi.transaction.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(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

getLogger

protected abstract org.jboss.jca.deployers.DeployersLogger getLogger()
Get the logger

Returns:
The value


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