[jboss-cvs] JBossAS SVN: r69719 - in trunk/connector/src: main/org/jboss/resource/deployers/management and 1 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Fri Feb 8 00:57:58 EST 2008
Author: scott.stark at jboss.org
Date: 2008-02-08 00:57:58 -0500 (Fri, 08 Feb 2008)
New Revision: 69719
Modified:
trunk/connector/src/main/org/jboss/resource/deployers/ManagedConnectionFactoryParserDeployer.java
trunk/connector/src/main/org/jboss/resource/deployers/management/DsDataSourceTemplateInfo.java
trunk/connector/src/tests/org/jboss/tests/jca/managed/ManagedObjectTestCase.java
Log:
JBAS-5179, correct the mapping of the deployment ManagedObject names
Modified: trunk/connector/src/main/org/jboss/resource/deployers/ManagedConnectionFactoryParserDeployer.java
===================================================================
--- trunk/connector/src/main/org/jboss/resource/deployers/ManagedConnectionFactoryParserDeployer.java 2008-02-08 05:43:59 UTC (rev 69718)
+++ trunk/connector/src/main/org/jboss/resource/deployers/ManagedConnectionFactoryParserDeployer.java 2008-02-08 05:57:58 UTC (rev 69719)
@@ -48,8 +48,15 @@
import org.jboss.resource.deployers.management.XADSInstanceClassFactory;
import org.jboss.virtual.VirtualFile;
import org.jboss.managed.api.ManagedObject;
+import org.jboss.managed.api.ManagedProperty;
import org.jboss.managed.api.factory.ManagedObjectFactory;
+import org.jboss.managed.plugins.factory.AbstractManagedObjectFactory;
import org.jboss.managed.plugins.factory.ManagedObjectFactoryBuilder;
+import org.jboss.metatype.api.types.CollectionMetaType;
+import org.jboss.metatype.api.types.MetaType;
+import org.jboss.metatype.api.values.CollectionValue;
+import org.jboss.metatype.api.values.GenericValue;
+import org.jboss.metatype.api.values.MetaValue;
/**
* A ManagedConnectionFactoryParserDeployer.
@@ -155,23 +162,32 @@
super.build(unit, managedObjects);
if(isBuildManagedObject())
{
- ManagedConnectionFactoryDeploymentGroup deployment = unit.getAttachment(getOutput());
- if (deployment != null)
+ ManagedObject mcfdgMO = managedObjects.get(ManagedConnectionFactoryDeploymentGroup.class.getName());
+ if(mcfdgMO != null)
{
- if(deployment.getDeployments() != null)
+ ManagedProperty deployments = mcfdgMO.getProperty("deployments");
+ MetaType propType = deployments.getMetaType();
+ if (propType.isCollection())
{
- for(ManagedConnectionFactoryDeploymentMetaData mcf : deployment.getDeployments())
+ CollectionMetaType amt = (CollectionMetaType) propType;
+ MetaType etype = amt.getElementType();
+ if (etype == AbstractManagedObjectFactory.MANAGED_OBJECT_META_TYPE)
{
- ManagedObject mo = moFactory.initManagedObject(mcf, null, null);
- if (mo != null)
+ CollectionValue avalue = (CollectionValue) deployments.getValue();
+ if(avalue != null)
{
- // mcf.getClass().getName(), mo.getName() returns JndiName
- // which won't work in the DsDataSourceTemplateInfo
- managedObjects.put(mcf.getClass().getName(), mo);
+ MetaValue[] elements = avalue.getElements();
+ for(int n = 0; n < avalue.getSize(); n ++)
+ {
+ GenericValue gv = (GenericValue) elements[n];
+ ManagedObject propMO = (ManagedObject) gv.getValue();
+ managedObjects.put(propMO.getName(), propMO);
+ }
}
}
}
}
+
}
}
}
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-08 05:43:59 UTC (rev 69718)
+++ trunk/connector/src/main/org/jboss/resource/deployers/management/DsDataSourceTemplateInfo.java 2008-02-08 05:57:58 UTC (rev 69719)
@@ -21,11 +21,17 @@
*/
package org.jboss.resource.deployers.management;
+import java.util.Collections;
+import java.util.HashMap;
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;
import org.jboss.managed.api.Fields;
+import org.jboss.managed.api.annotation.ManagementObjectID;
import org.jboss.managed.plugins.DefaultFieldsImpl;
import org.jboss.managed.plugins.ManagedObjectImpl;
import org.jboss.managed.plugins.ManagedPropertyImpl;
@@ -190,7 +196,7 @@
private void addCommonProperties(ManagedObjectImpl mo)
{
// perhaps these descriptions should be externalized in some way
- addManagedProperty("jndi-name", "The jndi name to bind the DataSource under", true, SimpleMetaType.STRING, mo);
+ addManagedProperty("jndi-name", "The jndi name to bind the DataSource under", true, true, SimpleMetaType.STRING, "", mo);
addManagedProperty("rar-name", "The resource adapter archive name", true, SimpleMetaType.STRING, mo);
addManagedProperty("use-java-context", "Whether to bind the connection factory under 'java:' context", true, SimpleMetaType.BOOLEAN, Boolean.TRUE, mo);
addManagedProperty("connection-definition", "The connection factory class name", true, SimpleMetaType.STRING, mo);
@@ -222,12 +228,22 @@
MetaType metaType,
ManagedObjectImpl mo)
{
- addManagedProperty(fieldName, fieldDescr, mandatory, metaType, null, mo);
+ addManagedProperty(fieldName, fieldDescr, mandatory, false, metaType, null, mo);
}
private void addManagedProperty(String fieldName,
+ String fieldDescr,
+ boolean mandatory,
+ MetaType metaType,
+ java.io.Serializable value,
+ ManagedObjectImpl mo)
+ {
+ addManagedProperty(fieldName, fieldDescr, mandatory, false, metaType, value, mo);
+ }
+ private void addManagedProperty(String fieldName,
String fieldDescr,
boolean mandatory,
+ boolean isID,
MetaType metaType,
java.io.Serializable value,
ManagedObjectImpl mo)
@@ -238,6 +254,21 @@
fields.setMandatory(mandatory);
fields.setMetaType(metaType);
ManagedPropertyImpl mp = new ManagedPropertyImpl(mo, fields);
+ if(isID)
+ {
+ Map<String, Annotation> annotations = new HashMap<String, Annotation>();
+ Map<String, Object> idFields = Collections.emptyMap();
+ try
+ {
+ ManagementObjectID id = (ManagementObjectID) AnnotationProxy.createProxy(idFields, ManagementObjectID.class);
+ annotations.put(ManagementObjectID.class.getName(), id);
+ mp.setAnnotations(annotations);
+ }
+ catch(Exception e)
+ {
+ throw new UndeclaredThrowableException(e);
+ }
+ }
super.addProperty(mp);
if(value != null)
mp.setValue(value);
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-08 05:43:59 UTC (rev 69718)
+++ trunk/connector/src/tests/org/jboss/tests/jca/managed/ManagedObjectTestCase.java 2008-02-08 05:57:58 UTC (rev 69719)
@@ -138,6 +138,7 @@
enableTrace("org.jboss.managed.plugins.factory");
ManagedObjectFactory mof = ManagedObjectFactory.getInstance();
ManagedObject mo = mof.createManagedObject(NoTxDataSourceDeploymentMetaData.class);
+ log.info(mo.getProperties());
// Validate the expected property names
Set<String> expectedPropertyNames = new TreeSet<String>();
expectedPropertyNames.addAll(Arrays.asList(ManagedConnectionFactoryDeploymentMetaData_NAMES));
More information about the jboss-cvs-commits
mailing list