Chapter 3. Translator Development 3.1. Environment Set-Up To create a new custom translator: Create a new (or reuse an existing) resource adapter for the data source, to be used with this translator. Decide whether to use the Teiid archetype template to create your initial custom translator project and classes or manually create your environment. Create an ExecutionFactory by: extending the org.teiid.translator.ExecutionFactory class or extending the org.teiid.translator.jdbc.JDBCExecutionFactory class . Package the translator. Deploy your translator. Deploy a Virtual Database (VDB) that uses your translator. Execute queries via the Teiid engine. For sample translator code, refer to the teiid/connectors directory of the Red Hat JBoss Data Virtualization 6.4 Source Code ZIP file which can be downloaded from the Red Hat Customer Portal at https://access.redhat.com . To set up the environment for developing a custom translator, you can either manually configure the build environment, structure and framework classes and resources or use the Teiid Translator Archetype template to generate the initial project. To create the build environment in Red Hat JBoss Developer Studio without any Maven integration, create a Java project and add dependencies to "teiid-common-core", "teiid-api" and JEE "connector-api" jars. However, if you wish to use Maven, add these dependencies: <dependencies> <dependency> <groupId>org.jboss.teiid</groupId> <artifactId>teiid-api</artifactId> <version>USD{teiid-version}</version> <scope>provided</scope> </dependency> <dependency> <groupId>org.jboss.teiid</groupId> <artifactId>teiid-common-core</artifactId> <version>USD{teiid-version}</version> <scope>provided</scope> </dependency> <dependency> <groupId>javax.resource</groupId> <artifactId>connector-api</artifactId> <version>USD{version.connector.api}</version> <scope>provided</scope> </dependency> </dependencies> In this case, the USD{teiid-version} property should be set to the expected version, such as 8.12.0.Final. You can find Teiid artifacts in the JBoss maven repository . The first way to create a translator project is by using JBoss Developer Studio: Procedure 3.1. Create a Project in JBDS Open the Java perspective. From the menu select File - New - Other. In the tree, expand Maven and select Maven Project. Click . On the "Select project name and Location" window, you can accept the defaults, so click On the "Select an Archetype" window, click the Configure button Add the remote catalog found at https://repository.jboss.org/nexus/content/repositories/releases/ then click OK to return. Uncheck Show the last version of Archetype only and enter "teiid" in the filter to see the Teiid archetypes. Select the translator-archetype 8.12.x and then click . Enter all the information (such as Group ID and, Artifact ID) needed to generate the project. Click Finish. The other method involves using the command line. You can create a project using the Teiid archetype template. When the project is created from the template, it will contain the essential classes (in other words, the ExecutionFactory) and resources for you to begin adding your custom logic. Additionally, the maven dependencies are defined in the pom.xml file so that you can begin compiling the classes. Procedure 3.2. Create a Project Using the Command Line Issue the following template command: This is what the instructions mean: -DarchetypeGroupId - this is the group ID for the archetype to use to generate -DarchetypeArtifactId - this is the artifact ID for the archetype to use to generate. -DarchetypeVersion - this is the version for the archetype to use to generate. -DgroupId - this is a (user defined) group ID for the new translator project pom.xml. -DartifactId - this is a (user defined) artifact ID for the new translator project pom.xml. -Dpackage - this is a (user defined) the package structure where the java and resource files will be created. -Dversion - this is a (user defined) the version that the new connector project pom.xml will be. -Dtranslator-name - this is a (user defined) the name (type) of the new translator project, used to create the java class names. -Dteiid-version - the Teiid version upon which the connector will depend. -Dtranslator-type - This specifies the identifier used for the translator in EAP configuration files. Here is a sample command: After you execute it, you will be asked to confirm the properties: Type Y (for Yes) and press enter. Upon creation, a directory based on the artifactId will be created, that will contain the project. Navigate to that directory. Execute a test build to confirm the project was created correctly: mvn clean package It should build successfully. If so, you are now ready to start adding your custom code.

Commands:
<dependencies> <dependency> <groupId>org.jboss.teiid</groupId> <artifactId>teiid-api</artifactId> <version>USD{teiid-version}</version> <scope>provided</scope> </dependency> <dependency> <groupId>org.jboss.teiid</groupId> <artifactId>teiid-common-core</artifactId> <version>USD{teiid-version}</version> <scope>provided</scope> </dependency> <dependency> <groupId>javax.resource</groupId> <artifactId>connector-api</artifactId> <version>USD{version.connector.api}</version> <scope>provided</scope> </dependency> </dependencies>
mvn archetype:generate \ -DarchetypeGroupId=org.jboss.teiid.arche-types \ -DarchetypeArtifactId=translator-archetype \ -DarchetypeVersion=8.12.0 \ -DgroupId=USD{groupId} \ -DartifactId=translator-USD{translator-name} \ -Dpackage=org.teiid.translator.USD{translator-name} \ -Dversion=USD{version} \ -Dtranslator-name=USD{translator-name} \ -Dtranslator-type=USD{translator-type} -Dteiid-version=USD{teiid-version}
mvn archetype:generate \ -DarchetypeGroupId=org.jboss.teiid.arche-types \ -DarchetypeArtifactId=translator-archetype \ -DarchetypeVersion=8.12.0 \ -DgroupId=org.jboss.teiid.connector \ -DartifactId=translator-myType -Dpackage=org.teiid.translator.myType \ -Dversion=0.0.1-SNAPSHOT \ -Dtranslator-name=MyType \ -Dtranslator-type=MyType -Dteiid-version=8.12.0.Final
Confirm properties configuration: groupId: org.jboss.teiid.connector artifactId: translator-myType version: 0.0.1-SNAPSHOT package: org.teiid.translator.myType teiid-version: 8.12.0.Final translator-name: MyType Y: :