[jboss-cvs] JBossAS SVN: r96988 - in branches/JBPAPP_5_0: connector/src/main/org/jboss/resource/deployment and 7 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Wed Nov 25 14:37:43 EST 2009
Author: jesper.pedersen
Date: 2009-11-25 14:37:43 -0500 (Wed, 25 Nov 2009)
New Revision: 96988
Added:
branches/JBPAPP_5_0/connector/src/main/org/jboss/resource/deployment/ConfigProperty.java
branches/JBPAPP_5_0/connector/src/main/org/jboss/resource/deployment/ConfigPropertyHandler.java
branches/JBPAPP_5_0/testsuite/src/main/org/jboss/test/jca/primitive/
branches/JBPAPP_5_0/testsuite/src/main/org/jboss/test/jca/primitive/AdminObject.java
branches/JBPAPP_5_0/testsuite/src/main/org/jboss/test/jca/primitive/Connection.java
branches/JBPAPP_5_0/testsuite/src/main/org/jboss/test/jca/primitive/ConnectionFactory.java
branches/JBPAPP_5_0/testsuite/src/main/org/jboss/test/jca/primitive/ManagedConnection.java
branches/JBPAPP_5_0/testsuite/src/main/org/jboss/test/jca/primitive/TestConnectionFactory.java
branches/JBPAPP_5_0/testsuite/src/main/org/jboss/test/jca/primitive/TestResourceAdapter.java
branches/JBPAPP_5_0/testsuite/src/main/org/jboss/test/jca/test/PrimitiveUnitTestCase.java
branches/JBPAPP_5_0/testsuite/src/resources/jca/primitive/
branches/JBPAPP_5_0/testsuite/src/resources/jca/primitive/META-INF/
branches/JBPAPP_5_0/testsuite/src/resources/jca/primitive/META-INF/ra.xml
branches/JBPAPP_5_0/testsuite/src/resources/jca/primitive/jcaprimitive-ds.xml
Modified:
branches/JBPAPP_5_0/connector/src/main/org/jboss/resource/connectionmanager/RARDeployment.java
branches/JBPAPP_5_0/connector/src/main/org/jboss/resource/deployment/AdminObjectFactory.java
branches/JBPAPP_5_0/connector/src/main/org/jboss/resource/deployment/ResourceAdapterFactory.java
branches/JBPAPP_5_0/testsuite/imports/sections/jca.xml
Log:
[JBPAPP-2810] Support primitive types for config-properties
Modified: branches/JBPAPP_5_0/connector/src/main/org/jboss/resource/connectionmanager/RARDeployment.java
===================================================================
--- branches/JBPAPP_5_0/connector/src/main/org/jboss/resource/connectionmanager/RARDeployment.java 2009-11-25 19:36:57 UTC (rev 96987)
+++ branches/JBPAPP_5_0/connector/src/main/org/jboss/resource/connectionmanager/RARDeployment.java 2009-11-25 19:37:43 UTC (rev 96988)
@@ -40,6 +40,8 @@
import org.jboss.deployers.spi.DeploymentException;
import org.jboss.logging.Logger;
import org.jboss.metadata.MetaData;
+import org.jboss.resource.deployment.ConfigProperty;
+import org.jboss.resource.deployment.ConfigPropertyHandler;
import org.jboss.resource.metadata.ConfigPropertyMetaData;
import org.jboss.resource.metadata.ConnectionDefinitionMetaData;
import org.jboss.resource.metadata.ConnectorMetaData;
@@ -49,6 +51,7 @@
import org.w3c.dom.Element;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
+
/**
* The RARDeployment mbean manages instantiation and configuration of a
* ManagedConnectionFactory instance. It is intended to be configured
@@ -110,6 +113,8 @@
private ManagedConnectionFactory mcf;
+ private ConfigPropertyHandler configPropertyHandler;
+
/**
* Default managed constructor for RARDeployment mbeans.
*/
@@ -346,7 +351,7 @@
}
//set overridden properties;
setMcfProperties(managedConnectionFactoryProperties);
-
+
if (resourceAdapter != null && mcf instanceof ResourceAdapterAssociation)
{
ResourceAdapterAssociation raa = (ResourceAdapterAssociation) mcf;
@@ -364,38 +369,16 @@
{
setManagedConnectionFactoryAttribute(name, clazz, value, false);
}
-
+
protected void setManagedConnectionFactoryAttribute(String name, Class clazz, Object value, boolean mustExist)
{
- if (name == null || name.length() == 0)
- throw new IllegalArgumentException("Null or empty attribute name " + name);
- String setterName = "set" + Character.toUpperCase(name.charAt(0));
- if (name.length() > 1)
- setterName = setterName.concat(name.substring(1));
- Method setter;
try
{
- setter = mcfClass.getMethod(setterName, new Class[] {clazz});
+ getConfigPropertyHandler().handle(new ConfigProperty(name, clazz, value), mustExist);
}
- catch (NoSuchMethodException nsme)
- {
- String error = "The class '" + mcfClass.toString() + "' has no setter for config property '" + name + "'";
- if (mustExist)
- throw new IllegalArgumentException(error);
- else
- {
- log.trace(error, nsme);
- return;
- }
- }
- try
- {
- setter.invoke(mcf, new Object[] {value});
- log.debug("set property " + name + " to value " + value);
- }
catch (Exception e)
{
- String error = "Unable to invoke setter method '" + setter + "' " + "on object '" + mcf + "'";
+ String error = "Unable to set property '" + name + "' " + "on object '" + mcf + "'";
if (e instanceof InvocationTargetException)
throw new NestedRuntimeException(error, ((InvocationTargetException) e).getCause());
else
@@ -447,48 +430,21 @@
{
ConfigPropertyMetaData cpmd = (ConfigPropertyMetaData) i.next();
String name = cpmd.getName();
- String type = cpmd.getType();
String value = cpmd.getValue();
- if (name == null || name.length() == 0 || value == null || value.length() == 0)
- {
- log.debug("Not setting config property '" + name + "'");
- continue;
- }
- // see if it is a primitive type first
- Class clazz = Classes.getPrimitiveTypeForName(type);
- if (clazz == null)
- {
- //not primitive, look for it.
- try
- {
- clazz = Thread.currentThread().getContextClassLoader().loadClass(type);
- }
- catch (ClassNotFoundException cnfe)
- {
- log.warn("Unable to find class '" + type + "' for " + "property '" + name + "' - skipping property.");
- continue;
- }
- }
- PropertyEditor pe = PropertyEditorManager.findEditor(clazz);
- if (pe == null)
- {
- log.warn("Unable to find a PropertyEditor for class '" + clazz + "' of property '" + name + "' - "
- + "skipping property");
- continue;
- }
- log.debug("setting property: " + name + " to value " + value);
try
{
- pe.setAsText(value);
+ getConfigPropertyHandler().handle(cpmd, mustExist);
}
- catch (IllegalArgumentException iae)
+ catch (Exception e)
{
- log.warn("Value '" + value + "' is not valid for property '" + name + "' of class '" + clazz
- + "' - skipping " + "property");
- continue;
+ String error = "Unable to set property '" + name + "' " + "on object '" + mcf + "'";
+ if (e instanceof InvocationTargetException)
+ throw new NestedRuntimeException(error, ((InvocationTargetException) e).getCause());
+ else
+ throw new NestedRuntimeException(error, e);
}
- Object v = pe.getValue();
- setManagedConnectionFactoryAttribute(name, clazz, v, mustExist);
+ sendNotification(new Notification(MCF_ATTRIBUTE_CHANGED_NOTIFICATION, getServiceName(),
+ getNextNotificationSequenceNumber()));
}
}
@@ -607,7 +563,7 @@
buffer.append(Integer.toHexString(System.identityHashCode(this)));
return buffer.toString();
}
-
+
public int hashCode()
{
return mcf.hashCode();
@@ -623,4 +579,13 @@
{
mcf.setLogWriter(out);
}
+
+ protected ConfigPropertyHandler getConfigPropertyHandler()
+ {
+ if (configPropertyHandler == null)
+ {
+ configPropertyHandler = new ConfigPropertyHandler(mcf, mcfClass);
+ }
+ return configPropertyHandler;
+ }
}
Modified: branches/JBPAPP_5_0/connector/src/main/org/jboss/resource/deployment/AdminObjectFactory.java
===================================================================
--- branches/JBPAPP_5_0/connector/src/main/org/jboss/resource/deployment/AdminObjectFactory.java 2009-11-25 19:36:57 UTC (rev 96987)
+++ branches/JBPAPP_5_0/connector/src/main/org/jboss/resource/deployment/AdminObjectFactory.java 2009-11-25 19:37:43 UTC (rev 96988)
@@ -48,43 +48,50 @@
/** The logger */
private static final Logger log = Logger.getLogger(AdminObjectFactory.class);
- public static Object createAdminObject(String jndiName, ObjectName rarName, AdminObjectMetaData aomd, Properties properties) throws Exception
+ public static Object createAdminObject(final String jndiName, ObjectName rarName, AdminObjectMetaData aomd,
+ Properties properties) throws Exception
{
- boolean trace = log.isTraceEnabled();
-
+ final boolean trace = log.isTraceEnabled();
+
// Get the current classloader
ClassLoader cl = Thread.currentThread().getContextClassLoader();
if (trace)
- log.trace("Creating AdminObject '" + jndiName + "' metadata=" + aomd + " rar=" + rarName + " properties=" + properties + " classloader=" + cl);
-
+ log.trace("Creating AdminObject '" + jndiName + "' metadata=" + aomd + " rar=" + rarName + " properties="
+ + properties + " classloader=" + cl);
+
// The interface class
String interfaceName = aomd.getAdminObjectInterfaceClass();
// Load the interface class class
if (trace)
- log.trace("AdminObject '" + jndiName + "' loading interface=" + interfaceName);
+ log.trace("AdminObject '" + jndiName + "' loading interface=" + interfaceName);
Class interfaceClass = cl.loadClass(interfaceName);
-
+
// Determine the implementation class
String implName = aomd.getAdminObjectImplementationClass();
if (implName == null)
- throw new DeploymentException("No implementation class for admin object '" + interfaceClass + "' ra=" + rarName);
-
+ throw new DeploymentException("No implementation class for admin object '" + interfaceClass + "' ra="
+ + rarName);
+
// Load the implementation class
if (trace)
- log.trace("AdminObject '" + jndiName + "' loading implementation=" + implName);
+ log.trace("AdminObject '" + jndiName + "' loading implementation=" + implName);
Class implClass = cl.loadClass(implName);
if (interfaceClass.isAssignableFrom(implClass) == false)
throw new DeploymentException(implClass.getName() + " is not a '" + interfaceClass + "' ra=" + rarName);
Object result = implClass.newInstance();
if (trace)
- log.trace("AdminObject '" + jndiName + "' created instance=" + result);
+ log.trace("AdminObject '" + jndiName + "' created instance=" + result);
+
+ // Create ConfigPropertyHandler for the AdminObject
+ ConfigPropertyHandler configPropertyHandler = new ConfigPropertyHandler(result, implClass, "AdminObject: ");
// Apply values from the ra.xml
Collection raProperties = aomd.getProperties();
if (raProperties != null && raProperties.size() != 0)
{
+
for (Iterator i = raProperties.iterator(); i.hasNext();)
{
ConfigPropertyMetaData cpmd = (ConfigPropertyMetaData) i.next();
@@ -95,46 +102,36 @@
if (properties.containsKey(name))
{
if (trace)
- log.trace("AdminObject '" + jndiName + "' property=" + name + " IGNORING value=" + value +" specified in MBean properties.");
+ log.trace("AdminObject '" + jndiName + "' property=" + name + " IGNORING value=" + value
+ + " specified in MBean properties.");
}
else
{
// Load the property class as defined in the meta data
String typeName = cpmd.getType();
if (trace)
- log.trace("AdminObject '" + jndiName + "' property=" + name + " loading class=" + typeName);
- Class type = cl.loadClass(typeName);
-
- // Find the property editor for this class
- PropertyEditor editor = PropertyEditorManager.findEditor(type);
- if (editor == null)
- throw new DeploymentException("No property editor found for property '" + name + " class='" + type + "' for admin object '" + interfaceClass + "' ra=" + rarName);
- editor.setAsText(value);
- Object object = editor.getValue();
-
+ log.trace("AdminObject '" + jndiName + "' property=" + name + " loading class=" + typeName);
+
try
{
- String setter = "set" + Character.toUpperCase(name.charAt(0));
- if (name.length() > 1)
- setter = setter.concat(name.substring(1));
- Method method = implClass.getMethod(setter, new Class[] { type });
- if (trace)
- log.trace("AdminObject '" + jndiName + "' property=" + name + " set=" + object);
- method.invoke(result, new Object[] { object });
+ configPropertyHandler.handle(cpmd);
}
catch (InvocationTargetException e)
{
- DeploymentException.rethrowAsDeploymentException("Error for property '" + name + "' class=" + implClass + "' for admin object '" + interfaceClass + "' ra=" + rarName, e.getTargetException());
+ DeploymentException.rethrowAsDeploymentException("Error for property '" + name + "' class="
+ + implClass + "' for admin object '" + interfaceClass + "' ra=" + rarName, e
+ .getTargetException());
}
catch (Throwable t)
{
- DeploymentException.rethrowAsDeploymentException("Error for property '" + name + "' class=" + implClass + "' for admin object '" + interfaceClass + "' ra=" + rarName, t);
+ DeploymentException.rethrowAsDeploymentException("Error for property '" + name + "' class="
+ + implClass + "' for admin object '" + interfaceClass + "' ra=" + rarName, t);
}
}
}
}
}
-
+
// Apply the properties
if (properties != null)
{
@@ -143,50 +140,39 @@
Map.Entry property = (Map.Entry) i.next();
String name = (String) property.getKey();
String value = (String) property.getValue();
- if (trace)
- log.trace("AdminObject '" + jndiName + "' property=" + name + " value=" + value);
+ if (trace)
+ log.trace("AdminObject '" + jndiName + "' property=" + name + " value=" + value);
+
// Pick up the property metadata
ConfigPropertyMetaData cpmd = aomd.getProperty(name);
if (cpmd == null)
- throw new DeploymentException("No property '" + name + "' for admin object '" + interfaceClass + "' ra=" + rarName);
- if (trace)
- log.trace("AdminObject '" + jndiName + "' property=" + name + " metadata=" + cpmd);
-
- // Load the property class as defined in the meta data
- String typeName = cpmd.getType();
- if (trace)
- log.trace("AdminObject '" + jndiName + "' property=" + name + " loading class=" + typeName);
- Class type = cl.loadClass(typeName);
+ throw new DeploymentException("No property '" + name + "' for admin object '" + interfaceClass + "' ra="
+ + rarName);
- // Find the property editor for this class
- PropertyEditor editor = PropertyEditorManager.findEditor(type);
- if (editor == null)
- throw new DeploymentException("No property editor found for property '" + name + " class='" + type + "' for admin object '" + interfaceClass + "' ra=" + rarName);
- editor.setAsText(value);
- Object object = editor.getValue();
+ // Make copy of the ConfigPropertyMetaData with new value
+ ConfigPropertyMetaData cpmdCopy = new ConfigPropertyMetaData();
+ cpmdCopy.setName(name);
+ cpmdCopy.setType(cpmd.getType());
+ cpmdCopy.setValue(value);
try
{
- String setter = "set" + Character.toUpperCase(name.charAt(0));
- if (name.length() > 1)
- setter = setter.concat(name.substring(1));
- Method method = implClass.getMethod(setter, new Class[] { type });
- if (trace)
- log.trace("AdminObject '" + jndiName + "' property=" + name + " set=" + object);
- method.invoke(result, new Object[] { object });
+ configPropertyHandler.handle(cpmdCopy);
}
catch (InvocationTargetException e)
{
- DeploymentException.rethrowAsDeploymentException("Error for property '" + name + "' class=" + implClass + "' for admin object '" + interfaceClass + "' ra=" + rarName, e.getTargetException());
+ DeploymentException.rethrowAsDeploymentException("Error for property '" + name + "' class=" + implClass
+ + "' for admin object '" + interfaceClass + "' ra=" + rarName, e.getTargetException());
}
catch (Throwable t)
{
- DeploymentException.rethrowAsDeploymentException("Error for property '" + name + "' class=" + implClass + "' for admin object '" + interfaceClass + "' ra=" + rarName, t);
+ DeploymentException.rethrowAsDeploymentException("Error for property '" + name + "' class=" + implClass
+ + "' for admin object '" + interfaceClass + "' ra=" + rarName, t);
}
}
}
-
+
return result;
}
}
Added: branches/JBPAPP_5_0/connector/src/main/org/jboss/resource/deployment/ConfigProperty.java
===================================================================
--- branches/JBPAPP_5_0/connector/src/main/org/jboss/resource/deployment/ConfigProperty.java (rev 0)
+++ branches/JBPAPP_5_0/connector/src/main/org/jboss/resource/deployment/ConfigProperty.java 2009-11-25 19:37:43 UTC (rev 96988)
@@ -0,0 +1,106 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, 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.resource.deployment;
+
+/**
+ * Holder for resolved configuration properties.
+
+ * @author <a href="baileyje at gmail.com">John Bailey</a>
+ * @version $Revision: $
+ */
+public class ConfigProperty
+{
+ /**
+ * Name of config property
+ */
+ private final String name;
+
+ /**
+ * Class type of the config property
+ */
+ private final Class type;
+
+ /**
+ * Value of the config property
+ */
+ private final Object value;
+
+ /**
+ * Constructor
+ *
+ * @param name The name of the property
+ * @param type The type of the property
+ * @param value The value of the property
+ */
+ public ConfigProperty(String name, Class type, Object value)
+ {
+ super();
+ this.name = name;
+ this.type = type;
+ this.value = value;
+ }
+
+ /**
+ * Get the name of the property
+ * @return The value
+ */
+ public String getName()
+ {
+ return name;
+ }
+
+ /**
+ * Get the type of the property
+ * @return The value
+ */
+ public Class getType()
+ {
+ return type;
+ }
+
+ /**
+ * Get the value of the property
+ * @return The value
+ */
+ public Object getValue()
+ {
+ return value;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see java.lang.Object#toString()
+ */
+ public String toString()
+ {
+ StringBuffer buffer = new StringBuffer();
+ buffer.append("ConfigProperty").append('@');
+ buffer.append(Integer.toHexString(System.identityHashCode(this)));
+ buffer.append("[name=").append(name);
+ if (type != null)
+ buffer.append(" type=").append(type);
+ if (value != null)
+ buffer.append(" value=").append(value);
+ buffer.append(']');
+ return buffer.toString();
+ }
+}
Added: branches/JBPAPP_5_0/connector/src/main/org/jboss/resource/deployment/ConfigPropertyHandler.java
===================================================================
--- branches/JBPAPP_5_0/connector/src/main/org/jboss/resource/deployment/ConfigPropertyHandler.java (rev 0)
+++ branches/JBPAPP_5_0/connector/src/main/org/jboss/resource/deployment/ConfigPropertyHandler.java 2009-11-25 19:37:43 UTC (rev 96988)
@@ -0,0 +1,312 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, 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.resource.deployment;
+
+import java.beans.PropertyEditor;
+import java.beans.PropertyEditorManager;
+import java.lang.reflect.Method;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.jboss.logging.Logger;
+import org.jboss.resource.metadata.ConfigPropertyMetaData;
+import org.jboss.util.Classes;
+
+/**
+ * Utility used to handle setting configuration properties from ra.xml file.
+ *
+ * @author <a href="baileyje at gmail.com">John Bailey</a>
+ * @author <a href="jesper.pedersen at jboss.org">Jesper Pedersen</a>
+ * @version $Revision: $
+ */
+public class ConfigPropertyHandler
+{
+ private static final Logger log = Logger.getLogger(ConfigPropertyHandler.class);
+
+ /** A map of possible alternate property types to try. Used to support primitive types on ResourceAdapter impls **/
+ private static Map<String, Class<?>> PRIMATIVE_TYPE_ALTERNATES = new HashMap<String, Class<?>>();
+ static
+ {
+ PRIMATIVE_TYPE_ALTERNATES.put(Boolean.class.getName(), Boolean.TYPE);
+ PRIMATIVE_TYPE_ALTERNATES.put(Byte.class.getName(), Byte.TYPE);
+ PRIMATIVE_TYPE_ALTERNATES.put(Character.class.getName(), Character.TYPE);
+ PRIMATIVE_TYPE_ALTERNATES.put(Double.class.getName(), Double.TYPE);
+ PRIMATIVE_TYPE_ALTERNATES.put(Float.class.getName(), Float.TYPE);
+ PRIMATIVE_TYPE_ALTERNATES.put(Integer.class.getName(), Integer.TYPE);
+ PRIMATIVE_TYPE_ALTERNATES.put(Long.class.getName(), Long.TYPE);
+ PRIMATIVE_TYPE_ALTERNATES.put(Short.class.getName(), Short.TYPE);
+ }
+
+ /** Object to set the Config Property on **/
+ private final Object configTarget;
+
+ /** Object type to set the Config Property on **/
+ private final Class configTargetType;
+
+ /** Identifier used to trace property values being set **/
+ private final String traceIdentifier;
+
+ /**
+ * Constructor
+ *
+ * @param configTarget
+ * @param configTargetType
+ */
+ public ConfigPropertyHandler(Object configTarget, Class configTargetType)
+ {
+ this(configTarget, configTargetType, "");
+ }
+
+ /**
+ * Constructor with trace string
+ * @param configTarget
+ * @param configTargetType
+ * @param traceIdentifier
+ */
+ public ConfigPropertyHandler(Object configTarget, Class configTargetType, String traceIdentifier)
+ {
+ super();
+ this.configTarget = configTarget;
+ this.configTargetType = configTargetType;
+ this.traceIdentifier = traceIdentifier;
+ }
+
+ /**
+ * Handles setting a configuration property on a target object.
+ *
+ * @param configProperty
+ * @throws Exception
+ */
+ public void handle(ConfigProperty configProperty) throws Exception
+ {
+ handle(configProperty, true);
+ }
+
+ /**
+ * Handles setting a configuration property on a target object.
+ *
+ * @param configProperty
+ * @param mustExist
+ * @throws Exception
+ */
+ public void handle(ConfigProperty configProperty, boolean mustExist) throws Exception
+ {
+ if (log.isTraceEnabled())
+ {
+ log.trace("Handling config property - " + configProperty);
+ }
+
+ String propertyName = configProperty.getName();
+ if (propertyName == null || propertyName.length() == 0)
+ {
+ throw new IllegalArgumentException("Null or empty attribute name " + propertyName);
+ }
+
+ Object propertyValue = configProperty.getValue();
+
+ if (propertyValue == null)
+ {
+ if (log.isDebugEnabled())
+ {
+ log.debug("Not setting config property with null value " + configProperty);
+ }
+ return;
+ }
+
+ // Generate the setter name
+ String setterName = getSetterName(propertyName);
+
+ // Get the setter method using the setter name
+ Method method = null;
+ try
+ {
+ method = getMethod(setterName, configProperty.getType());
+ }
+ catch (NoSuchMethodException nsme)
+ {
+ String error = "The class '" + configTargetType + "' has no setter for config property '" + propertyName + "'";
+ if (mustExist)
+ {
+ throw new IllegalArgumentException(error, nsme);
+ }
+ if (log.isTraceEnabled())
+ {
+ log.trace(error, nsme);
+ }
+ return;
+ }
+
+ if (log.isTraceEnabled())
+ {
+ log.trace(traceIdentifier + " setting property=" + propertyName + " value=" + configProperty.getValue());
+ }
+
+ // Invoke the setter
+ method.invoke(configTarget, new Object[] {configProperty.getValue()});
+ }
+
+ /**
+ * Handles setting a configuration property on a target object based on ConfigPropertyMetaData.
+ *
+ * @param configPropertyMetaData
+ * @throws Exception
+ */
+ public void handle(ConfigPropertyMetaData configPropertyMetaData) throws Exception
+ {
+ this.handle(configPropertyMetaData, true);
+ }
+
+ /**
+ * Handles setting a configuration property on a target object based on ConfigPropertyMetaData.
+ *
+ * @param configPropertyMetaData
+ * @param mustExist
+ * @throws Exception
+ */
+ public void handle(ConfigPropertyMetaData configPropertyMetaData, boolean mustExist) throws Exception
+ {
+ String propertyName = configPropertyMetaData.getName();
+ String propertyType = configPropertyMetaData.getType();
+ String propertyValue = configPropertyMetaData.getValue();
+
+ if (propertyValue == null || propertyValue.length() == 0)
+ {
+ log.debug("Not setting config property with null value " + configPropertyMetaData);
+ return;
+ }
+
+ // See if it is a primitive type alias first
+ Class expectedPropertyType = Classes.getPrimitiveTypeForName(propertyType);
+ if (expectedPropertyType == null)
+ {
+ // Not primitive alias, look for it.
+ try
+ {
+ expectedPropertyType = Thread.currentThread().getContextClassLoader().loadClass(propertyType);
+ }
+ catch (ClassNotFoundException cnfe)
+ {
+ if (mustExist)
+ {
+ throw cnfe;
+ }
+ log.warn("Unable to find class '" + propertyType + "' for " + "property '" + propertyName
+ + "' - skipping property.");
+ }
+ }
+
+ // Use the actual property type to get the value
+ Object value = getValue(propertyName, expectedPropertyType, propertyValue, mustExist);
+
+ // Invoke handle with constructed ConfigProperty
+ handle(new ConfigProperty(propertyName, expectedPropertyType, value), mustExist);
+ }
+
+ /**
+ * Generates the setter name for a property
+ *
+ * @param propertyName
+ * @return
+ */
+ private String getSetterName(String propertyName)
+ {
+ String setter = "set" + Character.toUpperCase(propertyName.charAt(0));
+ if (propertyName.length() > 1)
+ setter = setter.concat(propertyName.substring(1));
+ return setter;
+ }
+
+ /**
+ * Retrieves the setter method for the property. Will check the expected type first,
+ * and if not found it will check for primitive alternatives.
+ *
+ * @param setterName
+ * @param expectedPropertyType
+ * @return
+ * @throws NoSuchMethodException
+ */
+ private Method getMethod(String setterName, Class expectedPropertyType) throws NoSuchMethodException
+ {
+ Method method = null;
+ try
+ {
+ // Check to see if the method exists with the expected type
+ method = configTargetType.getMethod(setterName, new Class[] {expectedPropertyType});
+ }
+ catch (NoSuchMethodException nsme)
+ {
+ // Check to see if a primitive alternative is available
+ expectedPropertyType = PRIMATIVE_TYPE_ALTERNATES.get(expectedPropertyType.getName());
+ if (expectedPropertyType == null)
+ {
+ // No alternative to try
+ throw nsme;
+ }
+ // Check to see if a setter with the primitive alternative exists
+ method = configTargetType.getMethod(setterName, new Class[] {expectedPropertyType});
+ }
+ return method;
+ }
+
+ /**
+ * Get the correctly typed value from the string value.
+ *
+ * @param propertyName
+ * @param actualType
+ * @param value
+ * @param mustExist
+ * @return
+ */
+ private Object getValue(String propertyName, Class actualType, String value, boolean mustExist)
+ {
+ PropertyEditor editor = PropertyEditorManager.findEditor(actualType);
+ if (editor == null)
+ {
+ String error = "No property editor found for property " + propertyName;
+ if (mustExist)
+ {
+ throw new IllegalArgumentException(error);
+ }
+ else
+ {
+ log.warn(error);
+ return null;
+ }
+ }
+ try
+ {
+ editor.setAsText(value);
+ }
+ catch (IllegalArgumentException iae)
+ {
+ if (mustExist)
+ {
+ throw iae;
+ }
+ log.warn("Value '" + value + "' is not valid for property '" + propertyName + "' of class '" + actualType
+ + "' - skipping " + "property");
+ return null;
+ }
+
+ return editor.getValue();
+ }
+}
Modified: branches/JBPAPP_5_0/connector/src/main/org/jboss/resource/deployment/ResourceAdapterFactory.java
===================================================================
--- branches/JBPAPP_5_0/connector/src/main/org/jboss/resource/deployment/ResourceAdapterFactory.java 2009-11-25 19:36:57 UTC (rev 96987)
+++ branches/JBPAPP_5_0/connector/src/main/org/jboss/resource/deployment/ResourceAdapterFactory.java 2009-11-25 19:37:43 UTC (rev 96988)
@@ -25,7 +25,9 @@
import java.beans.PropertyEditorManager;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
+import java.util.HashMap;
import java.util.Iterator;
+import java.util.Map;
import javax.resource.spi.ResourceAdapter;
@@ -57,11 +59,11 @@
{
ResourceAdapter adapter = createResourceAdapter(ramd.getConnectorMetaData());
+ ConfigPropertyHandler configPropertyHandler = new ConfigPropertyHandler(adapter, adapter.getClass(), "ResourceAdapter: ");
for(Iterator iter = ramd.getRaXmlMetaData().getProperties().iterator(); iter.hasNext();)
{
ConfigPropertyMetaData cpmd = (ConfigPropertyMetaData)iter.next();
- applyProperty(cpmd, adapter.getClass(), adapter);
-
+ applyProperty(configPropertyHandler, cpmd, adapter.getClass());
}
return adapter;
@@ -87,38 +89,23 @@
ResourceAdapter result = (ResourceAdapter) raClass.newInstance();
// Apply the properties
+ ConfigPropertyHandler configPropertyHandler = new ConfigPropertyHandler(result, raClass, "ResourceAdapter: ");
for (Iterator i = cmd.getProperties().iterator(); i.hasNext();)
{
ConfigPropertyMetaData cpmd = (ConfigPropertyMetaData) i.next();
- applyProperty(cpmd, raClass, result);
-
-
+ applyProperty(configPropertyHandler, cpmd, raClass);
}
return result;
}
- private static void applyProperty(ConfigPropertyMetaData cpmd, Class clz, ResourceAdapter ra) throws Exception
+ private static void applyProperty(ConfigPropertyHandler configPropertyHandler,
+ ConfigPropertyMetaData cpmd,
+ Class clz) throws Exception
{
-
- String name = cpmd.getName();
- String type = cpmd.getType();
- String value = cpmd.getValue();
-
- Class clazz = Thread.currentThread().getContextClassLoader().loadClass(type);
- PropertyEditor editor = PropertyEditorManager.findEditor(clazz);
- if (editor == null)
- throw new IllegalArgumentException("No property editor found for property " + cpmd);
- editor.setAsText(value);
- Object object = editor.getValue();
-
try
{
- String setter = "set" + Character.toUpperCase(name.charAt(0));
- if (name.length() > 1)
- setter = setter.concat(name.substring(1));
- Method method = clz.getMethod(setter, new Class[] { clazz });
- method.invoke(ra, new Object[] { object });
+ configPropertyHandler.handle(cpmd);
}
catch (InvocationTargetException e)
{
@@ -128,7 +115,5 @@
{
DeploymentException.rethrowAsDeploymentException("Error for resource adapter class " + clz.getName() + " accessing property setter " + cpmd, t);
}
-
}
-
}
Modified: branches/JBPAPP_5_0/testsuite/imports/sections/jca.xml
===================================================================
--- branches/JBPAPP_5_0/testsuite/imports/sections/jca.xml 2009-11-25 19:36:57 UTC (rev 96987)
+++ branches/JBPAPP_5_0/testsuite/imports/sections/jca.xml 2009-11-25 19:37:43 UTC (rev 96988)
@@ -396,6 +396,26 @@
</fileset>
</jar>
+ <!-- Primitive properties -->
+ <jar destfile="${build.lib}/jcaprimitive.jar">
+ <fileset dir="${build.classes}">
+ <include name="org/jboss/test/jca/primitive/**"/>
+ </fileset>
+ </jar>
+ <jar destfile="${build.lib}/jcaprimitive.rar">
+ <fileset dir="${build.lib}">
+ <include name="jcaprimitive.jar"/>
+ </fileset>
+ <fileset dir="${build.resources}/jca/primitive">
+ <include name="META-INF/ra.xml"/>
+ </fileset>
+ </jar>
+ <copy todir="${build.lib}" filtering="no">
+ <fileset dir="${build.resources}/jca/primitive">
+ <include name="jcaprimitive-ds.xml"/>
+ </fileset>
+ </copy>
+
</target>
Added: branches/JBPAPP_5_0/testsuite/src/main/org/jboss/test/jca/primitive/AdminObject.java
===================================================================
--- branches/JBPAPP_5_0/testsuite/src/main/org/jboss/test/jca/primitive/AdminObject.java (rev 0)
+++ branches/JBPAPP_5_0/testsuite/src/main/org/jboss/test/jca/primitive/AdminObject.java 2009-11-25 19:37:43 UTC (rev 96988)
@@ -0,0 +1,96 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 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.test.jca.primitive;
+
+import java.io.Serializable;
+
+import javax.jms.JMSException;
+
+public class AdminObject implements javax.jms.Queue, Serializable
+{
+ private static final long serialVersionUID = 1L;
+
+ private int someIntProperty;
+
+ private Integer someIntegerObjectProperty;
+
+ private boolean someBooleanProperty;
+
+ private Boolean someBooleanObjectProperty;
+
+ public int getSomeIntProperty()
+ {
+ return someIntProperty;
+ }
+
+ public void setSomeIntProperty(int someIntProperty)
+ {
+ this.someIntProperty = someIntProperty;
+ }
+
+ public Integer getSomeIntegerObjectProperty()
+ {
+ return someIntegerObjectProperty;
+ }
+
+ public void setSomeIntegerObjectProperty(Integer someIntegerObjectProperty)
+ {
+ this.someIntegerObjectProperty = someIntegerObjectProperty;
+ }
+
+ public boolean isSomeBooleanProperty()
+ {
+ return someBooleanProperty;
+ }
+
+ public void setSomeBooleanProperty(boolean someBooleanProperty)
+ {
+ this.someBooleanProperty = someBooleanProperty;
+ }
+
+ public Boolean getSomeBooleanObjectProperty()
+ {
+ return someBooleanObjectProperty;
+ }
+
+ public void setSomeBooleanObjectProperty(Boolean someBooleanObjectProperty)
+ {
+ this.someBooleanObjectProperty = someBooleanObjectProperty;
+ }
+
+ public String getQueueName() throws JMSException
+ {
+ return null;
+ }
+
+ @Override
+ public String toString()
+ {
+ StringBuilder sb = new StringBuilder();
+ sb.append("#======= TEST AdminObject ========#").append("\n");
+ sb.append("Integer Primitive: " + someIntProperty).append("\n");
+ sb.append("Integer Object: " + someIntegerObjectProperty).append("\n");
+ sb.append("Boolean Primitive: " + someBooleanProperty).append("\n");
+ sb.append("Boolean Object: " + someBooleanObjectProperty).append("\n");
+ return sb.toString();
+ }
+}
Added: branches/JBPAPP_5_0/testsuite/src/main/org/jboss/test/jca/primitive/Connection.java
===================================================================
--- branches/JBPAPP_5_0/testsuite/src/main/org/jboss/test/jca/primitive/Connection.java (rev 0)
+++ branches/JBPAPP_5_0/testsuite/src/main/org/jboss/test/jca/primitive/Connection.java 2009-11-25 19:37:43 UTC (rev 96988)
@@ -0,0 +1,87 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 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.test.jca.primitive;
+
+import javax.jms.ConnectionConsumer;
+import javax.jms.ConnectionMetaData;
+import javax.jms.Destination;
+import javax.jms.ExceptionListener;
+import javax.jms.JMSException;
+import javax.jms.ServerSessionPool;
+import javax.jms.Session;
+import javax.jms.Topic;
+
+public class Connection implements javax.jms.Connection
+{
+
+ public void close() throws JMSException
+ {
+ }
+
+ public ConnectionConsumer createConnectionConsumer(Destination destination, String messageSelector,
+ ServerSessionPool sessionPool, int maxMessages) throws JMSException
+ {
+ return null;
+ }
+
+ public ConnectionConsumer createDurableConnectionConsumer(Topic topic, String subscriptionName,
+ String messageSelector, ServerSessionPool sessionPool, int maxMessages) throws JMSException
+ {
+ return null;
+ }
+
+ public Session createSession(boolean transacted, int acknowledgeMode) throws JMSException
+ {
+ return null;
+ }
+
+ public String getClientID() throws JMSException
+ {
+ return null;
+ }
+
+ public ExceptionListener getExceptionListener() throws JMSException
+ {
+ return null;
+ }
+
+ public ConnectionMetaData getMetaData() throws JMSException
+ {
+ return null;
+ }
+
+ public void setClientID(String clientID) throws JMSException
+ {
+ }
+
+ public void setExceptionListener(ExceptionListener listener) throws JMSException
+ {
+ }
+
+ public void start() throws JMSException
+ {
+ }
+
+ public void stop() throws JMSException
+ {
+ }
+}
Added: branches/JBPAPP_5_0/testsuite/src/main/org/jboss/test/jca/primitive/ConnectionFactory.java
===================================================================
--- branches/JBPAPP_5_0/testsuite/src/main/org/jboss/test/jca/primitive/ConnectionFactory.java (rev 0)
+++ branches/JBPAPP_5_0/testsuite/src/main/org/jboss/test/jca/primitive/ConnectionFactory.java 2009-11-25 19:37:43 UTC (rev 96988)
@@ -0,0 +1,39 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 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.test.jca.primitive;
+
+import javax.jms.Connection;
+import javax.jms.JMSException;
+
+public class ConnectionFactory implements javax.jms.ConnectionFactory
+{
+
+ public Connection createConnection() throws JMSException
+ {
+ return new org.jboss.test.jca.primitive.Connection();
+ }
+
+ public Connection createConnection(String userName, String password) throws JMSException
+ {
+ return null;
+ }
+}
Added: branches/JBPAPP_5_0/testsuite/src/main/org/jboss/test/jca/primitive/ManagedConnection.java
===================================================================
--- branches/JBPAPP_5_0/testsuite/src/main/org/jboss/test/jca/primitive/ManagedConnection.java (rev 0)
+++ branches/JBPAPP_5_0/testsuite/src/main/org/jboss/test/jca/primitive/ManagedConnection.java 2009-11-25 19:37:43 UTC (rev 96988)
@@ -0,0 +1,85 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 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.test.jca.primitive;
+
+import java.io.PrintWriter;
+
+import javax.resource.ResourceException;
+import javax.resource.spi.ConnectionEventListener;
+import javax.resource.spi.ConnectionRequestInfo;
+import javax.resource.spi.LocalTransaction;
+import javax.resource.spi.ManagedConnectionMetaData;
+import javax.security.auth.Subject;
+import javax.transaction.xa.XAResource;
+
+public class ManagedConnection implements javax.resource.spi.ManagedConnection
+{
+
+ public void addConnectionEventListener(ConnectionEventListener listener)
+ {
+ }
+
+ public void associateConnection(Object connection) throws ResourceException
+ {
+ }
+
+ public void cleanup() throws ResourceException
+ {
+ }
+
+ public void destroy() throws ResourceException
+ {
+ }
+
+ public Object getConnection(Subject subject, ConnectionRequestInfo cxRequestInfo) throws ResourceException
+ {
+ return null;
+ }
+
+ public LocalTransaction getLocalTransaction() throws ResourceException
+ {
+ return null;
+ }
+
+ public PrintWriter getLogWriter() throws ResourceException
+ {
+ return null;
+ }
+
+ public ManagedConnectionMetaData getMetaData() throws ResourceException
+ {
+ return null;
+ }
+
+ public XAResource getXAResource() throws ResourceException
+ {
+ return null;
+ }
+
+ public void removeConnectionEventListener(ConnectionEventListener listener)
+ {
+ }
+
+ public void setLogWriter(PrintWriter out) throws ResourceException
+ {
+ }
+}
Added: branches/JBPAPP_5_0/testsuite/src/main/org/jboss/test/jca/primitive/TestConnectionFactory.java
===================================================================
--- branches/JBPAPP_5_0/testsuite/src/main/org/jboss/test/jca/primitive/TestConnectionFactory.java (rev 0)
+++ branches/JBPAPP_5_0/testsuite/src/main/org/jboss/test/jca/primitive/TestConnectionFactory.java 2009-11-25 19:37:43 UTC (rev 96988)
@@ -0,0 +1,118 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 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.test.jca.primitive;
+
+import java.io.PrintWriter;
+import java.util.Set;
+
+import javax.resource.ResourceException;
+import javax.resource.spi.ConnectionManager;
+import javax.resource.spi.ConnectionRequestInfo;
+import javax.resource.spi.ManagedConnection;
+import javax.resource.spi.ManagedConnectionFactory;
+import javax.security.auth.Subject;
+
+public class TestConnectionFactory implements ManagedConnectionFactory
+{
+ private static final long serialVersionUID = 1L;
+
+ private int someIntProperty;
+
+ private Integer someIntegerObjectProperty;
+
+ private boolean someBooleanProperty;
+
+ private Boolean someBooleanObjectProperty;
+
+ public Object createConnectionFactory() throws ResourceException
+ {
+ return null;
+ }
+
+ public Object createConnectionFactory(ConnectionManager cxManager) throws ResourceException
+ {
+ return new ConnectionFactory();
+ }
+
+ public ManagedConnection createManagedConnection(Subject subject, ConnectionRequestInfo cxRequestInfo)
+ throws ResourceException
+ {
+ return new org.jboss.test.jca.primitive.ManagedConnection();
+ }
+
+ public PrintWriter getLogWriter() throws ResourceException
+ {
+ return null;
+ }
+
+ @SuppressWarnings("unchecked")
+ public ManagedConnection matchManagedConnections(Set connectionSet, Subject subject,
+ ConnectionRequestInfo cxRequestInfo) throws ResourceException
+ {
+ return null;
+ }
+
+ public void setLogWriter(PrintWriter out) throws ResourceException
+ {
+
+ }
+
+ public int getSomeIntProperty()
+ {
+ return someIntProperty;
+ }
+
+ public void setSomeIntProperty(int someIntProperty)
+ {
+ this.someIntProperty = someIntProperty;
+ }
+
+ public Integer getSomeIntegerObjectProperty()
+ {
+ return someIntegerObjectProperty;
+ }
+
+ public void setSomeIntegerObjectProperty(Integer someIntegerObjectProperty)
+ {
+ this.someIntegerObjectProperty = someIntegerObjectProperty;
+ }
+
+ public boolean isSomeBooleanProperty()
+ {
+ return someBooleanProperty;
+ }
+
+ public void setSomeBooleanProperty(boolean someBooleanProperty)
+ {
+ this.someBooleanProperty = someBooleanProperty;
+ }
+
+ public Boolean getSomeBooleanObjectProperty()
+ {
+ return someBooleanObjectProperty;
+ }
+
+ public void setSomeBooleanObjectProperty(Boolean someBooleanObjectProperty)
+ {
+ this.someBooleanObjectProperty = someBooleanObjectProperty;
+ }
+}
Added: branches/JBPAPP_5_0/testsuite/src/main/org/jboss/test/jca/primitive/TestResourceAdapter.java
===================================================================
--- branches/JBPAPP_5_0/testsuite/src/main/org/jboss/test/jca/primitive/TestResourceAdapter.java (rev 0)
+++ branches/JBPAPP_5_0/testsuite/src/main/org/jboss/test/jca/primitive/TestResourceAdapter.java 2009-11-25 19:37:43 UTC (rev 96988)
@@ -0,0 +1,99 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 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.test.jca.primitive;
+
+import javax.resource.ResourceException;
+import javax.resource.spi.ActivationSpec;
+import javax.resource.spi.BootstrapContext;
+import javax.resource.spi.ResourceAdapter;
+import javax.resource.spi.ResourceAdapterInternalException;
+import javax.resource.spi.endpoint.MessageEndpointFactory;
+import javax.transaction.xa.XAResource;
+
+public class TestResourceAdapter implements ResourceAdapter
+{
+ private int someIntProperty;
+ private Integer someIntegerObjectProperty;
+ private boolean someBooleanProperty;
+ private Boolean someBooleanObjectProperty;
+
+ public void endpointActivation(MessageEndpointFactory endpointFactory, ActivationSpec spec) throws ResourceException
+ {
+ }
+
+ public void endpointDeactivation(MessageEndpointFactory endpointFactory, ActivationSpec spec)
+ {
+ }
+
+ public XAResource[] getXAResources(ActivationSpec[] specs) throws ResourceException
+ {
+ return null;
+ }
+
+ public void start(BootstrapContext ctx) throws ResourceAdapterInternalException
+ {
+ }
+
+ public void stop()
+ {
+ }
+
+ public int getSomeIntProperty()
+ {
+ return someIntProperty;
+ }
+
+ public void setSomeIntProperty(int someIntProperty)
+ {
+ this.someIntProperty = someIntProperty;
+ }
+
+ public Integer getSomeIntegerObjectProperty()
+ {
+ return someIntegerObjectProperty;
+ }
+
+ public void setSomeIntegerObjectProperty(Integer someIntegerObjectProperty)
+ {
+ this.someIntegerObjectProperty = someIntegerObjectProperty;
+ }
+
+ public boolean isSomeBooleanProperty()
+ {
+ return someBooleanProperty;
+ }
+
+ public void setSomeBooleanProperty(boolean someBooleanProperty)
+ {
+ this.someBooleanProperty = someBooleanProperty;
+ }
+
+ public Boolean getSomeBooleanObjectProperty()
+ {
+ return someBooleanObjectProperty;
+ }
+
+ public void setSomeBooleanObjectProperty(Boolean someBooleanObjectProperty)
+ {
+ this.someBooleanObjectProperty = someBooleanObjectProperty;
+ }
+}
Added: branches/JBPAPP_5_0/testsuite/src/main/org/jboss/test/jca/test/PrimitiveUnitTestCase.java
===================================================================
--- branches/JBPAPP_5_0/testsuite/src/main/org/jboss/test/jca/test/PrimitiveUnitTestCase.java (rev 0)
+++ branches/JBPAPP_5_0/testsuite/src/main/org/jboss/test/jca/test/PrimitiveUnitTestCase.java 2009-11-25 19:37:43 UTC (rev 96988)
@@ -0,0 +1,86 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 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.test.jca.test;
+
+import javax.management.ObjectName;
+
+import org.jboss.resource.metadata.ConfigPropertyMetaData;
+import org.jboss.test.JBossTestCase;
+
+/**
+ * Test case for resource adapters with primitive config-property definitions
+ * @author <a href="mailto:jesper.pedersen at jboss.org">Jesper Pedersen</a>
+ * @version $Revision: $
+ */
+
+public class PrimitiveUnitTestCase extends JBossTestCase
+{
+
+ public PrimitiveUnitTestCase(String name)
+ {
+ super(name);
+ }
+
+ public void testRA() throws Exception
+ {
+ ObjectName raName = new ObjectName("jboss.jca:name='jcaprimitive.rar',service=RARDeployment");
+ deploy("jcaprimitive.rar");
+ try
+ {
+ deploy("jcaprimitive-ds.xml");
+ try
+ {
+ assertTrue("RA should be registered", getServer().isRegistered(raName));
+ assertTrue("someIntegerObjectProperty should be 1, is " + getAttribute(raName, "someIntegerObjectProperty"),
+ new Integer(1).equals(getAttribute(raName, "someIntegerObjectProperty")));
+ assertTrue("someIntProperty should be 1, is " + getAttribute(raName, "someIntProperty"),
+ new Integer(1).equals(getAttribute(raName, "someIntProperty")));
+ assertTrue("someBooleanObjectProperty should be TRUE, is " + getAttribute(raName, "someBooleanObjectProperty"),
+ Boolean.TRUE.equals(getAttribute(raName, "someBooleanObjectProperty")));
+ assertTrue("someBooleanProperty should be TRUE, is " + getAttribute(raName, "someBooleanProperty"),
+ Boolean.TRUE.equals(getAttribute(raName, "someBooleanProperty")));
+ }
+ finally
+ {
+ undeploy("jcaprimitive-ds.xml");
+ }
+ }
+ finally
+ {
+ undeploy("jcaprimitive.rar");
+ }
+ }
+
+ private Object getAttribute(ObjectName raName, String attrName) throws Exception
+ {
+ ConfigPropertyMetaData cpmd = (ConfigPropertyMetaData)getServer().getAttribute(raName, attrName);
+ if ("java.lang.Integer".equals(cpmd.getType()))
+ {
+ return Integer.valueOf(cpmd.getValue());
+ }
+ else if ("java.lang.Boolean".equals(cpmd.getType()))
+ {
+ return Boolean.valueOf(cpmd.getValue());
+ }
+ return cpmd.getValue();
+ }
+}
Added: branches/JBPAPP_5_0/testsuite/src/resources/jca/primitive/META-INF/ra.xml
===================================================================
--- branches/JBPAPP_5_0/testsuite/src/resources/jca/primitive/META-INF/ra.xml (rev 0)
+++ branches/JBPAPP_5_0/testsuite/src/resources/jca/primitive/META-INF/ra.xml 2009-11-25 19:37:43 UTC (rev 96988)
@@ -0,0 +1,115 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<connector id="IMSTM" version="1.5"
+ xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/connector_1_5.xsd">
+ <display-name>Test Resource Adapter</display-name>
+ <vendor-name>Test</vendor-name>
+ <eis-type>TEST</eis-type>
+ <resourceadapter-version>1.0</resourceadapter-version>
+ <license>
+ <description>
+ </description>
+ <license-required>false</license-required>
+ </license>
+ <resourceadapter>
+ <resourceadapter-class>org.jboss.test.jca.primitive.TestResourceAdapter</resourceadapter-class>
+ <config-property>
+ <config-property-name>someIntProperty</config-property-name>
+ <config-property-type>java.lang.Integer</config-property-type>
+ <config-property-value>1</config-property-value>
+ </config-property>
+ <config-property>
+ <config-property-name>someIntegerObjectProperty</config-property-name>
+ <config-property-type>java.lang.Integer</config-property-type>
+ <config-property-value>1</config-property-value>
+ </config-property>
+ <config-property>
+ <config-property-name>someBooleanProperty</config-property-name>
+ <config-property-type>java.lang.Boolean</config-property-type>
+ <config-property-value>true</config-property-value>
+ </config-property>
+
+ <config-property>
+ <config-property-name>someBooleanObjectProperty</config-property-name>
+ <config-property-type>java.lang.Boolean</config-property-type>
+ <config-property-value>true</config-property-value>
+ </config-property>
+
+ <!-- Outbound -->
+
+ <outbound-resourceadapter>
+
+ <connection-definition>
+ <managedconnectionfactory-class>org.jboss.test.jca.primitive.TestConnectionFactory</managedconnectionfactory-class>
+
+ <config-property>
+ <description>Some Primitive int Property</description>
+ <config-property-name>someIntProperty</config-property-name>
+ <config-property-type>java.lang.Integer</config-property-type>
+ </config-property>
+
+ <config-property>
+ <description>Some Object Integer Property</description>
+ <config-property-name>someIntegerObjectProperty</config-property-name>
+ <config-property-type>java.lang.Integer</config-property-type>
+ </config-property>
+
+ <config-property>
+ <description>Some Primitive boolean Property</description>
+ <config-property-name>someBooleanProperty</config-property-name>
+ <config-property-type>java.lang.Boolean</config-property-type>
+ </config-property>
+
+ <config-property>
+ <description>Some Object Boolean Property</description>
+ <config-property-name>someBooleanObjectProperty</config-property-name>
+ <config-property-type>java.lang.Boolean</config-property-type>
+ </config-property>
+
+ <connectionfactory-interface>javax.jms.ConnectionFactory</connectionfactory-interface>
+ <connectionfactory-impl-class>org.jboss.test.jca.primitive.ConnectionFactory</connectionfactory-impl-class>
+ <connection-interface>javax.jms.Connection</connection-interface>
+ <connection-impl-class>org.jboss.test.jca.primitive.Connection</connection-impl-class>
+
+ </connection-definition>
+
+ <transaction-support>XATransaction</transaction-support>
+
+ <authentication-mechanism>
+ <description>User name and password supported</description>
+ <authentication-mechanism-type>BasicPassword</authentication-mechanism-type>
+ <credential-interface>
+ javax.resource.spi.security.PasswordCredential</credential-interface>
+ </authentication-mechanism>
+ <reauthentication-support>true</reauthentication-support>
+ </outbound-resourceadapter>
+
+ <adminobject>
+ <adminobject-interface>javax.jms.Queue</adminobject-interface>
+ <adminobject-class>org.jboss.test.jca.primitive.AdminObject</adminobject-class>
+ <config-property>
+ <description>Some Primitive int Property</description>
+ <config-property-name>someIntProperty</config-property-name>
+ <config-property-type>java.lang.Integer</config-property-type>
+ </config-property>
+
+ <config-property>
+ <description>Some Object Integer Property</description>
+ <config-property-name>someIntegerObjectProperty</config-property-name>
+ <config-property-type>java.lang.Integer</config-property-type>
+ </config-property>
+
+ <config-property>
+ <description>Some Primitive boolean Property</description>
+ <config-property-name>someBooleanProperty</config-property-name>
+ <config-property-type>java.lang.Boolean</config-property-type>
+ </config-property>
+
+ <config-property>
+ <description>Some Object Boolean Property</description>
+ <config-property-name>someBooleanObjectProperty</config-property-name>
+ <config-property-type>java.lang.Boolean</config-property-type>
+ </config-property>
+ </adminobject>
+ </resourceadapter>
+</connector>
Added: branches/JBPAPP_5_0/testsuite/src/resources/jca/primitive/jcaprimitive-ds.xml
===================================================================
--- branches/JBPAPP_5_0/testsuite/src/resources/jca/primitive/jcaprimitive-ds.xml (rev 0)
+++ branches/JBPAPP_5_0/testsuite/src/resources/jca/primitive/jcaprimitive-ds.xml 2009-11-25 19:37:43 UTC (rev 96988)
@@ -0,0 +1,12 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<connection-factories>
+
+ <no-tx-connection-factory>
+ <jndi-name>JCAPrimitive</jndi-name>
+ <rar-name>jcaprimitive.rar</rar-name>
+ <connection-definition>javax.jms.ConnectionFactory</connection-definition>
+ <max-pool-size>10</max-pool-size>
+ </no-tx-connection-factory>
+
+</connection-factories>
More information about the jboss-cvs-commits
mailing list