[teiid-commits] teiid SVN: r2055 - in trunk: build/kit-jboss-container/deploy/teiid and 6 other directories.

teiid-commits at lists.jboss.org teiid-commits at lists.jboss.org
Tue Apr 13 14:42:25 EDT 2010


Author: rareddy
Date: 2010-04-13 14:42:24 -0400 (Tue, 13 Apr 2010)
New Revision: 2055

Added:
   trunk/jboss-integration/src/main/java/org/teiid/adminapi/jboss/ExtendedComponentType.java
   trunk/jboss-integration/src/main/java/org/teiid/templates/connector/ExportConnectorTypeTemplateInfo.java
Modified:
   trunk/adminshell/src/main/resources/scripts/adminapi.bsh
   trunk/build/kit-jboss-container/deploy/teiid/teiid-connector-templates-jboss-beans.xml
   trunk/client/src/main/java/org/teiid/adminapi/Admin.java
   trunk/common-core/src/main/java/com/metamatrix/core/util/ObjectConverterUtil.java
   trunk/jboss-integration/src/main/java/org/teiid/adminapi/jboss/Admin.java
   trunk/jboss-integration/src/main/resources/org/teiid/jboss/i18n.properties
   trunk/test-integration/db/src/test/java/org/teiid/adminapi/jboss/TestConnectorBindings.java
Log:
TEIID-1044, TEIID-1045: Correcting the export functionality of the Connection factory and adding the export of the data source

Modified: trunk/adminshell/src/main/resources/scripts/adminapi.bsh
===================================================================
--- trunk/adminshell/src/main/resources/scripts/adminapi.bsh	2010-04-13 17:52:41 UTC (rev 2054)
+++ trunk/adminshell/src/main/resources/scripts/adminapi.bsh	2010-04-13 18:42:24 UTC (rev 2055)
@@ -12,7 +12,7 @@
  * @return the {@link VDB} representing the current property values and runtime state.
  */
 VDB deployVDB(String vdbFile) {
-    debug("Adding VDB " + name + " from " + vdbFile);
+    debug("Adding VDB " + vdbFile);
     checkAdmin();    
     return internalAdmin.deployVDB(vdbFile, new FileInputStream(new File(vdbFile)));
 }
@@ -44,7 +44,7 @@
     	ObjectConverterUtil.write(contents, fileName);
     }
     else {
-    	throw new AdminProcessingException("VDB with name "+ name + " is not found to export");
+    	throw new AdminProcessingException("VDB with name "+ vdbName + " is not found to export");
     }
 }
 
@@ -104,7 +104,7 @@
     	ObjectConverterUtil.write(contents, fileName);	
     }
     else {
-    	throw new AdminProcessingException("Connector Binding "+ bindingName + " not found for exporting");
+    	throw new AdminProcessingException("Connector Binding "+ deployedName + " not found for exporting");
     }
 }
 
@@ -128,13 +128,14 @@
 /**
  * Adds JDBC XA Data Source in the container.
  * @param dsName - name of the source
+ * @param type - type of data source
  * @param properties - properties
  * @throws AdminException
  */
-void addDataSource(String dsName, Properties properties) {
+void addDataSource(String dsName, DataSourceType type,Properties properties) {
     debug("Adding Datasource " + dsName);
     checkAdmin();    
-    return internalAdmin.addDataSource(dsName, properties);	
+    return internalAdmin.addDataSource(dsName, type, properties);	
 }
 
 /**
@@ -148,6 +149,24 @@
     return internalAdmin.deleteDataSource(dsName);	
 }
 
+/**
+ * Export the data source in "-ds.xml" file format. 
+ * @param dsName - name of the data source
+ * @param fileName
+ * @return
+ * @throws AdminException
+ */
+void exportDataSource(String dsName, String fileName) {
+    debug("Exporting Data source " + dsName + " to file " + fileName);
+    checkAdmin();
+    contents = internalAdmin.exportDataSource(dsName);
+    if (contents != null) {
+    	ObjectConverterUtil.write(contents, fileName);	
+    }
+    else {
+    	throw new AdminProcessingException("Data Source "+ dsName + " not found for exporting");
+    }	
+}
 
 /**
  * Get the property definitions for creating the JDBC data source.

Modified: trunk/build/kit-jboss-container/deploy/teiid/teiid-connector-templates-jboss-beans.xml
===================================================================
--- trunk/build/kit-jboss-container/deploy/teiid/teiid-connector-templates-jboss-beans.xml	2010-04-13 17:52:41 UTC (rev 2054)
+++ trunk/build/kit-jboss-container/deploy/teiid/teiid-connector-templates-jboss-beans.xml	2010-04-13 18:42:24 UTC (rev 2055)
@@ -1,6 +1,20 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <deployment xmlns="urn:jboss:bean-deployer:2.0">
-    <!-- This file defines the connector templates for Teiid based connectors -->
+
+    <!-- This file defines the connector templates for Teiid based connectors -->  
+   <bean name="export-template" class="org.jboss.resource.deployers.management.DsDataSourceTemplate">
+      <property name="info"><inject bean="export-templateinfo"/></property>
+   </bean>
+   <bean name="export-templateinfo" class="org.teiid.templates.connector.ExportConnectorTypeTemplateInfo">
+      <constructor factoryMethod="createTemplateInfo">
+         <factory bean="DSDeploymentTemplateInfoFactory"/>
+         <parameter class="java.lang.Class">org.teiid.templates.connector.ExportConnectorTypeTemplateInfo</parameter>
+         <parameter class="java.lang.Class">org.jboss.resource.metadata.mcf.NoTxConnectionFactoryDeploymentMetaData</parameter>
+         <parameter class="java.lang.String">export-template</parameter>
+         <parameter class="java.lang.String">Teiid Export Template</parameter>
+      </constructor>
+   </bean>     
+    
    <bean name="connector-jdbc-${project.version}" class="org.teiid.templates.connector.ConnectorTypeTemplate">
       <property name="info"><inject bean="connector-jdbc-templateinfo"/></property>
       <property name="targetTemplate"><inject bean="NoTxConnectionFactoryTemplate"/></property>

Modified: trunk/client/src/main/java/org/teiid/adminapi/Admin.java
===================================================================
--- trunk/client/src/main/java/org/teiid/adminapi/Admin.java	2010-04-13 17:52:41 UTC (rev 2054)
+++ trunk/client/src/main/java/org/teiid/adminapi/Admin.java	2010-04-13 18:42:24 UTC (rev 2055)
@@ -29,7 +29,8 @@
 import java.util.Set;
 
 public interface Admin {
-	
+
+	public enum DataSourceType {XA, LOCAL};
 	public enum Cache {CODE_TABLE_CACHE,PREPARED_PLAN_CACHE, QUERY_SERVICE_RESULT_SET_CACHE};
     
     /**
@@ -327,20 +328,29 @@
     
     /**
      * Adds JDBC XA Data Source in the container.
-     * @param dsName - name of the source
+     * @param deploymentName - name of the source
+     * @param type - type of data source
      * @param properties - properties
      * @throws AdminException
      */
-    void addDataSource(String deploymentName, Properties properties) throws AdminException;
+    void addDataSource(String deploymentName, DataSourceType type, Properties properties) throws AdminException;
     
     /**
      * Delete data source. 
-     * @param dsName
+     * @param deployedName
      * @throws AdminException
      */
-    void deleteDataSource(String deploymentName) throws AdminException;
+    void deleteDataSource(String deployedName) throws AdminException;
     
     /**
+     * Export the data source in "-ds.xml" file format. 
+     * @param deployedName
+     * @return
+     * @throws AdminException
+     */
+    Reader exportDataSource(String deployedName) throws AdminException;
+    
+    /**
      * Get the property definitions for creating the JDBC data source.
      * @return
      * @throws AdminException

Modified: trunk/common-core/src/main/java/com/metamatrix/core/util/ObjectConverterUtil.java
===================================================================
--- trunk/common-core/src/main/java/com/metamatrix/core/util/ObjectConverterUtil.java	2010-04-13 17:52:41 UTC (rev 2054)
+++ trunk/common-core/src/main/java/com/metamatrix/core/util/ObjectConverterUtil.java	2010-04-13 18:42:24 UTC (rev 2055)
@@ -29,6 +29,7 @@
 import java.io.File;
 import java.io.FileInputStream;
 import java.io.FileOutputStream;
+import java.io.FileWriter;
 import java.io.IOException;
 import java.io.InputStream;
 import java.io.InputStreamReader;
@@ -128,7 +129,29 @@
 
         write(is, f);
     }
+    
+    public static void write(final Reader reader, final String fileName) throws IOException {
+        File f = new File(fileName);
+        f.delete();
 
+        write(reader, f);
+    }    
+    
+    public static void write(final Reader reader, final File f) throws IOException {
+        FileWriter fw = new FileWriter(f);        
+        try {
+		    char[] buff = new char[2048];
+		    int bytesRead;
+		
+		    // Simple read/write loop.
+		    while (-1 != (bytesRead = reader.read(buff, 0, buff.length))) {
+		        fw.write(buff, 0, bytesRead);
+		    }
+        } finally {
+        	fw.close();
+        }   
+    }
+
     public static void write(final InputStream is, final File f) throws IOException {
         FileOutputStream fio = new FileOutputStream(f);
         BufferedOutputStream bos = new BufferedOutputStream(fio);

Modified: trunk/jboss-integration/src/main/java/org/teiid/adminapi/jboss/Admin.java
===================================================================
--- trunk/jboss-integration/src/main/java/org/teiid/adminapi/jboss/Admin.java	2010-04-13 17:52:41 UTC (rev 2054)
+++ trunk/jboss-integration/src/main/java/org/teiid/adminapi/jboss/Admin.java	2010-04-13 18:42:24 UTC (rev 2055)
@@ -27,8 +27,8 @@
 import java.io.FileOutputStream;
 import java.io.IOException;
 import java.io.InputStream;
-import java.io.InputStreamReader;
 import java.io.Reader;
+import java.io.StringReader;
 import java.net.MalformedURLException;
 import java.net.URL;
 import java.util.ArrayList;
@@ -47,6 +47,7 @@
 import org.jboss.managed.api.ComponentType;
 import org.jboss.managed.api.DeploymentTemplateInfo;
 import org.jboss.managed.api.ManagedComponent;
+import org.jboss.managed.api.ManagedDeployment;
 import org.jboss.managed.api.ManagedObject;
 import org.jboss.managed.api.ManagedProperty;
 import org.jboss.managed.plugins.DefaultFieldsImpl;
@@ -66,8 +67,8 @@
 import org.teiid.adminapi.AdminException;
 import org.teiid.adminapi.AdminObject;
 import org.teiid.adminapi.AdminProcessingException;
+import org.teiid.adminapi.ConnectionFactory;
 import org.teiid.adminapi.ConnectionPoolStatistics;
-import org.teiid.adminapi.ConnectionFactory;
 import org.teiid.adminapi.Model;
 import org.teiid.adminapi.PropertyDefinition;
 import org.teiid.adminapi.Request;
@@ -76,8 +77,8 @@
 import org.teiid.adminapi.Transaction;
 import org.teiid.adminapi.VDB;
 import org.teiid.adminapi.WorkerPoolStatistics;
+import org.teiid.adminapi.impl.ConnectionFactoryMetaData;
 import org.teiid.adminapi.impl.ConnectionPoolStatisticsMetadata;
-import org.teiid.adminapi.impl.ConnectionFactoryMetaData;
 import org.teiid.adminapi.impl.DataPolicyMetadata;
 import org.teiid.adminapi.impl.ModelMetaData;
 import org.teiid.adminapi.impl.PropertyDefinitionMetadata;
@@ -90,18 +91,26 @@
 import org.teiid.connector.api.Connector;
 import org.teiid.jboss.IntegrationPlugin;
 import org.teiid.jboss.deployers.RuntimeEngineDeployer;
+import org.teiid.templates.connector.ExportConnectorTypeTemplateInfo;
 
+import com.metamatrix.core.util.ObjectConverterUtil;
+
 public class Admin extends TeiidAdmin {
 	private static final ProfileKey DEFAULT_PROFILE_KEY = new ProfileKey(ProfileKey.DEFAULT);
-	
+
 	private static final String XA_DATA_SOURCE_TEMPLATE = "XADataSourceTemplate"; //$NON-NLS-1$
+	private static final String LOCAL_DATA_SOURCE_TEMPLATE = "LocalTxDataSourceTemplateInfo";  //$NON-NLS-1$	
 	private static final long serialVersionUID = 7081309086056911304L;
 	private static ComponentType VDBTYPE = new ComponentType("teiid", "vdb");//$NON-NLS-1$ //$NON-NLS-2$
-	private static ComponentType NOTXTYPE = new ComponentType("ConnectionFactory", "NoTx");//$NON-NLS-1$ //$NON-NLS-2$
-	private static ComponentType TXTYPE = new ComponentType("ConnectionFactory", "Tx");//$NON-NLS-1$ //$NON-NLS-2$
 	private static ComponentType DQPTYPE = new ComponentType("teiid", "dqp");//$NON-NLS-1$ //$NON-NLS-2$
-	private static ComponentType DSTYPE = new ComponentType("DataSource", "XA");//$NON-NLS-1$ //$NON-NLS-2$
 	private static String DQPNAME = RuntimeEngineDeployer.class.getName();
+	private static ExtendedComponentType NOTXTYPE = new ExtendedComponentType("ConnectionFactory", "NoTx", "no-tx-connection-factory");//$NON-NLS-1$ //$NON-NLS-2$
+	private static ExtendedComponentType TXTYPE = new ExtendedComponentType("ConnectionFactory", "Tx", "tx-connection-factory");//$NON-NLS-1$ //$NON-NLS-2$	
+	private static ExtendedComponentType DS_LOCAL_TX = new ExtendedComponentType("DataSource", "LocalTx", "local-tx-datasource");//$NON-NLS-1$ //$NON-NLS-2$
+	private static ExtendedComponentType DS_XA_TX = new ExtendedComponentType("DataSource", "XA", "xa-datasource");//$NON-NLS-1$ //$NON-NLS-2$
+	private static ExtendedComponentType DS_NO_TX = new ExtendedComponentType("DataSource", "NoTx", "no-tx-datasource");//$NON-NLS-1$ //$NON-NLS-2$
+	private static ExtendedComponentType[] DS_TYPES = new ExtendedComponentType[] {DS_XA_TX, DS_LOCAL_TX, DS_NO_TX};
+	private static ExtendedComponentType[] CF_TYPES = new ExtendedComponentType[] {NOTXTYPE, TXTYPE};
 	
 	private ManagementView view;
 	private DeploymentManager deploymentMgr;
@@ -178,12 +187,72 @@
 
 	@Override
 	public Reader exportConnectionFactory(String deployedName) throws AdminException {
-		ManagedComponent mc = getConnectorBindingComponent(deployedName);
-		if (mc != null) {
-			return new InputStreamReader(exportDeployment(mc.getDeployment().getName()));
+		ManagementView view = getView();
+		try {
+			for (ExtendedComponentType type:CF_TYPES) {
+				ManagedComponent mc = view.getComponent(deployedName, type);
+				if (mc != null) {
+					return exportJCAConnection(deployedName, mc, type);
+				}				
+			}	
+			throw new AdminProcessingException(IntegrationPlugin.Util.getString("connector_not_found", deployedName)); //$NON-NLS-1$
+		} catch (Exception e) {
+			throw new AdminComponentException(e);			
 		}
-		return null;
 	}
+		
+	private Reader exportJCAConnection(String deployedName, ManagedComponent mc, ExtendedComponentType type) throws AdminException {		
+		try {
+			DeploymentTemplateInfo info = getView().getTemplate("export-template");
+			if(info == null) {
+				throw new AdminProcessingException(IntegrationPlugin.Util.getString("connector_type_not_found", "export-template")); //$NON-NLS-1$
+			}
+			
+			for (ManagedProperty infoProperty:info.getProperties().values()) {
+				if (infoProperty != null) {
+					ManagedProperty mp = mc.getProperty(infoProperty.getName());
+					if (mp != null) {
+						infoProperty.setValue(mp.getValue());
+					}
+				}
+			}			
+			
+			ManagedProperty dsType = info.getProperties().get("dsType");
+			dsType.setValue(ManagedUtil.wrap(SimpleMetaType.STRING, type.getDsType()));
+			
+			File dsXml = File.createTempFile(deployedName, "-ds.xml");
+			ExportConnectorTypeTemplateInfo.writeTemplate(dsXml, info);
+			Reader r  = new StringReader(ObjectConverterUtil.convertFileToString(dsXml));
+			dsXml.delete();
+			return r;
+		} catch (NoSuchDeploymentException e) {
+			throw new AdminComponentException(e);
+		} catch (IOException e) {
+			throw new AdminComponentException(e);
+		} catch(Exception e) {
+			throw new AdminComponentException(e);
+		}
+	}
+	
+	@Override
+	public Reader exportDataSource(String deployedName) throws AdminException {
+		if (deployedName.startsWith("java:")) { //$NON-NLS-1$
+			deployedName = deployedName.substring(5);
+		}
+		try {
+			ManagedComponent mc = null;
+			ManagementView view = getView();
+			for (ExtendedComponentType type:DS_TYPES) {
+				mc = view.getComponent(deployedName, type);
+				if (mc != null) {
+					return exportJCAConnection(deployedName, mc, type);
+				}
+			}
+			throw new AdminProcessingException(IntegrationPlugin.Util.getString("datasource_not_found", deployedName)); //$NON-NLS-1$
+		} catch (Exception e) {
+			throw new AdminComponentException(e);
+		}
+	}
 
 	private InputStream exportDeployment(String url) throws AdminComponentException {
 		try {
@@ -202,19 +271,14 @@
 				deployedName = deployedName.substring(5);
 			}
 			ManagementView view = getView();
-			ManagedComponent mc = view.getComponent(deployedName, NOTXTYPE);
-			if (mc != null) {
-				if (isConnectorBinding(mc)) {
-					return mc;	
-				}
-			}
-	
-			mc = view.getComponent(deployedName, TXTYPE);
-			if (mc != null) {
-				if (isConnectorBinding(mc)) {
-					return mc;	
-				}
-			}			
+			for (ExtendedComponentType type:CF_TYPES) {
+				ManagedComponent mc = view.getComponent(deployedName, type);
+				if (mc != null) {
+					if (isConnectorBinding(mc)) {
+						return mc;	
+					}
+				}				
+			}	
 		} catch(Exception e) {
 			throw new AdminProcessingException(e.getMessage(), e);
 		}
@@ -374,14 +438,19 @@
 	
 	@Override
 	public Set<String> getConnectorNames() throws AdminException{
-		Set<String> names = getView().getTemplateNames();
-		HashSet<String> matched = new HashSet<String>();
-		for(String name:names) {
-			if (name.startsWith("connector-")) {//$NON-NLS-1$
-				matched.add(name);
+		try {
+			Set<ManagedDeployment> rarFiles = getView().getDeploymentsForType("rar");//$NON-NLS-1$ 
+			HashSet<String> matched = new HashSet<String>();
+			for(ManagedDeployment md:rarFiles) {
+				String name = md.getSimpleName();
+				if (name.startsWith("connector-") && name.endsWith(".rar")) {//$NON-NLS-1$ //$NON-NLS-2$
+					matched.add(name.substring(0, name.length()-4));
+				}
 			}
+			return matched;
+		} catch(Exception e) {
+			throw new AdminComponentException(e.getMessage(), e);
 		}
-		return matched;
 	}
 	
     boolean matches(String regEx, String value) {
@@ -848,8 +917,13 @@
 	}	
 	
 	@Override
-    public void addDataSource(String deploymentName, Properties properties) throws AdminException {
-		addConnectionfactory(deploymentName, XA_DATA_SOURCE_TEMPLATE, properties);
+    public void addDataSource(String deploymentName, DataSourceType type, Properties properties) throws AdminException {
+		if (type == DataSourceType.XA) { 
+			addConnectionfactory(deploymentName, XA_DATA_SOURCE_TEMPLATE, properties);
+		}
+		else if (type == DataSourceType.LOCAL) {
+			addConnectionfactory(deploymentName, LOCAL_DATA_SOURCE_TEMPLATE, properties);
+		}
 	}
 	
     private void addConnectionfactory(String deploymentName, String typeName, Properties properties) throws AdminException {	
@@ -899,10 +973,13 @@
     public void deleteDataSource(String deployedName) throws AdminException {
 		try {
 			ManagementView view = getView();
-			ManagedComponent mc = view.getComponent(deployedName, DSTYPE);
-			if (mc != null) {
-				ManagedUtil.removeArchive(getDeploymentManager(),mc.getDeployment().getName());
-			}
+			for (ExtendedComponentType type:DS_TYPES) {
+				ManagedComponent mc = view.getComponent(deployedName, type);
+				if (mc != null) {
+					ManagedUtil.removeArchive(getDeploymentManager(),mc.getDeployment().getName());
+					break;
+				}
+			}			
 		} catch (Exception e) {
 			throw new AdminComponentException(e.getMessage(), e);
 		}

Added: trunk/jboss-integration/src/main/java/org/teiid/adminapi/jboss/ExtendedComponentType.java
===================================================================
--- trunk/jboss-integration/src/main/java/org/teiid/adminapi/jboss/ExtendedComponentType.java	                        (rev 0)
+++ trunk/jboss-integration/src/main/java/org/teiid/adminapi/jboss/ExtendedComponentType.java	2010-04-13 18:42:24 UTC (rev 2055)
@@ -0,0 +1,39 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership.  Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ * 
+ * This library 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 library 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 library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+package org.teiid.adminapi.jboss;
+
+import org.jboss.managed.api.ComponentType;
+
+public class ExtendedComponentType extends ComponentType {
+	private static final long serialVersionUID = 5526223504408812809L;
+	
+	private String dsType;
+	
+	public ExtendedComponentType(String type, String subtype, String dsType) {
+		super(type, subtype);
+		this.dsType = dsType;
+	}
+	
+	public String getDsType() {
+		return this.dsType;
+	}
+}


Property changes on: trunk/jboss-integration/src/main/java/org/teiid/adminapi/jboss/ExtendedComponentType.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain

Added: trunk/jboss-integration/src/main/java/org/teiid/templates/connector/ExportConnectorTypeTemplateInfo.java
===================================================================
--- trunk/jboss-integration/src/main/java/org/teiid/templates/connector/ExportConnectorTypeTemplateInfo.java	                        (rev 0)
+++ trunk/jboss-integration/src/main/java/org/teiid/templates/connector/ExportConnectorTypeTemplateInfo.java	2010-04-13 18:42:24 UTC (rev 2055)
@@ -0,0 +1,57 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership.  Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ * 
+ * This library 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 library 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 library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+package org.teiid.templates.connector;
+
+import java.io.File;
+import java.util.Map;
+
+import org.jboss.managed.api.DeploymentTemplateInfo;
+import org.jboss.managed.api.ManagedProperty;
+import org.jboss.profileservice.management.FilteredDeploymentTemplateInfo;
+import org.jboss.resource.deployers.management.DsDataSourceTemplate;
+import org.jboss.resource.deployers.management.DsDataSourceTemplateInfo;
+
+public class ExportConnectorTypeTemplateInfo extends DsDataSourceTemplateInfo{
+	private static final long serialVersionUID = 7725742249912578496L;
+	
+	public ExportConnectorTypeTemplateInfo(String name, String description, String datasourceType) {
+		super(name, description, datasourceType);
+	}
+
+	public ExportConnectorTypeTemplateInfo(String arg0, String arg1, Map<String, ManagedProperty> arg2) {
+		super(arg0, arg1, arg2);
+	}
+
+	public static void writeTemplate(File dsXml, DeploymentTemplateInfo info) throws Exception {
+		ExportConnectionFactoryTemplate template = new ExportConnectionFactoryTemplate();
+		template.writeTemplate(dsXml, info);
+	}
+	
+	public static class ExportConnectionFactoryTemplate extends DsDataSourceTemplate {
+		@Override
+		public void writeTemplate(File dsXml, DeploymentTemplateInfo values) throws Exception {
+			FilteredDeploymentTemplateInfo filterInfo = new FilteredDeploymentTemplateInfo(values);
+			super.writeTemplate(dsXml, filterInfo);
+		}
+	}		
+
+}


Property changes on: trunk/jboss-integration/src/main/java/org/teiid/templates/connector/ExportConnectorTypeTemplateInfo.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain

Modified: trunk/jboss-integration/src/main/resources/org/teiid/jboss/i18n.properties
===================================================================
--- trunk/jboss-integration/src/main/resources/org/teiid/jboss/i18n.properties	2010-04-13 17:52:41 UTC (rev 2054)
+++ trunk/jboss-integration/src/main/resources/org/teiid/jboss/i18n.properties	2010-04-13 18:42:24 UTC (rev 2055)
@@ -36,6 +36,8 @@
 vdb_not_found=VDB with name "{0}" version "{1}" not found in configuration
 model_not_found=Model name "{0}" not found in the VDB with name "{1}" version "{2}"
 policy_not_found=Policy name "{0}" not found in the VDB with name "{1}" version "{2}"
+connector_not_found=Connection factory {0} not found in the configuration.
+datasource_not_found=Datasource {0} not found in the configuration.
 
 sourcename_not_found=No source name {0} found in the model: {1}.{2}.{3}
 connector_started= Teiid connector {0} started

Modified: trunk/test-integration/db/src/test/java/org/teiid/adminapi/jboss/TestConnectorBindings.java
===================================================================
--- trunk/test-integration/db/src/test/java/org/teiid/adminapi/jboss/TestConnectorBindings.java	2010-04-13 17:52:41 UTC (rev 2054)
+++ trunk/test-integration/db/src/test/java/org/teiid/adminapi/jboss/TestConnectorBindings.java	2010-04-13 18:42:24 UTC (rev 2055)
@@ -389,4 +389,12 @@
 		// remove non-existent role name
 		admin.removeRoleFromDataPolicy("TransactionsRevisited", 1, "policy1", "FOO");
 	}	
+	
+	@Test public void testExportConnectionFactory() throws Exception {
+		ObjectConverterUtil.write(admin.exportConnectionFactory("products-cf"), "cf.xml");
+	}	
+	
+	@Test public void testExportDataSource() throws Exception {
+		ObjectConverterUtil.write(admin.exportDataSource("CustomersDS"), "ds.xml");
+	}
 }



More information about the teiid-commits mailing list