[jboss-cvs] JBossAS SVN: r61510 - trunk/connector/src/main/org/jboss/resource/deployers/builder.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Wed Mar 21 00:36:14 EDT 2007


Author: weston.price at jboss.com
Date: 2007-03-21 00:36:14 -0400 (Wed, 21 Mar 2007)
New Revision: 61510

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

Added: trunk/connector/src/main/org/jboss/resource/deployers/builder/ConnectionFactoryBindingBuilder.java
===================================================================
--- trunk/connector/src/main/org/jboss/resource/deployers/builder/ConnectionFactoryBindingBuilder.java	                        (rev 0)
+++ trunk/connector/src/main/org/jboss/resource/deployers/builder/ConnectionFactoryBindingBuilder.java	2007-03-21 04:36:14 UTC (rev 61510)
@@ -0,0 +1,98 @@
+/*
+* 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.mx.util.ObjectNameFactory;
+import org.jboss.resource.metadata.mcf.DataSourceDeploymentMetaData;
+import org.jboss.resource.metadata.mcf.ManagedConnectionFactoryDeploymentMetaData;
+import org.jboss.system.metadata.ServiceAttributeMetaData;
+import org.jboss.system.metadata.ServiceTextValueMetaData;
+
+/**
+ * A ConnectionFactoryBindingBuilder.
+ * 
+ * @author <a href="weston.price at jboss.org">Weston Price</a>
+ * @version $Revision: 1.1 $
+ */
+public class ConnectionFactoryBindingBuilder extends AbstractBuilder
+{
+   private static final String DATASOURCE = "org.jboss.resource.adapter.jdbc.remote.WrapperDataSourceService";
+   private static final String CONNECTION_FACTORY = "org.jboss.resource.connectionmanager.ConnectionFactoryBindingService";
+   private static final String DATASOURCE_JMX = "jboss.jca:service=DataSourceBinding,name=";
+   private static final String CONNNECTION_FACTORY_JMX = "jboss.jca:service=ConnectionFactoryBinding,name=";
+   
+   @Override
+   public List<ServiceAttributeMetaData> buildAttributes(ManagedConnectionFactoryDeploymentMetaData md)
+   {
+      List<ServiceAttributeMetaData> attributes = new ArrayList<ServiceAttributeMetaData>();
+      ServiceAttributeMetaData attribute = new ServiceAttributeMetaData();
+      attribute.setName("JndiName");
+      attribute.setValue(new ServiceTextValueMetaData(md.getJndiName()));
+      attributes.add(attribute);
+      
+      attribute = new ServiceAttributeMetaData();
+      attribute.setName("UseJavaContext");
+      attribute.setValue(new ServiceTextValueMetaData(String.valueOf(md.isUseJavaContext())));
+      attributes.add(attribute);
+                                    
+      return attributes;
+   }
+
+   @Override
+   public ObjectName buildObjectName(ManagedConnectionFactoryDeploymentMetaData md)
+   {
+      
+      ObjectName on = null;
+      
+      if(md instanceof DataSourceDeploymentMetaData)
+      {
+         on = ObjectNameFactory.create(DATASOURCE_JMX + md.getJndiName());
+      }
+      else
+      {
+         on = ObjectNameFactory.create(CONNNECTION_FACTORY_JMX + md.getJndiName());
+         
+      }
+      return on;
+   }
+   
+   @Override
+   public String getCode(ManagedConnectionFactoryDeploymentMetaData md)
+   {
+      
+      if(md instanceof DataSourceDeploymentMetaData)
+      {
+         return DATASOURCE;
+      
+      }
+      else
+      {
+         return CONNECTION_FACTORY;         
+      }
+      
+   }
+}

Added: trunk/connector/src/main/org/jboss/resource/deployers/builder/ManagedConnectionFactoryBuilder.java
===================================================================
--- trunk/connector/src/main/org/jboss/resource/deployers/builder/ManagedConnectionFactoryBuilder.java	                        (rev 0)
+++ trunk/connector/src/main/org/jboss/resource/deployers/builder/ManagedConnectionFactoryBuilder.java	2007-03-21 04:36:14 UTC (rev 61510)
@@ -0,0 +1,94 @@
+/*
+* 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.mx.util.ObjectNameFactory;
+import org.jboss.resource.metadata.ConnectorMetaData;
+import org.jboss.resource.metadata.mcf.ManagedConnectionFactoryDeploymentMetaData;
+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;
+
+/**
+ * A ManagedConnectionFactoryBuilder.
+ * 
+ * @author <a href="weston.price at jboss.org">Weston Price</a>
+ * @version $Revision: 1.1 $
+ */
+public class ManagedConnectionFactoryBuilder extends AbstractBuilder
+{
+   private JCAMetaDataRepository repository;
+   private static final String MCF = "";
+   private static final String MCF_JMX = "";
+   
+   public void setMetaDataRepository(JCAMetaDataRepository repository)
+   {
+      this.repository = repository;      
+   }
+
+   @Override
+   public ObjectName buildObjectName(ManagedConnectionFactoryDeploymentMetaData md)
+   {
+      return ObjectNameFactory.create("" + md.getJndiName());      
+   }
+   
+   @Override
+   public List<ServiceAttributeMetaData> buildAttributes(ManagedConnectionFactoryDeploymentMetaData deployment)
+   {
+      List<ServiceAttributeMetaData> attributes = new ArrayList<ServiceAttributeMetaData>();
+      ServiceAttributeMetaData attribute = null;
+      ServiceDependencyValueMetaData dep = new ServiceDependencyValueMetaData();
+      dep.setDependency("jboss.jca:service=RARDeployment,name='" + deployment.getRarName() + "'");
+
+      attribute = new ServiceAttributeMetaData();
+      attribute.setName("OldRarDeployment");
+      attribute.setValue(dep);
+      attribute.setTrim(false);
+      attributes.add(attribute);      
+      return attributes;
+   }
+   
+   @Override
+   public ServiceConstructorMetaData buildConstructor(ManagedConnectionFactoryDeploymentMetaData mcfmd)
+   {
+      ServiceConstructorMetaData constructor = new ServiceConstructorMetaData();
+
+      ConnectorMetaData md = repository.getConnectorMetaData(mcfmd.getRarName());      
+      constructor.setParameters(new Object[]{md, mcfmd});
+      constructor.setSignature(new String[]{md.getClass().getName(), ManagedConnectionFactoryDeploymentMetaData.class.getName()});
+      return constructor;       
+   }
+   
+   @Override
+   public String getCode(ManagedConnectionFactoryDeploymentMetaData md)
+   {
+      return null;
+   }
+ 
+}




More information about the jboss-cvs-commits mailing list