2.2. Define a Managed Connection Factory
2.2. Define a Managed Connection Factory Extend the org.teiid.resource.spi.BasicManagedConnectionFactory class, providing an implementation for the createConnectionFactory() method. This method will create and return an instance of a Connection Factory. Define an attribute for each configuration variable, and then provide both "getter" and "setter" methods for them. This class will define various configuration variables (such as user, password, and URL) used to connect to the datasource. See the following code for an example. public class MyManagedConnectionFactory extends BasicManagedConnectionFactory { @Override public BasicConnectionFactory createConnectionFactory() throws ResourceException { return new MyConnectionFactory(); } // config property name (metadata for these are defined inside the ra.xml) String userName; public String getUserName() { return this.userName; } public void setUserName(String name){ this.userName = name; } // config property count (metadata for these are defined inside the ra.xml) Integer count; public Integer getCount() { return this.count; } public void setCount(Integer value) { this.count = value; } } Important Use only java.lang objects as the attributes. DO NOT use Java primitives for defining and accessing the properties.
public class MyManagedConnectionFactory extends BasicManagedConnectionFactory { @Override public BasicConnectionFactory createConnectionFactory() throws ResourceException { return new MyConnectionFactory(); } // config property name (metadata for these are defined inside the ra.xml) String userName; public String getUserName() { return this.userName; } public void setUserName(String name){ this.userName = name; } // config property count (metadata for these are defined inside the ra.xml) Integer count; public Integer getCount() { return this.count; } public void setCount(Integer value) { this.count = value; } }