[jboss-cvs] JBossAS SVN: r69689 - in trunk: connector/src/main/org/jboss/resource/deployers/management and 3 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Thu Feb 7 02:33:44 EST 2008
Author: scott.stark at jboss.org
Date: 2008-02-07 02:33:44 -0500 (Thu, 07 Feb 2008)
New Revision: 69689
Added:
trunk/connector/src/main/org/jboss/resource/deployers/management/InstanceClassFactoryUtils.java
trunk/connector/src/main/org/jboss/resource/deployers/management/NoTxCFInstanceClassFactory.java
trunk/connector/src/main/org/jboss/resource/deployers/management/NoTxInstanceClassFactory.java
trunk/connector/src/main/org/jboss/resource/deployers/management/TxInstanceClassFactory.java
trunk/connector/src/main/org/jboss/resource/deployers/management/XADSInstanceClassFactory.java
trunk/connector/src/tests/org/jboss/tests/jca/managed/TestICFOverloadingTestCase.java
trunk/connector/src/tests/org/jboss/tests/jca/managed/icf/
trunk/connector/src/tests/org/jboss/tests/jca/managed/icf/AbstractInstanceClassFactory.java
trunk/connector/src/tests/org/jboss/tests/jca/managed/icf/XADSInstanceClassFactory.java
Removed:
trunk/connector/src/main/org/jboss/resource/deployers/management/XADataSourceDeploymentMetaDataBuilder.java
Modified:
trunk/connector/src/main/org/jboss/resource/deployers/ManagedConnectionFactoryParserDeployer.java
trunk/connector/src/main/org/jboss/resource/deployers/management/DsDataSourceTemplate.java
trunk/connector/src/main/org/jboss/resource/deployers/management/LocalDSInstanceClassFactory.java
trunk/connector/src/tests/org/jboss/tests/jca/managed/ManagedObjectTestCase.java
trunk/testsuite/src/main/org/jboss/test/profileservice/test/ProfileServiceUnitTestCase.java
Log:
JBAS-5194, ds properties are working
Modified: trunk/connector/src/main/org/jboss/resource/deployers/ManagedConnectionFactoryParserDeployer.java
===================================================================
--- trunk/connector/src/main/org/jboss/resource/deployers/ManagedConnectionFactoryParserDeployer.java 2008-02-07 07:12:35 UTC (rev 69688)
+++ trunk/connector/src/main/org/jboss/resource/deployers/ManagedConnectionFactoryParserDeployer.java 2008-02-07 07:33:44 UTC (rev 69689)
@@ -35,12 +35,17 @@
import org.jboss.deployers.structure.spi.DeploymentUnit;
import org.jboss.resource.metadata.mcf.ManagedConnectionFactoryDeploymentGroup;
import org.jboss.resource.metadata.mcf.ManagedConnectionFactoryDeploymentMetaData;
+import org.jboss.resource.metadata.mcf.NoTxConnectionFactoryDeploymentMetaData;
import org.jboss.resource.metadata.mcf.XADataSourceDeploymentMetaData;
import org.jboss.resource.metadata.mcf.LocalDataSourceDeploymentMetaData;
import org.jboss.resource.metadata.mcf.NoTxDataSourceDeploymentMetaData;
import org.jboss.resource.metadata.mcf.TxConnectionFactoryDeploymentMetaData;
import org.jboss.resource.metadata.repository.JCAMetaDataRepository;
-import org.jboss.resource.deployers.management.XADataSourceDeploymentMetaDataBuilder;
+import org.jboss.resource.deployers.management.LocalDSInstanceClassFactory;
+import org.jboss.resource.deployers.management.NoTxCFInstanceClassFactory;
+import org.jboss.resource.deployers.management.NoTxInstanceClassFactory;
+import org.jboss.resource.deployers.management.TxInstanceClassFactory;
+import org.jboss.resource.deployers.management.XADSInstanceClassFactory;
import org.jboss.virtual.VirtualFile;
import org.jboss.managed.api.ManagedObject;
import org.jboss.managed.api.factory.ManagedObjectFactory;
@@ -75,12 +80,12 @@
setBuildManagedObject(true);
moFactory = ManagedObjectFactoryBuilder.create();
- XADataSourceDeploymentMetaDataBuilder builder = new XADataSourceDeploymentMetaDataBuilder();
- moFactory.setBuilder(LocalDataSourceDeploymentMetaData.class, builder);
- moFactory.setBuilder(XADataSourceDeploymentMetaData.class, builder);
- moFactory.setBuilder(NoTxDataSourceDeploymentMetaData.class, builder);
- moFactory.setBuilder(TxConnectionFactoryDeploymentMetaData.class, builder);
- moFactory.setBuilder(TxConnectionFactoryDeploymentMetaData.class, builder);
+ // Setup the ManagedObject builders and InstanceClassFactorys
+ moFactory.setInstanceClassFactory(LocalDataSourceDeploymentMetaData.class, new LocalDSInstanceClassFactory());
+ moFactory.setInstanceClassFactory(XADataSourceDeploymentMetaData.class, new XADSInstanceClassFactory());
+ moFactory.setInstanceClassFactory(NoTxDataSourceDeploymentMetaData.class, new NoTxInstanceClassFactory());
+ moFactory.setInstanceClassFactory(TxConnectionFactoryDeploymentMetaData.class, new TxInstanceClassFactory());
+ moFactory.setInstanceClassFactory(NoTxConnectionFactoryDeploymentMetaData.class, new NoTxCFInstanceClassFactory());
}
/**
Modified: trunk/connector/src/main/org/jboss/resource/deployers/management/DsDataSourceTemplate.java
===================================================================
--- trunk/connector/src/main/org/jboss/resource/deployers/management/DsDataSourceTemplate.java 2008-02-07 07:12:35 UTC (rev 69688)
+++ trunk/connector/src/main/org/jboss/resource/deployers/management/DsDataSourceTemplate.java 2008-02-07 07:33:44 UTC (rev 69689)
@@ -51,6 +51,7 @@
* The connection factory template implementation.
*
* @author Scott.Stark at jboss.org
+ * @author <a href="mailto:alex at jboss.org">Alexey Loubyansky</a>
* @version $Revision$
*/
public class DsDataSourceTemplate
@@ -97,7 +98,6 @@
if("local-tx-datasource".equals(cfType))
{
mcf = new LocalDataSourceDeploymentMetaData();
- mof.setBuilder(mcf.getClass(), new XADataSourceDeploymentMetaDataBuilder());
mof.setInstanceClassFactory(LocalDataSourceDeploymentMetaData.class, new LocalDSInstanceClassFactory());
cfMO = mof.initManagedObject(mcf,
KnownComponentTypes.DataSourceTypes.LocalTx.getType().getType(),
@@ -106,7 +106,7 @@
else if("xa-datasource".equals(cfType))
{
mcf = new XADataSourceDeploymentMetaData();
- mof.setBuilder(mcf.getClass(), new XADataSourceDeploymentMetaDataBuilder());
+ mof.setInstanceClassFactory(XADataSourceDeploymentMetaData.class, new XADSInstanceClassFactory());
cfMO = mof.initManagedObject(mcf,
KnownComponentTypes.DataSourceTypes.XA.getType().getType(),
KnownComponentTypes.DataSourceTypes.XA.getType().getSubtype());
@@ -115,26 +115,24 @@
{
rootElementName = "connection-factories";
mcf = new TxConnectionFactoryDeploymentMetaData();
- mof.setBuilder(mcf.getClass(), new XADataSourceDeploymentMetaDataBuilder());
- // TODO: add constants to the KnownComponentTypes
+ mof.setInstanceClassFactory(TxConnectionFactoryDeploymentMetaData.class, new TxInstanceClassFactory());
cfMO = mof.initManagedObject(mcf,
- "ConnectionFactory",
- "XA");
+ KnownComponentTypes.ConnectionFactoryTypes.XA.getType().getType(),
+ KnownComponentTypes.ConnectionFactoryTypes.XA.getType().getSubtype());
}
else if("no-tx-connection-factory".equals(cfType))
{
rootElementName = "connection-factories";
mcf = new NoTxConnectionFactoryDeploymentMetaData();
- mof.setBuilder(mcf.getClass(), new XADataSourceDeploymentMetaDataBuilder());
- // TODO: add constants to the KnownComponentTypes
+ mof.setInstanceClassFactory(NoTxConnectionFactoryDeploymentMetaData.class, new NoTxCFInstanceClassFactory());
cfMO = mof.initManagedObject(mcf,
- "ConnectionFactory",
- "NoTx");
+ KnownComponentTypes.ConnectionFactoryTypes.NoTx.getType().getType(),
+ KnownComponentTypes.ConnectionFactoryTypes.NoTx.getType().getSubtype());
}
else if("no-tx-datasource".equals(cfType))
{
mcf = new NoTxDataSourceDeploymentMetaData();
- mof.setBuilder(mcf.getClass(), new XADataSourceDeploymentMetaDataBuilder());
+ mof.setInstanceClassFactory(NoTxDataSourceDeploymentMetaData.class, new NoTxInstanceClassFactory());
cfMO = mof.initManagedObject(mcf,
KnownComponentTypes.DataSourceTypes.NoTx.getType().getType(),
KnownComponentTypes.DataSourceTypes.NoTx.getType().getSubtype());
Added: trunk/connector/src/main/org/jboss/resource/deployers/management/InstanceClassFactoryUtils.java
===================================================================
--- trunk/connector/src/main/org/jboss/resource/deployers/management/InstanceClassFactoryUtils.java (rev 0)
+++ trunk/connector/src/main/org/jboss/resource/deployers/management/InstanceClassFactoryUtils.java 2008-02-07 07:33:44 UTC (rev 69689)
@@ -0,0 +1,103 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2007, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt 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.deployers.management;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.jboss.beans.info.spi.BeanInfo;
+import org.jboss.managed.api.ManagedProperty;
+import org.jboss.metatype.api.types.SimpleMetaType;
+import org.jboss.metatype.api.values.MapCompositeValueSupport;
+import org.jboss.metatype.api.values.MetaValue;
+import org.jboss.metatype.api.values.MetaValueFactory;
+import org.jboss.metatype.api.values.SimpleValueSupport;
+import org.jboss.resource.metadata.mcf.ManagedConnectionFactoryDeploymentMetaData;
+import org.jboss.resource.metadata.mcf.ManagedConnectionFactoryPropertyMetaData;
+import org.jboss.resource.metadata.mcf.XADataSourceDeploymentMetaData;
+
+/**
+ * property to meta value conversion for common properties
+ * @author Scott.Stark at jboss.org
+ * @version $Revision$
+ */
+public class InstanceClassFactoryUtils
+{
+ /**
+ * Transform the ManagedConnectionFactoryProperties into a
+ * MapCompositeValueSupport value.
+ *
+ * @param <T>
+ * @param beanInfo
+ * @param property
+ * @param attachment
+ * @return
+ */
+ static <T extends ManagedConnectionFactoryDeploymentMetaData>
+ MetaValue getConfigPropertyValue(BeanInfo beanInfo, ManagedProperty property, T attachment)
+ {
+ MapCompositeValueSupport map = new MapCompositeValueSupport(SimpleMetaType.STRING);
+ List<ManagedConnectionFactoryPropertyMetaData> list = attachment.getManagedConnectionFactoryProperties();
+ if(list != null)
+ {
+ for(ManagedConnectionFactoryPropertyMetaData prop : list)
+ {
+ String name = prop.getName();
+ MetaValue svalue = SimpleValueSupport.wrap(prop.getValue());
+ map.put(name, svalue);
+ MetaValue stype = SimpleValueSupport.wrap(prop.getValue());
+ map.put(name+".type", stype);
+ }
+ }
+ return map;
+ }
+ /**
+ *
+ * @param beanInfo
+ * @param property
+ * @param value
+ * @param metaValueFactory
+ * @return
+ */
+ static Object unwrapConfigPropertyValue(BeanInfo beanInfo, ManagedProperty property,
+ MetaValue value, MetaValueFactory metaValueFactory)
+ {
+ MapCompositeValueSupport mapValue = (MapCompositeValueSupport) value;
+ List<ManagedConnectionFactoryPropertyMetaData> list = new ArrayList<ManagedConnectionFactoryPropertyMetaData>();
+ for(String name : mapValue.getMetaType().keySet())
+ {
+ ManagedConnectionFactoryPropertyMetaData prop = new ManagedConnectionFactoryPropertyMetaData();
+ prop.setName(name);
+ String svalue = (String) metaValueFactory.unwrap(mapValue.get(name));
+ prop.setValue(svalue);
+ String nameType = name+".type";
+ MetaValue typeValue = mapValue.get(nameType);
+ if(typeValue != null)
+ {
+ String type = (String) metaValueFactory.unwrap(typeValue);
+ prop.setType(type);
+ }
+ list.add(prop);
+ }
+ return list;
+ }
+}
Property changes on: trunk/connector/src/main/org/jboss/resource/deployers/management/InstanceClassFactoryUtils.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ native
Modified: trunk/connector/src/main/org/jboss/resource/deployers/management/LocalDSInstanceClassFactory.java
===================================================================
--- trunk/connector/src/main/org/jboss/resource/deployers/management/LocalDSInstanceClassFactory.java 2008-02-07 07:12:35 UTC (rev 69688)
+++ trunk/connector/src/main/org/jboss/resource/deployers/management/LocalDSInstanceClassFactory.java 2008-02-07 07:33:44 UTC (rev 69689)
@@ -21,6 +21,7 @@
*/
package org.jboss.resource.deployers.management;
+import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
@@ -43,6 +44,13 @@
extends AbstractInstanceClassFactory<LocalDataSourceDeploymentMetaData>
{
+ public Class<? extends Serializable> getManagedObjectClass(
+ LocalDataSourceDeploymentMetaData attachment)
+ throws ClassNotFoundException
+ {
+ return attachment.getClass();
+ }
+
public MetaValue getValue(BeanInfo beanInfo, ManagedProperty property,
LocalDataSourceDeploymentMetaData attachment)
{
@@ -73,7 +81,9 @@
MetaValue value)
{
if((value instanceof MapCompositeValueSupport) == false)
- super.unwrapValue(beanInfo, property, value);
+ {
+ return super.unwrapValue(beanInfo, property, value);
+ }
MapCompositeValueSupport mapValue = (MapCompositeValueSupport) value;
Object unwrapValue = null;
Added: trunk/connector/src/main/org/jboss/resource/deployers/management/NoTxCFInstanceClassFactory.java
===================================================================
--- trunk/connector/src/main/org/jboss/resource/deployers/management/NoTxCFInstanceClassFactory.java (rev 0)
+++ trunk/connector/src/main/org/jboss/resource/deployers/management/NoTxCFInstanceClassFactory.java 2008-02-07 07:33:44 UTC (rev 69689)
@@ -0,0 +1,71 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2007, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt 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.deployers.management;
+
+import org.jboss.beans.info.spi.BeanInfo;
+import org.jboss.managed.api.ManagedProperty;
+import org.jboss.managed.plugins.factory.AbstractInstanceClassFactory;
+import org.jboss.metatype.api.values.MapCompositeValueSupport;
+import org.jboss.metatype.api.values.MetaValue;
+import org.jboss.resource.metadata.mcf.NoTxConnectionFactoryDeploymentMetaData;
+
+/**
+ *
+ * @author Scott.Stark at jboss.org
+ * @version $Revision$
+ */
+public class NoTxCFInstanceClassFactory
+ extends AbstractInstanceClassFactory<NoTxConnectionFactoryDeploymentMetaData>
+{
+ public MetaValue getValue(BeanInfo beanInfo, ManagedProperty property,
+ NoTxConnectionFactoryDeploymentMetaData attachment)
+ {
+ MetaValue value = null;
+ if("config-property".equals(property.getName()))
+ {
+ value = InstanceClassFactoryUtils.getConfigPropertyValue(beanInfo, property, attachment);
+ }
+ else
+ {
+ value = super.getValue(beanInfo, property, attachment);
+ }
+ return value;
+ }
+
+ @Override
+ protected Object unwrapValue(BeanInfo beanInfo, ManagedProperty property,
+ MetaValue value)
+ {
+ if((value instanceof MapCompositeValueSupport) == false)
+ {
+ return super.unwrapValue(beanInfo, property, value);
+ }
+
+ Object unwrapValue = null;
+ if("config-property".equals(property.getName()))
+ {
+ unwrapValue = InstanceClassFactoryUtils.unwrapConfigPropertyValue(beanInfo,
+ property, value, getMetaValueFactory());
+ }
+ return unwrapValue;
+ }
+}
Property changes on: trunk/connector/src/main/org/jboss/resource/deployers/management/NoTxCFInstanceClassFactory.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ native
Added: trunk/connector/src/main/org/jboss/resource/deployers/management/NoTxInstanceClassFactory.java
===================================================================
--- trunk/connector/src/main/org/jboss/resource/deployers/management/NoTxInstanceClassFactory.java (rev 0)
+++ trunk/connector/src/main/org/jboss/resource/deployers/management/NoTxInstanceClassFactory.java 2008-02-07 07:33:44 UTC (rev 69689)
@@ -0,0 +1,73 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2007, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt 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.deployers.management;
+
+import java.io.Serializable;
+
+import org.jboss.beans.info.spi.BeanInfo;
+import org.jboss.managed.api.ManagedProperty;
+import org.jboss.managed.plugins.factory.AbstractInstanceClassFactory;
+import org.jboss.metatype.api.values.MapCompositeValueSupport;
+import org.jboss.metatype.api.values.MetaValue;
+import org.jboss.resource.metadata.mcf.NoTxDataSourceDeploymentMetaData;
+
+/**
+ *
+ * @author Scott.Stark at jboss.org
+ * @version $Revision$
+ */
+public class NoTxInstanceClassFactory
+ extends AbstractInstanceClassFactory<NoTxDataSourceDeploymentMetaData>
+{
+ public MetaValue getValue(BeanInfo beanInfo, ManagedProperty property,
+ NoTxDataSourceDeploymentMetaData attachment)
+ {
+ MetaValue value = null;
+ if("config-property".equals(property.getName()))
+ {
+ value = InstanceClassFactoryUtils.getConfigPropertyValue(beanInfo, property, attachment);
+ }
+ else
+ {
+ value = super.getValue(beanInfo, property, attachment);
+ }
+ return value;
+ }
+
+ @Override
+ protected Object unwrapValue(BeanInfo beanInfo, ManagedProperty property,
+ MetaValue value)
+ {
+ if((value instanceof MapCompositeValueSupport) == false)
+ {
+ return super.unwrapValue(beanInfo, property, value);
+ }
+
+ Object unwrapValue = null;
+ if("config-property".equals(property.getName()))
+ {
+ unwrapValue = InstanceClassFactoryUtils.unwrapConfigPropertyValue(beanInfo,
+ property, value, getMetaValueFactory());
+ }
+ return unwrapValue;
+ }
+}
Property changes on: trunk/connector/src/main/org/jboss/resource/deployers/management/NoTxInstanceClassFactory.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ native
Added: trunk/connector/src/main/org/jboss/resource/deployers/management/TxInstanceClassFactory.java
===================================================================
--- trunk/connector/src/main/org/jboss/resource/deployers/management/TxInstanceClassFactory.java (rev 0)
+++ trunk/connector/src/main/org/jboss/resource/deployers/management/TxInstanceClassFactory.java 2008-02-07 07:33:44 UTC (rev 69689)
@@ -0,0 +1,73 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2007, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt 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.deployers.management;
+
+import java.io.Serializable;
+
+import org.jboss.beans.info.spi.BeanInfo;
+import org.jboss.managed.api.ManagedProperty;
+import org.jboss.managed.plugins.factory.AbstractInstanceClassFactory;
+import org.jboss.metatype.api.values.MapCompositeValueSupport;
+import org.jboss.metatype.api.values.MetaValue;
+import org.jboss.resource.metadata.mcf.TxConnectionFactoryDeploymentMetaData;
+
+/**
+ *
+ * @author Scott.Stark at jboss.org
+ * @version $Revision$
+ */
+public class TxInstanceClassFactory
+ extends AbstractInstanceClassFactory<TxConnectionFactoryDeploymentMetaData>
+{
+ public MetaValue getValue(BeanInfo beanInfo, ManagedProperty property,
+ TxConnectionFactoryDeploymentMetaData attachment)
+ {
+ MetaValue value = null;
+ if("config-property".equals(property.getName()))
+ {
+ value = InstanceClassFactoryUtils.getConfigPropertyValue(beanInfo, property, attachment);
+ }
+ else
+ {
+ value = super.getValue(beanInfo, property, attachment);
+ }
+ return value;
+ }
+
+ @Override
+ protected Object unwrapValue(BeanInfo beanInfo, ManagedProperty property,
+ MetaValue value)
+ {
+ if((value instanceof MapCompositeValueSupport) == false)
+ {
+ return super.unwrapValue(beanInfo, property, value);
+ }
+
+ Object unwrapValue = null;
+ if("config-property".equals(property.getName()))
+ {
+ unwrapValue = InstanceClassFactoryUtils.unwrapConfigPropertyValue(beanInfo,
+ property, value, getMetaValueFactory());
+ }
+ return unwrapValue;
+ }
+}
Property changes on: trunk/connector/src/main/org/jboss/resource/deployers/management/TxInstanceClassFactory.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ native
Added: trunk/connector/src/main/org/jboss/resource/deployers/management/XADSInstanceClassFactory.java
===================================================================
--- trunk/connector/src/main/org/jboss/resource/deployers/management/XADSInstanceClassFactory.java (rev 0)
+++ trunk/connector/src/main/org/jboss/resource/deployers/management/XADSInstanceClassFactory.java 2008-02-07 07:33:44 UTC (rev 69689)
@@ -0,0 +1,111 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2007, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt 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.deployers.management;
+
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.jboss.beans.info.spi.BeanInfo;
+import org.jboss.logging.Logger;
+import org.jboss.managed.api.ManagedProperty;
+import org.jboss.managed.plugins.factory.AbstractInstanceClassFactory;
+import org.jboss.metatype.api.types.SimpleMetaType;
+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.metadata.mcf.XAConnectionPropertyMetaData;
+import org.jboss.resource.metadata.mcf.XADataSourceDeploymentMetaData;
+
+/**
+ * InstanceClassFactory for XADataSourceDeploymentMetaData
+ * @author Scott.Stark at jboss.org
+ * @version $Revision$
+ */
+public class XADSInstanceClassFactory
+ extends AbstractInstanceClassFactory<XADataSourceDeploymentMetaData>
+{
+ private static final Logger log = Logger.getLogger(XADSInstanceClassFactory.class);
+
+ public MetaValue getValue(BeanInfo beanInfo, ManagedProperty property,
+ XADataSourceDeploymentMetaData attachment)
+ {
+ MetaValue metaValue = null;
+ if("xa-datasource-properties".equals(property.getName()))
+ {
+ List<XAConnectionPropertyMetaData> list = attachment.getXADataSourceProperties();
+ if(list != null)
+ {
+ MapCompositeValueSupport map = new MapCompositeValueSupport(SimpleMetaType.STRING);
+ for(XAConnectionPropertyMetaData prop : list)
+ {
+ MetaValue svalue = SimpleValueSupport.wrap(prop.getValue());
+ map.put(prop.getName(), svalue);
+ }
+ metaValue = map;
+ }
+ }
+ else if("config-property".equals(property.getName()))
+ {
+ metaValue = InstanceClassFactoryUtils.getConfigPropertyValue(beanInfo, property, attachment);
+ return metaValue;
+ }
+ else
+ {
+ metaValue = super.getValue(beanInfo, property, attachment);
+ }
+ return metaValue;
+ }
+
+ @Override
+ protected Object unwrapValue(BeanInfo beanInfo, ManagedProperty property,
+ MetaValue value)
+ {
+ if((value instanceof MapCompositeValueSupport) == false)
+ {
+ return super.unwrapValue(beanInfo, property, value);
+ }
+
+ MapCompositeValueSupport mapValue = (MapCompositeValueSupport) value;
+ Object unwrapValue = null;
+ if("xa-datasource-properties".equals(property.getName()))
+ {
+ List<XAConnectionPropertyMetaData> list = new ArrayList<XAConnectionPropertyMetaData>();
+ for(String name : mapValue.getMetaType().keySet())
+ {
+ XAConnectionPropertyMetaData prop = new XAConnectionPropertyMetaData();
+ prop.setName(name);
+ String svalue = (String) getMetaValueFactory().unwrap(mapValue.get(name));
+ prop.setValue(svalue);
+ list.add(prop);
+ }
+ unwrapValue = list;
+ }
+ else if("config-property".equals(property.getName()))
+ {
+ unwrapValue = InstanceClassFactoryUtils.unwrapConfigPropertyValue(beanInfo,
+ property, value, getMetaValueFactory());
+ }
+
+ return unwrapValue;
+ }
+}
Property changes on: trunk/connector/src/main/org/jboss/resource/deployers/management/XADSInstanceClassFactory.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ native
Deleted: trunk/connector/src/main/org/jboss/resource/deployers/management/XADataSourceDeploymentMetaDataBuilder.java
===================================================================
--- trunk/connector/src/main/org/jboss/resource/deployers/management/XADataSourceDeploymentMetaDataBuilder.java 2008-02-07 07:12:35 UTC (rev 69688)
+++ trunk/connector/src/main/org/jboss/resource/deployers/management/XADataSourceDeploymentMetaDataBuilder.java 2008-02-07 07:33:44 UTC (rev 69689)
@@ -1,243 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2005, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt 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.deployers.management;
-
-import java.io.Serializable;
-import java.util.Map;
-import java.util.List;
-import java.util.ArrayList;
-import java.lang.reflect.Type;
-import java.lang.reflect.UndeclaredThrowableException;
-import org.jboss.beans.info.spi.BeanInfo;
-import org.jboss.beans.info.spi.PropertyInfo;
-import org.jboss.managed.api.ManagedProperty;
-import org.jboss.managed.plugins.factory.AbstractManagedObjectFactory;
-import org.jboss.managed.spi.factory.InstanceClassFactory;
-import org.jboss.metatype.api.types.SimpleMetaType;
-import org.jboss.metatype.api.values.MapCompositeValueSupport;
-import org.jboss.metatype.api.values.MetaValue;
-import org.jboss.metatype.api.values.MetaValueFactory;
-import org.jboss.resource.metadata.mcf.DataSourceConnectionPropertyMetaData;
-import org.jboss.resource.metadata.mcf.LocalDataSourceDeploymentMetaData;
-import org.jboss.resource.metadata.mcf.NonXADataSourceDeploymentMetaData;
-import org.jboss.resource.metadata.mcf.XADataSourceDeploymentMetaData;
-import org.jboss.resource.metadata.mcf.XAConnectionPropertyMetaData;
-import org.jboss.resource.metadata.mcf.ManagedConnectionFactoryDeploymentMetaData;
-import org.jboss.resource.metadata.mcf.ManagedConnectionFactoryPropertyMetaData;
-
-/**
- * @author <a href="mailto:alex at jboss.org">Alexey Loubyansky</a>
- * @author Scott.Stark at jboss.org
- * @version <tt>$Revision: $</tt>
- */
-public class XADataSourceDeploymentMetaDataBuilder
- extends AbstractManagedObjectFactory
-{
- private final Type mapType;
- private final Type mapOfMapsType;
- private MetaValueFactory metaValueFactory;
-
- public XADataSourceDeploymentMetaDataBuilder()
- {
- metaValueFactory = MetaValueFactory.getInstance();
-
- try
- {
- mapType = getClass().getMethod("compositeValueMap").getGenericReturnType();
- }
- catch(NoSuchMethodException e)
- {
- throw new IllegalStateException("Failed to find compoditeValueMap method.");
- }
-
- try
- {
- mapOfMapsType = getClass().getMethod("mapOfMaps").getGenericReturnType();
- }
- catch(NoSuchMethodException e)
- {
- throw new IllegalStateException("Failed to find mapOfMaps method.");
- }
- }
-
- public MetaValue getValue(BeanInfo beanInfo, ManagedProperty property, Serializable object)
- {
- if("xa-datasource-properties".equals(property.getName()))
- {
- MetaValue metaValue = null;
- XADataSourceDeploymentMetaData ds = (XADataSourceDeploymentMetaData)object;
- List<XAConnectionPropertyMetaData> list = ds.getXADataSourceProperties();
- if(list != null)
- {
- MapCompositeValueSupport map = new MapCompositeValueSupport(SimpleMetaType.STRING);
- for(XAConnectionPropertyMetaData prop : list)
- {
- MetaValue svalue = metaValueFactory.create(prop.getValue());
- map.put(prop.getName(), svalue);
- }
- metaValue = map;
- }
- return metaValue;
- }
-
- if("config-property".equals(property.getName()))
- {
- MetaValue metaValue = null;
- ManagedConnectionFactoryDeploymentMetaData mcf = (ManagedConnectionFactoryDeploymentMetaData)object;
- List<ManagedConnectionFactoryPropertyMetaData> list = mcf.getManagedConnectionFactoryProperties();
- if(list != null)
- {
- MapCompositeValueSupport map = new MapCompositeValueSupport(SimpleMetaType.STRING);
- for(ManagedConnectionFactoryPropertyMetaData prop : list)
- {
- String name = prop.getName();
- MetaValue svalue = metaValueFactory.create(prop.getValue());
- map.put(name, svalue);
- MetaValue stype = metaValueFactory.create(prop.getType());
- map.put(name+".type", stype);
- }
- metaValue = map;
- }
- return metaValue;
- }
- if("connection-properties".equals(property.getName()))
- {
- MetaValue metaValue = null;
- NonXADataSourceDeploymentMetaData dsmd = (NonXADataSourceDeploymentMetaData)object;
- List<DataSourceConnectionPropertyMetaData> list = dsmd.getDataSourceConnectionProperties();
- if(list != null)
- {
- MapCompositeValueSupport map = new MapCompositeValueSupport(SimpleMetaType.STRING);
- for(DataSourceConnectionPropertyMetaData prop : list)
- {
- MetaValue svalue = metaValueFactory.create(prop.getValue());
- map.put(prop.getName(), svalue);
- }
- metaValue = map;
- }
- return metaValue;
- }
-
- return super.getValue(beanInfo, property, object);
- }
-
- public void setValue(BeanInfo beanInfo, ManagedProperty property, Serializable object, MetaValue value)
- {
- if((value instanceof MapCompositeValueSupport) == false)
- {
- super.setValue(beanInfo, property, object, value);
- return;
- }
-
- MapCompositeValueSupport mapValue = (MapCompositeValueSupport) value;
- if("xa-datasource-properties".equals(property.getName()))
- {
- String propName = getPropertyName(property);
- PropertyInfo propertyInfo = beanInfo.getProperty(propName);
- List<XAConnectionPropertyMetaData> list = null;
- list = new ArrayList<XAConnectionPropertyMetaData>();
- for(String name : mapValue.getMetaType().keySet())
- {
- XAConnectionPropertyMetaData xaProp = new XAConnectionPropertyMetaData();
- xaProp.setName(name);
- String svalue = (String) metaValueFactory.unwrap(mapValue.get(name));
- xaProp.setValue(svalue);
- list.add(xaProp);
- }
-
- try
- {
- propertyInfo.set(object, list);
- }
- catch (Throwable t)
- {
- throw new UndeclaredThrowableException(t);
- }
- }
- else if("config-property".equals(property.getName()))
- {
- String propName = getPropertyName(property);
- PropertyInfo propertyInfo = beanInfo.getProperty(propName);
-
- List<ManagedConnectionFactoryPropertyMetaData> list = null;
- list = new ArrayList<ManagedConnectionFactoryPropertyMetaData>();
- for(String name : mapValue.getMetaType().keySet())
- {
- ManagedConnectionFactoryPropertyMetaData prop = new ManagedConnectionFactoryPropertyMetaData();
- prop.setName(name);
- String svalue = (String) metaValueFactory.unwrap(mapValue.get(name));
- prop.setValue(svalue);
- String nameType = name+".type";
- MetaValue typeValue = mapValue.get(nameType);
- if(typeValue != null)
- {
- String type = (String) metaValueFactory.unwrap(typeValue);
- prop.setType(type);
- }
- list.add(prop);
- }
-
- try
- {
- propertyInfo.set(object, list);
- }
- catch (Throwable t)
- {
- throw new UndeclaredThrowableException(t);
- }
- }
- else if("connection-properties".equals(property.getName()))
- {
- String propName = getPropertyName(property);
- PropertyInfo propertyInfo = beanInfo.getProperty(propName);
-
- List<DataSourceConnectionPropertyMetaData> list = new ArrayList<DataSourceConnectionPropertyMetaData>();
- for(String name : mapValue.getMetaType().keySet())
- {
- DataSourceConnectionPropertyMetaData prop = new DataSourceConnectionPropertyMetaData();
- prop.setName(name);
- String svalue = (String) metaValueFactory.unwrap(mapValue.get(name));
- prop.setValue(svalue);
- list.add(prop);
- }
-
- try
- {
- propertyInfo.set(object, list);
- }
- catch (Throwable t)
- {
- throw new UndeclaredThrowableException(t);
- }
- }
- }
-
- 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-07 07:12:35 UTC (rev 69688)
+++ trunk/connector/src/tests/org/jboss/tests/jca/managed/ManagedObjectTestCase.java 2008-02-07 07:33:44 UTC (rev 69689)
@@ -36,10 +36,13 @@
import org.jboss.metatype.api.values.SimpleValueSupport;
import org.jboss.resource.connectionmanager.JBossManagedConnectionPool;
import org.jboss.resource.deployers.management.LocalDSInstanceClassFactory;
-import org.jboss.resource.deployers.management.XADataSourceDeploymentMetaDataBuilder;
+import org.jboss.resource.deployers.management.TxInstanceClassFactory;
+import org.jboss.resource.deployers.management.XADSInstanceClassFactory;
import org.jboss.resource.metadata.mcf.DataSourceConnectionPropertyMetaData;
import org.jboss.resource.metadata.mcf.LocalDataSourceDeploymentMetaData;
import org.jboss.resource.metadata.mcf.NoTxDataSourceDeploymentMetaData;
+import org.jboss.resource.metadata.mcf.TxConnectionFactoryDeploymentMetaData;
+import org.jboss.resource.metadata.mcf.XAConnectionPropertyMetaData;
import org.jboss.resource.metadata.mcf.XADataSourceDeploymentMetaData;
import org.jboss.system.deployers.managed.ServiceMetaDataICF;
import org.jboss.system.metadata.ServiceMetaData;
@@ -67,7 +70,6 @@
"prefill",
"background-validation",
"background-validation-minutes",
- "valid-connection-checker-class-name",
"validate-on-match",
"use-strict-min",
"statistics-formatter",
@@ -86,6 +88,7 @@
"password",
"new-connection-sql",
"check-valid-connection-sql",
+ "valid-connection-checker-class-name",
"exception-sorter-class-name",
"track-statements",
"prepared-statement-cache-size",
@@ -107,6 +110,12 @@
"xa-datasource-class",
"xa-resource-timeout"
};
+ static final String[] TxConnectionFactoryDeploymentMetaData_NAMES = {
+ "xa-resource-timeout",
+ "xa-transaction",
+ "local-transaction"
+ };
+
static final String[] JBossManagedConnectionPool_NAMES = {
"availableConnectionCount",
"connectionCount",
@@ -138,12 +147,49 @@
TreeSet<String> sortedPropertyNames = new TreeSet<String>(propertyNames);
assertEquals(expectedPropertyNames, sortedPropertyNames);
}
+ public void testTxConnectionFactoryMetaData()
+ {
+ enableTrace("org.jboss.managed.plugins.factory");
+ ManagedObjectFactory mof = ManagedObjectFactory.getInstance();
+ TxInstanceClassFactory icf = new TxInstanceClassFactory();
+ mof.setInstanceClassFactory(TxConnectionFactoryDeploymentMetaData.class, icf);
+ TxConnectionFactoryDeploymentMetaData txcf = new TxConnectionFactoryDeploymentMetaData();
+ ManagedObject mo = mof.initManagedObject(txcf, "TxConnectionFactoryDeploymentMetaData", null);
+ // Validate the expected property names
+ Set<String> expectedPropertyNames = new TreeSet<String>();
+ expectedPropertyNames.addAll(Arrays.asList(ManagedConnectionFactoryDeploymentMetaData_NAMES));
+ expectedPropertyNames.addAll(Arrays.asList(TxConnectionFactoryDeploymentMetaData_NAMES));
+ Set<String> propertyNames = mo.getPropertyNames();
+ TreeSet<String> sortedPropertyNames = new TreeSet<String>(propertyNames);
+ if(expectedPropertyNames.equals(sortedPropertyNames) == false)
+ {
+ Set<String> missingNames = new TreeSet<String>();
+ Set<String> extraNames = new TreeSet<String>();
+ analyzeDiffs(expectedPropertyNames, sortedPropertyNames,
+ missingNames, extraNames);
+ fail("Extra properties: "+extraNames+", missing properties: "+missingNames);
+ }
+ ManagedProperty connectionProperties = mo.getProperty("config-property");
+ MetaType cpType = connectionProperties.getMetaType();
+ assertTrue("connection-properties.type="+cpType, cpType instanceof CompositeMetaType);
+ Object cpValue = connectionProperties.getValue();
+ assertTrue("connection-properties.value="+cpValue, cpValue instanceof CompositeValue);
+ CompositeValue cvalue = (CompositeValue) cpValue;
+ // Now update the values
+ MapCompositeValueSupport map = (MapCompositeValueSupport) cvalue;
+
+ // Test simple property types
+ ManagedProperty xatx = mo.getProperty("xa-transaction");
+ xatx.setValue(SimpleValueSupport.wrap(true));
+ assertEquals(Boolean.TRUE, txcf.getXATransaction());
+ ManagedProperty xart = mo.getProperty("xa-resource-timeout");
+ xart.setValue(SimpleValueSupport.wrap(12345));
+ assertEquals(12345, txcf.getXaResourceTimeout());
+ }
public void testLocalDataSourceDeploymentMetaData()
{
enableTrace("org.jboss.managed.plugins.factory");
ManagedObjectFactory mof = ManagedObjectFactory.getInstance();
- XADataSourceDeploymentMetaDataBuilder builder = new XADataSourceDeploymentMetaDataBuilder();
- mof.setBuilder(LocalDataSourceDeploymentMetaData.class, builder);
LocalDSInstanceClassFactory icf = new LocalDSInstanceClassFactory();
mof.setInstanceClassFactory(LocalDataSourceDeploymentMetaData.class, icf);
LocalDataSourceDeploymentMetaData lds = new LocalDataSourceDeploymentMetaData();
@@ -191,14 +237,20 @@
assertEquals("value1", key1.getValue());
assertNotNull(key2);
assertEquals("value2", key2.getValue());
+ // Test a simple property
+ ManagedProperty driverClass = mo.getProperty("driver-class");
+ driverClass.setValue("org.jboss.jdbc.ClusteredDriver");
+ String driverClassName = lds.getDriverClass();
+ assertEquals("org.jboss.jdbc.ClusteredDriver", driverClassName);
}
public void testXADataSourceDeploymentMetaData()
{
enableTrace("org.jboss.managed.plugins.factory");
ManagedObjectFactory mof = ManagedObjectFactory.getInstance();
- XADataSourceDeploymentMetaDataBuilder builder = new XADataSourceDeploymentMetaDataBuilder();
- mof.setBuilder(XADataSourceDeploymentMetaData.class, builder);
- ManagedObject mo = mof.createManagedObject(XADataSourceDeploymentMetaData.class);
+ XADSInstanceClassFactory icf = new XADSInstanceClassFactory();
+ mof.setInstanceClassFactory(XADataSourceDeploymentMetaData.class, icf);
+ XADataSourceDeploymentMetaData xads = new XADataSourceDeploymentMetaData();
+ ManagedObject mo = mof.initManagedObject(xads, "XADataSourceDeploymentMetaData", null);
// Validate the expected property names
Set<String> expectedPropertyNames = new TreeSet<String>();
expectedPropertyNames.addAll(Arrays.asList(ManagedConnectionFactoryDeploymentMetaData_NAMES));
@@ -215,6 +267,38 @@
fail("Extra properties: "+extraNames+", missing properties: "+missingNames);
}
// Validate the xa-datasource-properties type
+ ManagedProperty connectionProperties = mo.getProperty("xa-datasource-properties");
+ MetaType cpType = connectionProperties.getMetaType();
+ assertTrue("xa-datasource-properties.type="+cpType, cpType instanceof CompositeMetaType);
+ Object cpValue = connectionProperties.getValue();
+ assertTrue("xa-datasource-properties.value="+cpValue, cpValue instanceof CompositeValue);
+ CompositeValue cvalue = (CompositeValue) cpValue;
+ // Now update the values
+ MapCompositeValueSupport map = (MapCompositeValueSupport) cvalue;
+ map.put("key1", SimpleValueSupport.wrap("value1"));
+ map.put("key2", SimpleValueSupport.wrap("value2"));
+ connectionProperties.setValue(map);
+ // Check the underlying values
+ List<XAConnectionPropertyMetaData> xaProps = xads.getXADataSourceProperties();
+ assertEquals(2, xaProps.size());
+ DataSourceConnectionPropertyMetaData key1 = null;
+ DataSourceConnectionPropertyMetaData key2 = null;
+ for(XAConnectionPropertyMetaData dspmd : xaProps)
+ {
+ if(dspmd.getName().equals("key1"))
+ key1 = dspmd;
+ else if(dspmd.getName().equals("key2"))
+ key2 = dspmd;
+ }
+ assertNotNull(key1);
+ assertEquals("value1", key1.getValue());
+ assertNotNull(key2);
+ assertEquals("value2", key2.getValue());
+ // Test a simple property
+ ManagedProperty jndiName = mo.getProperty("jndi-name");
+ jndiName.setValue("java:ClusteredDS");
+ String jndiNameTest = xads.getJndiName();
+ assertEquals("java:ClusteredDS", jndiNameTest);
}
public void testJBossManagedConnectionPool()
Added: trunk/connector/src/tests/org/jboss/tests/jca/managed/TestICFOverloadingTestCase.java
===================================================================
--- trunk/connector/src/tests/org/jboss/tests/jca/managed/TestICFOverloadingTestCase.java (rev 0)
+++ trunk/connector/src/tests/org/jboss/tests/jca/managed/TestICFOverloadingTestCase.java 2008-02-07 07:33:44 UTC (rev 69689)
@@ -0,0 +1,54 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2007, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt 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.tests.jca.managed;
+
+import java.io.Serializable;
+
+import org.jboss.managed.plugins.ManagedPropertyImpl;
+import org.jboss.managed.spi.factory.InstanceClassFactory;
+import org.jboss.resource.metadata.mcf.XADataSourceDeploymentMetaData;
+import org.jboss.test.BaseTestCase;
+import org.jboss.tests.jca.managed.icf.XADSInstanceClassFactory;
+
+/**
+ * @author Scott.Stark at jboss.org
+ * @version $Revision$
+ */
+public class TestICFOverloadingTestCase extends BaseTestCase
+{
+ public TestICFOverloadingTestCase(String name)
+ {
+ super(name);
+ }
+
+ public void testXADSInstanceClassFactory()
+ throws Exception
+ {
+ XADSInstanceClassFactory icf = new XADSInstanceClassFactory();
+ XADataSourceDeploymentMetaData xads = new XADataSourceDeploymentMetaData();
+ ManagedPropertyImpl property = new ManagedPropertyImpl("xa-datasource-properties");
+ icf.getValue(null, property, xads);
+ InstanceClassFactory icfref = icf;
+ Serializable x = xads;
+ icfref.getValue(null, property, x);
+ }
+}
Property changes on: trunk/connector/src/tests/org/jboss/tests/jca/managed/TestICFOverloadingTestCase.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ native
Added: trunk/connector/src/tests/org/jboss/tests/jca/managed/icf/AbstractInstanceClassFactory.java
===================================================================
--- trunk/connector/src/tests/org/jboss/tests/jca/managed/icf/AbstractInstanceClassFactory.java (rev 0)
+++ trunk/connector/src/tests/org/jboss/tests/jca/managed/icf/AbstractInstanceClassFactory.java 2008-02-07 07:33:44 UTC (rev 69689)
@@ -0,0 +1,74 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2007, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt 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.tests.jca.managed.icf;
+
+import java.io.Serializable;
+
+import org.jboss.beans.info.spi.BeanInfo;
+import org.jboss.logging.Logger;
+import org.jboss.managed.api.ManagedProperty;
+import org.jboss.managed.spi.factory.InstanceClassFactory;
+import org.jboss.metatype.api.values.MetaValue;
+
+/**
+ * @author Scott.Stark at jboss.org
+ * @version $Revision$
+ */
+public class AbstractInstanceClassFactory<T extends Serializable>
+ implements InstanceClassFactory<T>
+{
+ private static Logger log = Logger.getLogger(AbstractInstanceClassFactory.class);
+
+ public Class<? extends Serializable> getManagedObjectClass(T attachment)
+ throws ClassNotFoundException
+ {
+ log.info("getManagedObjectClass, "+attachment);
+ return attachment.getClass();
+ }
+
+ public MetaValue getValue(BeanInfo beanInfo, ManagedProperty property,
+ T attachment)
+ {
+ log.info("getValue, "+attachment);
+ return null;
+ }
+
+ public Object getComponentName(BeanInfo beanInfo, ManagedProperty property,
+ T attachment, MetaValue value)
+ {
+ return null;
+ }
+
+ /**
+ * Set a value
+ *
+ * @param beanInfo the bean info
+ * @param property the property
+ * @param object the object
+ * @param the meta value
+ */
+ public void setValue(BeanInfo beanInfo, ManagedProperty property, T object, MetaValue value)
+ {
+ log.info("setValue, "+object.getClass());
+ }
+
+}
Property changes on: trunk/connector/src/tests/org/jboss/tests/jca/managed/icf/AbstractInstanceClassFactory.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ native
Added: trunk/connector/src/tests/org/jboss/tests/jca/managed/icf/XADSInstanceClassFactory.java
===================================================================
--- trunk/connector/src/tests/org/jboss/tests/jca/managed/icf/XADSInstanceClassFactory.java (rev 0)
+++ trunk/connector/src/tests/org/jboss/tests/jca/managed/icf/XADSInstanceClassFactory.java 2008-02-07 07:33:44 UTC (rev 69689)
@@ -0,0 +1,57 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2007, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt 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.tests.jca.managed.icf;
+
+import java.io.Serializable;
+
+import org.jboss.beans.info.spi.BeanInfo;
+import org.jboss.logging.Logger;
+import org.jboss.managed.api.ManagedProperty;
+import org.jboss.metatype.api.values.MetaValue;
+import org.jboss.resource.metadata.mcf.XADataSourceDeploymentMetaData;
+
+/**
+ * InstanceClassFactory for XADataSourceDeploymentMetaData
+ * @author Scott.Stark at jboss.org
+ * @version $Revision$
+ */
+public class XADSInstanceClassFactory
+ extends AbstractInstanceClassFactory<XADataSourceDeploymentMetaData>
+{
+ private static final Logger log = Logger.getLogger(XADSInstanceClassFactory.class);
+
+ public Class<? extends Serializable> getManagedObjectClass(
+ XADataSourceDeploymentMetaData attachment)
+ throws ClassNotFoundException
+ {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public MetaValue getValue(BeanInfo beanInfo, ManagedProperty property,
+ XADataSourceDeploymentMetaData attachment)
+ {
+ log.info("getValue, "+property);
+ return null;
+ }
+
+}
Property changes on: trunk/connector/src/tests/org/jboss/tests/jca/managed/icf/XADSInstanceClassFactory.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ native
Modified: trunk/testsuite/src/main/org/jboss/test/profileservice/test/ProfileServiceUnitTestCase.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/profileservice/test/ProfileServiceUnitTestCase.java 2008-02-07 07:12:35 UTC (rev 69688)
+++ trunk/testsuite/src/main/org/jboss/test/profileservice/test/ProfileServiceUnitTestCase.java 2008-02-07 07:33:44 UTC (rev 69689)
@@ -86,6 +86,7 @@
suite.addTest(new ProfileServiceUnitTestCase("testListDataSourceComponents"));
suite.addTest(new ProfileServiceUnitTestCase("testUpdateDefaultDS"));
suite.addTest(new ProfileServiceUnitTestCase("testDefaultDSOps"));
+ suite.addTest(new ProfileServiceUnitTestCase("testDefaultDSStats"));
suite.addTest(new ProfileServiceUnitTestCase("testAddDataSource"));
suite.addTest(new ProfileServiceUnitTestCase("testRemoveDataSource"));
suite.addTest(new ProfileServiceUnitTestCase("testAddXADataSource"));
@@ -474,18 +475,13 @@
addCommonCfProperties(propValues, jndiName, "jms-ra.rar", "org.jboss.resource.adapter.jms.JmsConnectionFactory");
- Map<String, Map<String, String>> xaProps = new HashMap<String, Map<String, String>>();
- Map<String, String> value = new HashMap<String, String>();
- value.put("name", "SessionDefaultType");
- value.put("type", "java.lang.String");
- value.put("value", "javax.jms.Topic");
- xaProps.put(value.get("name"), value);
- value = new HashMap<String, String>();
- value.put("name", "JmsProviderAdapterJNDI");
- value.put("type", "java.lang.String");
- value.put("value", "java:/DefaultJMSProvider");
- xaProps.put(value.get("name"), value);
- MetaValue metaValue = getMetaValueFactory().create(xaProps, getMapOfMapsType());
+ Map<String, String> xaProps = new HashMap<String, String>();
+ xaProps.put("SessionDefaultType", "javax.jms.Topic");
+ xaProps.put("SessionDefaultType.type", "java.lang.String");
+ xaProps.put("JmsProviderAdapterJNDI", "java:/DefaultJMSProvider");
+ xaProps.put("JmsProviderAdapterJNDI.type", "java.lang.String");
+ MetaValue metaValue = this.compositeValueMap(xaProps);
+
propValues.put("config-property", metaValue);
propValues.put("xa-transaction", Boolean.TRUE);
@@ -539,18 +535,12 @@
addCommonCfProperties(propValues, jndiName, "jms-ra.rar", "org.jboss.resource.adapter.jms.JmsConnectionFactory");
- Map<String, Map<String, String>> xaProps = new HashMap<String, Map<String, String>>();
- Map<String, String> value = new HashMap<String, String>();
- value.put("name", "SessionDefaultType");
- value.put("type", "java.lang.String");
- value.put("value", "javax.jms.Topic");
- xaProps.put(value.get("name"), value);
- value = new HashMap<String, String>();
- value.put("name", "JmsProviderAdapterJNDI");
- value.put("type", "java.lang.String");
- value.put("value", "java:/DefaultJMSProvider");
- xaProps.put(value.get("name"), value);
- MetaValue metaValue = getMetaValueFactory().create(xaProps, getMapOfMapsType());
+ Map<String, String> xaProps = new HashMap<String, String>();
+ xaProps.put("SessionDefaultType", "javax.jms.Topic");
+ xaProps.put("SessionDefaultType.type", "java.lang.String");
+ xaProps.put("JmsProviderAdapterJNDI", "java:/DefaultJMSProvider");
+ xaProps.put("JmsProviderAdapterJNDI.type", "java.lang.String");
+ MetaValue metaValue = this.compositeValueMap(xaProps);
propValues.put("config-property", metaValue);
// todo: how to set the specific domain?
@@ -677,15 +667,11 @@
Object expectedValue = propValues.get(propName);
if(propValue instanceof MetaValue)
{
+ // Compare simple types to the java expected type
if(prop.getMetaType().isSimple())
assertEquals(prop.getName(), expectedValue, ((SimpleValue)propValue).getValue());
else
{
- Type valueType = expectedValue.getClass();
- if("xa-datasource-properties".equals(prop.getName()))
- valueType = getMapType();
- else if("config-property".equals(prop.getName()))
- valueType = getMapOfMapsType();
/*
propValue = getMetaValueFactory().unwrap((MetaValue)propValue, valueType);
expectedValue = getMetaValueFactory().unwrap((MetaValue)expectedValue, valueType);
@@ -706,38 +692,6 @@
}
}
- 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;
- }
-
- 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;
- }
-
public MapCompositeValueSupport compositeValueMap(Map<String,String> map)
{
// TODO: update MetaValueFactory for MapCompositeMetaType
More information about the jboss-cvs-commits
mailing list