[jboss-cvs] JBossAS SVN: r106308 - in projects/jboss-jca/trunk: common and 16 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Tue Jun 29 10:09:32 EDT 2010
Author: jesper.pedersen
Date: 2010-06-29 10:09:30 -0400 (Tue, 29 Jun 2010)
New Revision: 106308
Added:
projects/jboss-jca/trunk/common/src/main/java/org/jboss/jca/common/JBossResourceException.java
projects/jboss-jca/trunk/common/src/main/java/org/jboss/jca/common/annotations/
projects/jboss-jca/trunk/common/src/main/java/org/jboss/jca/common/annotations/Annotations.java
projects/jboss-jca/trunk/common/src/main/java/org/jboss/jca/common/annotations/SecurityActions.java
projects/jboss-jca/trunk/common/src/main/java/org/jboss/jca/common/annotations/package.html
projects/jboss-jca/trunk/common/src/main/java/org/jboss/jca/common/metadata/
projects/jboss-jca/trunk/common/src/main/java/org/jboss/jca/common/metadata/Metadata.java
projects/jboss-jca/trunk/common/src/main/java/org/jboss/jca/common/metadata/package.html
projects/jboss-jca/trunk/common/src/main/java/org/jboss/jca/common/validator/
projects/jboss-jca/trunk/common/src/main/java/org/jboss/jca/common/validator/ValidateException.java
projects/jboss-jca/trunk/common/src/main/java/org/jboss/jca/common/validator/package.html
projects/jboss-jca/trunk/common/src/main/resources/common-manifest.mf
projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/connectionmanager/pool/SecurityActions.java
projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/connectionmanager/pool/strategy/SubjectActions.java
projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/workmanager/ClassUtil.java
Removed:
projects/jboss-jca/trunk/common/src/main/java/org/jboss/jca/common/Annotations.java
projects/jboss-jca/trunk/common/src/main/java/org/jboss/jca/common/Metadata.java
projects/jboss-jca/trunk/common/src/main/java/org/jboss/jca/common/SecurityActions.java
projects/jboss-jca/trunk/common/src/main/java/org/jboss/jca/common/ValidateException.java
projects/jboss-jca/trunk/common/src/main/java/org/jboss/jca/common/api/JBossResourceException.java
projects/jboss-jca/trunk/common/src/main/java/org/jboss/jca/common/util/ClassUtil.java
projects/jboss-jca/trunk/common/src/main/java/org/jboss/jca/common/util/SecurityActions.java
projects/jboss-jca/trunk/common/src/main/java/org/jboss/jca/common/util/SubjectActions.java
projects/jboss-jca/trunk/common/src/main/resources/api-manifest.mf
projects/jboss-jca/trunk/common/src/main/resources/impl-manifest.mf
Modified:
projects/jboss-jca/trunk/build.xml
projects/jboss-jca/trunk/common/build.xml
projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/connectionmanager/AbstractConnectionManager.java
projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/connectionmanager/listener/TxConnectionListener.java
projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/connectionmanager/pool/AbstractPool.java
projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/connectionmanager/pool/InternalManagedConnectionPool.java
projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/connectionmanager/pool/PoolFiller.java
projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/connectionmanager/pool/strategy/SubjectCriKey.java
projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/connectionmanager/pool/strategy/SubjectKey.java
projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/connectionmanager/tx/TxConnectionManager.java
projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/workmanager/WorkManagerImpl.java
projects/jboss-jca/trunk/deployers/src/main/java/org/jboss/jca/deployers/fungal/RADeployer.java
projects/jboss-jca/trunk/deployers/src/test/java/org/jboss/jca/deployers/annotations/AnnotationsTestCase.java
projects/jboss-jca/trunk/validator/src/main/java/org/jboss/jca/validator/Validation.java
Log:
[JBJCA-369] Refactor common module
Modified: projects/jboss-jca/trunk/build.xml
===================================================================
--- projects/jboss-jca/trunk/build.xml 2010-06-29 14:05:46 UTC (rev 106307)
+++ projects/jboss-jca/trunk/build.xml 2010-06-29 14:09:30 UTC (rev 106308)
@@ -407,8 +407,7 @@
</fileset>
</auxClasspath>
<class location="${target.dir}/jboss-jca-codegenerator.jar" />
- <class location="${target.dir}/jboss-jca-common-api.jar" />
- <class location="${target.dir}/jboss-jca-common-impl.jar" />
+ <class location="${target.dir}/jboss-jca-common.jar" />
<class location="${target.dir}/jboss-jca-core-api.jar" />
<class location="${target.dir}/jboss-jca-core-impl.jar" />
<class location="${target.dir}/jboss-jca-core-spi.jar" />
@@ -438,8 +437,7 @@
</fileset>
</auxClasspath>
<class location="${target.dir}/jboss-jca-codegenerator.jar" />
- <class location="${target.dir}/jboss-jca-common-api.jar" />
- <class location="${target.dir}/jboss-jca-common-impl.jar" />
+ <class location="${target.dir}/jboss-jca-common.jar" />
<class location="${target.dir}/jboss-jca-core-api.jar" />
<class location="${target.dir}/jboss-jca-core-impl.jar" />
<class location="${target.dir}/jboss-jca-core-spi.jar" />
Modified: projects/jboss-jca/trunk/common/build.xml
===================================================================
--- projects/jboss-jca/trunk/common/build.xml 2010-06-29 14:05:46 UTC (rev 106307)
+++ projects/jboss-jca/trunk/common/build.xml 2010-06-29 14:09:30 UTC (rev 106308)
@@ -47,15 +47,9 @@
Target: jars
================================= -->
<target name="jars" depends="compile">
- <jar destfile="${target.dir}/jboss-jca-common-api.jar"
- manifest="src/main/resources/api-manifest.mf"
- basedir="${build.common.dir}"
- includes="**/api/**"
- excludes="**/*.java"/>
- <jar destfile="${target.dir}/jboss-jca-common-impl.jar"
- manifest="src/main/resources/impl-manifest.mf"
- basedir="${build.common.dir}"
- excludes="**/api/**, **/*.java"/>
+ <jar destfile="${target.dir}/jboss-jca-common.jar"
+ manifest="src/main/resources/common-manifest.mf"
+ basedir="${build.common.dir}"/>
</target>
<!-- =================================
Deleted: projects/jboss-jca/trunk/common/src/main/java/org/jboss/jca/common/Annotations.java
===================================================================
--- projects/jboss-jca/trunk/common/src/main/java/org/jboss/jca/common/Annotations.java 2010-06-29 14:05:46 UTC (rev 106307)
+++ projects/jboss-jca/trunk/common/src/main/java/org/jboss/jca/common/Annotations.java 2010-06-29 14:09:30 UTC (rev 106308)
@@ -1,1124 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2008-2009, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file in the
- * distribution for a full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-
-package org.jboss.jca.common;
-
-import java.lang.reflect.Array;
-import java.lang.reflect.Field;
-import java.lang.reflect.Method;
-import java.net.URL;
-import java.util.ArrayList;
-import java.util.Collection;
-
-import javax.resource.spi.Activation;
-import javax.resource.spi.AdministeredObject;
-import javax.resource.spi.AuthenticationMechanism;
-import javax.resource.spi.AuthenticationMechanism.CredentialInterface;
-import javax.resource.spi.ConfigProperty;
-import javax.resource.spi.ConnectionDefinition;
-import javax.resource.spi.ConnectionDefinitions;
-import javax.resource.spi.Connector;
-import javax.resource.spi.SecurityPermission;
-import javax.resource.spi.TransactionSupport;
-import javax.resource.spi.TransactionSupport.TransactionSupportLevel;
-import javax.resource.spi.work.WorkContext;
-
-import org.jboss.logging.Logger;
-
-import org.jboss.metadata.javaee.spec.DescriptionGroupMetaData;
-import org.jboss.metadata.javaee.spec.DescriptionImpl;
-import org.jboss.metadata.javaee.spec.DescriptionsImpl;
-import org.jboss.metadata.javaee.spec.DisplayNameImpl;
-import org.jboss.metadata.javaee.spec.DisplayNamesImpl;
-import org.jboss.metadata.javaee.spec.IconImpl;
-import org.jboss.metadata.javaee.spec.IconsImpl;
-
-import org.jboss.metadata.rar.spec.ActivationspecMetaData;
-import org.jboss.metadata.rar.spec.AdminObjectMetaData;
-import org.jboss.metadata.rar.spec.AuthenticationMechanismMetaData;
-import org.jboss.metadata.rar.spec.ConfigPropertyMetaData;
-import org.jboss.metadata.rar.spec.ConnectionDefinitionMetaData;
-import org.jboss.metadata.rar.spec.ConnectorMetaData;
-import org.jboss.metadata.rar.spec.InboundRaMetaData;
-import org.jboss.metadata.rar.spec.JCA16Base;
-import org.jboss.metadata.rar.spec.JCA16MetaData;
-import org.jboss.metadata.rar.spec.LicenseMetaData;
-import org.jboss.metadata.rar.spec.MessageAdapterMetaData;
-import org.jboss.metadata.rar.spec.MessageListenerMetaData;
-import org.jboss.metadata.rar.spec.OutboundRaMetaData;
-import org.jboss.metadata.rar.spec.ResourceAdapterMetaData;
-import org.jboss.metadata.rar.spec.SecurityPermissionMetaData;
-import org.jboss.metadata.rar.spec.TransactionSupportMetaData;
-
-import org.jboss.papaki.Annotation;
-import org.jboss.papaki.AnnotationRepository;
-import org.jboss.papaki.AnnotationScanner;
-import org.jboss.papaki.AnnotationScannerFactory;
-import org.jboss.papaki.AnnotationType;
-
-/**
- * The annotation processor for JCA 1.6
- * @author <a href="mailto:jesper.pedersen at jboss.org">Jesper Pedersen</a>
- */
-public class Annotations
-{
- private static Logger log = Logger.getLogger(Annotations.class);
- private static boolean trace = log.isTraceEnabled();
-
- /**
- * Constructor
- */
- public Annotations()
- {
- }
-
- /**
- * Scan for annotations in the URLs specified
- * @param cmd The resource adapter metadata
- * @param urls The URLs to be scanned
- * @param cl The referenced classloader
- * @return The updated metadata
- * @exception Exception Thrown if an error occurs
- */
- public ConnectorMetaData scan(ConnectorMetaData cmd, URL[] urls, ClassLoader cl) throws Exception
- {
- // Process annotations
- if (cmd == null || cmd.is16())
- {
- AnnotationScanner annotationScanner =
- AnnotationScannerFactory.getStrategy(AnnotationScannerFactory.JAVASSIST_INPUT_STREAM);
- annotationScanner.configure().constructorLevel(false).parameterLevel(false);
- AnnotationRepository annotationRepository = annotationScanner.scan(urls, cl);
-
- boolean isMetadataComplete = false;
- if (cmd != null && cmd instanceof JCA16Base)
- {
- JCA16Base jmd = (JCA16Base)cmd;
- isMetadataComplete = jmd.isMetadataComplete();
- }
-
- if (cmd == null || !isMetadataComplete)
- {
- cmd = process(cmd, annotationRepository);
- }
- }
- return cmd;
- }
- /**
- * Process annotations
- * @param md The metadata
- * @param annotationRepository The annotation repository
- * @return The updated metadata
- * @exception Exception Thrown if an error occurs
- */
- public ConnectorMetaData process(ConnectorMetaData md, AnnotationRepository annotationRepository)
- throws Exception
- {
- if (annotationRepository == null)
- throw new ValidateException("AnnotationRepository reference is null");
- /* Process
- -------
- javax.resource.spi.Activation
- javax.resource.spi.AdministeredObject
- javax.resource.spi.AuthenticationMechanism
- javax.resource.spi.ConfigProperty
- javax.resource.spi.ConnectionDefinition
- javax.resource.spi.ConnectionDefinitions
- javax.resource.spi.Connector
- javax.resource.spi.SecurityPermission
- */
-
- if (md == null)
- {
- JCA16MetaData jmd = new JCA16MetaData();
- jmd.setMetadataComplete(false);
- md = jmd;
- }
-
- // @Connector
- md = processConnector(md, annotationRepository);
-
- // @ConnectionDefinitions
- md = processConnectionDefinitions(md, annotationRepository);
-
- // @ConnectionDefinition (outside of @ConnectionDefinitions)
- md = processConnectionDefinition(md, annotationRepository);
-
- // @Activation
- md = processActivation(md, annotationRepository);
-
- // @AuthenticationMechanism
- //md = processAuthenticationMechanism(md, annotationRepository);
-
- // @AdministeredObject
- md = processAdministeredObject(md, annotationRepository);
-
- // @ConfigProperty handle at last
- md = processConfigProperty(md, annotationRepository);
-
- //log.debug("ConnectorMetadata " + md);
-
- return md;
- }
-
- /**
- * Process: @Connector
- * @param md The metadata
- * @param annotationRepository The annotation repository
- * @return The updated metadata
- * @exception Exception Thrown if an error occurs
- */
- private ConnectorMetaData processConnector(ConnectorMetaData md, AnnotationRepository annotationRepository)
- throws Exception
- {
- Collection<Annotation> values = annotationRepository.getAnnotation(Connector.class);
- if (values != null)
- {
- if (values.size() == 1)
- {
- Annotation annotation = values.iterator().next();
- String raClass = annotation.getClassName();
- Connector c = (Connector)annotation.getAnnotation();
-
- if (trace)
- log.trace("Processing: " + c + " for " + raClass);
-
- md = attachConnector(md, raClass, c);
- }
- else if (values.size() == 0)
- {
- // JBJCA-240
- if (md.getRa().getRaClass() == null || md.getRa().getRaClass().equals(""))
- {
- log.fatal("No @Connector was found and no definition in the ra.xml metadata either");
- throw new ValidateException("No @Connector defined");
- }
- }
- else
- {
- // JBJCA-240
- if (md.getRa().getRaClass() == null || md.getRa().getRaClass().equals(""))
- {
- log.fatal("More than one @Connector was found but the correct one " +
- "wasn't defined in the ra.xml metadata");
- throw new ValidateException("More than one @Connector defined");
- }
- }
- }
-
- return md;
- }
-
- /**
- * Attach @Connector
- * @param md The metadata
- * @param raClass The class name for the resource adapter
- * @param c The connector
- * @return The updated metadata
- * @exception Exception Thrown if an error occurs
- */
- private ConnectorMetaData attachConnector(ConnectorMetaData md, String raClass, Connector c)
- throws Exception
- {
- // Class definition
- if (md.getRa() == null)
- md.setRa(new ResourceAdapterMetaData());
-
- md.getRa().setRaClass(raClass);
-
- // AuthenticationMechanism
- AuthenticationMechanism[] authMechanisms = c.authMechanisms();
- if (authMechanisms != null)
- {
- for (AuthenticationMechanism authMechanism : authMechanisms)
- {
- attachAuthenticationMechanism(md, authMechanism);
- }
- }
-
- DescriptionGroupMetaData descGroup = new DescriptionGroupMetaData();
- md.setDescriptionGroup(descGroup);
-
- // Description
- String[] description = c.description();
- if (description != null)
- {
- if (descGroup.getDescriptions() == null)
- {
- DescriptionsImpl descsImpl = new DescriptionsImpl();
- descGroup.setDescriptions(descsImpl);
- }
- for (String desc : description)
- {
- DescriptionImpl descImpl = new DescriptionImpl();
- descImpl.setDescription(desc);
- ((DescriptionsImpl)descGroup.getDescriptions()).add(descImpl);
- }
- }
-
- // Display name
- String[] displayName = c.displayName();
- if (displayName != null)
- {
- if (descGroup.getDisplayNames() == null)
- {
- DisplayNamesImpl dnsImpl = new DisplayNamesImpl();
- descGroup.setDisplayNames(dnsImpl);
- }
- for (String dn : displayName)
- {
- DisplayNameImpl dnImpl = new DisplayNameImpl();
- dnImpl.setDisplayName(dn);
- ((DisplayNamesImpl)descGroup.getDisplayNames()).add(dnImpl);
- }
- }
-
- // EIS type
- String eisType = c.eisType();
- if (eisType != null)
- {
- if (md.getEISType() == null)
- md.setEISType(eisType);
- }
-
- // Large icon
- String[] largeIcon = c.largeIcon();
- if (largeIcon != null)
- {
- if (descGroup.getIcons() == null)
- {
- IconsImpl icsImpl = new IconsImpl();
- descGroup.setIcons(icsImpl);
- }
- for (String large : largeIcon)
- {
- IconImpl icImpl = new IconImpl();
- icImpl.setLargeIcon(large);
- ((IconsImpl)descGroup.getIcons()).add(icImpl);
- }
- }
-
- // License description
- String[] licenseDescription = c.licenseDescription();
- if (licenseDescription != null)
- {
- if (md.getLicense() == null)
- md.setLicense(new LicenseMetaData());
-
- if (md.getLicense().getDescriptions() == null)
- {
- DescriptionsImpl descsImpl = new DescriptionsImpl();
- md.getLicense().setDescriptions(descsImpl);
- }
- for (String desc : licenseDescription)
- {
- DescriptionImpl descImpl = new DescriptionImpl();
- descImpl.setDescription(desc);
- ((DescriptionsImpl)md.getLicense().getDescriptions()).add(descImpl);
- }
- }
-
- // License required
- boolean licenseRequired = c.licenseRequired();
- if (md.getLicense() == null)
- md.setLicense(new LicenseMetaData());
- md.getLicense().setRequired(licenseRequired);
-
- // Reauthentication support
- boolean reauthenticationSupport = c.reauthenticationSupport();
- if (md.getRa() != null && md.getRa().getOutboundRa() != null)
- {
- md.getRa().getOutboundRa().setReAuthSupport(reauthenticationSupport);
- }
-
- // RequiredWorkContext
- Class<? extends WorkContext>[] requiredWorkContexts = c.requiredWorkContexts();
- if (requiredWorkContexts != null)
- {
- for (Class<? extends WorkContext> requiredWorkContext : requiredWorkContexts)
- {
- if (md instanceof JCA16Base)
- {
- JCA16Base jmd = (JCA16Base)md;
- if (jmd.getRequiredWorkContexts() == null)
- jmd.setRequiredWorkContexts(new ArrayList<String>());
-
- if (!jmd.getRequiredWorkContexts().contains(requiredWorkContext.getName()))
- {
- if (trace)
- log.trace("RequiredWorkContext=" + requiredWorkContext.getName());
-
- jmd.getRequiredWorkContexts().add(requiredWorkContext.getName());
- }
- }
- }
- }
-
- // Security permission
- SecurityPermission[] securityPermissions = c.securityPermissions();
- if (securityPermissions != null)
- {
- if (md.getRa() == null)
- md.setRa(new ResourceAdapterMetaData());
-
- if (md.getRa().getSecurityPermissions() == null)
- md.getRa().setSecurityPermissions(new ArrayList<SecurityPermissionMetaData>());
-
- for (SecurityPermission securityPermission : securityPermissions)
- {
- SecurityPermissionMetaData spmd = new SecurityPermissionMetaData();
- spmd.setSecurityPermissionSpec(securityPermission.permissionSpec());
- md.getRa().getSecurityPermissions().add(spmd);
- }
- }
-
- // Small icon
- String[] smallIcon = c.smallIcon();
- if (smallIcon != null)
- {
- IconsImpl icsImpl;
- if (descGroup.getIcons() == null)
- {
- icsImpl = new IconsImpl();
- descGroup.setIcons(icsImpl);
- }
- else
- {
- icsImpl = (IconsImpl)descGroup.getIcons();
- }
- IconImpl[] icArray = icsImpl.toArray(new IconImpl[icsImpl.size()]);
- for (int i = 0; i < smallIcon.length; i++)
- {
- if (i < icArray.length)
- icArray[i].setSmallIcon(smallIcon[i]);
- else
- {
- IconImpl icImpl = new IconImpl();
- icImpl.setLargeIcon(smallIcon[i]);
- icsImpl.add(icImpl);
- }
- }
- }
-
- // Transaction support
- TransactionSupport.TransactionSupportLevel transactionSupport = c.transactionSupport();
- if (md.getRa() != null && md.getRa().getOutboundRa() != null)
- {
- if (transactionSupport.equals(TransactionSupportLevel.NoTransaction))
- {
- md.getRa().getOutboundRa().setTransSupport(TransactionSupportMetaData.NoTransaction);
- }
- else if (transactionSupport.equals(TransactionSupportLevel.XATransaction))
- {
- md.getRa().getOutboundRa().setTransSupport(TransactionSupportMetaData.XATransaction);
- }
- else if (transactionSupport.equals(TransactionSupportLevel.LocalTransaction))
- {
- md.getRa().getOutboundRa().setTransSupport(TransactionSupportMetaData.LocalTransaction);
- }
- }
-
- // Vendor name
- String vendorName = c.vendorName();
- if (vendorName != null)
- {
- if (md.getVendorName() == null)
- md.setVendorName(vendorName);
- }
-
- // Version
- String version = c.version();
- if (version != null)
- {
- if (md.getRAVersion() == null)
- md.setRAVersion(version);
- }
-
- return md;
- }
-
- /**
- * Process: @ConnectionDefinitions
- * @param md The metadata
- * @param annotationRepository The annotation repository
- * @return The updated metadata
- * @exception Exception Thrown if an error occurs
- */
- private ConnectorMetaData processConnectionDefinitions(ConnectorMetaData md,
- AnnotationRepository annotationRepository)
- throws Exception
- {
- Collection<Annotation> values = annotationRepository.getAnnotation(ConnectionDefinitions.class);
- if (values != null)
- {
- if (values.size() == 1)
- {
- Annotation annotation = values.iterator().next();
- ConnectionDefinitions c = (ConnectionDefinitions)annotation.getAnnotation();
-
- if (trace)
- log.trace("Processing: " + c);
-
- md = attachConnectionDefinitions(md , c, annotation.getClassName());
- }
- else
- throw new ValidateException("More than one @ConnectionDefinitions defined");
- }
-
- return md;
- }
-
- /**
- * Attach @ConnectionDefinitions
- * @param md The metadata
- * @param cds The connection definitions
- * @param mcf The managed connection factory
- * @return The updated metadata
- * @exception Exception Thrown if an error occurs
- */
- private ConnectorMetaData attachConnectionDefinitions(ConnectorMetaData md,
- ConnectionDefinitions cds,
- String mcf)
- throws Exception
- {
- createConDefs(md);
-
- if (cds.value() != null)
- {
- for (ConnectionDefinition cd : cds.value())
- {
- md = attachConnectionDefinition(md, mcf, cd);
- }
- }
-
- return md;
- }
-
- /**
- * Process: @ConnectionDefinition
- * @param md The metadata
- * @param annotationRepository The annotation repository
- * @return The updated metadata
- * @exception Exception Thrown if an error occurs
- */
- private ConnectorMetaData processConnectionDefinition(ConnectorMetaData md,
- AnnotationRepository annotationRepository)
- throws Exception
- {
- Collection<Annotation> values = annotationRepository.getAnnotation(ConnectionDefinition.class);
- if (values != null)
- {
- for (Annotation annotation : values)
- {
- md = attachConnectionDefinition(md, annotation);
- }
- }
-
- return md;
- }
-
- /**
- * Attach @ConnectionDefinition
- * @param md The metadata
- * @param cd The connection definition
- * @return The updated metadata
- * @exception Exception Thrown if an error occurs
- */
- private ConnectorMetaData attachConnectionDefinition(ConnectorMetaData md, Annotation annotation)
- throws Exception
- {
- ConnectionDefinition cd = (ConnectionDefinition)annotation.getAnnotation();
-
- if (trace)
- log.trace("Processing: " + annotation);
-
- createConDefs(md);
-
- for (ConnectionDefinitionMetaData cdMeta : md.getRa().getOutboundRa().getConDefs())
- {
- if (cdMeta.getManagedConnectionFactoryClass().equals(annotation.getClassName()))
- {
- //ra.xml define
- return md;
- }
- }
-
- return attachConnectionDefinition(md, annotation.getClassName(), cd);
- }
-
- /**
- * Attach @ConnectionDefinition
- * @param md The metadata
- * @param mcf The managed connection factory
- * @param cd The connection definition
- * @return The updated metadata
- * @exception Exception Thrown if an error occurs
- */
- private ConnectorMetaData attachConnectionDefinition(ConnectorMetaData md,
- String mcf,
- ConnectionDefinition cd)
- throws Exception
- {
- if (trace)
- log.trace("Processing: " + cd);
-
- createConDefs(md);
-
- ConnectionDefinitionMetaData cdMeta = new ConnectionDefinitionMetaData();
- cdMeta.setManagedConnectionFactoryClass(mcf);
- cdMeta.setConnectionFactoryInterfaceClass(cd.connectionFactory().getName());
- cdMeta.setConnectionFactoryImplementationClass(cd.connectionFactoryImpl().getName());
- cdMeta.setConnectionInterfaceClass(cd.connection().getName());
- cdMeta.setConnectionImplementationClass(cd.connectionImpl().getName());
- md.getRa().getOutboundRa().getConDefs().add(cdMeta);
- return md;
- }
-
- /**
- * Process: @ConfigProperty
- * @param md The metadata
- * @param annotationRepository The annotation repository
- * @return The updated metadata
- * @exception Exception Thrown if an error occurs
- */
- private ConnectorMetaData processConfigProperty(ConnectorMetaData md,
- AnnotationRepository annotationRepository)
- throws Exception
- {
- Collection<Annotation> values = annotationRepository.getAnnotation(ConfigProperty.class);
- if (values != null)
- {
- for (Annotation annotation : values)
- {
- md = attachConfigProperty(md, annotation);
- }
- }
-
- return md;
- }
-
- /**
- * Attach @ConfigProperty
- * @param md The metadata
- * @param configProperty The config property
- * @return The updated metadata
- * @exception Exception Thrown if an error occurs
- */
- private ConnectorMetaData attachConfigProperty(ConnectorMetaData md, Annotation annotation)
- throws Exception
- {
- ConfigProperty configProperty = (ConfigProperty)annotation.getAnnotation();
-
- if (trace)
- log.trace("Processing: " + configProperty);
-
- // Ignore config-property which has ignore=true
- if (configProperty.ignore())
- return md;
-
- ConfigPropertyMetaData cfgMeta = new ConfigPropertyMetaData();
- cfgMeta.setName(getConfigPropertyName(annotation));
-
- if (configProperty.defaultValue() != null && !configProperty.defaultValue().equals(""))
- cfgMeta.setValue(configProperty.defaultValue());
-
- if (!Object.class.equals(configProperty.type()))
- {
- cfgMeta.setType(configProperty.type().getName());
- }
- else
- {
- cfgMeta.setType(getConfigPropertyType(annotation));
- }
- cfgMeta.setIgnore(configProperty.ignore());
-
- String[] description = configProperty.description();
- if (description != null)
- {
- if (cfgMeta.getDescriptions() == null)
- {
- DescriptionsImpl descsImpl = new DescriptionsImpl();
- cfgMeta.setDescriptions(descsImpl);
- }
- for (String desc : description)
- {
- DescriptionImpl descImpl = new DescriptionImpl();
- descImpl.setDescription(desc);
- ((DescriptionsImpl)cfgMeta.getDescriptions()).add(descImpl);
- }
- }
-
- String attachedClassName = annotation.getClassName();
- ClassLoader cl = SecurityActions.getThreadContextClassLoader();
- Class attachedClass = Class.forName(attachedClassName, true, cl);
-
- if (hasInterface(attachedClass, "javax.resource.spi.ResourceAdapter"))
- {
- if (md.getRa() == null)
- {
- md.setRa(new ResourceAdapterMetaData());
- }
- if (md.getRa().getConfigProperty() == null)
- {
- md.getRa().setConfigProperty(new ArrayList<ConfigPropertyMetaData>());
- }
- for (ConfigPropertyMetaData cpMeta : md.getRa().getConfigProperty())
- {
- if (cpMeta.getName().equals(cfgMeta.getName()))
- {
- return md;
- }
- }
- md.getRa().getConfigProperty().add(cfgMeta);
- }
- else if (hasInterface(attachedClass, "javax.resource.spi.ManagedConnectionFactory"))
- {
- createConDefs(md);
- for (ConnectionDefinitionMetaData cdMeta : md.getRa().getOutboundRa().getConDefs())
- {
- if (attachedClassName.equals(cdMeta.getManagedConnectionFactoryClass()))
- {
- if (cdMeta.getConfigProps() == null)
- {
- cdMeta.setConfigProps(new ArrayList<ConfigPropertyMetaData>());
- }
- for (ConfigPropertyMetaData cpMeta : cdMeta.getConfigProps())
- {
- if (cpMeta.getName().equals(cfgMeta.getName()))
- {
- return md;
- }
- }
- cdMeta.getConfigProps().add(cfgMeta);
- }
- }
- }
- else if (hasInterface(attachedClass, "javax.resource.spi.ActivationSpec"))
- {
- createMessageListeners(md);
- for (MessageListenerMetaData mlMeta : md.getRa().getInboundRa().getMessageAdapter().getMessageListeners())
- {
- if (attachedClassName.equals(mlMeta.getActivationSpecType().getAsClass()))
- {
- if (mlMeta.getActivationSpecType().getConfigProps() == null)
- {
- mlMeta.getActivationSpecType().setConfigProps(new ArrayList<ConfigPropertyMetaData>());
- }
- for (ConfigPropertyMetaData cpMeta : mlMeta.getActivationSpecType().getConfigProps())
- {
- if (cpMeta.getName().equals(cfgMeta.getName()))
- {
- return md;
- }
- }
- mlMeta.getActivationSpecType().getConfigProps().add(cfgMeta);
- }
- }
- }
-
- return md;
- }
-
- /**
- * hasInterface
- *
- * @param c
- * @param targetClassName
- * @return
- */
- private boolean hasInterface(Class c, String targetClassName)
- {
- for (Class face : c.getInterfaces())
- {
- if (face.getName().equals(targetClassName))
- {
- return true;
- }
- else
- {
- for (Class face2 : face.getInterfaces())
- {
- if (face2.getName().equals(targetClassName))
- {
- return true;
- }
- else if (hasInterface(face2, targetClassName))
- {
- return true;
- }
- }
- }
- }
- if (null != c.getSuperclass())
- {
- return hasInterface(c.getSuperclass(), targetClassName);
- }
- return false;
- }
-
- /**
- * Attach @AuthenticationMechanism
- * @param md The metadata
- * @param authenticationmechanism The authentication mechanism
- * @return The updated metadata
- * @exception Exception Thrown if an error occurs
- */
- private ConnectorMetaData attachAuthenticationMechanism(ConnectorMetaData md,
- AuthenticationMechanism authenticationmechanism)
- throws Exception
- {
- if (md.getRa() == null)
- {
- md.setRa(new ResourceAdapterMetaData());
- }
- if (md.getRa().getOutboundRa() == null)
- {
- md.getRa().setOutboundRa(new OutboundRaMetaData());
- }
- if (md.getRa().getOutboundRa().getAuthMechanisms() == null)
- {
- md.getRa().getOutboundRa().setAuthMechanisms(new ArrayList<AuthenticationMechanismMetaData>());
- }
- AuthenticationMechanismMetaData ammd = new AuthenticationMechanismMetaData();
- ammd.setAuthenticationMechanismType(authenticationmechanism.authMechanism());
-
- String credentialInterfaceClass = null;
- if (authenticationmechanism.credentialInterface().equals(CredentialInterface.GenericCredential))
- {
- credentialInterfaceClass = "javax.resource.spi.security.GenericCredential";
- }
- else if (authenticationmechanism.credentialInterface().equals(CredentialInterface.GSSCredential))
- {
- credentialInterfaceClass = "org.ietf.jgss.GSSCredential";
- }
- else if (authenticationmechanism.credentialInterface().equals(CredentialInterface.PasswordCredential))
- {
- credentialInterfaceClass = "javax.resource.spi.security.PasswordCredential";
- }
- ammd.setCredentialInterfaceClass(credentialInterfaceClass);
-
- String[] description = authenticationmechanism.description();
- if (description != null)
- {
- if (ammd.getDescriptions() == null)
- {
- DescriptionsImpl descsImpl = new DescriptionsImpl();
- ammd.setDescriptions(descsImpl);
- }
- for (String desc : description)
- {
- DescriptionImpl descImpl = new DescriptionImpl();
- descImpl.setDescription(desc);
- ((DescriptionsImpl)ammd.getDescriptions()).add(descImpl);
- }
- }
-
- md.getRa().getOutboundRa().getAuthMechanisms().add(ammd);
-
- return md;
- }
-
- /**
- * Process: @AdministeredObject
- * @param md The metadata
- * @param annotationRepository The annotation repository
- * @return The updated metadata
- * @exception Exception Thrown if an error occurs
- */
- private ConnectorMetaData processAdministeredObject(ConnectorMetaData md,
- AnnotationRepository annotationRepository)
- throws Exception
- {
- Collection<Annotation> values = annotationRepository.getAnnotation(AdministeredObject.class);
- if (values != null)
- {
- for (Annotation annotation : values)
- {
- AdministeredObject a = (AdministeredObject)annotation.getAnnotation();
-
- if (trace)
- log.trace("Processing: " + a);
-
- md = attachAdministeredObject(md, a);
- }
- }
-
- return md;
- }
-
- /**
- * Attach @AdministeredObject
- * @param md The metadata
- * @param a The administered object
- * @return The updated metadata
- * @exception Exception Thrown if an error occurs
- */
- private ConnectorMetaData attachAdministeredObject(ConnectorMetaData md, AdministeredObject a)
- throws Exception
- {
- createAdminObject(md);
- String aoName = null;
- if (a.adminObjectInterfaces().length > 0)
- {
- aoName = ((Class)Array.get(a.adminObjectInterfaces(), 0)).getName();
- }
- AdminObjectMetaData aomd = new AdminObjectMetaData();
- aomd.setAdminObjectInterfaceClass(aoName);
- md.getRa().getAdminObjects().add(aomd);
- return md;
- }
-
- /**
- * Process: @Activation
- * @param md The metadata
- * @param annotationRepository The annotation repository
- * @return The updated metadata
- * @exception Exception Thrown if an error occurs
- */
- private ConnectorMetaData processActivation(ConnectorMetaData md,
- AnnotationRepository annotationRepository)
- throws Exception
- {
- Collection<Annotation> values = annotationRepository.getAnnotation(Activation.class);
- if (values != null)
- {
- for (Annotation annotation : values)
- {
- md = attachActivation(md, annotation);
- }
- }
-
- return md;
- }
-
- /**
- * Attach @Activation
- * @param md The metadata
- * @param activation The activation
- * @return The updated metadata
- * @exception Exception Thrown if an error occurs
- */
- private ConnectorMetaData attachActivation(ConnectorMetaData md, Annotation annotation)
- throws Exception
- {
- Activation activation = (Activation)annotation.getAnnotation();
-
- if (trace)
- log.trace("Processing: " + activation);
-
- createMessageListeners(md);
- for (Class asClass : activation.messageListeners())
- {
- ActivationspecMetaData asMeta = new ActivationspecMetaData();
- asMeta.setAsClass(annotation.getClassName());
- MessageListenerMetaData mlMeta = new MessageListenerMetaData();
- mlMeta.setActivationSpecType(asMeta);
- mlMeta.setType(asClass.getName());
- md.getRa().getInboundRa().getMessageAdapter().getMessageListeners().add(mlMeta);
- }
- return md;
- }
-
-
- /**
- * createMessageListeners
- * @param md
- * @throws Exception
- */
- private void createMessageListeners(ConnectorMetaData md) throws Exception
- {
- if (md.getRa() == null)
- {
- md.setRa(new ResourceAdapterMetaData());
- }
- if (md.getRa().getInboundRa() == null)
- {
- md.getRa().setInboundRa(new InboundRaMetaData());
- }
- if (md.getRa().getInboundRa().getMessageAdapter() == null)
- {
- md.getRa().getInboundRa().setMessageAdapter(new MessageAdapterMetaData());
- }
- if (md.getRa().getInboundRa().getMessageAdapter().getMessageListeners() == null)
- {
- md.getRa().getInboundRa().getMessageAdapter().setMessageListeners(new ArrayList<MessageListenerMetaData>());
- }
- }
-
- /**
- * createAdminObject
- * @param md
- * @throws Exception
- */
- private void createAdminObject(ConnectorMetaData md) throws Exception
- {
- if (md.getRa() == null)
- {
- md.setRa(new ResourceAdapterMetaData());
- }
- if (md.getRa().getAdminObjects() == null)
- {
- md.getRa().setAdminObjects(new ArrayList<AdminObjectMetaData>());
- }
- }
-
- /**
- * createConDefs
- * @param md
- * @throws Exception
- */
- private void createConDefs(ConnectorMetaData md) throws Exception
- {
- if (md.getRa() == null)
- {
- md.setRa(new ResourceAdapterMetaData());
- }
- if (md.getRa().getOutboundRa() == null)
- {
- md.getRa().setOutboundRa(new OutboundRaMetaData());
- }
- if (md.getRa().getOutboundRa().getConDefs() == null)
- {
- md.getRa().getOutboundRa().setConDefs(new ArrayList<ConnectionDefinitionMetaData>());
- }
- }
-
- /**
- * Get the config-property-name for an annotation
- * @param annotation The annotation
- * @return The name
- * @exception ClassNotFoundException Thrown if a class cannot be found
- * @exception NoSuchFieldException Thrown if a field cannot be found
- * @exception NoSuchMethodException Thrown if a method cannot be found
- */
- private String getConfigPropertyName(Annotation annotation)
- throws ClassNotFoundException, NoSuchFieldException, NoSuchMethodException
- {
- if (AnnotationType.FIELD.equals(annotation.getType()))
- {
- return annotation.getMemberName();
- }
- else if (AnnotationType.METHOD.equals(annotation.getType()))
- {
- String name = annotation.getMemberName();
-
- if (name.startsWith("set"))
- {
- name = name.substring(3);
- }
- else if (name.startsWith("get"))
- {
- name = name.substring(3);
- }
- else if (name.startsWith("is"))
- {
- name = name.substring(2);
- }
-
- if (name.length() > 1)
- {
- return Character.toLowerCase(name.charAt(0)) + name.substring(1);
- }
- else
- {
- return Character.toString(Character.toLowerCase(name.charAt(0)));
- }
- }
-
- throw new IllegalArgumentException("Unknown annotation: " + annotation);
- }
-
- /**
- * Get the config-property-type for an annotation
- * @param annotation The annotation
- * @return The fully qualified classname
- * @exception ClassNotFoundException Thrown if a class cannot be found
- */
- @SuppressWarnings("unchecked")
- private String getConfigPropertyType(Annotation annotation)
- throws ClassNotFoundException
- {
- if (AnnotationType.FIELD.equals(annotation.getType()))
- {
- ClassLoader cl = SecurityActions.getThreadContextClassLoader();
- Class clz = Class.forName(annotation.getClassName(), true, cl);
-
- while (!Object.class.equals(clz))
- {
- try
- {
- Field field = clz.getDeclaredField(annotation.getMemberName());
-
- return field.getType().getName();
- }
- catch (NoSuchFieldException nsfe)
- {
- clz = clz.getSuperclass();
- }
- }
- }
- else if (AnnotationType.METHOD.equals(annotation.getType()))
- {
- ClassLoader cl = SecurityActions.getThreadContextClassLoader();
- Class clz = Class.forName(annotation.getClassName(), true, cl);
-
- Class[] parameters = null;
-
- if (annotation.getParameterTypes() != null)
- {
- parameters = new Class[annotation.getParameterTypes().length];
-
- for (int i = 0; i < annotation.getParameterTypes().length; i++)
- {
- String parameter = annotation.getParameterTypes()[i];
- parameters[i] = Class.forName(parameter, true, cl);
- }
- }
-
- while (!Object.class.equals(clz))
- {
- try
- {
- Method method = clz.getDeclaredMethod(annotation.getMemberName(), parameters);
-
- if (void.class.equals(method.getReturnType()))
- {
- if (parameters != null && parameters.length > 0)
- {
- return parameters[0].getName();
- }
- }
- else
- {
- return method.getReturnType().getName();
- }
- }
- catch (NoSuchMethodException nsme)
- {
- clz = clz.getSuperclass();
- }
- }
- }
-
- throw new IllegalArgumentException("Unknown annotation: " + annotation);
- }
-}
Copied: projects/jboss-jca/trunk/common/src/main/java/org/jboss/jca/common/JBossResourceException.java (from rev 106305, projects/jboss-jca/trunk/common/src/main/java/org/jboss/jca/common/api/JBossResourceException.java)
===================================================================
--- projects/jboss-jca/trunk/common/src/main/java/org/jboss/jca/common/JBossResourceException.java (rev 0)
+++ projects/jboss-jca/trunk/common/src/main/java/org/jboss/jca/common/JBossResourceException.java 2010-06-29 14:09:30 UTC (rev 106308)
@@ -0,0 +1,212 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008-2009, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.jca.common;
+
+import java.io.PrintStream;
+import java.io.PrintWriter;
+import java.lang.reflect.UndeclaredThrowableException;
+
+import javax.resource.ResourceException;
+
+import org.jboss.util.NestedThrowable;
+
+/**
+ * Thrown to indicate a problem with a resource related operation.
+ *
+ * <p>
+ * Properly displays linked exception (ie. nested exception)
+ * when printing the stack trace.
+ *
+ * @version <tt>$Revision: 76129 $</tt>
+ * @author <a href="mailto:jason at planet57.com">Jason Dillon</a>
+ */
+public class JBossResourceException extends ResourceException implements NestedThrowable
+{
+ /** The servial version uid*/
+ private static final long serialVersionUID = 6614203184612359692L;
+
+ /**
+ * Rethrow as a resource exception if it is not already
+ *
+ * @param message the message
+ * @param t the original exception
+ * @throws ResourceException the resource exception
+ */
+ public static void rethrowAsResourceException(String message, Throwable t) throws ResourceException
+ {
+ if (t instanceof ResourceException)
+ throw (ResourceException) t;
+ else
+ throw new JBossResourceException(message, t);
+ }
+
+ /**
+ * Construct a <tt>JBossResourceException</tt> with the specified detail
+ * message.
+ *
+ * @param msg Detail message.
+ */
+ public JBossResourceException(final String msg)
+ {
+ super(msg);
+ }
+
+ /**
+ * Construct a <tt>JBossResourceException</tt> with the specified detail
+ * message and error code.
+ *
+ * @param msg Detail message.
+ * @param code Error code.
+ */
+ public JBossResourceException(final String msg, final String code)
+ {
+ super(msg, code);
+ }
+
+ /**
+ * Construct a <tt>JBossResourceException</tt> with the specified detail
+ * message, error code and linked <tt>Exception</tt>.
+ *
+ * @param msg Detail message.
+ * @param code Error code.
+ * @param linked Linked <tt>Exception</tt>.
+ */
+ @SuppressWarnings("deprecation")
+ public JBossResourceException(final String msg, final String code, final Throwable linked)
+ {
+ super(msg, code);
+ setLinkedException(process(linked));
+ }
+
+ /**
+ * Construct a <tt>JBossResourceException</tt> with the specified detail
+ * message and linked <tt>Exception</tt>.
+ *
+ * @param msg Detail message.
+ * @param linked Linked <tt>Exception</tt>.
+ */
+ @SuppressWarnings("deprecation")
+ public JBossResourceException(final String msg, final Throwable linked)
+ {
+ super(msg);
+ setLinkedException(process(linked));
+ }
+
+ /**
+ * Construct a <tt>JBossResourceException</tt> with the specified
+ * linked <tt>Exception</tt>.
+ *
+ * @param linked Linked <tt>Exception</tt>.
+ */
+ public JBossResourceException(final Throwable linked)
+ {
+ this(linked.getMessage(), linked);
+ }
+
+ /**
+ * Return the nested <tt>Throwable</tt>.
+ *
+ * @return Nested <tt>Throwable</tt>.
+ */
+ @SuppressWarnings("deprecation")
+ public Throwable getNested()
+ {
+ return getLinkedException();
+ }
+
+ /**
+ * Return the nested <tt>Throwable</tt>.
+ *
+ * <p>For JDK 1.4 compatibility.
+ *
+ * @return Nested <tt>Throwable</tt>.
+ */
+ @SuppressWarnings("deprecation")
+ public Throwable getCause()
+ {
+ return getLinkedException();
+ }
+
+ /**
+ * Returns the composite throwable message.
+ *
+ * @return The composite throwable message.
+ */
+ @SuppressWarnings("deprecation")
+ public String getMessage()
+ {
+ return NestedThrowable.Util.getMessage(super.getMessage(), getLinkedException());
+ }
+
+ /**
+ * Prints the composite message and the embedded stack trace to the
+ * specified print stream.
+ *
+ * @param stream Stream to print to.
+ */
+ @SuppressWarnings("deprecation")
+ public void printStackTrace(final PrintStream stream)
+ {
+ Exception linked = getLinkedException();
+ if (linked == null || NestedThrowable.PARENT_TRACE_ENABLED)
+ {
+ super.printStackTrace(stream);
+ }
+ NestedThrowable.Util.print(linked, stream);
+ }
+
+ /**
+ * Prints the composite message and the embedded stack trace to the
+ * specified print writer.
+ *
+ * @param writer Writer to print to.
+ */
+ @SuppressWarnings("deprecation")
+ public void printStackTrace(final PrintWriter writer)
+ {
+ Exception linked = getLinkedException();
+ if (linked == null || NestedThrowable.PARENT_TRACE_ENABLED)
+ {
+ super.printStackTrace(writer);
+ }
+ NestedThrowable.Util.print(linked, writer);
+ }
+
+ /**
+ * Prints the composite message and the embedded stack trace to
+ * <tt>System.err</tt>.
+ */
+ public void printStackTrace()
+ {
+ printStackTrace(System.err);
+ }
+
+ private Exception process(Throwable t)
+ {
+ if (t instanceof Exception)
+ {
+ return (Exception)t;
+ }
+ return new UndeclaredThrowableException(t);
+ }
+}
Deleted: projects/jboss-jca/trunk/common/src/main/java/org/jboss/jca/common/Metadata.java
===================================================================
--- projects/jboss-jca/trunk/common/src/main/java/org/jboss/jca/common/Metadata.java 2010-06-29 14:05:46 UTC (rev 106307)
+++ projects/jboss-jca/trunk/common/src/main/java/org/jboss/jca/common/Metadata.java 2010-06-29 14:09:30 UTC (rev 106308)
@@ -1,366 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2008-2009, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file in the
- * distribution for a full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-
-package org.jboss.jca.common;
-
-import java.io.File;
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-
-import org.jboss.logging.Logger;
-import org.jboss.metadata.rar.jboss.JBossRA10MetaData;
-import org.jboss.metadata.rar.jboss.JBossRA20DefaultNSMetaData;
-import org.jboss.metadata.rar.jboss.JBossRA20MetaData;
-import org.jboss.metadata.rar.jboss.JBossRAMetaData;
-import org.jboss.metadata.rar.jboss.RaConfigPropertyMetaData;
-import org.jboss.metadata.rar.spec.ConfigPropertyMetaData;
-import org.jboss.metadata.rar.spec.ConnectionDefinitionMetaData;
-import org.jboss.metadata.rar.spec.ConnectorMetaData;
-import org.jboss.metadata.rar.spec.InboundRaMetaData;
-import org.jboss.metadata.rar.spec.JCA10DTDMetaData;
-import org.jboss.metadata.rar.spec.JCA15DTDMetaData;
-import org.jboss.metadata.rar.spec.JCA15MetaData;
-import org.jboss.metadata.rar.spec.JCA16DTDMetaData;
-import org.jboss.metadata.rar.spec.JCA16DefaultNSMetaData;
-import org.jboss.metadata.rar.spec.JCA16MetaData;
-import org.jboss.metadata.rar.spec.MessageListenerMetaData;
-import org.jboss.metadata.rar.spec.OutboundRaMetaData;
-import org.jboss.metadata.rar.spec.RA10MetaData;
-
-import org.jboss.xb.binding.Unmarshaller;
-import org.jboss.xb.binding.UnmarshallerFactory;
-import org.jboss.xb.binding.resolver.MutableSchemaResolver;
-import org.jboss.xb.binding.sunday.unmarshalling.SingletonSchemaResolverFactory;
-
-/**
- * The metadata processor for JCA 1.x
- * @author <a href="mailto:jesper.pedersen at jboss.org">Jesper Pedersen</a>
- * @author <a href="mailto:jeff.zhang at redhat.com">Jeff Zhang</a>
- */
-public class Metadata
-{
- private static Logger log = Logger.getLogger(Metadata.class);
- private static boolean trace = log.isTraceEnabled();
-
- /**
- * Constructor
- */
- public Metadata()
- {
- }
-
- /**
- * Get the JCA standard metadata
- * @param root The root of the deployment
- * @return The metadata
- * @exception Exception Thrown if an error occurs
- */
- public ConnectorMetaData getStandardMetaData(File root) throws Exception
- {
- ConnectorMetaData result = null;
-
- UnmarshallerFactory unmarshallerFactory = UnmarshallerFactory.newInstance();
- Unmarshaller unmarshaller = unmarshallerFactory.newUnmarshaller();
-
- MutableSchemaResolver resolver = SingletonSchemaResolverFactory.getInstance().getSchemaBindingResolver();
- resolver.mapLocationToClass("connector_1_6.xsd", JCA16MetaData.class);
- resolver.mapLocationToClass("connector_1_5.xsd", JCA15MetaData.class);
- resolver.mapLocationToClass("connector_1_5.dtd", JCA15DTDMetaData.class);
- resolver.mapLocationToClass("connector_1_6.dtd", JCA16DTDMetaData.class);
- resolver.mapLocationToClass("connector_1_0.dtd", JCA10DTDMetaData.class);
- resolver.mapLocationToClass("connector", JCA16DefaultNSMetaData.class);
-
- File metadataFile = new File(root, "/META-INF/ra.xml");
-
- if (metadataFile.exists())
- {
- String url = metadataFile.getAbsolutePath();
- try
- {
- long start = System.currentTimeMillis();
-
- result = (ConnectorMetaData)unmarshaller.unmarshal(url, resolver);
-
- log.debug("Total parse for " + url + " took " + (System.currentTimeMillis() - start) + "ms");
-
- if (trace)
- {
- log.trace("successful parse " + result.getVersion() + " rar package " + result);
- }
-
- }
- catch (Exception e)
- {
- log.error("Error during parsing: " + url, e);
- throw e;
- }
- }
-
- return result;
- }
-
- /**
- * Get the JBoss specific metadata
- * @param root The root of the deployment
- * @return The metadata
- * @exception Exception Thrown if an error occurs
- */
- public JBossRAMetaData getJBossMetaData(File root) throws Exception
- {
- JBossRAMetaData result = null;
-
- UnmarshallerFactory unmarshallerFactory = UnmarshallerFactory.newInstance();
- Unmarshaller unmarshaller = unmarshallerFactory.newUnmarshaller();
-
- MutableSchemaResolver resolver = SingletonSchemaResolverFactory.getInstance().getSchemaBindingResolver();
- resolver.mapLocationToClass("http://www.jboss.org/schema/jboss-ra_1_0.xsd", JBossRA10MetaData.class);
- resolver.mapLocationToClass("http://www.jboss.org/schema/jboss-ra_2_0.xsd", JBossRA20MetaData.class);
- resolver.mapLocationToClass("jboss-ra", JBossRA20DefaultNSMetaData.class);
-
- File metadataFile = new File(root, "/META-INF/jboss-ra.xml");
-
- if (metadataFile.exists())
- {
- String url = metadataFile.getAbsolutePath();
- try
- {
- long start = System.currentTimeMillis();
-
- result = (JBossRAMetaData)unmarshaller.unmarshal(url, resolver);
-
- log.debug("Total parse for " + url + " took " + (System.currentTimeMillis() - start) + "ms");
-
- if (trace)
- log.trace(result);
- }
- catch (Exception e)
- {
- log.error("Error during parsing: " + url, e);
- throw e;
- }
- }
-
- return result;
- }
-
- /**
- * Merge specification metadata with vendor metadata
- * @param cmd The specification metadata
- * @param jmd The vendor metadata
- * @return The merged metadata
- * @exception Exception Thrown if an error occurs
- */
- public ConnectorMetaData merge(ConnectorMetaData cmd, JBossRAMetaData jmd) throws Exception
- {
- if (cmd != null && jmd != null)
- {
- /*
- <xs:restriction base="javaee:string">
- <xs:enumeration value="connection-definition"/>
- <xs:enumeration value="resourceadapter"/>
- <xs:enumeration value="activationspec"/>
- <xs:enumeration value="adminobject"/>
- </xs:restriction>
- */
-
- List<RaConfigPropertyMetaData> props = jmd.getRaConfigProps();
-
- List<ConfigPropertyMetaData> append = null;
-
- if (props != null)
- {
- for (RaConfigPropertyMetaData rcmd : props)
- {
- List<ConfigPropertyMetaData> listConfigProp = null;
- String override = rcmd.getOverride();
- if (override == null || override.equals("resourceadapter"))
- {
- if (cmd.getRa() != null)
- {
- listConfigProp = cmd.getRa().getConfigProperty();
- }
- }
- else if (override.equals("connection-definition"))
- {
- if (cmd.getRa() != null &&
- cmd.getRa().getOutboundRa() != null &&
- cmd.getRa().getOutboundRa().getConDefs() != null &&
- cmd.getRa().getOutboundRa().getConDefs().size() > 0 &&
- cmd.getRa().getOutboundRa().getConDefs().get(0) != null)
- {
- listConfigProp = cmd.getRa().getOutboundRa().getConDefs().get(0).getConfigProps();
- }
- }
- else if (override.equals("activationspec"))
- {
- if (cmd.getRa() != null &&
- cmd.getRa().getInboundRa() != null &&
- cmd.getRa().getInboundRa().getMessageAdapter() != null &&
- cmd.getRa().getInboundRa().getMessageAdapter().getMessageListeners() != null &&
- cmd.getRa().getInboundRa().getMessageAdapter().getMessageListeners().size() > 0 &&
- cmd.getRa().getInboundRa().getMessageAdapter().getMessageListeners().get(0) != null &&
- cmd.getRa().getInboundRa().getMessageAdapter().getMessageListeners().get(0).
- getActivationSpecType() != null)
- {
- listConfigProp = cmd.getRa().getInboundRa().getMessageAdapter().getMessageListeners().
- get(0).getActivationSpecType().getConfigProps();
- }
- }
- else if (override.equals("adminobject"))
- {
- if (cmd.getRa() != null &&
- cmd.getRa().getAdminObjects() != null &&
- cmd.getRa().getAdminObjects().size() > 0 &&
- cmd.getRa().getAdminObjects().get(0) != null)
- {
- listConfigProp = cmd.getRa().getAdminObjects().get(0).getConfigProps();
- }
- }
-
- boolean found = false;
-
- if (listConfigProp != null)
- {
- Iterator<ConfigPropertyMetaData> it = listConfigProp.iterator();
-
- while (!found && it.hasNext())
- {
- ConfigPropertyMetaData cpmd = it.next();
- if (cpmd.getName().equals(rcmd.getName()) &&
- cpmd.getType().equals(rcmd.getType()))
- {
- cpmd.setValue(rcmd.getValue());
- found = true;
- }
- }
- }
-
- if (!found)
- {
- if (append == null)
- append = new ArrayList<ConfigPropertyMetaData>();
-
- ConfigPropertyMetaData cpmd = new ConfigPropertyMetaData();
- cpmd.setName(rcmd.getName());
- cpmd.setType(rcmd.getType());
- cpmd.setValue(rcmd.getValue());
-
- append.add(cpmd);
- }
- }
-
- if (append != null)
- {
- if (cmd.getRa().getConfigProperty() == null)
- cmd.getRa().setConfigProperty(new ArrayList<ConfigPropertyMetaData>());
-
- for (ConfigPropertyMetaData cpmd : append)
- {
- cmd.getRa().getConfigProperty().add(cpmd);
- }
- }
- }
- }
-
- return cmd;
- }
-
- /**
- * Validate specification metadata
- * @param cmd The specification metadata
- * @return The merged metadata
- * @exception Exception Thrown if an error occurs
- */
- public ConnectorMetaData validate(ConnectorMetaData cmd) throws Exception
- {
- if (cmd.is10())
- {
- RA10MetaData ra10 = ((JCA10DTDMetaData)cmd).getRa10();
- if (ra10 == null
- || ra10.getManagedConnectionFactoryClass() == null
- || ra10.getManagedConnectionFactoryClass().equals(""))
- {
- throw new ValidateException("ManagedConnectionFactoryClass should be defined");
- }
- return cmd;
- }
- //make sure all need metadata parsered and processed after annotation handle
- if (cmd.getRa() == null)
- throw new ValidateException("ResourceAdapter metadata should be defined");
-
- //make sure ra metadata contains inbound or outbound at least
- boolean inboundOrOutbound = false;
- if (validateOutbound(cmd.getRa().getOutboundRa()))
- inboundOrOutbound = true;
- if (validateInbound(cmd.getRa().getInboundRa()) && cmd.getRa().getRaClass() != null)
- inboundOrOutbound = true;
- if (!inboundOrOutbound)
- throw new ValidateException("ResourceAdapter metadata should contains inbound or outbound at least");
- return cmd;
- }
-
- /**
- * Validate outbound metadata
- * @param omd The specification metadata
- * @return validate
- * @exception Exception Thrown if an error occurs
- */
- private boolean validateOutbound(OutboundRaMetaData omd) throws Exception
- {
- if (omd == null)
- return false;
- if (omd.getConDefs() == null || omd.getConDefs().size() == 0)
- return false;
- ConnectionDefinitionMetaData cdm = omd.getConDefs().get(0);
- if (cdm.getManagedConnectionFactoryClass() == null ||
- cdm.getConnectionFactoryInterfaceClass() == null ||
- cdm.getConnectionFactoryImplementationClass() == null ||
- cdm.getConnectionInterfaceClass() == null ||
- cdm.getConnectionImplementationClass() == null)
- return false;
-
- return true;
- }
-
- /**
- * Validate inbound metadata
- * @param cmd The specification metadata
- * @return validate
- * @exception Exception Thrown if an error occurs
- */
- private boolean validateInbound(InboundRaMetaData imd) throws Exception
- {
- if (imd == null)
- return false;
- if (imd.getMessageAdapter() == null ||
- imd.getMessageAdapter().getMessageListeners() == null ||
- imd.getMessageAdapter().getMessageListeners().size() == 0)
- return false;
- MessageListenerMetaData mlmd = imd.getMessageAdapter().getMessageListeners().get(0);
- if (mlmd.getType() == null ||
- mlmd.getActivationSpecType() == null ||
- mlmd.getActivationSpecType().getAsClass() == null)
- return false;
- return true;
- }
-}
Deleted: projects/jboss-jca/trunk/common/src/main/java/org/jboss/jca/common/SecurityActions.java
===================================================================
--- projects/jboss-jca/trunk/common/src/main/java/org/jboss/jca/common/SecurityActions.java 2010-06-29 14:05:46 UTC (rev 106307)
+++ projects/jboss-jca/trunk/common/src/main/java/org/jboss/jca/common/SecurityActions.java 2010-06-29 14:09:30 UTC (rev 106308)
@@ -1,106 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2008-2009, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file in the
- * distribution for a full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-
-package org.jboss.jca.common;
-
-import java.net.URL;
-import java.net.URLClassLoader;
-import java.security.AccessController;
-import java.security.PrivilegedAction;
-
-/**
- * Privileged Blocks
- * @author <a href="mailto:jesper.pedersen at jboss.org">Jesper Pedersen</a>
- */
-class SecurityActions
-{
- /**
- * Constructor
- */
- private SecurityActions()
- {
- }
-
- /**
- * Get the thread context class loader
- * @return The class loader
- */
- static ClassLoader getThreadContextClassLoader()
- {
- return AccessController.doPrivileged(new PrivilegedAction<ClassLoader>()
- {
- public ClassLoader run()
- {
- return Thread.currentThread().getContextClassLoader();
- }
- });
- }
-
- /**
- * Set the thread context class loader
- * @param cl The class loader
- */
- static void setThreadContextClassLoader(final ClassLoader cl)
- {
- AccessController.doPrivileged(new PrivilegedAction<Object>()
- {
- public Object run()
- {
- Thread.currentThread().setContextClassLoader(cl);
- return null;
- }
- });
- }
-
- /**
- * Get a system property
- * @param name The property name
- * @return The property value
- */
- static String getSystemProperty(final String name)
- {
- return AccessController.doPrivileged(new PrivilegedAction<String>()
- {
- public String run()
- {
- return System.getProperty(name);
- }
- });
- }
-
- /**
- * Create an URLClassLoader
- * @param urls The urls
- * @param parent The parent class loader
- * @return The class loader
- */
- static URLClassLoader createURLCLassLoader(final URL[] urls, final ClassLoader parent)
- {
- return AccessController.doPrivileged(new PrivilegedAction<URLClassLoader>()
- {
- public URLClassLoader run()
- {
- return new URLClassLoader(urls, parent);
- }
- });
- }
-}
Deleted: projects/jboss-jca/trunk/common/src/main/java/org/jboss/jca/common/ValidateException.java
===================================================================
--- projects/jboss-jca/trunk/common/src/main/java/org/jboss/jca/common/ValidateException.java 2010-06-29 14:05:46 UTC (rev 106307)
+++ projects/jboss-jca/trunk/common/src/main/java/org/jboss/jca/common/ValidateException.java 2010-06-29 14:09:30 UTC (rev 106308)
@@ -1,52 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2008-2009, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file in the
- * distribution for a full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-
-package org.jboss.jca.common;
-
-/**
- * The validate exception
- * @author <a href="mailto:jesper.pedersen at jboss.org">Jesper Pedersen</a>
- */
-public class ValidateException extends Exception
-{
- /** Serial version UID */
- static final long serialVersionUID = 3820032266224196804L;
-
- /**
- * Constructs a new exception with the specified detail message.
- * @param message The message
- */
- public ValidateException(String message)
- {
- super(message);
- }
-
- /**
- * Constructs a new exception with the specified detail message and cause.
- * @param message The message
- * @param cause The cause
- */
- public ValidateException(String message, Throwable cause)
- {
- super(message, cause);
- }
-}
Copied: projects/jboss-jca/trunk/common/src/main/java/org/jboss/jca/common/annotations/Annotations.java (from rev 106305, projects/jboss-jca/trunk/common/src/main/java/org/jboss/jca/common/Annotations.java)
===================================================================
--- projects/jboss-jca/trunk/common/src/main/java/org/jboss/jca/common/annotations/Annotations.java (rev 0)
+++ projects/jboss-jca/trunk/common/src/main/java/org/jboss/jca/common/annotations/Annotations.java 2010-06-29 14:09:30 UTC (rev 106308)
@@ -0,0 +1,1126 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008-2009, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.jca.common.annotations;
+
+import org.jboss.jca.common.validator.ValidateException;
+
+import java.lang.reflect.Array;
+import java.lang.reflect.Field;
+import java.lang.reflect.Method;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.Collection;
+
+import javax.resource.spi.Activation;
+import javax.resource.spi.AdministeredObject;
+import javax.resource.spi.AuthenticationMechanism;
+import javax.resource.spi.AuthenticationMechanism.CredentialInterface;
+import javax.resource.spi.ConfigProperty;
+import javax.resource.spi.ConnectionDefinition;
+import javax.resource.spi.ConnectionDefinitions;
+import javax.resource.spi.Connector;
+import javax.resource.spi.SecurityPermission;
+import javax.resource.spi.TransactionSupport;
+import javax.resource.spi.TransactionSupport.TransactionSupportLevel;
+import javax.resource.spi.work.WorkContext;
+
+import org.jboss.logging.Logger;
+
+import org.jboss.metadata.javaee.spec.DescriptionGroupMetaData;
+import org.jboss.metadata.javaee.spec.DescriptionImpl;
+import org.jboss.metadata.javaee.spec.DescriptionsImpl;
+import org.jboss.metadata.javaee.spec.DisplayNameImpl;
+import org.jboss.metadata.javaee.spec.DisplayNamesImpl;
+import org.jboss.metadata.javaee.spec.IconImpl;
+import org.jboss.metadata.javaee.spec.IconsImpl;
+
+import org.jboss.metadata.rar.spec.ActivationspecMetaData;
+import org.jboss.metadata.rar.spec.AdminObjectMetaData;
+import org.jboss.metadata.rar.spec.AuthenticationMechanismMetaData;
+import org.jboss.metadata.rar.spec.ConfigPropertyMetaData;
+import org.jboss.metadata.rar.spec.ConnectionDefinitionMetaData;
+import org.jboss.metadata.rar.spec.ConnectorMetaData;
+import org.jboss.metadata.rar.spec.InboundRaMetaData;
+import org.jboss.metadata.rar.spec.JCA16Base;
+import org.jboss.metadata.rar.spec.JCA16MetaData;
+import org.jboss.metadata.rar.spec.LicenseMetaData;
+import org.jboss.metadata.rar.spec.MessageAdapterMetaData;
+import org.jboss.metadata.rar.spec.MessageListenerMetaData;
+import org.jboss.metadata.rar.spec.OutboundRaMetaData;
+import org.jboss.metadata.rar.spec.ResourceAdapterMetaData;
+import org.jboss.metadata.rar.spec.SecurityPermissionMetaData;
+import org.jboss.metadata.rar.spec.TransactionSupportMetaData;
+
+import org.jboss.papaki.Annotation;
+import org.jboss.papaki.AnnotationRepository;
+import org.jboss.papaki.AnnotationScanner;
+import org.jboss.papaki.AnnotationScannerFactory;
+import org.jboss.papaki.AnnotationType;
+
+/**
+ * The annotation processor for JCA 1.6
+ * @author <a href="mailto:jesper.pedersen at jboss.org">Jesper Pedersen</a>
+ */
+public class Annotations
+{
+ private static Logger log = Logger.getLogger(Annotations.class);
+ private static boolean trace = log.isTraceEnabled();
+
+ /**
+ * Constructor
+ */
+ public Annotations()
+ {
+ }
+
+ /**
+ * Scan for annotations in the URLs specified
+ * @param cmd The resource adapter metadata
+ * @param urls The URLs to be scanned
+ * @param cl The referenced classloader
+ * @return The updated metadata
+ * @exception Exception Thrown if an error occurs
+ */
+ public ConnectorMetaData scan(ConnectorMetaData cmd, URL[] urls, ClassLoader cl) throws Exception
+ {
+ // Process annotations
+ if (cmd == null || cmd.is16())
+ {
+ AnnotationScanner annotationScanner =
+ AnnotationScannerFactory.getStrategy(AnnotationScannerFactory.JAVASSIST_INPUT_STREAM);
+ annotationScanner.configure().constructorLevel(false).parameterLevel(false);
+ AnnotationRepository annotationRepository = annotationScanner.scan(urls, cl);
+
+ boolean isMetadataComplete = false;
+ if (cmd != null && cmd instanceof JCA16Base)
+ {
+ JCA16Base jmd = (JCA16Base)cmd;
+ isMetadataComplete = jmd.isMetadataComplete();
+ }
+
+ if (cmd == null || !isMetadataComplete)
+ {
+ cmd = process(cmd, annotationRepository);
+ }
+ }
+ return cmd;
+ }
+ /**
+ * Process annotations
+ * @param md The metadata
+ * @param annotationRepository The annotation repository
+ * @return The updated metadata
+ * @exception Exception Thrown if an error occurs
+ */
+ public ConnectorMetaData process(ConnectorMetaData md, AnnotationRepository annotationRepository)
+ throws Exception
+ {
+ if (annotationRepository == null)
+ throw new ValidateException("AnnotationRepository reference is null");
+ /* Process
+ -------
+ javax.resource.spi.Activation
+ javax.resource.spi.AdministeredObject
+ javax.resource.spi.AuthenticationMechanism
+ javax.resource.spi.ConfigProperty
+ javax.resource.spi.ConnectionDefinition
+ javax.resource.spi.ConnectionDefinitions
+ javax.resource.spi.Connector
+ javax.resource.spi.SecurityPermission
+ */
+
+ if (md == null)
+ {
+ JCA16MetaData jmd = new JCA16MetaData();
+ jmd.setMetadataComplete(false);
+ md = jmd;
+ }
+
+ // @Connector
+ md = processConnector(md, annotationRepository);
+
+ // @ConnectionDefinitions
+ md = processConnectionDefinitions(md, annotationRepository);
+
+ // @ConnectionDefinition (outside of @ConnectionDefinitions)
+ md = processConnectionDefinition(md, annotationRepository);
+
+ // @Activation
+ md = processActivation(md, annotationRepository);
+
+ // @AuthenticationMechanism
+ //md = processAuthenticationMechanism(md, annotationRepository);
+
+ // @AdministeredObject
+ md = processAdministeredObject(md, annotationRepository);
+
+ // @ConfigProperty handle at last
+ md = processConfigProperty(md, annotationRepository);
+
+ //log.debug("ConnectorMetadata " + md);
+
+ return md;
+ }
+
+ /**
+ * Process: @Connector
+ * @param md The metadata
+ * @param annotationRepository The annotation repository
+ * @return The updated metadata
+ * @exception Exception Thrown if an error occurs
+ */
+ private ConnectorMetaData processConnector(ConnectorMetaData md, AnnotationRepository annotationRepository)
+ throws Exception
+ {
+ Collection<Annotation> values = annotationRepository.getAnnotation(Connector.class);
+ if (values != null)
+ {
+ if (values.size() == 1)
+ {
+ Annotation annotation = values.iterator().next();
+ String raClass = annotation.getClassName();
+ Connector c = (Connector)annotation.getAnnotation();
+
+ if (trace)
+ log.trace("Processing: " + c + " for " + raClass);
+
+ md = attachConnector(md, raClass, c);
+ }
+ else if (values.size() == 0)
+ {
+ // JBJCA-240
+ if (md.getRa().getRaClass() == null || md.getRa().getRaClass().equals(""))
+ {
+ log.fatal("No @Connector was found and no definition in the ra.xml metadata either");
+ throw new ValidateException("No @Connector defined");
+ }
+ }
+ else
+ {
+ // JBJCA-240
+ if (md.getRa().getRaClass() == null || md.getRa().getRaClass().equals(""))
+ {
+ log.fatal("More than one @Connector was found but the correct one " +
+ "wasn't defined in the ra.xml metadata");
+ throw new ValidateException("More than one @Connector defined");
+ }
+ }
+ }
+
+ return md;
+ }
+
+ /**
+ * Attach @Connector
+ * @param md The metadata
+ * @param raClass The class name for the resource adapter
+ * @param c The connector
+ * @return The updated metadata
+ * @exception Exception Thrown if an error occurs
+ */
+ private ConnectorMetaData attachConnector(ConnectorMetaData md, String raClass, Connector c)
+ throws Exception
+ {
+ // Class definition
+ if (md.getRa() == null)
+ md.setRa(new ResourceAdapterMetaData());
+
+ md.getRa().setRaClass(raClass);
+
+ // AuthenticationMechanism
+ AuthenticationMechanism[] authMechanisms = c.authMechanisms();
+ if (authMechanisms != null)
+ {
+ for (AuthenticationMechanism authMechanism : authMechanisms)
+ {
+ attachAuthenticationMechanism(md, authMechanism);
+ }
+ }
+
+ DescriptionGroupMetaData descGroup = new DescriptionGroupMetaData();
+ md.setDescriptionGroup(descGroup);
+
+ // Description
+ String[] description = c.description();
+ if (description != null)
+ {
+ if (descGroup.getDescriptions() == null)
+ {
+ DescriptionsImpl descsImpl = new DescriptionsImpl();
+ descGroup.setDescriptions(descsImpl);
+ }
+ for (String desc : description)
+ {
+ DescriptionImpl descImpl = new DescriptionImpl();
+ descImpl.setDescription(desc);
+ ((DescriptionsImpl)descGroup.getDescriptions()).add(descImpl);
+ }
+ }
+
+ // Display name
+ String[] displayName = c.displayName();
+ if (displayName != null)
+ {
+ if (descGroup.getDisplayNames() == null)
+ {
+ DisplayNamesImpl dnsImpl = new DisplayNamesImpl();
+ descGroup.setDisplayNames(dnsImpl);
+ }
+ for (String dn : displayName)
+ {
+ DisplayNameImpl dnImpl = new DisplayNameImpl();
+ dnImpl.setDisplayName(dn);
+ ((DisplayNamesImpl)descGroup.getDisplayNames()).add(dnImpl);
+ }
+ }
+
+ // EIS type
+ String eisType = c.eisType();
+ if (eisType != null)
+ {
+ if (md.getEISType() == null)
+ md.setEISType(eisType);
+ }
+
+ // Large icon
+ String[] largeIcon = c.largeIcon();
+ if (largeIcon != null)
+ {
+ if (descGroup.getIcons() == null)
+ {
+ IconsImpl icsImpl = new IconsImpl();
+ descGroup.setIcons(icsImpl);
+ }
+ for (String large : largeIcon)
+ {
+ IconImpl icImpl = new IconImpl();
+ icImpl.setLargeIcon(large);
+ ((IconsImpl)descGroup.getIcons()).add(icImpl);
+ }
+ }
+
+ // License description
+ String[] licenseDescription = c.licenseDescription();
+ if (licenseDescription != null)
+ {
+ if (md.getLicense() == null)
+ md.setLicense(new LicenseMetaData());
+
+ if (md.getLicense().getDescriptions() == null)
+ {
+ DescriptionsImpl descsImpl = new DescriptionsImpl();
+ md.getLicense().setDescriptions(descsImpl);
+ }
+ for (String desc : licenseDescription)
+ {
+ DescriptionImpl descImpl = new DescriptionImpl();
+ descImpl.setDescription(desc);
+ ((DescriptionsImpl)md.getLicense().getDescriptions()).add(descImpl);
+ }
+ }
+
+ // License required
+ boolean licenseRequired = c.licenseRequired();
+ if (md.getLicense() == null)
+ md.setLicense(new LicenseMetaData());
+ md.getLicense().setRequired(licenseRequired);
+
+ // Reauthentication support
+ boolean reauthenticationSupport = c.reauthenticationSupport();
+ if (md.getRa() != null && md.getRa().getOutboundRa() != null)
+ {
+ md.getRa().getOutboundRa().setReAuthSupport(reauthenticationSupport);
+ }
+
+ // RequiredWorkContext
+ Class<? extends WorkContext>[] requiredWorkContexts = c.requiredWorkContexts();
+ if (requiredWorkContexts != null)
+ {
+ for (Class<? extends WorkContext> requiredWorkContext : requiredWorkContexts)
+ {
+ if (md instanceof JCA16Base)
+ {
+ JCA16Base jmd = (JCA16Base)md;
+ if (jmd.getRequiredWorkContexts() == null)
+ jmd.setRequiredWorkContexts(new ArrayList<String>());
+
+ if (!jmd.getRequiredWorkContexts().contains(requiredWorkContext.getName()))
+ {
+ if (trace)
+ log.trace("RequiredWorkContext=" + requiredWorkContext.getName());
+
+ jmd.getRequiredWorkContexts().add(requiredWorkContext.getName());
+ }
+ }
+ }
+ }
+
+ // Security permission
+ SecurityPermission[] securityPermissions = c.securityPermissions();
+ if (securityPermissions != null)
+ {
+ if (md.getRa() == null)
+ md.setRa(new ResourceAdapterMetaData());
+
+ if (md.getRa().getSecurityPermissions() == null)
+ md.getRa().setSecurityPermissions(new ArrayList<SecurityPermissionMetaData>());
+
+ for (SecurityPermission securityPermission : securityPermissions)
+ {
+ SecurityPermissionMetaData spmd = new SecurityPermissionMetaData();
+ spmd.setSecurityPermissionSpec(securityPermission.permissionSpec());
+ md.getRa().getSecurityPermissions().add(spmd);
+ }
+ }
+
+ // Small icon
+ String[] smallIcon = c.smallIcon();
+ if (smallIcon != null)
+ {
+ IconsImpl icsImpl;
+ if (descGroup.getIcons() == null)
+ {
+ icsImpl = new IconsImpl();
+ descGroup.setIcons(icsImpl);
+ }
+ else
+ {
+ icsImpl = (IconsImpl)descGroup.getIcons();
+ }
+ IconImpl[] icArray = icsImpl.toArray(new IconImpl[icsImpl.size()]);
+ for (int i = 0; i < smallIcon.length; i++)
+ {
+ if (i < icArray.length)
+ icArray[i].setSmallIcon(smallIcon[i]);
+ else
+ {
+ IconImpl icImpl = new IconImpl();
+ icImpl.setLargeIcon(smallIcon[i]);
+ icsImpl.add(icImpl);
+ }
+ }
+ }
+
+ // Transaction support
+ TransactionSupport.TransactionSupportLevel transactionSupport = c.transactionSupport();
+ if (md.getRa() != null && md.getRa().getOutboundRa() != null)
+ {
+ if (transactionSupport.equals(TransactionSupportLevel.NoTransaction))
+ {
+ md.getRa().getOutboundRa().setTransSupport(TransactionSupportMetaData.NoTransaction);
+ }
+ else if (transactionSupport.equals(TransactionSupportLevel.XATransaction))
+ {
+ md.getRa().getOutboundRa().setTransSupport(TransactionSupportMetaData.XATransaction);
+ }
+ else if (transactionSupport.equals(TransactionSupportLevel.LocalTransaction))
+ {
+ md.getRa().getOutboundRa().setTransSupport(TransactionSupportMetaData.LocalTransaction);
+ }
+ }
+
+ // Vendor name
+ String vendorName = c.vendorName();
+ if (vendorName != null)
+ {
+ if (md.getVendorName() == null)
+ md.setVendorName(vendorName);
+ }
+
+ // Version
+ String version = c.version();
+ if (version != null)
+ {
+ if (md.getRAVersion() == null)
+ md.setRAVersion(version);
+ }
+
+ return md;
+ }
+
+ /**
+ * Process: @ConnectionDefinitions
+ * @param md The metadata
+ * @param annotationRepository The annotation repository
+ * @return The updated metadata
+ * @exception Exception Thrown if an error occurs
+ */
+ private ConnectorMetaData processConnectionDefinitions(ConnectorMetaData md,
+ AnnotationRepository annotationRepository)
+ throws Exception
+ {
+ Collection<Annotation> values = annotationRepository.getAnnotation(ConnectionDefinitions.class);
+ if (values != null)
+ {
+ if (values.size() == 1)
+ {
+ Annotation annotation = values.iterator().next();
+ ConnectionDefinitions c = (ConnectionDefinitions)annotation.getAnnotation();
+
+ if (trace)
+ log.trace("Processing: " + c);
+
+ md = attachConnectionDefinitions(md , c, annotation.getClassName());
+ }
+ else
+ throw new ValidateException("More than one @ConnectionDefinitions defined");
+ }
+
+ return md;
+ }
+
+ /**
+ * Attach @ConnectionDefinitions
+ * @param md The metadata
+ * @param cds The connection definitions
+ * @param mcf The managed connection factory
+ * @return The updated metadata
+ * @exception Exception Thrown if an error occurs
+ */
+ private ConnectorMetaData attachConnectionDefinitions(ConnectorMetaData md,
+ ConnectionDefinitions cds,
+ String mcf)
+ throws Exception
+ {
+ createConDefs(md);
+
+ if (cds.value() != null)
+ {
+ for (ConnectionDefinition cd : cds.value())
+ {
+ md = attachConnectionDefinition(md, mcf, cd);
+ }
+ }
+
+ return md;
+ }
+
+ /**
+ * Process: @ConnectionDefinition
+ * @param md The metadata
+ * @param annotationRepository The annotation repository
+ * @return The updated metadata
+ * @exception Exception Thrown if an error occurs
+ */
+ private ConnectorMetaData processConnectionDefinition(ConnectorMetaData md,
+ AnnotationRepository annotationRepository)
+ throws Exception
+ {
+ Collection<Annotation> values = annotationRepository.getAnnotation(ConnectionDefinition.class);
+ if (values != null)
+ {
+ for (Annotation annotation : values)
+ {
+ md = attachConnectionDefinition(md, annotation);
+ }
+ }
+
+ return md;
+ }
+
+ /**
+ * Attach @ConnectionDefinition
+ * @param md The metadata
+ * @param cd The connection definition
+ * @return The updated metadata
+ * @exception Exception Thrown if an error occurs
+ */
+ private ConnectorMetaData attachConnectionDefinition(ConnectorMetaData md, Annotation annotation)
+ throws Exception
+ {
+ ConnectionDefinition cd = (ConnectionDefinition)annotation.getAnnotation();
+
+ if (trace)
+ log.trace("Processing: " + annotation);
+
+ createConDefs(md);
+
+ for (ConnectionDefinitionMetaData cdMeta : md.getRa().getOutboundRa().getConDefs())
+ {
+ if (cdMeta.getManagedConnectionFactoryClass().equals(annotation.getClassName()))
+ {
+ //ra.xml define
+ return md;
+ }
+ }
+
+ return attachConnectionDefinition(md, annotation.getClassName(), cd);
+ }
+
+ /**
+ * Attach @ConnectionDefinition
+ * @param md The metadata
+ * @param mcf The managed connection factory
+ * @param cd The connection definition
+ * @return The updated metadata
+ * @exception Exception Thrown if an error occurs
+ */
+ private ConnectorMetaData attachConnectionDefinition(ConnectorMetaData md,
+ String mcf,
+ ConnectionDefinition cd)
+ throws Exception
+ {
+ if (trace)
+ log.trace("Processing: " + cd);
+
+ createConDefs(md);
+
+ ConnectionDefinitionMetaData cdMeta = new ConnectionDefinitionMetaData();
+ cdMeta.setManagedConnectionFactoryClass(mcf);
+ cdMeta.setConnectionFactoryInterfaceClass(cd.connectionFactory().getName());
+ cdMeta.setConnectionFactoryImplementationClass(cd.connectionFactoryImpl().getName());
+ cdMeta.setConnectionInterfaceClass(cd.connection().getName());
+ cdMeta.setConnectionImplementationClass(cd.connectionImpl().getName());
+ md.getRa().getOutboundRa().getConDefs().add(cdMeta);
+ return md;
+ }
+
+ /**
+ * Process: @ConfigProperty
+ * @param md The metadata
+ * @param annotationRepository The annotation repository
+ * @return The updated metadata
+ * @exception Exception Thrown if an error occurs
+ */
+ private ConnectorMetaData processConfigProperty(ConnectorMetaData md,
+ AnnotationRepository annotationRepository)
+ throws Exception
+ {
+ Collection<Annotation> values = annotationRepository.getAnnotation(ConfigProperty.class);
+ if (values != null)
+ {
+ for (Annotation annotation : values)
+ {
+ md = attachConfigProperty(md, annotation);
+ }
+ }
+
+ return md;
+ }
+
+ /**
+ * Attach @ConfigProperty
+ * @param md The metadata
+ * @param configProperty The config property
+ * @return The updated metadata
+ * @exception Exception Thrown if an error occurs
+ */
+ private ConnectorMetaData attachConfigProperty(ConnectorMetaData md, Annotation annotation)
+ throws Exception
+ {
+ ConfigProperty configProperty = (ConfigProperty)annotation.getAnnotation();
+
+ if (trace)
+ log.trace("Processing: " + configProperty);
+
+ // Ignore config-property which has ignore=true
+ if (configProperty.ignore())
+ return md;
+
+ ConfigPropertyMetaData cfgMeta = new ConfigPropertyMetaData();
+ cfgMeta.setName(getConfigPropertyName(annotation));
+
+ if (configProperty.defaultValue() != null && !configProperty.defaultValue().equals(""))
+ cfgMeta.setValue(configProperty.defaultValue());
+
+ if (!Object.class.equals(configProperty.type()))
+ {
+ cfgMeta.setType(configProperty.type().getName());
+ }
+ else
+ {
+ cfgMeta.setType(getConfigPropertyType(annotation));
+ }
+ cfgMeta.setIgnore(configProperty.ignore());
+
+ String[] description = configProperty.description();
+ if (description != null)
+ {
+ if (cfgMeta.getDescriptions() == null)
+ {
+ DescriptionsImpl descsImpl = new DescriptionsImpl();
+ cfgMeta.setDescriptions(descsImpl);
+ }
+ for (String desc : description)
+ {
+ DescriptionImpl descImpl = new DescriptionImpl();
+ descImpl.setDescription(desc);
+ ((DescriptionsImpl)cfgMeta.getDescriptions()).add(descImpl);
+ }
+ }
+
+ String attachedClassName = annotation.getClassName();
+ ClassLoader cl = SecurityActions.getThreadContextClassLoader();
+ Class attachedClass = Class.forName(attachedClassName, true, cl);
+
+ if (hasInterface(attachedClass, "javax.resource.spi.ResourceAdapter"))
+ {
+ if (md.getRa() == null)
+ {
+ md.setRa(new ResourceAdapterMetaData());
+ }
+ if (md.getRa().getConfigProperty() == null)
+ {
+ md.getRa().setConfigProperty(new ArrayList<ConfigPropertyMetaData>());
+ }
+ for (ConfigPropertyMetaData cpMeta : md.getRa().getConfigProperty())
+ {
+ if (cpMeta.getName().equals(cfgMeta.getName()))
+ {
+ return md;
+ }
+ }
+ md.getRa().getConfigProperty().add(cfgMeta);
+ }
+ else if (hasInterface(attachedClass, "javax.resource.spi.ManagedConnectionFactory"))
+ {
+ createConDefs(md);
+ for (ConnectionDefinitionMetaData cdMeta : md.getRa().getOutboundRa().getConDefs())
+ {
+ if (attachedClassName.equals(cdMeta.getManagedConnectionFactoryClass()))
+ {
+ if (cdMeta.getConfigProps() == null)
+ {
+ cdMeta.setConfigProps(new ArrayList<ConfigPropertyMetaData>());
+ }
+ for (ConfigPropertyMetaData cpMeta : cdMeta.getConfigProps())
+ {
+ if (cpMeta.getName().equals(cfgMeta.getName()))
+ {
+ return md;
+ }
+ }
+ cdMeta.getConfigProps().add(cfgMeta);
+ }
+ }
+ }
+ else if (hasInterface(attachedClass, "javax.resource.spi.ActivationSpec"))
+ {
+ createMessageListeners(md);
+ for (MessageListenerMetaData mlMeta : md.getRa().getInboundRa().getMessageAdapter().getMessageListeners())
+ {
+ if (attachedClassName.equals(mlMeta.getActivationSpecType().getAsClass()))
+ {
+ if (mlMeta.getActivationSpecType().getConfigProps() == null)
+ {
+ mlMeta.getActivationSpecType().setConfigProps(new ArrayList<ConfigPropertyMetaData>());
+ }
+ for (ConfigPropertyMetaData cpMeta : mlMeta.getActivationSpecType().getConfigProps())
+ {
+ if (cpMeta.getName().equals(cfgMeta.getName()))
+ {
+ return md;
+ }
+ }
+ mlMeta.getActivationSpecType().getConfigProps().add(cfgMeta);
+ }
+ }
+ }
+
+ return md;
+ }
+
+ /**
+ * hasInterface
+ *
+ * @param c
+ * @param targetClassName
+ * @return
+ */
+ private boolean hasInterface(Class c, String targetClassName)
+ {
+ for (Class face : c.getInterfaces())
+ {
+ if (face.getName().equals(targetClassName))
+ {
+ return true;
+ }
+ else
+ {
+ for (Class face2 : face.getInterfaces())
+ {
+ if (face2.getName().equals(targetClassName))
+ {
+ return true;
+ }
+ else if (hasInterface(face2, targetClassName))
+ {
+ return true;
+ }
+ }
+ }
+ }
+ if (null != c.getSuperclass())
+ {
+ return hasInterface(c.getSuperclass(), targetClassName);
+ }
+ return false;
+ }
+
+ /**
+ * Attach @AuthenticationMechanism
+ * @param md The metadata
+ * @param authenticationmechanism The authentication mechanism
+ * @return The updated metadata
+ * @exception Exception Thrown if an error occurs
+ */
+ private ConnectorMetaData attachAuthenticationMechanism(ConnectorMetaData md,
+ AuthenticationMechanism authenticationmechanism)
+ throws Exception
+ {
+ if (md.getRa() == null)
+ {
+ md.setRa(new ResourceAdapterMetaData());
+ }
+ if (md.getRa().getOutboundRa() == null)
+ {
+ md.getRa().setOutboundRa(new OutboundRaMetaData());
+ }
+ if (md.getRa().getOutboundRa().getAuthMechanisms() == null)
+ {
+ md.getRa().getOutboundRa().setAuthMechanisms(new ArrayList<AuthenticationMechanismMetaData>());
+ }
+ AuthenticationMechanismMetaData ammd = new AuthenticationMechanismMetaData();
+ ammd.setAuthenticationMechanismType(authenticationmechanism.authMechanism());
+
+ String credentialInterfaceClass = null;
+ if (authenticationmechanism.credentialInterface().equals(CredentialInterface.GenericCredential))
+ {
+ credentialInterfaceClass = "javax.resource.spi.security.GenericCredential";
+ }
+ else if (authenticationmechanism.credentialInterface().equals(CredentialInterface.GSSCredential))
+ {
+ credentialInterfaceClass = "org.ietf.jgss.GSSCredential";
+ }
+ else if (authenticationmechanism.credentialInterface().equals(CredentialInterface.PasswordCredential))
+ {
+ credentialInterfaceClass = "javax.resource.spi.security.PasswordCredential";
+ }
+ ammd.setCredentialInterfaceClass(credentialInterfaceClass);
+
+ String[] description = authenticationmechanism.description();
+ if (description != null)
+ {
+ if (ammd.getDescriptions() == null)
+ {
+ DescriptionsImpl descsImpl = new DescriptionsImpl();
+ ammd.setDescriptions(descsImpl);
+ }
+ for (String desc : description)
+ {
+ DescriptionImpl descImpl = new DescriptionImpl();
+ descImpl.setDescription(desc);
+ ((DescriptionsImpl)ammd.getDescriptions()).add(descImpl);
+ }
+ }
+
+ md.getRa().getOutboundRa().getAuthMechanisms().add(ammd);
+
+ return md;
+ }
+
+ /**
+ * Process: @AdministeredObject
+ * @param md The metadata
+ * @param annotationRepository The annotation repository
+ * @return The updated metadata
+ * @exception Exception Thrown if an error occurs
+ */
+ private ConnectorMetaData processAdministeredObject(ConnectorMetaData md,
+ AnnotationRepository annotationRepository)
+ throws Exception
+ {
+ Collection<Annotation> values = annotationRepository.getAnnotation(AdministeredObject.class);
+ if (values != null)
+ {
+ for (Annotation annotation : values)
+ {
+ AdministeredObject a = (AdministeredObject)annotation.getAnnotation();
+
+ if (trace)
+ log.trace("Processing: " + a);
+
+ md = attachAdministeredObject(md, a);
+ }
+ }
+
+ return md;
+ }
+
+ /**
+ * Attach @AdministeredObject
+ * @param md The metadata
+ * @param a The administered object
+ * @return The updated metadata
+ * @exception Exception Thrown if an error occurs
+ */
+ private ConnectorMetaData attachAdministeredObject(ConnectorMetaData md, AdministeredObject a)
+ throws Exception
+ {
+ createAdminObject(md);
+ String aoName = null;
+ if (a.adminObjectInterfaces().length > 0)
+ {
+ aoName = ((Class)Array.get(a.adminObjectInterfaces(), 0)).getName();
+ }
+ AdminObjectMetaData aomd = new AdminObjectMetaData();
+ aomd.setAdminObjectInterfaceClass(aoName);
+ md.getRa().getAdminObjects().add(aomd);
+ return md;
+ }
+
+ /**
+ * Process: @Activation
+ * @param md The metadata
+ * @param annotationRepository The annotation repository
+ * @return The updated metadata
+ * @exception Exception Thrown if an error occurs
+ */
+ private ConnectorMetaData processActivation(ConnectorMetaData md,
+ AnnotationRepository annotationRepository)
+ throws Exception
+ {
+ Collection<Annotation> values = annotationRepository.getAnnotation(Activation.class);
+ if (values != null)
+ {
+ for (Annotation annotation : values)
+ {
+ md = attachActivation(md, annotation);
+ }
+ }
+
+ return md;
+ }
+
+ /**
+ * Attach @Activation
+ * @param md The metadata
+ * @param activation The activation
+ * @return The updated metadata
+ * @exception Exception Thrown if an error occurs
+ */
+ private ConnectorMetaData attachActivation(ConnectorMetaData md, Annotation annotation)
+ throws Exception
+ {
+ Activation activation = (Activation)annotation.getAnnotation();
+
+ if (trace)
+ log.trace("Processing: " + activation);
+
+ createMessageListeners(md);
+ for (Class asClass : activation.messageListeners())
+ {
+ ActivationspecMetaData asMeta = new ActivationspecMetaData();
+ asMeta.setAsClass(annotation.getClassName());
+ MessageListenerMetaData mlMeta = new MessageListenerMetaData();
+ mlMeta.setActivationSpecType(asMeta);
+ mlMeta.setType(asClass.getName());
+ md.getRa().getInboundRa().getMessageAdapter().getMessageListeners().add(mlMeta);
+ }
+ return md;
+ }
+
+
+ /**
+ * createMessageListeners
+ * @param md
+ * @throws Exception
+ */
+ private void createMessageListeners(ConnectorMetaData md) throws Exception
+ {
+ if (md.getRa() == null)
+ {
+ md.setRa(new ResourceAdapterMetaData());
+ }
+ if (md.getRa().getInboundRa() == null)
+ {
+ md.getRa().setInboundRa(new InboundRaMetaData());
+ }
+ if (md.getRa().getInboundRa().getMessageAdapter() == null)
+ {
+ md.getRa().getInboundRa().setMessageAdapter(new MessageAdapterMetaData());
+ }
+ if (md.getRa().getInboundRa().getMessageAdapter().getMessageListeners() == null)
+ {
+ md.getRa().getInboundRa().getMessageAdapter().setMessageListeners(new ArrayList<MessageListenerMetaData>());
+ }
+ }
+
+ /**
+ * createAdminObject
+ * @param md
+ * @throws Exception
+ */
+ private void createAdminObject(ConnectorMetaData md) throws Exception
+ {
+ if (md.getRa() == null)
+ {
+ md.setRa(new ResourceAdapterMetaData());
+ }
+ if (md.getRa().getAdminObjects() == null)
+ {
+ md.getRa().setAdminObjects(new ArrayList<AdminObjectMetaData>());
+ }
+ }
+
+ /**
+ * createConDefs
+ * @param md
+ * @throws Exception
+ */
+ private void createConDefs(ConnectorMetaData md) throws Exception
+ {
+ if (md.getRa() == null)
+ {
+ md.setRa(new ResourceAdapterMetaData());
+ }
+ if (md.getRa().getOutboundRa() == null)
+ {
+ md.getRa().setOutboundRa(new OutboundRaMetaData());
+ }
+ if (md.getRa().getOutboundRa().getConDefs() == null)
+ {
+ md.getRa().getOutboundRa().setConDefs(new ArrayList<ConnectionDefinitionMetaData>());
+ }
+ }
+
+ /**
+ * Get the config-property-name for an annotation
+ * @param annotation The annotation
+ * @return The name
+ * @exception ClassNotFoundException Thrown if a class cannot be found
+ * @exception NoSuchFieldException Thrown if a field cannot be found
+ * @exception NoSuchMethodException Thrown if a method cannot be found
+ */
+ private String getConfigPropertyName(Annotation annotation)
+ throws ClassNotFoundException, NoSuchFieldException, NoSuchMethodException
+ {
+ if (AnnotationType.FIELD.equals(annotation.getType()))
+ {
+ return annotation.getMemberName();
+ }
+ else if (AnnotationType.METHOD.equals(annotation.getType()))
+ {
+ String name = annotation.getMemberName();
+
+ if (name.startsWith("set"))
+ {
+ name = name.substring(3);
+ }
+ else if (name.startsWith("get"))
+ {
+ name = name.substring(3);
+ }
+ else if (name.startsWith("is"))
+ {
+ name = name.substring(2);
+ }
+
+ if (name.length() > 1)
+ {
+ return Character.toLowerCase(name.charAt(0)) + name.substring(1);
+ }
+ else
+ {
+ return Character.toString(Character.toLowerCase(name.charAt(0)));
+ }
+ }
+
+ throw new IllegalArgumentException("Unknown annotation: " + annotation);
+ }
+
+ /**
+ * Get the config-property-type for an annotation
+ * @param annotation The annotation
+ * @return The fully qualified classname
+ * @exception ClassNotFoundException Thrown if a class cannot be found
+ */
+ @SuppressWarnings("unchecked")
+ private String getConfigPropertyType(Annotation annotation)
+ throws ClassNotFoundException
+ {
+ if (AnnotationType.FIELD.equals(annotation.getType()))
+ {
+ ClassLoader cl = SecurityActions.getThreadContextClassLoader();
+ Class clz = Class.forName(annotation.getClassName(), true, cl);
+
+ while (!Object.class.equals(clz))
+ {
+ try
+ {
+ Field field = clz.getDeclaredField(annotation.getMemberName());
+
+ return field.getType().getName();
+ }
+ catch (NoSuchFieldException nsfe)
+ {
+ clz = clz.getSuperclass();
+ }
+ }
+ }
+ else if (AnnotationType.METHOD.equals(annotation.getType()))
+ {
+ ClassLoader cl = SecurityActions.getThreadContextClassLoader();
+ Class clz = Class.forName(annotation.getClassName(), true, cl);
+
+ Class[] parameters = null;
+
+ if (annotation.getParameterTypes() != null)
+ {
+ parameters = new Class[annotation.getParameterTypes().length];
+
+ for (int i = 0; i < annotation.getParameterTypes().length; i++)
+ {
+ String parameter = annotation.getParameterTypes()[i];
+ parameters[i] = Class.forName(parameter, true, cl);
+ }
+ }
+
+ while (!Object.class.equals(clz))
+ {
+ try
+ {
+ Method method = clz.getDeclaredMethod(annotation.getMemberName(), parameters);
+
+ if (void.class.equals(method.getReturnType()))
+ {
+ if (parameters != null && parameters.length > 0)
+ {
+ return parameters[0].getName();
+ }
+ }
+ else
+ {
+ return method.getReturnType().getName();
+ }
+ }
+ catch (NoSuchMethodException nsme)
+ {
+ clz = clz.getSuperclass();
+ }
+ }
+ }
+
+ throw new IllegalArgumentException("Unknown annotation: " + annotation);
+ }
+}
Copied: projects/jboss-jca/trunk/common/src/main/java/org/jboss/jca/common/annotations/SecurityActions.java (from rev 106305, projects/jboss-jca/trunk/common/src/main/java/org/jboss/jca/common/SecurityActions.java)
===================================================================
--- projects/jboss-jca/trunk/common/src/main/java/org/jboss/jca/common/annotations/SecurityActions.java (rev 0)
+++ projects/jboss-jca/trunk/common/src/main/java/org/jboss/jca/common/annotations/SecurityActions.java 2010-06-29 14:09:30 UTC (rev 106308)
@@ -0,0 +1,106 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008-2009, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.jca.common.annotations;
+
+import java.net.URL;
+import java.net.URLClassLoader;
+import java.security.AccessController;
+import java.security.PrivilegedAction;
+
+/**
+ * Privileged Blocks
+ * @author <a href="mailto:jesper.pedersen at jboss.org">Jesper Pedersen</a>
+ */
+class SecurityActions
+{
+ /**
+ * Constructor
+ */
+ private SecurityActions()
+ {
+ }
+
+ /**
+ * Get the thread context class loader
+ * @return The class loader
+ */
+ static ClassLoader getThreadContextClassLoader()
+ {
+ return AccessController.doPrivileged(new PrivilegedAction<ClassLoader>()
+ {
+ public ClassLoader run()
+ {
+ return Thread.currentThread().getContextClassLoader();
+ }
+ });
+ }
+
+ /**
+ * Set the thread context class loader
+ * @param cl The class loader
+ */
+ static void setThreadContextClassLoader(final ClassLoader cl)
+ {
+ AccessController.doPrivileged(new PrivilegedAction<Object>()
+ {
+ public Object run()
+ {
+ Thread.currentThread().setContextClassLoader(cl);
+ return null;
+ }
+ });
+ }
+
+ /**
+ * Get a system property
+ * @param name The property name
+ * @return The property value
+ */
+ static String getSystemProperty(final String name)
+ {
+ return AccessController.doPrivileged(new PrivilegedAction<String>()
+ {
+ public String run()
+ {
+ return System.getProperty(name);
+ }
+ });
+ }
+
+ /**
+ * Create an URLClassLoader
+ * @param urls The urls
+ * @param parent The parent class loader
+ * @return The class loader
+ */
+ static URLClassLoader createURLCLassLoader(final URL[] urls, final ClassLoader parent)
+ {
+ return AccessController.doPrivileged(new PrivilegedAction<URLClassLoader>()
+ {
+ public URLClassLoader run()
+ {
+ return new URLClassLoader(urls, parent);
+ }
+ });
+ }
+}
Added: projects/jboss-jca/trunk/common/src/main/java/org/jboss/jca/common/annotations/package.html
===================================================================
--- projects/jboss-jca/trunk/common/src/main/java/org/jboss/jca/common/annotations/package.html (rev 0)
+++ projects/jboss-jca/trunk/common/src/main/java/org/jboss/jca/common/annotations/package.html 2010-06-29 14:09:30 UTC (rev 106308)
@@ -0,0 +1,3 @@
+<body>
+This package contains classes that handles common annotations operations.
+</body>
Deleted: projects/jboss-jca/trunk/common/src/main/java/org/jboss/jca/common/api/JBossResourceException.java
===================================================================
--- projects/jboss-jca/trunk/common/src/main/java/org/jboss/jca/common/api/JBossResourceException.java 2010-06-29 14:05:46 UTC (rev 106307)
+++ projects/jboss-jca/trunk/common/src/main/java/org/jboss/jca/common/api/JBossResourceException.java 2010-06-29 14:09:30 UTC (rev 106308)
@@ -1,212 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2008-2009, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file in the
- * distribution for a full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-
-package org.jboss.jca.common.api;
-
-import java.io.PrintStream;
-import java.io.PrintWriter;
-import java.lang.reflect.UndeclaredThrowableException;
-
-import javax.resource.ResourceException;
-
-import org.jboss.util.NestedThrowable;
-
-/**
- * Thrown to indicate a problem with a resource related operation.
- *
- * <p>
- * Properly displays linked exception (ie. nested exception)
- * when printing the stack trace.
- *
- * @version <tt>$Revision: 76129 $</tt>
- * @author <a href="mailto:jason at planet57.com">Jason Dillon</a>
- */
-public class JBossResourceException extends ResourceException implements NestedThrowable
-{
- /** The servial version uid*/
- private static final long serialVersionUID = 6614203184612359692L;
-
- /**
- * Rethrow as a resource exception if it is not already
- *
- * @param message the message
- * @param t the original exception
- * @throws ResourceException the resource exception
- */
- public static void rethrowAsResourceException(String message, Throwable t) throws ResourceException
- {
- if (t instanceof ResourceException)
- throw (ResourceException) t;
- else
- throw new JBossResourceException(message, t);
- }
-
- /**
- * Construct a <tt>JBossResourceException</tt> with the specified detail
- * message.
- *
- * @param msg Detail message.
- */
- public JBossResourceException(final String msg)
- {
- super(msg);
- }
-
- /**
- * Construct a <tt>JBossResourceException</tt> with the specified detail
- * message and error code.
- *
- * @param msg Detail message.
- * @param code Error code.
- */
- public JBossResourceException(final String msg, final String code)
- {
- super(msg, code);
- }
-
- /**
- * Construct a <tt>JBossResourceException</tt> with the specified detail
- * message, error code and linked <tt>Exception</tt>.
- *
- * @param msg Detail message.
- * @param code Error code.
- * @param linked Linked <tt>Exception</tt>.
- */
- @SuppressWarnings("deprecation")
- public JBossResourceException(final String msg, final String code, final Throwable linked)
- {
- super(msg, code);
- setLinkedException(process(linked));
- }
-
- /**
- * Construct a <tt>JBossResourceException</tt> with the specified detail
- * message and linked <tt>Exception</tt>.
- *
- * @param msg Detail message.
- * @param linked Linked <tt>Exception</tt>.
- */
- @SuppressWarnings("deprecation")
- public JBossResourceException(final String msg, final Throwable linked)
- {
- super(msg);
- setLinkedException(process(linked));
- }
-
- /**
- * Construct a <tt>JBossResourceException</tt> with the specified
- * linked <tt>Exception</tt>.
- *
- * @param linked Linked <tt>Exception</tt>.
- */
- public JBossResourceException(final Throwable linked)
- {
- this(linked.getMessage(), linked);
- }
-
- /**
- * Return the nested <tt>Throwable</tt>.
- *
- * @return Nested <tt>Throwable</tt>.
- */
- @SuppressWarnings("deprecation")
- public Throwable getNested()
- {
- return getLinkedException();
- }
-
- /**
- * Return the nested <tt>Throwable</tt>.
- *
- * <p>For JDK 1.4 compatibility.
- *
- * @return Nested <tt>Throwable</tt>.
- */
- @SuppressWarnings("deprecation")
- public Throwable getCause()
- {
- return getLinkedException();
- }
-
- /**
- * Returns the composite throwable message.
- *
- * @return The composite throwable message.
- */
- @SuppressWarnings("deprecation")
- public String getMessage()
- {
- return NestedThrowable.Util.getMessage(super.getMessage(), getLinkedException());
- }
-
- /**
- * Prints the composite message and the embedded stack trace to the
- * specified print stream.
- *
- * @param stream Stream to print to.
- */
- @SuppressWarnings("deprecation")
- public void printStackTrace(final PrintStream stream)
- {
- Exception linked = getLinkedException();
- if (linked == null || NestedThrowable.PARENT_TRACE_ENABLED)
- {
- super.printStackTrace(stream);
- }
- NestedThrowable.Util.print(linked, stream);
- }
-
- /**
- * Prints the composite message and the embedded stack trace to the
- * specified print writer.
- *
- * @param writer Writer to print to.
- */
- @SuppressWarnings("deprecation")
- public void printStackTrace(final PrintWriter writer)
- {
- Exception linked = getLinkedException();
- if (linked == null || NestedThrowable.PARENT_TRACE_ENABLED)
- {
- super.printStackTrace(writer);
- }
- NestedThrowable.Util.print(linked, writer);
- }
-
- /**
- * Prints the composite message and the embedded stack trace to
- * <tt>System.err</tt>.
- */
- public void printStackTrace()
- {
- printStackTrace(System.err);
- }
-
- private Exception process(Throwable t)
- {
- if (t instanceof Exception)
- {
- return (Exception)t;
- }
- return new UndeclaredThrowableException(t);
- }
-}
Copied: projects/jboss-jca/trunk/common/src/main/java/org/jboss/jca/common/metadata/Metadata.java (from rev 106305, projects/jboss-jca/trunk/common/src/main/java/org/jboss/jca/common/Metadata.java)
===================================================================
--- projects/jboss-jca/trunk/common/src/main/java/org/jboss/jca/common/metadata/Metadata.java (rev 0)
+++ projects/jboss-jca/trunk/common/src/main/java/org/jboss/jca/common/metadata/Metadata.java 2010-06-29 14:09:30 UTC (rev 106308)
@@ -0,0 +1,368 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008-2009, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.jca.common.metadata;
+
+import org.jboss.jca.common.validator.ValidateException;
+
+import java.io.File;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import org.jboss.logging.Logger;
+import org.jboss.metadata.rar.jboss.JBossRA10MetaData;
+import org.jboss.metadata.rar.jboss.JBossRA20DefaultNSMetaData;
+import org.jboss.metadata.rar.jboss.JBossRA20MetaData;
+import org.jboss.metadata.rar.jboss.JBossRAMetaData;
+import org.jboss.metadata.rar.jboss.RaConfigPropertyMetaData;
+import org.jboss.metadata.rar.spec.ConfigPropertyMetaData;
+import org.jboss.metadata.rar.spec.ConnectionDefinitionMetaData;
+import org.jboss.metadata.rar.spec.ConnectorMetaData;
+import org.jboss.metadata.rar.spec.InboundRaMetaData;
+import org.jboss.metadata.rar.spec.JCA10DTDMetaData;
+import org.jboss.metadata.rar.spec.JCA15DTDMetaData;
+import org.jboss.metadata.rar.spec.JCA15MetaData;
+import org.jboss.metadata.rar.spec.JCA16DTDMetaData;
+import org.jboss.metadata.rar.spec.JCA16DefaultNSMetaData;
+import org.jboss.metadata.rar.spec.JCA16MetaData;
+import org.jboss.metadata.rar.spec.MessageListenerMetaData;
+import org.jboss.metadata.rar.spec.OutboundRaMetaData;
+import org.jboss.metadata.rar.spec.RA10MetaData;
+
+import org.jboss.xb.binding.Unmarshaller;
+import org.jboss.xb.binding.UnmarshallerFactory;
+import org.jboss.xb.binding.resolver.MutableSchemaResolver;
+import org.jboss.xb.binding.sunday.unmarshalling.SingletonSchemaResolverFactory;
+
+/**
+ * The metadata processor for JCA 1.x
+ * @author <a href="mailto:jesper.pedersen at jboss.org">Jesper Pedersen</a>
+ * @author <a href="mailto:jeff.zhang at redhat.com">Jeff Zhang</a>
+ */
+public class Metadata
+{
+ private static Logger log = Logger.getLogger(Metadata.class);
+ private static boolean trace = log.isTraceEnabled();
+
+ /**
+ * Constructor
+ */
+ public Metadata()
+ {
+ }
+
+ /**
+ * Get the JCA standard metadata
+ * @param root The root of the deployment
+ * @return The metadata
+ * @exception Exception Thrown if an error occurs
+ */
+ public ConnectorMetaData getStandardMetaData(File root) throws Exception
+ {
+ ConnectorMetaData result = null;
+
+ UnmarshallerFactory unmarshallerFactory = UnmarshallerFactory.newInstance();
+ Unmarshaller unmarshaller = unmarshallerFactory.newUnmarshaller();
+
+ MutableSchemaResolver resolver = SingletonSchemaResolverFactory.getInstance().getSchemaBindingResolver();
+ resolver.mapLocationToClass("connector_1_6.xsd", JCA16MetaData.class);
+ resolver.mapLocationToClass("connector_1_5.xsd", JCA15MetaData.class);
+ resolver.mapLocationToClass("connector_1_5.dtd", JCA15DTDMetaData.class);
+ resolver.mapLocationToClass("connector_1_6.dtd", JCA16DTDMetaData.class);
+ resolver.mapLocationToClass("connector_1_0.dtd", JCA10DTDMetaData.class);
+ resolver.mapLocationToClass("connector", JCA16DefaultNSMetaData.class);
+
+ File metadataFile = new File(root, "/META-INF/ra.xml");
+
+ if (metadataFile.exists())
+ {
+ String url = metadataFile.getAbsolutePath();
+ try
+ {
+ long start = System.currentTimeMillis();
+
+ result = (ConnectorMetaData)unmarshaller.unmarshal(url, resolver);
+
+ log.debug("Total parse for " + url + " took " + (System.currentTimeMillis() - start) + "ms");
+
+ if (trace)
+ {
+ log.trace("successful parse " + result.getVersion() + " rar package " + result);
+ }
+
+ }
+ catch (Exception e)
+ {
+ log.error("Error during parsing: " + url, e);
+ throw e;
+ }
+ }
+
+ return result;
+ }
+
+ /**
+ * Get the JBoss specific metadata
+ * @param root The root of the deployment
+ * @return The metadata
+ * @exception Exception Thrown if an error occurs
+ */
+ public JBossRAMetaData getJBossMetaData(File root) throws Exception
+ {
+ JBossRAMetaData result = null;
+
+ UnmarshallerFactory unmarshallerFactory = UnmarshallerFactory.newInstance();
+ Unmarshaller unmarshaller = unmarshallerFactory.newUnmarshaller();
+
+ MutableSchemaResolver resolver = SingletonSchemaResolverFactory.getInstance().getSchemaBindingResolver();
+ resolver.mapLocationToClass("http://www.jboss.org/schema/jboss-ra_1_0.xsd", JBossRA10MetaData.class);
+ resolver.mapLocationToClass("http://www.jboss.org/schema/jboss-ra_2_0.xsd", JBossRA20MetaData.class);
+ resolver.mapLocationToClass("jboss-ra", JBossRA20DefaultNSMetaData.class);
+
+ File metadataFile = new File(root, "/META-INF/jboss-ra.xml");
+
+ if (metadataFile.exists())
+ {
+ String url = metadataFile.getAbsolutePath();
+ try
+ {
+ long start = System.currentTimeMillis();
+
+ result = (JBossRAMetaData)unmarshaller.unmarshal(url, resolver);
+
+ log.debug("Total parse for " + url + " took " + (System.currentTimeMillis() - start) + "ms");
+
+ if (trace)
+ log.trace(result);
+ }
+ catch (Exception e)
+ {
+ log.error("Error during parsing: " + url, e);
+ throw e;
+ }
+ }
+
+ return result;
+ }
+
+ /**
+ * Merge specification metadata with vendor metadata
+ * @param cmd The specification metadata
+ * @param jmd The vendor metadata
+ * @return The merged metadata
+ * @exception Exception Thrown if an error occurs
+ */
+ public ConnectorMetaData merge(ConnectorMetaData cmd, JBossRAMetaData jmd) throws Exception
+ {
+ if (cmd != null && jmd != null)
+ {
+ /*
+ <xs:restriction base="javaee:string">
+ <xs:enumeration value="connection-definition"/>
+ <xs:enumeration value="resourceadapter"/>
+ <xs:enumeration value="activationspec"/>
+ <xs:enumeration value="adminobject"/>
+ </xs:restriction>
+ */
+
+ List<RaConfigPropertyMetaData> props = jmd.getRaConfigProps();
+
+ List<ConfigPropertyMetaData> append = null;
+
+ if (props != null)
+ {
+ for (RaConfigPropertyMetaData rcmd : props)
+ {
+ List<ConfigPropertyMetaData> listConfigProp = null;
+ String override = rcmd.getOverride();
+ if (override == null || override.equals("resourceadapter"))
+ {
+ if (cmd.getRa() != null)
+ {
+ listConfigProp = cmd.getRa().getConfigProperty();
+ }
+ }
+ else if (override.equals("connection-definition"))
+ {
+ if (cmd.getRa() != null &&
+ cmd.getRa().getOutboundRa() != null &&
+ cmd.getRa().getOutboundRa().getConDefs() != null &&
+ cmd.getRa().getOutboundRa().getConDefs().size() > 0 &&
+ cmd.getRa().getOutboundRa().getConDefs().get(0) != null)
+ {
+ listConfigProp = cmd.getRa().getOutboundRa().getConDefs().get(0).getConfigProps();
+ }
+ }
+ else if (override.equals("activationspec"))
+ {
+ if (cmd.getRa() != null &&
+ cmd.getRa().getInboundRa() != null &&
+ cmd.getRa().getInboundRa().getMessageAdapter() != null &&
+ cmd.getRa().getInboundRa().getMessageAdapter().getMessageListeners() != null &&
+ cmd.getRa().getInboundRa().getMessageAdapter().getMessageListeners().size() > 0 &&
+ cmd.getRa().getInboundRa().getMessageAdapter().getMessageListeners().get(0) != null &&
+ cmd.getRa().getInboundRa().getMessageAdapter().getMessageListeners().get(0).
+ getActivationSpecType() != null)
+ {
+ listConfigProp = cmd.getRa().getInboundRa().getMessageAdapter().getMessageListeners().
+ get(0).getActivationSpecType().getConfigProps();
+ }
+ }
+ else if (override.equals("adminobject"))
+ {
+ if (cmd.getRa() != null &&
+ cmd.getRa().getAdminObjects() != null &&
+ cmd.getRa().getAdminObjects().size() > 0 &&
+ cmd.getRa().getAdminObjects().get(0) != null)
+ {
+ listConfigProp = cmd.getRa().getAdminObjects().get(0).getConfigProps();
+ }
+ }
+
+ boolean found = false;
+
+ if (listConfigProp != null)
+ {
+ Iterator<ConfigPropertyMetaData> it = listConfigProp.iterator();
+
+ while (!found && it.hasNext())
+ {
+ ConfigPropertyMetaData cpmd = it.next();
+ if (cpmd.getName().equals(rcmd.getName()) &&
+ cpmd.getType().equals(rcmd.getType()))
+ {
+ cpmd.setValue(rcmd.getValue());
+ found = true;
+ }
+ }
+ }
+
+ if (!found)
+ {
+ if (append == null)
+ append = new ArrayList<ConfigPropertyMetaData>();
+
+ ConfigPropertyMetaData cpmd = new ConfigPropertyMetaData();
+ cpmd.setName(rcmd.getName());
+ cpmd.setType(rcmd.getType());
+ cpmd.setValue(rcmd.getValue());
+
+ append.add(cpmd);
+ }
+ }
+
+ if (append != null)
+ {
+ if (cmd.getRa().getConfigProperty() == null)
+ cmd.getRa().setConfigProperty(new ArrayList<ConfigPropertyMetaData>());
+
+ for (ConfigPropertyMetaData cpmd : append)
+ {
+ cmd.getRa().getConfigProperty().add(cpmd);
+ }
+ }
+ }
+ }
+
+ return cmd;
+ }
+
+ /**
+ * Validate specification metadata
+ * @param cmd The specification metadata
+ * @return The merged metadata
+ * @exception Exception Thrown if an error occurs
+ */
+ public ConnectorMetaData validate(ConnectorMetaData cmd) throws Exception
+ {
+ if (cmd.is10() && (cmd instanceof JCA10DTDMetaData))
+ {
+ RA10MetaData ra10 = ((JCA10DTDMetaData)cmd).getRa10();
+ if (ra10 == null
+ || ra10.getManagedConnectionFactoryClass() == null
+ || ra10.getManagedConnectionFactoryClass().equals(""))
+ {
+ throw new ValidateException("ManagedConnectionFactoryClass should be defined");
+ }
+ return cmd;
+ }
+ //make sure all need metadata parsered and processed after annotation handle
+ if (cmd.getRa() == null)
+ throw new ValidateException("ResourceAdapter metadata should be defined");
+
+ //make sure ra metadata contains inbound or outbound at least
+ boolean inboundOrOutbound = false;
+ if (validateOutbound(cmd.getRa().getOutboundRa()))
+ inboundOrOutbound = true;
+ if (validateInbound(cmd.getRa().getInboundRa()) && cmd.getRa().getRaClass() != null)
+ inboundOrOutbound = true;
+ if (!inboundOrOutbound)
+ throw new ValidateException("ResourceAdapter metadata should contains inbound or outbound at least");
+ return cmd;
+ }
+
+ /**
+ * Validate outbound metadata
+ * @param omd The specification metadata
+ * @return validate
+ * @exception Exception Thrown if an error occurs
+ */
+ private boolean validateOutbound(OutboundRaMetaData omd) throws Exception
+ {
+ if (omd == null)
+ return false;
+ if (omd.getConDefs() == null || omd.getConDefs().size() == 0)
+ return false;
+ ConnectionDefinitionMetaData cdm = omd.getConDefs().get(0);
+ if (cdm.getManagedConnectionFactoryClass() == null ||
+ cdm.getConnectionFactoryInterfaceClass() == null ||
+ cdm.getConnectionFactoryImplementationClass() == null ||
+ cdm.getConnectionInterfaceClass() == null ||
+ cdm.getConnectionImplementationClass() == null)
+ return false;
+
+ return true;
+ }
+
+ /**
+ * Validate inbound metadata
+ * @param cmd The specification metadata
+ * @return validate
+ * @exception Exception Thrown if an error occurs
+ */
+ private boolean validateInbound(InboundRaMetaData imd) throws Exception
+ {
+ if (imd == null)
+ return false;
+ if (imd.getMessageAdapter() == null ||
+ imd.getMessageAdapter().getMessageListeners() == null ||
+ imd.getMessageAdapter().getMessageListeners().size() == 0)
+ return false;
+ MessageListenerMetaData mlmd = imd.getMessageAdapter().getMessageListeners().get(0);
+ if (mlmd.getType() == null ||
+ mlmd.getActivationSpecType() == null ||
+ mlmd.getActivationSpecType().getAsClass() == null)
+ return false;
+ return true;
+ }
+}
Added: projects/jboss-jca/trunk/common/src/main/java/org/jboss/jca/common/metadata/package.html
===================================================================
--- projects/jboss-jca/trunk/common/src/main/java/org/jboss/jca/common/metadata/package.html (rev 0)
+++ projects/jboss-jca/trunk/common/src/main/java/org/jboss/jca/common/metadata/package.html 2010-06-29 14:09:30 UTC (rev 106308)
@@ -0,0 +1,3 @@
+<body>
+This package contains classes that handles common metadata operations.
+</body>
Deleted: projects/jboss-jca/trunk/common/src/main/java/org/jboss/jca/common/util/ClassUtil.java
===================================================================
--- projects/jboss-jca/trunk/common/src/main/java/org/jboss/jca/common/util/ClassUtil.java 2010-06-29 14:05:46 UTC (rev 106307)
+++ projects/jboss-jca/trunk/common/src/main/java/org/jboss/jca/common/util/ClassUtil.java 2010-06-29 14:09:30 UTC (rev 106308)
@@ -1,105 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2008-2009, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file in the
- * distribution for a full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-
-package org.jboss.jca.common.util;
-
-import java.lang.reflect.Method;
-import java.lang.reflect.Modifier;
-
-/**
- * Utility for class related operations.
- *
- * @version $Rev$ $Date$
- */
-public final class ClassUtil
-{
- /** Empty class array */
- private static final Class<?>[] EMPTY_CLASS_ARRAY = new Class[0];
-
- // Not-instantiate me
- private ClassUtil()
- {
- // Empty
- }
-
- /**
- * Returns true if <b>from</b> is assignable to <b>to</b>, false otherwise.
- *
- * @param from assignable class
- * @param to assigned class
- * @return true if <b>from</b> is assignable to <b>to</b>, false ow.
- */
- public static boolean isClassAssignable(Class<?> from, Class<?> to)
- {
- if (from == null)
- {
- throw new IllegalArgumentException("from is null");
- }
-
- if (to == null)
- {
- throw new IllegalArgumentException("to is null");
- }
-
- return to.isAssignableFrom(from);
- }
-
- /**
- * Returns true if <b>synchronized</b> keyword exists, false otherwise.
- *
- * @param modifiers member modifieres
- * @return true if <b>synchronized</b> keyword exists, false otherwise
- */
- public static boolean modifiersHasSynchronizedKeyword(int modifiers)
- {
- return Modifier.isSynchronized(modifiers);
- }
-
- /**
- * Gets class' method with given name and parameter types.
- * @param clazz class
- * @param methodName method name
- * @param parameterTypes parameter types
- * @return method
- * @throws NoSuchMethodException if not method exist
- */
- public static Method getClassMethod(Class<?> clazz, String methodName,
- Class<?>[] parameterTypes) throws NoSuchMethodException
- {
- if (clazz == null)
- {
- throw new IllegalArgumentException("Class is null");
- }
-
- if (methodName == null || methodName.equals(""))
- {
- throw new IllegalArgumentException("Method name is null or empty");
- }
-
- if (parameterTypes == null)
- {
- parameterTypes = EMPTY_CLASS_ARRAY;
- }
-
- return clazz.getDeclaredMethod(methodName, parameterTypes);
- }
-}
Deleted: projects/jboss-jca/trunk/common/src/main/java/org/jboss/jca/common/util/SecurityActions.java
===================================================================
--- projects/jboss-jca/trunk/common/src/main/java/org/jboss/jca/common/util/SecurityActions.java 2010-06-29 14:05:46 UTC (rev 106307)
+++ projects/jboss-jca/trunk/common/src/main/java/org/jboss/jca/common/util/SecurityActions.java 2010-06-29 14:09:30 UTC (rev 106308)
@@ -1,54 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2008, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file in the
- * distribution for a full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-
-package org.jboss.jca.common.util;
-
-import java.security.AccessController;
-import java.security.PrivilegedAction;
-
-/**
- * Privileged Blocks
- *
- * @author Anil.Saldhana at redhat.com
- * @author <a href="mailto:gurkanerdogdu at yahoo.com">Gurkan Erdogdu</a>
- * @since Nov 7, 2008
- */
-public class SecurityActions
-{
- /**
- * Set context classloader.
- *
- * @param cl classloader
- */
- public static void setTCL(final ClassLoader cl)
- {
- AccessController.doPrivileged(new PrivilegedAction<Object>()
- {
- public Object run()
- {
- Thread.currentThread().setContextClassLoader(cl);
-
- return null;
- }
- });
- }
-}
Deleted: projects/jboss-jca/trunk/common/src/main/java/org/jboss/jca/common/util/SubjectActions.java
===================================================================
--- projects/jboss-jca/trunk/common/src/main/java/org/jboss/jca/common/util/SubjectActions.java 2010-06-29 14:05:46 UTC (rev 106307)
+++ projects/jboss-jca/trunk/common/src/main/java/org/jboss/jca/common/util/SubjectActions.java 2010-06-29 14:09:30 UTC (rev 106308)
@@ -1,96 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2008, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file in the
- * distribution for a full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.jca.common.util;
-
-import java.security.AccessController;
-import java.security.PrivilegedAction;
-
-import javax.security.auth.Subject;
-
-/**
- * SubjectActions.
- * @author <a href="mailto:gurkanerdogdu at yahoo.com">Gurkan Erdogdu</a>
- * @version $Rev$ $Date$
- *
- */
-public class SubjectActions implements PrivilegedAction<Object>
-{
- /**First subject instance*/
- private Subject subject;
-
- /**Other subject instance*/
- private Subject other;
-
- /**
- * Creates a new subject action.
- * @param subject first instance
- * @param other othe instance
- */
- SubjectActions(Subject subject, Subject other)
- {
- this.subject = subject;
- this.other = other;
- }
-
- /**
- * {@inheritDoc}
- */
- public Object run()
- {
- Object value = null;
-
- if (other == null)
- {
- value = Integer.valueOf(subject.hashCode());
- }
- else
- {
- value = Boolean.valueOf(subject.equals(other));
- }
-
- return value;
- }
-
- /**
- * HashCode.
- * @param subject subject instance
- * @return hash code
- */
- public static int hashCode(Subject subject)
- {
- SubjectActions action = new SubjectActions(subject, null);
- return ((Integer) AccessController.doPrivileged(action)).intValue();
- }
-
- /**
- * Equals.
- * @param subject subject instance
- * @param other other instance
- * @return equality
- */
- public static boolean equals(Subject subject, Subject other)
- {
- SubjectActions action = new SubjectActions(subject, other);
- return ((Boolean) AccessController.doPrivileged(action)).booleanValue();
- }
-}
-
Copied: projects/jboss-jca/trunk/common/src/main/java/org/jboss/jca/common/validator/ValidateException.java (from rev 106305, projects/jboss-jca/trunk/common/src/main/java/org/jboss/jca/common/ValidateException.java)
===================================================================
--- projects/jboss-jca/trunk/common/src/main/java/org/jboss/jca/common/validator/ValidateException.java (rev 0)
+++ projects/jboss-jca/trunk/common/src/main/java/org/jboss/jca/common/validator/ValidateException.java 2010-06-29 14:09:30 UTC (rev 106308)
@@ -0,0 +1,52 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008-2009, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.jca.common.validator;
+
+/**
+ * The validate exception
+ * @author <a href="mailto:jesper.pedersen at jboss.org">Jesper Pedersen</a>
+ */
+public class ValidateException extends Exception
+{
+ /** Serial version UID */
+ static final long serialVersionUID = 3820032266224196804L;
+
+ /**
+ * Constructs a new exception with the specified detail message.
+ * @param message The message
+ */
+ public ValidateException(String message)
+ {
+ super(message);
+ }
+
+ /**
+ * Constructs a new exception with the specified detail message and cause.
+ * @param message The message
+ * @param cause The cause
+ */
+ public ValidateException(String message, Throwable cause)
+ {
+ super(message, cause);
+ }
+}
Added: projects/jboss-jca/trunk/common/src/main/java/org/jboss/jca/common/validator/package.html
===================================================================
--- projects/jboss-jca/trunk/common/src/main/java/org/jboss/jca/common/validator/package.html (rev 0)
+++ projects/jboss-jca/trunk/common/src/main/java/org/jboss/jca/common/validator/package.html 2010-06-29 14:09:30 UTC (rev 106308)
@@ -0,0 +1,3 @@
+<body>
+This package contains classes that handles common validator operations.
+</body>
Deleted: projects/jboss-jca/trunk/common/src/main/resources/api-manifest.mf
===================================================================
--- projects/jboss-jca/trunk/common/src/main/resources/api-manifest.mf 2010-06-29 14:05:46 UTC (rev 106307)
+++ projects/jboss-jca/trunk/common/src/main/resources/api-manifest.mf 2010-06-29 14:09:30 UTC (rev 106308)
@@ -1,4 +0,0 @@
-Implementation-Title: JBoss JCA Common API
-Implementation-Vendor: Red Hat Middleware LLC
-Implementation-Vendor-Id: org.jboss
-Implementation-Version: 0.1
Copied: projects/jboss-jca/trunk/common/src/main/resources/common-manifest.mf (from rev 106305, projects/jboss-jca/trunk/common/src/main/resources/impl-manifest.mf)
===================================================================
--- projects/jboss-jca/trunk/common/src/main/resources/common-manifest.mf (rev 0)
+++ projects/jboss-jca/trunk/common/src/main/resources/common-manifest.mf 2010-06-29 14:09:30 UTC (rev 106308)
@@ -0,0 +1,4 @@
+Implementation-Title: JBoss JCA Common
+Implementation-Vendor: Red Hat Middleware LLC
+Implementation-Vendor-Id: org.jboss
+Implementation-Version: 0.1
Deleted: projects/jboss-jca/trunk/common/src/main/resources/impl-manifest.mf
===================================================================
--- projects/jboss-jca/trunk/common/src/main/resources/impl-manifest.mf 2010-06-29 14:05:46 UTC (rev 106307)
+++ projects/jboss-jca/trunk/common/src/main/resources/impl-manifest.mf 2010-06-29 14:09:30 UTC (rev 106308)
@@ -1,4 +0,0 @@
-Implementation-Title: JBoss JCA Common Implementation
-Implementation-Vendor: Red Hat Middleware LLC
-Implementation-Vendor-Id: org.jboss
-Implementation-Version: 0.1
Modified: projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/connectionmanager/AbstractConnectionManager.java
===================================================================
--- projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/connectionmanager/AbstractConnectionManager.java 2010-06-29 14:05:46 UTC (rev 106307)
+++ projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/connectionmanager/AbstractConnectionManager.java 2010-06-29 14:09:30 UTC (rev 106308)
@@ -22,7 +22,7 @@
package org.jboss.jca.core.connectionmanager;
-import org.jboss.jca.common.api.JBossResourceException;
+import org.jboss.jca.common.JBossResourceException;
import org.jboss.jca.core.connectionmanager.listener.ConnectionListener;
import org.jboss.jca.core.connectionmanager.listener.ConnectionState;
import org.jboss.jca.core.connectionmanager.pool.api.ManagedConnectionPool;
Modified: projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/connectionmanager/listener/TxConnectionListener.java
===================================================================
--- projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/connectionmanager/listener/TxConnectionListener.java 2010-06-29 14:05:46 UTC (rev 106307)
+++ projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/connectionmanager/listener/TxConnectionListener.java 2010-06-29 14:09:30 UTC (rev 106308)
@@ -21,7 +21,7 @@
*/
package org.jboss.jca.core.connectionmanager.listener;
-import org.jboss.jca.common.api.JBossResourceException;
+import org.jboss.jca.common.JBossResourceException;
import org.jboss.jca.core.connectionmanager.AbstractConnectionManager;
import org.jboss.jca.core.connectionmanager.pool.api.ManagedConnectionPool;
import org.jboss.jca.core.connectionmanager.transaction.TransactionSynchronizer;
Modified: projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/connectionmanager/pool/AbstractPool.java
===================================================================
--- projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/connectionmanager/pool/AbstractPool.java 2010-06-29 14:05:46 UTC (rev 106307)
+++ projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/connectionmanager/pool/AbstractPool.java 2010-06-29 14:09:30 UTC (rev 106308)
@@ -22,7 +22,7 @@
package org.jboss.jca.core.connectionmanager.pool;
-import org.jboss.jca.common.api.JBossResourceException;
+import org.jboss.jca.common.JBossResourceException;
import org.jboss.jca.core.connectionmanager.exception.RetryableResourceException;
import org.jboss.jca.core.connectionmanager.listener.ConnectionListener;
import org.jboss.jca.core.connectionmanager.listener.ConnectionListenerFactory;
Modified: projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/connectionmanager/pool/InternalManagedConnectionPool.java
===================================================================
--- projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/connectionmanager/pool/InternalManagedConnectionPool.java 2010-06-29 14:05:46 UTC (rev 106307)
+++ projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/connectionmanager/pool/InternalManagedConnectionPool.java 2010-06-29 14:09:30 UTC (rev 106308)
@@ -22,7 +22,7 @@
package org.jboss.jca.core.connectionmanager.pool;
-import org.jboss.jca.common.api.JBossResourceException;
+import org.jboss.jca.common.JBossResourceException;
import org.jboss.jca.core.connectionmanager.ConnectionValidator;
import org.jboss.jca.core.connectionmanager.IdleConnectionRemovalSupport;
import org.jboss.jca.core.connectionmanager.IdleRemover;
Modified: projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/connectionmanager/pool/PoolFiller.java
===================================================================
--- projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/connectionmanager/pool/PoolFiller.java 2010-06-29 14:05:46 UTC (rev 106307)
+++ projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/connectionmanager/pool/PoolFiller.java 2010-06-29 14:09:30 UTC (rev 106308)
@@ -21,8 +21,6 @@
*/
package org.jboss.jca.core.connectionmanager.pool;
-import org.jboss.jca.common.util.SecurityActions;
-
import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.locks.Condition;
@@ -91,7 +89,7 @@
public void run()
{
final ClassLoader myClassLoader = getClass().getClassLoader();
- SecurityActions.setTCL(myClassLoader);
+ SecurityActions.setThreadContextClassLoader(myClassLoader);
// keep going unless interrupted
while (true)
Copied: projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/connectionmanager/pool/SecurityActions.java (from rev 106305, projects/jboss-jca/trunk/common/src/main/java/org/jboss/jca/common/util/SecurityActions.java)
===================================================================
--- projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/connectionmanager/pool/SecurityActions.java (rev 0)
+++ projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/connectionmanager/pool/SecurityActions.java 2010-06-29 14:09:30 UTC (rev 106308)
@@ -0,0 +1,58 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.jca.core.connectionmanager.pool;
+
+import java.security.AccessController;
+import java.security.PrivilegedAction;
+
+/**
+ * Privileged Blocks
+ *
+ * @author <a href="mailto:gurkanerdogdu at yahoo.com">Gurkan Erdogdu</a>
+ */
+class SecurityActions
+{
+ /**
+ * Set the context classloader.
+ * @param cl classloader
+ */
+ public static void setThreadContextClassLoader(final ClassLoader cl)
+ {
+ if (System.getSecurityManager() == null)
+ {
+ Thread.currentThread().setContextClassLoader(cl);
+ }
+ else
+ {
+ AccessController.doPrivileged(new PrivilegedAction<Object>()
+ {
+ public Object run()
+ {
+ Thread.currentThread().setContextClassLoader(cl);
+
+ return null;
+ }
+ });
+ }
+ }
+}
Copied: projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/connectionmanager/pool/strategy/SubjectActions.java (from rev 106305, projects/jboss-jca/trunk/common/src/main/java/org/jboss/jca/common/util/SubjectActions.java)
===================================================================
--- projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/connectionmanager/pool/strategy/SubjectActions.java (rev 0)
+++ projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/connectionmanager/pool/strategy/SubjectActions.java 2010-06-29 14:09:30 UTC (rev 106308)
@@ -0,0 +1,96 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.jca.core.connectionmanager.pool.strategy;
+
+import java.security.AccessController;
+import java.security.PrivilegedAction;
+
+import javax.security.auth.Subject;
+
+/**
+ * SubjectActions.
+ * @author <a href="mailto:gurkanerdogdu at yahoo.com">Gurkan Erdogdu</a>
+ * @version $Rev$ $Date$
+ *
+ */
+class SubjectActions implements PrivilegedAction<Object>
+{
+ /**First subject instance*/
+ private Subject subject;
+
+ /**Other subject instance*/
+ private Subject other;
+
+ /**
+ * Creates a new subject action.
+ * @param subject first instance
+ * @param other othe instance
+ */
+ SubjectActions(Subject subject, Subject other)
+ {
+ this.subject = subject;
+ this.other = other;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public Object run()
+ {
+ Object value = null;
+
+ if (other == null)
+ {
+ value = Integer.valueOf(subject.hashCode());
+ }
+ else
+ {
+ value = Boolean.valueOf(subject.equals(other));
+ }
+
+ return value;
+ }
+
+ /**
+ * HashCode.
+ * @param subject subject instance
+ * @return hash code
+ */
+ public static int hashCode(Subject subject)
+ {
+ SubjectActions action = new SubjectActions(subject, null);
+ return ((Integer) AccessController.doPrivileged(action)).intValue();
+ }
+
+ /**
+ * Equals.
+ * @param subject subject instance
+ * @param other other instance
+ * @return equality
+ */
+ public static boolean equals(Subject subject, Subject other)
+ {
+ SubjectActions action = new SubjectActions(subject, other);
+ return ((Boolean) AccessController.doPrivileged(action)).booleanValue();
+ }
+}
+
Modified: projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/connectionmanager/pool/strategy/SubjectCriKey.java
===================================================================
--- projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/connectionmanager/pool/strategy/SubjectCriKey.java 2010-06-29 14:05:46 UTC (rev 106307)
+++ projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/connectionmanager/pool/strategy/SubjectCriKey.java 2010-06-29 14:09:30 UTC (rev 106308)
@@ -22,8 +22,6 @@
package org.jboss.jca.core.connectionmanager.pool.strategy;
-import org.jboss.jca.common.util.SubjectActions;
-
import javax.resource.spi.ConnectionRequestInfo;
import javax.security.auth.Subject;
Modified: projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/connectionmanager/pool/strategy/SubjectKey.java
===================================================================
--- projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/connectionmanager/pool/strategy/SubjectKey.java 2010-06-29 14:05:46 UTC (rev 106307)
+++ projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/connectionmanager/pool/strategy/SubjectKey.java 2010-06-29 14:09:30 UTC (rev 106308)
@@ -22,8 +22,6 @@
package org.jboss.jca.core.connectionmanager.pool.strategy;
-import org.jboss.jca.common.util.SubjectActions;
-
import javax.security.auth.Subject;
/**
Modified: projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/connectionmanager/tx/TxConnectionManager.java
===================================================================
--- projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/connectionmanager/tx/TxConnectionManager.java 2010-06-29 14:05:46 UTC (rev 106307)
+++ projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/connectionmanager/tx/TxConnectionManager.java 2010-06-29 14:09:30 UTC (rev 106308)
@@ -21,7 +21,7 @@
*/
package org.jboss.jca.core.connectionmanager.tx;
-import org.jboss.jca.common.api.JBossResourceException;
+import org.jboss.jca.common.JBossResourceException;
import org.jboss.jca.core.connectionmanager.AbstractConnectionManager;
import org.jboss.jca.core.connectionmanager.ConnectionRecord;
import org.jboss.jca.core.connectionmanager.listener.ConnectionListener;
Copied: projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/workmanager/ClassUtil.java (from rev 106305, projects/jboss-jca/trunk/common/src/main/java/org/jboss/jca/common/util/ClassUtil.java)
===================================================================
--- projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/workmanager/ClassUtil.java (rev 0)
+++ projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/workmanager/ClassUtil.java 2010-06-29 14:09:30 UTC (rev 106308)
@@ -0,0 +1,97 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008-2009, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.jca.core.workmanager;
+
+import java.lang.reflect.Method;
+import java.lang.reflect.Modifier;
+
+/**
+ * Utility for class related operations.
+ *
+ * @version $Rev$ $Date$
+ */
+final class ClassUtil
+{
+ /** Empty class array */
+ private static final Class<?>[] EMPTY_CLASS_ARRAY = new Class[0];
+
+ /**
+ * Private constructor
+ */
+ private ClassUtil()
+ {
+ }
+
+ /**
+ * Returns true if <b>from</b> is assignable to <b>to</b>, false otherwise.
+ *
+ * @param from assignable class
+ * @param to assigned class
+ * @return true if <b>from</b> is assignable to <b>to</b>, false ow.
+ */
+ static boolean isClassAssignable(Class<?> from, Class<?> to)
+ {
+ if (from == null)
+ throw new IllegalArgumentException("from is null");
+
+ if (to == null)
+ throw new IllegalArgumentException("to is null");
+
+ return to.isAssignableFrom(from);
+ }
+
+ /**
+ * Returns true if <b>synchronized</b> keyword exists, false otherwise.
+ *
+ * @param modifiers member modifieres
+ * @return true if <b>synchronized</b> keyword exists, false otherwise
+ */
+ static boolean modifiersHasSynchronizedKeyword(int modifiers)
+ {
+ return Modifier.isSynchronized(modifiers);
+ }
+
+ /**
+ * Gets class' method with given name and parameter types.
+ * @param clazz class
+ * @param methodName method name
+ * @param parameterTypes parameter types
+ * @return method
+ * @throws NoSuchMethodException if not method exist
+ */
+ static Method getClassMethod(Class<?> clazz, String methodName,
+ Class<?>[] parameterTypes) throws NoSuchMethodException
+ {
+ if (clazz == null)
+ throw new IllegalArgumentException("Class is null");
+
+
+ if (methodName == null || methodName.equals(""))
+ throw new IllegalArgumentException("Method name is null or empty");
+
+ if (parameterTypes == null)
+ parameterTypes = EMPTY_CLASS_ARRAY;
+
+ return clazz.getDeclaredMethod(methodName, parameterTypes);
+ }
+}
Modified: projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/workmanager/WorkManagerImpl.java
===================================================================
--- projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/workmanager/WorkManagerImpl.java 2010-06-29 14:05:46 UTC (rev 106307)
+++ projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/workmanager/WorkManagerImpl.java 2010-06-29 14:09:30 UTC (rev 106308)
@@ -22,7 +22,6 @@
package org.jboss.jca.core.workmanager;
-import org.jboss.jca.common.util.ClassUtil;
import org.jboss.jca.core.api.WorkManager;
import org.jboss.jca.core.spi.security.Callback;
Modified: projects/jboss-jca/trunk/deployers/src/main/java/org/jboss/jca/deployers/fungal/RADeployer.java
===================================================================
--- projects/jboss-jca/trunk/deployers/src/main/java/org/jboss/jca/deployers/fungal/RADeployer.java 2010-06-29 14:05:46 UTC (rev 106307)
+++ projects/jboss-jca/trunk/deployers/src/main/java/org/jboss/jca/deployers/fungal/RADeployer.java 2010-06-29 14:09:30 UTC (rev 106308)
@@ -22,10 +22,10 @@
package org.jboss.jca.deployers.fungal;
-import org.jboss.jca.common.Annotations;
-import org.jboss.jca.common.Metadata;
+import org.jboss.jca.common.annotations.Annotations;
import org.jboss.jca.common.api.ConnectionFactoryBuilder;
import org.jboss.jca.common.api.ConnectionFactoryJndiNameBuilder;
+import org.jboss.jca.common.metadata.Metadata;
import org.jboss.jca.common.util.ContainerConnectionFactoryJndiNameBuilder;
import org.jboss.jca.common.util.LocalConnectionFactoryBuilder;
import org.jboss.jca.core.api.CloneableBootstrapContext;
Modified: projects/jboss-jca/trunk/deployers/src/test/java/org/jboss/jca/deployers/annotations/AnnotationsTestCase.java
===================================================================
--- projects/jboss-jca/trunk/deployers/src/test/java/org/jboss/jca/deployers/annotations/AnnotationsTestCase.java 2010-06-29 14:05:46 UTC (rev 106307)
+++ projects/jboss-jca/trunk/deployers/src/test/java/org/jboss/jca/deployers/annotations/AnnotationsTestCase.java 2010-06-29 14:09:30 UTC (rev 106308)
@@ -22,8 +22,8 @@
package org.jboss.jca.deployers.annotations;
-import org.jboss.jca.common.Annotations;
-import org.jboss.jca.common.ValidateException;
+import org.jboss.jca.common.annotations.Annotations;
+import org.jboss.jca.common.validator.ValidateException;
import org.jboss.jca.embedded.EmbeddedJCA;
import java.io.File;
Modified: projects/jboss-jca/trunk/validator/src/main/java/org/jboss/jca/validator/Validation.java
===================================================================
--- projects/jboss-jca/trunk/validator/src/main/java/org/jboss/jca/validator/Validation.java 2010-06-29 14:05:46 UTC (rev 106307)
+++ projects/jboss-jca/trunk/validator/src/main/java/org/jboss/jca/validator/Validation.java 2010-06-29 14:09:30 UTC (rev 106308)
@@ -21,8 +21,8 @@
*/
package org.jboss.jca.validator;
-import org.jboss.jca.common.Annotations;
-import org.jboss.jca.common.Metadata;
+import org.jboss.jca.common.annotations.Annotations;
+import org.jboss.jca.common.metadata.Metadata;
import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
More information about the jboss-cvs-commits
mailing list