}
if ( !exists ) {
try {
// Doesn't exist in deployment descriptor -- add new
ResourceEnvRefType resourceEnvRef = webApp.addNewResourceEnvRef();
//------------------------------------------------------------------------------
// <resource-env-ref> required elements:
//------------------------------------------------------------------------------
// resource-env-ref-name
JndiNameType resourceEnvRefName = JndiNameType.Factory.newInstance();
resourceEnvRefName.setStringValue( resourceName );
resourceEnvRef.setResourceEnvRefName( resourceEnvRefName );
if ( !resourceType.equals("") ) {
// resource-env-ref-type
FullyQualifiedClassType classType = FullyQualifiedClassType.Factory.newInstance();
classType.setStringValue( resourceType );
resourceEnvRef.setResourceEnvRefType( classType );
}
else if ( !injectionJavaType.equals("") ) {
// injectionTarget
InjectionTargetType injectionTarget = InjectionTargetType.Factory.newInstance();
FullyQualifiedClassType qualifiedClass = FullyQualifiedClassType.Factory.newInstance();
JavaIdentifierType javaType = JavaIdentifierType.Factory.newInstance();
qualifiedClass.setStringValue( injectionClass );
javaType.setStringValue( injectionJavaType );
injectionTarget.setInjectionTargetClass( qualifiedClass );
injectionTarget.setInjectionTargetName( javaType );
int arraySize = resourceEnvRef.sizeOfInjectionTargetArray();
resourceEnvRef.insertNewInjectionTarget( arraySize );
resourceEnvRef.setInjectionTargetArray( arraySize, injectionTarget );
}
//------------------------------------------------------------------------------
// <resource-env-ref> optional elements:
//------------------------------------------------------------------------------
// description
String descriptionAnnotation = annotation.description();
if ( descriptionAnnotation.length() > 0 ) {
DescriptionType description = DescriptionType.Factory.newInstance();
description.setStringValue( descriptionAnnotation );
int arraySize = resourceEnvRef.sizeOfDescriptionArray();
resourceEnvRef.insertNewDescription( arraySize );
resourceEnvRef.setDescriptionArray( arraySize,description );
}
// mappedName
String mappdedNameAnnotation = annotation.mappedName();
if ( mappdedNameAnnotation.length() > 0 ) {
XsdStringType mappedName = XsdStringType.Factory.newInstance();
mappedName.setStringValue( mappdedNameAnnotation );
resourceEnvRef.setMappedName( mappedName );
}
}
catch ( Exception anyException ) {
log.debug( "ResourceAnnotationHelper: Exception caught while processing <resource-env-ref>" );