[jboss-cvs] JBossAS SVN: r69759 - in trunk/connector/src: tests/org/jboss/tests/jca/managed and 1 other directory.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Sun Feb 10 02:30:07 EST 2008
Author: scott.stark at jboss.org
Date: 2008-02-10 02:30:07 -0500 (Sun, 10 Feb 2008)
New Revision: 69759
Modified:
trunk/connector/src/main/org/jboss/resource/deployers/management/DsDataSourceTemplateInfo.java
trunk/connector/src/tests/org/jboss/tests/jca/managed/ManagedObjectTestCase.java
Log:
Template info property values need to be MetaValues. Correct the connection property MetaTypes as well.
Modified: trunk/connector/src/main/org/jboss/resource/deployers/management/DsDataSourceTemplateInfo.java
===================================================================
--- trunk/connector/src/main/org/jboss/resource/deployers/management/DsDataSourceTemplateInfo.java 2008-02-10 06:26:16 UTC (rev 69758)
+++ trunk/connector/src/main/org/jboss/resource/deployers/management/DsDataSourceTemplateInfo.java 2008-02-10 07:30:07 UTC (rev 69759)
@@ -26,7 +26,6 @@
import java.util.Map;
import java.util.List;
import java.lang.annotation.Annotation;
-import java.lang.reflect.Type;
import java.lang.reflect.UndeclaredThrowableException;
import org.jboss.annotation.factory.AnnotationProxy;
@@ -35,9 +34,12 @@
import org.jboss.managed.plugins.DefaultFieldsImpl;
import org.jboss.managed.plugins.ManagedObjectImpl;
import org.jboss.managed.plugins.ManagedPropertyImpl;
+import org.jboss.metatype.api.types.MapCompositeMetaType;
import org.jboss.metatype.api.types.MetaType;
import org.jboss.metatype.api.types.SimpleMetaType;
import org.jboss.metatype.api.types.MetaTypeFactory;
+import org.jboss.metatype.api.values.MetaValue;
+import org.jboss.metatype.api.values.MetaValueFactory;
import org.jboss.profileservice.management.plugins.BasicDeploymentTemplateInfo;
import org.jboss.resource.metadata.mcf.LocalDataSourceDeploymentMetaData;
import org.jboss.resource.metadata.mcf.XADataSourceDeploymentMetaData;
@@ -47,7 +49,7 @@
import org.jboss.resource.metadata.mcf.TxConnectionFactoryDeploymentMetaData;
/**
- * The template for creating
+ * The template for creating jca datasources, connection factories
*
* @author Scott.Stark at jboss.org
* @version $Revision$
@@ -55,11 +57,11 @@
public class DsDataSourceTemplateInfo extends BasicDeploymentTemplateInfo
{
private static final long serialVersionUID = 1;
+ /** The meta value factory */
+ private static MetaValueFactory METAVALUE_FACTORY = MetaValueFactory.getInstance();
private static final MetaTypeFactory METATYPE_FACTORY = MetaTypeFactory.getInstance();
private Map<String, String> propertyNameMappings;
private String dsType = "local-tx-datasource";
- private transient Type mapType;
- private transient Type mapOfMapsType;
public DsDataSourceTemplateInfo(String name, String description, String datasourceType)
{
@@ -134,7 +136,8 @@
ManagedObjectImpl mo = new ManagedObjectImpl(XADataSourceDeploymentMetaData.class.getName());
addDsProperties(mo);
addManagedProperty("xa-datasource-class", "The xa datasource class name", true, SimpleMetaType.STRING, mo);
- addManagedProperty("xa-datasource-properties", "The xa datasource properties", false, METATYPE_FACTORY.resolve(getMapType()), mo);
+ MetaType type = new MapCompositeMetaType(SimpleMetaType.STRING);
+ addManagedProperty("xa-datasource-properties", "The xa datasource properties", false, type, mo);
addManagedProperty("url-property", "The URL property", true, SimpleMetaType.STRING, mo);
addManagedProperty("xa-resource-timeout", "The XA resource timeout", true, SimpleMetaType.INTEGER, new Integer(0), mo);
}
@@ -170,7 +173,8 @@
addDsProperties(mo);
addManagedProperty("driver-class", "The jdbc driver class name", true, SimpleMetaType.STRING, mo);
addManagedProperty("connection-url", "The jdbc url of the DataSource", true, SimpleMetaType.STRING, mo);
- addManagedProperty("connection-properties", "The jdbc driver connection properties", false, METATYPE_FACTORY.resolve(List.class), mo);
+ MetaType type = new MapCompositeMetaType(SimpleMetaType.STRING);
+ addManagedProperty("connection-properties", "The jdbc driver connection properties", false, type, mo);
}
private void addDsProperties(ManagedObjectImpl mo)
@@ -214,7 +218,8 @@
addManagedProperty("statistics-formatter", "", true, SimpleMetaType.STRING, mo);
addManagedProperty("isSameRM-override-value", "", true, SimpleMetaType.BOOLEAN, mo);
addManagedProperty("track-connection-by-tx", "", true, SimpleMetaType.BOOLEAN, mo);
- addManagedProperty("config-property", "The connection factory config properties", false, METATYPE_FACTORY.resolve(getMapOfMapsType()), mo);
+ MetaType type = new MapCompositeMetaType(SimpleMetaType.STRING);
+ addManagedProperty("config-property", "The connection factory config properties", false, type, mo);
addManagedProperty("security-domain", "The security-domain used to validate connections", false, SimpleMetaType.STRING, mo);
addManagedProperty("depends", "", false, METATYPE_FACTORY.resolve(List.class), mo);
addManagedProperty("metadata", "", false, METATYPE_FACTORY.resolve(DBMSMetaData.class), mo);
@@ -271,7 +276,11 @@
}
super.addProperty(mp);
if(value != null)
+ {
+ if((value instanceof MetaValue) == false)
+ value = METAVALUE_FACTORY.create(value);
mp.setValue(value);
+ }
}
protected void setFieldName(String name, Fields f)
@@ -285,45 +294,4 @@
}
}
- private Type getMapOfMapsType()
- {
- if(mapOfMapsType == null)
- {
- try
- {
- mapOfMapsType = getClass().getMethod("mapOfMaps").getGenericReturnType();
- }
- catch(NoSuchMethodException e)
- {
- throw new IllegalStateException("Failed to find compoditeValueMap method.");
- }
- }
- return mapOfMapsType;
- }
-
- private Type getMapType()
- {
- if(mapType == null)
- {
- try
- {
- mapType = getClass().getMethod("compositeValueMap").getGenericReturnType();
- }
- catch(NoSuchMethodException e)
- {
- throw new IllegalStateException("Failed to find compoditeValueMap method.");
- }
- }
- return mapType;
- }
-
- public Map<String, String> compositeValueMap()
- {
- return null;
- }
-
- public Map<String, Map<String, String>> mapOfMaps()
- {
- return null;
- }
}
Modified: trunk/connector/src/tests/org/jboss/tests/jca/managed/ManagedObjectTestCase.java
===================================================================
--- trunk/connector/src/tests/org/jboss/tests/jca/managed/ManagedObjectTestCase.java 2008-02-10 06:26:16 UTC (rev 69758)
+++ trunk/connector/src/tests/org/jboss/tests/jca/managed/ManagedObjectTestCase.java 2008-02-10 07:30:07 UTC (rev 69759)
@@ -22,10 +22,14 @@
package org.jboss.tests.jca.managed;
import java.util.Arrays;
+import java.util.HashMap;
import java.util.List;
+import java.util.Map;
import java.util.Set;
import java.util.TreeSet;
+import org.jboss.deployers.spi.management.DeploymentTemplateInfo;
+import org.jboss.deployers.spi.management.ManagementView;
import org.jboss.managed.api.ManagedObject;
import org.jboss.managed.api.ManagedProperty;
import org.jboss.managed.api.factory.ManagedObjectFactory;
@@ -33,8 +37,10 @@
import org.jboss.metatype.api.types.MetaType;
import org.jboss.metatype.api.values.CompositeValue;
import org.jboss.metatype.api.values.MapCompositeValueSupport;
+import org.jboss.metatype.api.values.MetaValue;
import org.jboss.metatype.api.values.SimpleValueSupport;
import org.jboss.resource.connectionmanager.JBossManagedConnectionPool;
+import org.jboss.resource.deployers.management.DsDataSourceTemplateInfo;
import org.jboss.resource.deployers.management.LocalDSInstanceClassFactory;
import org.jboss.resource.deployers.management.TxInstanceClassFactory;
import org.jboss.resource.deployers.management.XADSInstanceClassFactory;
@@ -301,6 +307,30 @@
String jndiNameTest = xads.getJndiName();
assertEquals("java:ClusteredDS", jndiNameTest);
}
+ /**
+ * Validate that the XATxDataSourceTemplate ManagedPropertys are values are of type MetaValue
+ * @throws Exception
+ */
+ public void testXADataSourceTemplatePropertiesAreMetaValues()
+ throws Exception
+ {
+ DsDataSourceTemplateInfo dsInfo = new DsDataSourceTemplateInfo("TestDS", "test ds", "local-tx-datasource");
+ dsInfo.start();
+ Map<String,ManagedProperty> props = dsInfo.getProperties();
+ validatePropertyMetaValues(props);
+ }
+ /**
+ * Validate that the LocalTxDataSourceTemplate ManagedPropertys are values are of type MetaValue
+ * @throws Exception
+ */
+ public void testLocalTxDataSourceTemplatePropertiesAreMetaValues()
+ throws Exception
+ {
+ DsDataSourceTemplateInfo dsInfo = new DsDataSourceTemplateInfo("TestDS", "test ds", "xa-datasource");
+ dsInfo.start();
+ Map<String,ManagedProperty> props = dsInfo.getProperties();
+ validatePropertyMetaValues(props);
+ }
public void testJBossManagedConnectionPool()
{
@@ -352,4 +382,23 @@
missingNames.add(name);
}
}
+
+ protected void validatePropertyMetaValues(Map<String, ManagedProperty> props)
+ {
+ HashMap<String, Object> invalidValues = new HashMap<String, Object>();
+ HashMap<String, Object> nullValues = new HashMap<String, Object>();
+ for(ManagedProperty prop : props.values())
+ {
+ Object value = prop.getValue();
+ if((value instanceof MetaValue) == false)
+ {
+ if(value == null)
+ nullValues.put(prop.getName(), value);
+ else
+ invalidValues.put(prop.getName(), value);
+ }
+ }
+ log.info("Propertys with null values: "+nullValues);
+ assertEquals("InvalidPropertys: "+invalidValues, 0, invalidValues.size());
+ }
}
More information about the jboss-cvs-commits
mailing list