A helper library to make working with Teiid Embedded easier.
No Transaction DataSource Creation
import org.teiid.embedded.helper.EmbeddedHelper;
import javax.sql.DataSource;
DataSource ds = EmbeddedHelper.Factory.newNoTxDataSource(c -> c.localManagedConnectionFactory(mcf -> {
mcf.setDriverClass("org.h2.Driver");
mcf.setConnectionURL("jdbc:h2:mem:test;DB_CLOSE_DELAY=-1");
mcf.setUserName("sa");
mcf.setPassword("sa");
}).poolConfiguration(p -> {
p.setMaxSize(30);
p.setMinSize(5);
p.setBlockingTimeout(30000);
p.setIdleTimeoutMinutes(10);
}));
Transaction Enable DataSource Creation
import org.teiid.embedded.helper.EmbeddedHelper;
import javax.sql.DataSource;
DataSource ds = EmbeddedHelper.Factory.newDataSource(c -> c.localManagedConnectionFactory(mcf -> {
mcf.setDriverClass("org.h2.Driver");
mcf.setConnectionURL("jdbc:h2:mem:test;DB_CLOSE_DELAY=-1");
mcf.setUserName("sa");
mcf.setPassword("sa");
}).poolConfiguration(p -> {
p.setMaxSize(30);
p.setMinSize(5);
p.setBlockingTimeout(30000);
p.setIdleTimeoutMinutes(10);
}));
TransactionManager Creation
import org.teiid.embedded.helper.EmbeddedHelper;
import javax.transaction.TransactionManager;
TransactionManager tm = EmbeddedHelper.Factory.transactionManager(c -> c.coreEnvironmentBean(core -> {
core.setSocketProcessIdPort(0);
core.setSocketProcessIdMaxPorts(10);
}).coordinatorEnvironmentBean(coordinator -> {
coordinator.setEnableStatistics(false);
coordinator.setDefaultTimeout(300);
coordinator.setTransactionStatusManagerEnable(false);
coordinator.setTxReaperCancelFailWaitPeriod(120000);
}).objectStoreEnvironmentBean(objectStore -> {
objectStore.setObjectStoreDir("target/narayana/data");
}));
AuthenticationManager Creation
import org.teiid.embedded.helper.EmbeddedHelper;
import org.jboss.security.AuthenticationManager;
AuthenticationManager authManager = EmbeddedHelper.Factory.authenticationManager("sample-file", "config/sample-file.xml");
authManager.isValid(principal, credential, subject);
JDBCUtils Usage
import static org.teiid.embedded.helper.utils.JDBCUtils.*;
Connection conn = getDriverConnection("org.h2.Driver", "jdbc:h2:mem:test;DB_CLOSE_DELAY=-1", "sa", "sa");
insert(conn, sql);
update(conn, sql);
query(conn, sql);
delete(conn, sql);
close(conn);
-
install JDK 1.8 or higher
-
install maven 3 - http://maven.apache.org/download.html
-
Create a github account and fork
Enter the following:
$ git clone https://github.com/<yourname>/teiid-embedded.git $ cd teiid-embedded $ mvn clean install