[jboss-cvs] JBossAS SVN: r61509 - in trunk/connector/src/main/org/jboss/resource/deployers: builder and 1 other directory.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Wed Mar 21 00:35:53 EDT 2007


Author: weston.price at jboss.com
Date: 2007-03-21 00:35:52 -0400 (Wed, 21 Mar 2007)
New Revision: 61509

Added:
   trunk/connector/src/main/org/jboss/resource/deployers/builder/
   trunk/connector/src/main/org/jboss/resource/deployers/builder/AbstractBuilder.java
   trunk/connector/src/main/org/jboss/resource/deployers/builder/ConnectionManagerBuilder.java
   trunk/connector/src/main/org/jboss/resource/deployers/builder/ManagedConnectionPoolBuilder.java
   trunk/connector/src/main/org/jboss/resource/deployers/builder/MetaDataTypeMappingBuilder.java
Log:
[JBAS-1425] Builders for programmatic deployment.

Added: trunk/connector/src/main/org/jboss/resource/deployers/builder/AbstractBuilder.java
===================================================================
--- trunk/connector/src/main/org/jboss/resource/deployers/builder/AbstractBuilder.java	                        (rev 0)
+++ trunk/connector/src/main/org/jboss/resource/deployers/builder/AbstractBuilder.java	2007-03-21 04:35:52 UTC (rev 61509)
@@ -0,0 +1,97 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, 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.builder;
+
+import java.util.List;
+
+import javax.management.ObjectName;
+
+import org.jboss.resource.metadata.mcf.ManagedConnectionFactoryDeploymentMetaData;
+import org.jboss.system.metadata.ServiceAttributeMetaData;
+import org.jboss.system.metadata.ServiceConstructorMetaData;
+import org.jboss.system.metadata.ServiceDependencyValueMetaData;
+import org.jboss.system.metadata.ServiceMetaData;
+import org.jboss.system.metadata.ServiceTextValueMetaData;
+
+public abstract class AbstractBuilder
+{   
+   
+   public abstract ObjectName buildObjectName(ManagedConnectionFactoryDeploymentMetaData md);
+   public abstract String getCode(ManagedConnectionFactoryDeploymentMetaData md);
+   
+   public ServiceMetaData buildService(ManagedConnectionFactoryDeploymentMetaData mcfmd)
+   {
+      ServiceMetaData md = new ServiceMetaData();
+      ObjectName on = buildObjectName(mcfmd);
+      md.setObjectName(on);
+      String code = getCode(mcfmd);
+      md.setCode(code);
+      ServiceConstructorMetaData cmd = buildConstructor(mcfmd);
+      md.setConstructor(cmd);
+      return md;
+      
+   }
+   
+   
+   public ServiceMetaData build(ManagedConnectionFactoryDeploymentMetaData mcfmd)
+   {
+      ServiceMetaData md = buildService(mcfmd);
+      List<ServiceAttributeMetaData> attributes = buildAttributes(mcfmd);
+      md.setAttributes(attributes);
+      return md;      
+      
+   }
+   
+   public abstract List<ServiceAttributeMetaData> buildAttributes(ManagedConnectionFactoryDeploymentMetaData md);
+   
+   public ServiceConstructorMetaData buildConstructor(ManagedConnectionFactoryDeploymentMetaData mcfmd)
+   {
+      ServiceConstructorMetaData constructor = new ServiceConstructorMetaData();
+      constructor.setParameters(new Object[]{});
+      constructor.setParams(new String[]{});      
+      return constructor;
+   
+   }
+   
+   
+   public ServiceAttributeMetaData buildSimpleAttribute(String name, String value)
+   {
+      ServiceAttributeMetaData att = new ServiceAttributeMetaData();
+      att.setName(name);
+      ServiceTextValueMetaData dep = new ServiceTextValueMetaData(value);
+      att.setValue(dep);
+      return att;
+      
+   }
+   
+   public ServiceAttributeMetaData buildDependencyAttribute(String name, String dependency)
+   {
+      ServiceAttributeMetaData att = new ServiceAttributeMetaData();
+      ServiceDependencyValueMetaData dep = new ServiceDependencyValueMetaData();
+      dep.setDependency(dependency);      
+      att.setName(name);
+      att.setValue(dep);
+      return att;
+   }
+   
+   
+}

Added: trunk/connector/src/main/org/jboss/resource/deployers/builder/ConnectionManagerBuilder.java
===================================================================
--- trunk/connector/src/main/org/jboss/resource/deployers/builder/ConnectionManagerBuilder.java	                        (rev 0)
+++ trunk/connector/src/main/org/jboss/resource/deployers/builder/ConnectionManagerBuilder.java	2007-03-21 04:35:52 UTC (rev 61509)
@@ -0,0 +1,137 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, 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.builder;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.management.ObjectName;
+
+import org.jboss.resource.connectionmanager.NoTxConnectionManager;
+import org.jboss.resource.connectionmanager.TxConnectionManager;
+import org.jboss.resource.metadata.mcf.DataSourceDeploymentMetaData;
+import org.jboss.resource.metadata.mcf.ManagedConnectionFactoryDeploymentMetaData;
+import org.jboss.resource.metadata.mcf.ManagedConnectionFactoryTransactionSupportMetaData;
+import org.jboss.resource.metadata.repository.JCAMetaDataRepository;
+import org.jboss.system.metadata.ServiceAttributeMetaData;
+import org.jboss.system.metadata.ServiceConstructorMetaData;
+import org.jboss.system.metadata.ServiceDependencyValueMetaData;
+import org.jboss.system.metadata.ServiceMetaData;
+import org.jboss.system.metadata.ServiceTextValueMetaData;
+
+public class ConnectionManagerBuilder extends AbstractBuilder
+{
+   private JCAMetaDataRepository repository;
+   
+   @Override
+   public List<ServiceAttributeMetaData> buildAttributes(ManagedConnectionFactoryDeploymentMetaData md)
+   {
+      // TODO Auto-generated method stub
+      return null;
+   }
+   
+   @Override
+   public ObjectName buildObjectName(ManagedConnectionFactoryDeploymentMetaData md)
+   {
+      return null;
+   }
+   
+   @Override
+   public String getCode(ManagedConnectionFactoryDeploymentMetaData md)
+   {
+      // TODO Auto-generated method stub
+      return null;
+   }
+   
+   public ServiceMetaData buildManagedConnectionFactoryDeployment(ManagedConnectionFactoryDeploymentMetaData deployment, List<ServiceMetaData> deployments) throws Exception
+   {
+      ServiceMetaData cmMetaData = new ServiceMetaData();
+      String jndiName = deployment.getJndiName();
+      
+      String cmType = "jboss.jca:service=";
+      
+      if(deployment.getTransactionSupportMetaData().equals(ManagedConnectionFactoryTransactionSupportMetaData.NONE))
+      {
+         cmType += "NoTxCM,name=" + deployment.getJndiName();
+         cmMetaData.setCode(NoTxConnectionManager.class.getName());         
+      
+      }else if(deployment.getTransactionSupportMetaData().equals(ManagedConnectionFactoryTransactionSupportMetaData.LOCAL))
+      {
+         
+         if(deployment instanceof DataSourceDeploymentMetaData)
+         {
+            cmType += "LocalTxCM,name=" + jndiName;               
+         }
+         else
+         {
+            cmType += "TxCM,name=" + jndiName;               
+            
+         }
+
+         cmMetaData.setCode(TxConnectionManager.class.getName());
+
+      }else
+      {
+         if(deployment instanceof DataSourceDeploymentMetaData)
+         {
+            cmType += "XATxCM,name=" + jndiName;               
+            
+         }
+         else
+         {
+            cmType += "TxCM,name=" + jndiName;               
+            
+         }
+         cmMetaData.setCode(TxConnectionManager.class.getName());
+
+      }
+      
+      ObjectName cmName = new ObjectName(cmType);
+      cmMetaData.setObjectName(cmName);
+      List<ServiceAttributeMetaData> cmAttributes = new ArrayList<ServiceAttributeMetaData>();
+      ServiceAttributeMetaData cmAttribute = null;
+      ServiceConstructorMetaData constructor = new ServiceConstructorMetaData();
+      constructor.setParameters(new Object[]{});
+      constructor.setParams(new String[]{});
+      cmMetaData.setConstructor(constructor);
+      
+      cmAttribute = buildSimpleAttribute("JndiName", jndiName);
+      cmAttributes.add(cmAttribute);
+      
+      cmAttribute = buildDependencyAttribute("CachedConnectionManager", "jboss.jca:service=CachedConnectionManager");
+      
+      cmAttributes.add(cmAttribute);
+            
+      return cmMetaData;
+   }
+
+   public boolean hasDependency()
+   {
+      return true;
+   }
+      
+   public void setMetaDataRepository(JCAMetaDataRepository repository)
+   {
+      this.repository = repository;
+   }   
+
+}

Added: trunk/connector/src/main/org/jboss/resource/deployers/builder/ManagedConnectionPoolBuilder.java
===================================================================
--- trunk/connector/src/main/org/jboss/resource/deployers/builder/ManagedConnectionPoolBuilder.java	                        (rev 0)
+++ trunk/connector/src/main/org/jboss/resource/deployers/builder/ManagedConnectionPoolBuilder.java	2007-03-21 04:35:52 UTC (rev 61509)
@@ -0,0 +1,151 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, 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.builder;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import javax.management.ObjectName;
+
+import org.jboss.mx.util.ObjectNameFactory;
+import org.jboss.resource.connectionmanager.JBossManagedConnectionPool;
+import org.jboss.resource.metadata.mcf.ManagedConnectionFactoryDeploymentMetaData;
+import org.jboss.resource.metadata.mcf.SecurityDeploymentType;
+import org.jboss.resource.metadata.repository.JCAMetaDataRepository;
+import org.jboss.system.metadata.ServiceAttributeMetaData;
+import org.jboss.system.metadata.ServiceConstructorMetaData;
+import org.jboss.system.metadata.ServiceDependencyValueMetaData;
+import org.jboss.system.metadata.ServiceMetaData;
+import org.jboss.system.metadata.ServiceTextValueMetaData;
+
+public class ManagedConnectionPoolBuilder extends AbstractBuilder 
+{
+   private static final Map<SecurityDeploymentType, String> securityTypeMap = new HashMap<SecurityDeploymentType, String>();
+   
+   static
+   {
+      securityTypeMap.put(SecurityDeploymentType.NONE, "ByNothing");      
+      securityTypeMap.put(SecurityDeploymentType.APPLICATION, "ByApplication");
+      securityTypeMap.put(SecurityDeploymentType.DOMAIN, "ByContainer");
+      securityTypeMap.put(SecurityDeploymentType.APPLICATION, "ByContainerAndApplication");   
+   }
+      
+   @Override
+   public ObjectName buildObjectName(ManagedConnectionFactoryDeploymentMetaData md)
+   {
+     return ObjectNameFactory.create("jboss.jca:service=ManagedConnectionPool,name=" + md.getJndiName());    
+   }
+   
+   @Override
+   public String getCode(ManagedConnectionFactoryDeploymentMetaData md)
+   {
+      // TODO Auto-generated method stub
+      return null;
+   }
+   
+   @Override
+   public List<ServiceAttributeMetaData> buildAttributes(ManagedConnectionFactoryDeploymentMetaData md)
+   {
+      List<ServiceAttributeMetaData> poolAttributes = new ArrayList<ServiceAttributeMetaData>();
+      ServiceAttributeMetaData poolAttribute = null;
+            
+      poolAttribute = new ServiceAttributeMetaData();
+      poolAttribute.setName("PoolJndiName");
+      poolAttribute.setValue(new ServiceTextValueMetaData(md.getJndiName()));      
+      poolAttributes.add(poolAttribute);
+      
+      poolAttribute = new ServiceAttributeMetaData();
+      poolAttribute.setName("MinSize");
+      poolAttribute.setValue(new ServiceTextValueMetaData(String.valueOf(md.getMinSize())));      
+      poolAttributes.add(poolAttribute);
+      
+      poolAttribute = new ServiceAttributeMetaData();
+      poolAttribute.setName("MaxSize");
+      poolAttribute.setValue(new ServiceTextValueMetaData(String.valueOf(md.getMaxSize())));      
+      poolAttributes.add(poolAttribute);
+      
+      poolAttribute = new ServiceAttributeMetaData();
+      poolAttribute.setName("BlockingTimeoutMillis");
+      poolAttribute.setValue(new ServiceTextValueMetaData(String.valueOf(md.getBlockingTimeoutMilliSeconds())));      
+      poolAttributes.add(poolAttribute);
+
+      poolAttribute = new ServiceAttributeMetaData();
+      poolAttribute.setName("IdleTimeoutMinutes");
+      poolAttribute.setValue(new ServiceTextValueMetaData(String.valueOf(md.getIdleTimeoutMinutes())));      
+      poolAttributes.add(poolAttribute);
+
+      poolAttribute = new ServiceAttributeMetaData();
+      poolAttribute.setName("BackGroundValidation");
+      poolAttribute.setValue(new ServiceTextValueMetaData(String.valueOf(md.isBackgroundValidation())));      
+      poolAttributes.add(poolAttribute);
+
+      poolAttribute = new ServiceAttributeMetaData();
+      poolAttribute.setName("BackGroundValidationMinutes");
+      poolAttribute.setValue(new ServiceTextValueMetaData(String.valueOf(md.getBackgroundValidationMinutes())));      
+      poolAttributes.add(poolAttribute);
+      
+      poolAttribute = new ServiceAttributeMetaData();
+      poolAttribute.setName("PreFill");
+      poolAttribute.setValue(new ServiceTextValueMetaData(String.valueOf(md.isPrefill())));      
+      poolAttributes.add(poolAttribute);
+
+       //TODO strict min
+//      poolAttribute = new ServiceAttributeMetaData();
+//      poolAttribute.setName("StrictMin");
+//      poolAttribute.setValue(new ServiceTextValueMetaData(String.valueOf(pmd.isStrictMin())));      
+//      poolAttributes.add(poolAttribute);
+      
+//      poolAttribute = new ServiceAttributeMetaData();
+//      poolAttribute.setName("StatisticsFormatter");
+//      poolAttribute.setValue(new ServiceTextValueMetaData(String.valueOf(deployment.get)));      
+//      poolAttributes.add(poolAttribute);
+//      
+//      poolAttribute = new ServiceAttributeMetaData();
+//      poolAttribute.setName("UseFastFail");
+//      poolAttribute.setValue(new ServiceTextValueMetaData(String.valueOf(pmd.isUseFastFail())));      
+//      poolAttributes.add(poolAttribute);
+
+      poolAttribute = new ServiceAttributeMetaData();
+      poolAttribute.setName("Criteria");                  
+      poolAttribute.setValue(new ServiceTextValueMetaData(getCriteria(md.getSecurityMetaData().getSecurityDeploymentType())));      
+      poolAttributes.add(poolAttribute);
+      
+      ServiceDependencyValueMetaData dependValue = new ServiceDependencyValueMetaData();
+      dependValue.setObjectName(ObjectNameFactory.create("jboss.jca:service=ManagedConnectionFactory,name=" + md.getJndiName()));
+      ServiceAttributeMetaData attribute = new ServiceAttributeMetaData();
+      attribute.setName("ManagedConnectionFactoryName");
+      attribute.setValue(dependValue);
+      poolAttributes.add(attribute);
+
+      return poolAttributes;
+
+   }
+
+   private String getCriteria(SecurityDeploymentType type)
+   {
+      return securityTypeMap.get(type);
+      
+   }
+
+}

Added: trunk/connector/src/main/org/jboss/resource/deployers/builder/MetaDataTypeMappingBuilder.java
===================================================================
--- trunk/connector/src/main/org/jboss/resource/deployers/builder/MetaDataTypeMappingBuilder.java	                        (rev 0)
+++ trunk/connector/src/main/org/jboss/resource/deployers/builder/MetaDataTypeMappingBuilder.java	2007-03-21 04:35:52 UTC (rev 61509)
@@ -0,0 +1,52 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, 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.builder;
+
+import java.util.List;
+
+import javax.management.ObjectName;
+
+import org.jboss.resource.metadata.mcf.ManagedConnectionFactoryDeploymentMetaData;
+import org.jboss.system.metadata.ServiceAttributeMetaData;
+
+public class MetaDataTypeMappingBuilder extends AbstractBuilder
+{
+
+   @Override
+   public List<ServiceAttributeMetaData> buildAttributes(ManagedConnectionFactoryDeploymentMetaData md)
+   {
+      return null;
+   }
+
+   @Override
+   public ObjectName buildObjectName(ManagedConnectionFactoryDeploymentMetaData md)
+   {
+      return null;
+   }
+
+   @Override
+   public String getCode(ManagedConnectionFactoryDeploymentMetaData md)
+   {
+      return null;
+   }
+
+}




More information about the jboss-cvs-commits mailing list