[jboss-cvs] JBossAS SVN: r86411 - branches/Branch_5_x/connector/src/main/org/jboss/resource/deployers/management.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Fri Mar 27 05:06:26 EDT 2009
Author: emuckenhuber
Date: 2009-03-27 05:06:26 -0400 (Fri, 27 Mar 2009)
New Revision: 86411
Modified:
branches/Branch_5_x/connector/src/main/org/jboss/resource/deployers/management/DsDataSourceTemplateInfo.java
Log:
[JBAS-6671] update jca deployment templates
Modified: branches/Branch_5_x/connector/src/main/org/jboss/resource/deployers/management/DsDataSourceTemplateInfo.java
===================================================================
--- branches/Branch_5_x/connector/src/main/org/jboss/resource/deployers/management/DsDataSourceTemplateInfo.java 2009-03-27 09:05:25 UTC (rev 86410)
+++ branches/Branch_5_x/connector/src/main/org/jboss/resource/deployers/management/DsDataSourceTemplateInfo.java 2009-03-27 09:06:26 UTC (rev 86411)
@@ -21,12 +21,10 @@
*/
package org.jboss.resource.deployers.management;
-import java.io.Serializable;
import java.lang.annotation.Annotation;
import java.lang.reflect.UndeclaredThrowableException;
import java.util.Collections;
import java.util.HashMap;
-import java.util.List;
import java.util.Map;
import org.jboss.annotation.factory.AnnotationProxy;
@@ -34,37 +32,50 @@
import org.jboss.managed.api.ManagedProperty;
import org.jboss.managed.api.annotation.ManagementObjectID;
import org.jboss.managed.plugins.BasicDeploymentTemplateInfo;
-import org.jboss.managed.plugins.DefaultFieldsImpl;
-import org.jboss.managed.plugins.ManagedObjectImpl;
import org.jboss.managed.plugins.ManagedPropertyImpl;
-import org.jboss.managed.plugins.factory.AbstractManagedObjectFactory;
-import org.jboss.metatype.api.types.MapCompositeMetaType;
-import org.jboss.metatype.api.types.MetaType;
-import org.jboss.metatype.api.types.MetaTypeFactory;
import org.jboss.metatype.api.types.SimpleMetaType;
import org.jboss.metatype.api.values.MetaValue;
-import org.jboss.metatype.api.values.MetaValueFactory;
-import org.jboss.resource.metadata.mcf.DBMSMetaData;
-import org.jboss.resource.metadata.mcf.LocalDataSourceDeploymentMetaData;
-import org.jboss.resource.metadata.mcf.NoTxConnectionFactoryDeploymentMetaData;
-import org.jboss.resource.metadata.mcf.NoTxDataSourceDeploymentMetaData;
-import org.jboss.resource.metadata.mcf.TxConnectionFactoryDeploymentMetaData;
-import org.jboss.resource.metadata.mcf.XADataSourceDeploymentMetaData;
+import org.jboss.metatype.api.values.SimpleValueSupport;
/**
* The template for creating jca datasources, connection factories
*
* @author Scott.Stark at jboss.org
+ * @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
* @version $Revision$
*/
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();
+
+ /** The default values. */
+ private static final Map<String, MetaValue> defaultValues = new HashMap<String, MetaValue>();
+
+ /** The property name mappings. */
private Map<String, String> propertyNameMappings;
+
+ /** The datasource type. */
private String dsType = "local-tx-datasource";
+
+ static
+ {
+ // populate the default values
+ defaultValues.put("use-java-context", new SimpleValueSupport(SimpleMetaType.BOOLEAN_PRIMITIVE, true));
+ defaultValues.put("min-pool-size", new SimpleValueSupport(SimpleMetaType.INTEGER_PRIMITIVE, 0));
+ defaultValues.put("max-pool-size", new SimpleValueSupport(SimpleMetaType.INTEGER_PRIMITIVE, 10));
+ defaultValues.put("blocking-timeout-millis", new SimpleValueSupport(SimpleMetaType.LONG_PRIMITIVE, 3000));
+ defaultValues.put("idle-timeout-minutes", new SimpleValueSupport(SimpleMetaType.INTEGER_PRIMITIVE, 30));
+ defaultValues.put("background-validation", new SimpleValueSupport(SimpleMetaType.BOOLEAN_PRIMITIVE, false));
+ defaultValues.put("background-validation-millis", new SimpleValueSupport(SimpleMetaType.LONG_PRIMITIVE, 0));
+ defaultValues.put("validate-on-match", new SimpleValueSupport(SimpleMetaType.BOOLEAN_PRIMITIVE, true));
+ defaultValues.put("track-connection-by-tx", new SimpleValueSupport(SimpleMetaType.BOOLEAN_PRIMITIVE, true));
+ defaultValues.put("allocation-retry", new SimpleValueSupport(SimpleMetaType.INTEGER_PRIMITIVE, 0));
+ defaultValues.put("allocation-retry-wait-millis", new SimpleValueSupport(SimpleMetaType.INTEGER_PRIMITIVE, 5000));
+ defaultValues.put("prepared-statement-cache-size", new SimpleValueSupport(SimpleMetaType.INTEGER_PRIMITIVE, 0));
+ defaultValues.put("share-prepared-statements", new SimpleValueSupport(SimpleMetaType.BOOLEAN_PRIMITIVE, false));
+ defaultValues.put("set-tx-query-timeout", new SimpleValueSupport(SimpleMetaType.BOOLEAN_PRIMITIVE, false));
+ defaultValues.put("query-timeout", new SimpleValueSupport(SimpleMetaType.INTEGER_PRIMITIVE, 0));
+ }
public DsDataSourceTemplateInfo(String arg0, String arg1, Map<String, ManagedProperty> arg2)
{
@@ -105,8 +116,9 @@
@Override
public DsDataSourceTemplateInfo copy()
{
- DsDataSourceTemplateInfo copy = new DsDataSourceTemplateInfo(getName(), getDescription(), dsType);
+ DsDataSourceTemplateInfo copy = new DsDataSourceTemplateInfo(getName(), getDescription(), getProperties());
copy.setPropertyNameMappings(propertyNameMappings);
+ copy.setConnectionFactoryType(getConnectionFactoryType());
super.copy(copy);
copy.populate();
return copy;
@@ -114,206 +126,68 @@
private void populate()
{
+ populateDefaultValues();
+
// DataSource
- if("local-tx-datasource".equals(dsType))
- createLocalTxDsTemplate();
- else if("xa-datasource".equals(dsType))
- createXaDsTemplate();
- else if("tx-connection-factory".equals(dsType))
- createTxCfTemplate();
- else if("no-tx-datasource".equals(dsType))
- createNoTxDsTemplate();
- else if("no-tx-connection-factory".equals(dsType))
- createNoTxCfTemplate();
- else
- throw new IllegalStateException("Unsupported dsType: " + dsType);
+// if("local-tx-datasource".equals(dsType))
+// createLocalTxDsTemplate();
+// else if("xa-datasource".equals(dsType))
+// createXaDsTemplate();
+// else if("tx-connection-factory".equals(dsType))
+// createTxCfTemplate();
+// else if("no-tx-datasource".equals(dsType))
+// createNoTxDsTemplate();
+// else if("no-tx-connection-factory".equals(dsType))
+// createNoTxCfTemplate();
+// else
+// throw new IllegalStateException("Unsupported dsType: " + dsType);
}
- private void createXaDsTemplate()
+
+ private void populateDefaultValues()
{
- ManagedObjectImpl mo = new ManagedObjectImpl(XADataSourceDeploymentMetaData.class.getName());
- addDsProperties(mo);
- addManagedProperty("xa-datasource-class", "The xa datasource class name", true, SimpleMetaType.STRING, 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);
- }
-
- private void createLocalTxDsTemplate()
- {
- ManagedObjectImpl mo = new ManagedObjectImpl(LocalDataSourceDeploymentMetaData.class.getName());
- addNonXADsProperties(mo);
- }
-
- private void createNoTxDsTemplate()
- {
- ManagedObjectImpl mo = new ManagedObjectImpl(NoTxDataSourceDeploymentMetaData.class.getName());
- addNonXADsProperties(mo);
- }
-
- private void createTxCfTemplate()
- {
- ManagedObjectImpl mo = new ManagedObjectImpl(TxConnectionFactoryDeploymentMetaData.class.getName());
- addCommonProperties(mo);
- addManagedProperty("xa-resource-timeout", "The XA resource timeout", true, SimpleMetaType.INTEGER, new Integer(0), mo);
- addManagedProperty("xa-transaction", "", true, SimpleMetaType.BOOLEAN, mo);
- }
-
- private void createNoTxCfTemplate()
- {
- ManagedObjectImpl mo = new ManagedObjectImpl(NoTxConnectionFactoryDeploymentMetaData.class.getName());
- addCommonProperties(mo);
- }
-
- private void addNonXADsProperties(ManagedObjectImpl mo)
- {
- 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);
- MetaType type = new MapCompositeMetaType(SimpleMetaType.STRING);
- addManagedProperty("connection-properties", "The jdbc driver connection properties", false, type, mo);
- }
-
- private void addDsProperties(ManagedObjectImpl mo)
- {
- addCommonProperties(mo);
- addManagedProperty("transaction-isolation", "The transaction isolation level", false, SimpleMetaType.STRING, mo);
- addManagedProperty("user-name", "The username for the connection-url", false, SimpleMetaType.STRING, mo);
- addManagedProperty("password", "The password for the connection-url", false, SimpleMetaType.STRING, mo);
- addManagedProperty("new-connection-sql", "", false, SimpleMetaType.STRING, mo);
- addManagedProperty("check-valid-connection-sql", "", false, SimpleMetaType.STRING, mo);
- addManagedProperty("valid-connection-checker-class-name", "", false, SimpleMetaType.STRING, mo);
- addManagedProperty("exception-sorter-class-name", "", false, SimpleMetaType.STRING, mo);
- addManagedProperty("stale-connection-checker-class-name", "", false, SimpleMetaType.STRING, mo);
- addManagedProperty("track-statements", "", false, SimpleMetaType.STRING, mo);
- addManagedProperty("prepared-statement-cache-size", "", false, SimpleMetaType.INTEGER, new Integer(0), mo);
- addManagedProperty("share-prepared-statements", "", false, SimpleMetaType.BOOLEAN, Boolean.FALSE, mo);
- addManagedProperty("set-tx-query-timeout", "", false, SimpleMetaType.BOOLEAN, Boolean.FALSE, mo);
- addManagedProperty("query-timeout", "", false, SimpleMetaType.INTEGER, new Integer(0), mo);
- addManagedProperty("url-delimiter", "", false, SimpleMetaType.STRING, mo);
- addManagedProperty("url-selector-strategy-class-name", "", false, SimpleMetaType.STRING, mo);
- addManagedProperty("use-try-lock", "", false, SimpleMetaType.LONG, mo);
- }
-
- 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, 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);
- addManagedProperty("jmx-invoker-name", "The name of the JMX invoker", true, SimpleMetaType.STRING, mo);
- addManagedProperty("min-pool-size", "The min size of the pool", true, SimpleMetaType.INTEGER, new Integer(0), mo);
- addManagedProperty("max-pool-size", "The max size of the pool", true, SimpleMetaType.INTEGER, new Integer(10), mo);
- addManagedProperty("blocking-timeout-millis", "The time to wait for a connection to become available before giving up", true, SimpleMetaType.LONG, new Long(30000), mo);
- addManagedProperty("idle-timeout-minutes", "The idle timeout in minutes", true, SimpleMetaType.INTEGER, new Integer(30), mo);
- addManagedProperty("prefill", "Whether to prefill the pool", true, SimpleMetaType.BOOLEAN, mo);
- addManagedProperty("background-validation", "Whether to use backgroup validation", true, SimpleMetaType.BOOLEAN, Boolean.FALSE, mo);
- addManagedProperty("background-validation-millis", "", false, SimpleMetaType.LONG, new Long(0), mo);
- addManagedProperty("validate-on-match", "", true, SimpleMetaType.BOOLEAN, Boolean.TRUE, mo);
- addManagedProperty("use-strict-min", "", true, SimpleMetaType.BOOLEAN, mo);
- addManagedProperty("no-tx-separate-pools", "", true, SimpleMetaType.BOOLEAN, mo);
- addManagedProperty("statistics-formatter", "", true, SimpleMetaType.STRING, mo);
- addManagedProperty("isSameRM-override-value", "", true, SimpleMetaType.BOOLEAN, mo);
- addManagedProperty("track-connection-by-tx", "", false, SimpleMetaType.BOOLEAN, Boolean.TRUE, mo);
- addManagedProperty("interleaving", "", false, SimpleMetaType.BOOLEAN, mo);
- addManagedProperty("allocation-retry", "The number of times allocation retries should be tried", false, SimpleMetaType.INTEGER, new Integer(0), mo);
- addManagedProperty("allocation-retry-wait-millis", "The time to wait between allocation retries", false, SimpleMetaType.LONG, new Long(5000), mo);
- addManagedProperty("config-property", "The connection factory config properties", false, new MapCompositeMetaType(SimpleMetaType.STRING), mo);
- addManagedProperty("security-domain", "The security-domain used to validate connections", false, AbstractManagedObjectFactory.MANAGED_OBJECT_META_TYPE, mo);
- addManagedProperty("depends", "", false, METATYPE_FACTORY.resolve(List.class), mo);
- addManagedProperty("metadata", "", false, METATYPE_FACTORY.resolve(DBMSMetaData.class), mo);
- addManagedProperty("type-mapping", "", true, SimpleMetaType.STRING, mo);
- addManagedProperty("local-transaction", "", true, SimpleMetaType.BOOLEAN, mo);
- }
-
- private void addManagedProperty(String fieldName,
- String fieldDescr,
- boolean mandatory,
- MetaType metaType,
- ManagedObjectImpl mo)
- {
- addManagedProperty(fieldName, fieldDescr, mandatory, false, metaType, null, mo);
- }
-
- private void addManagedProperty(String fieldName,
- String fieldDescr,
- boolean mandatory,
- MetaType metaType,
- Serializable value,
- ManagedObjectImpl mo)
- {
- MetaValue mv = METAVALUE_FACTORY.create(value);
- addManagedProperty(fieldName, fieldDescr, mandatory, false, metaType, mv, mo);
- }
- private void addManagedProperty(String fieldName,
- String fieldDescr,
- boolean mandatory,
- MetaType metaType,
- MetaValue value,
- ManagedObjectImpl mo)
- {
- addManagedProperty(fieldName, fieldDescr, mandatory, false, metaType, value, mo);
- }
-
- private void addManagedProperty(String fieldName,
- String fieldDescr,
- boolean mandatory,
- boolean isID,
- MetaType metaType,
- Serializable value,
- ManagedObjectImpl mo)
- {
- MetaValue mv = METAVALUE_FACTORY.create(value);
- addManagedProperty(fieldName, fieldDescr, mandatory, isID, metaType, mv, mo);
- }
- private void addManagedProperty(String fieldName,
- String fieldDescr,
- boolean mandatory,
- boolean isID,
- MetaType metaType,
- MetaValue value,
- ManagedObjectImpl mo)
- {
- DefaultFieldsImpl fields = new DefaultFieldsImpl();
- setFieldName(fieldName, fields);
- fields.setDescription(fieldDescr);
- fields.setMandatory(mandatory);
- fields.setMetaType(metaType);
- ManagedPropertyImpl mp = new ManagedPropertyImpl(mo, fields);
- if(isID)
+ if(getProperties() == null) return;
+ for(ManagedProperty property : getProperties().values())
{
- Map<String, Annotation> annotations = new HashMap<String, Annotation>();
- Map<String, Object> idFields = Collections.emptyMap();
- try
+ String name = property.getName();
+
+
+ // Create a new (non-writethrough) managed property
+ Fields f = property.getFields();
+ if( propertyNameMappings != null )
{
- ManagementObjectID id = (ManagementObjectID) AnnotationProxy.createProxy(idFields, ManagementObjectID.class);
- annotations.put(ManagementObjectID.class.getName(), id);
- mp.setAnnotations(annotations);
+ String mappedName = propertyNameMappings.get(name);
+ if( mappedName != null )
+ f.setField(Fields.MAPPED_NAME, mappedName);
}
- catch(Exception e)
+
+ ManagedPropertyImpl newProperty = new ManagedPropertyImpl(f);
+
+ MetaValue v = defaultValues.get(name);
+ if(v != null)
{
- throw new UndeclaredThrowableException(e);
+ newProperty.setValue(v);
}
+
+ // Override
+ addProperty(newProperty);
}
- 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)
+
+ private void addID(ManagedPropertyImpl mp)
{
- f.setField(Fields.NAME, name);
- if( propertyNameMappings != null )
+ // TODO
+ Map<String, Annotation> annotations = new HashMap<String, Annotation>();
+ Map<String, Object> idFields = Collections.emptyMap();
+ try
{
- String mappedName = propertyNameMappings.get(name);
- if( mappedName != null )
- f.setField(Fields.MAPPED_NAME, mappedName);
+ ManagementObjectID id = (ManagementObjectID) AnnotationProxy.createProxy(idFields, ManagementObjectID.class);
+ annotations.put(ManagementObjectID.class.getName(), id);
+ mp.setAnnotations(annotations);
}
+ catch(Exception e)
+ {
+ throw new UndeclaredThrowableException(e);
+ }
}
}
More information about the jboss-cvs-commits
mailing list