h1. Differences Between Teiid Embedded and an AS Deployment |
Embedded is a light-weight version of Teiid for use in any Java 6+ JRE. JBoss AS nor any application server is not required. This feature/kit are still evolving. Please consult the source examples and even unit tests utilizing the EmbeddedServer for a more complete guide as to its use. |
|
* There is no vdb.xml file or vdb artifact of any kind for deployment in embedded. Models (schemas) are deployed as a set to form a named vdb. ** There is no direct vdb versioning concept in embedded. |
h1. Configuration The primary way to configure Teiid Embedded is with the {{EmbeddedConfiguration}} class. It is provided to the {{EmbeddedServer}} at start-up and dictates much of the behavior of the embedded instance. From there the running server instance may have translators and VDBs deployed as needed. h2. VDB Deployment VDB deployment is done through direct usage of the VDB metadata objects that are the underpinning of vdb.xml deployment. However there is no vdb.xml file or vdb artifact of any kind for deployment in embedded. Models (schemas) are deployed as a set to form a named vdb - see the {{EmbeddedServer.deployVDB}} method. There is also no direct vdb versioning concept in embedded. *Translators* Translators instances can be scoped to a VDB in AS using declarations in a vdb.xml file, however named instances are scoped to the entire {{EmbeddedServer}} and must be registered via the {{EmbeddedServer.addTranslator}} methods. A new server instance does not assume any translators are deployed and does not perform any sort of library scanning to find translators. *Sources* The Embedded Server will still attempt to lookup the given JNDI connection factory names via JNDI. In most non-container environments it is likely that no such bindings exist. In this case the Embedded Server instance must have {{ConnectionFactoryProvider}} instances manually registered using the {{EmbeddedServer.addConnectionFactoryProvider}} method. Note that the Embedded Server does not have built-in pooling logic, so to make better use of a standard {{java.sql.DataSource}} or to enable proper use of {{javax.sql.XADataSource}} you must first configure the instance via a third-party connection pool. {code:title=Example Deployment}EmbeddedServer es = new EmbeddedServer(); EmbeddedConfiguration ec = new EmbeddedConfiguration(); //set any configuration properties ec.setUseDisk(false); es.start(ec); //example of adding a translator by class - this will make a default instance available with the default name of oracle es.addTranslator(OracleExecutionFactory.class); //add a translator by instance - this is functionally equivalent to using a vdb.xml translator override OracleExecutionFactory oef = new OracleExecutionFactory(); //configure and start the instance oef.setDatabaseVersion("11.0"); oef.start(); es.addTranslator("my-oracle", oef); //add a connection factory provider if needed //the default is to perform a jndi lookup of the datasource names given //however out of a container you will likely need to manually inject the necessary connection factory ConnectionFactoryProvider<DataSource> cfp = new EmbeddedServer.SimpleConnectionFactoryProvider<DataSource>(...); es.addConnectionFactoryProvider("ora-ds", cfp); //add a vdb //physical model ModelMetaData mmd = new ModelMetaData(); mmd.setName("my-schema"); mmd.addSourceMapping("my-schema", "my-oracle", "ora-ds"); //virtual model ModelMetaData mmd1 = new ModelMetaData(); mmd1.setName("virt"); mmd1.setModelType(Type.VIRTUAL); mmd1.setSchemaSourceType("ddl"); mmd1.setSchemaText("create view \"my-view\" OPTIONS (UPDATABLE 'true') as select * from \"my-table\""); es.deployVDB("test", mmd, mmd1); {code} h1. Transactions Transaction processing requires setting the {{TransactionManager}} in the {{EmbeddedConfiguration}} used to start the {{EmbeddedServer}}. A client facing {{javax.sql.DataSource}} is not provided for embedded. However the usage of provided {{java.sql.Driver}} should be sufficient as the embedded server is by default able to detect thread bound transactions and appropriately propagate the transaction to threads launched as part of request processing. The usage of local connections is also permitted. h1. Other Differences Between Teiid Embedded and an AS Deployment |
* There is no JDBC/ODBC socket transport in embedded. You are expected to obtain a {{Driver}} connection via the {{EmbeddedServer.getDriver}} method. |
** A javax.sql.DataSource is not provided for embedded. The embedded server is by default able to detect thread bound transactions and appropriately propagate the transaction to threads launched as part of request processing. Transaction processing requires setting the {{TransactionManager}} in the {{EmbeddedConfiguration}} used to start the {{EmbeddedServer}}. * Translators instances can be scoped to a VDB in AS using declarations in a vdb.xml file, however named instances are scoped to the entire {{EmbeddedServer}} and must be registered via the {{EmbeddedServer.addTranslator}} method. |
* A {{MetadataRepository}} is scoped to a VDB in AS, but is scoped to the entire {{EmbeddedServer}} instance and must be registered via the {{EmbeddedServer.addMetadataRepository}} method. |
Embedded is a light-weight version of Teiid for use in any Java 6+ JRE. JBoss AS nor any application server is not required. This feature/kit are still evolving. Please consult the source examples and even unit tests utilizing the EmbeddedServer for a more complete guide as to its use.
The primary way to configure Teiid Embedded is with the EmbeddedConfiguration class. It is provided to the EmbeddedServer at start-up and dictates much of the behavior of the embedded instance. From there the running server instance may have translators and VDBs deployed as needed.
VDB deployment is done through direct usage of the VDB metadata objects that are the underpinning of vdb.xml deployment. However there is no vdb.xml file or vdb artifact of any kind for deployment in embedded. Models (schemas) are deployed as a set to form a named vdb - see the EmbeddedServer.deployVDB method. There is also no direct vdb versioning concept in embedded.
Translators
Translators instances can be scoped to a VDB in AS using declarations in a vdb.xml file, however named instances are scoped to the entire EmbeddedServer and must be registered via the EmbeddedServer.addTranslator methods. A new server instance does not assume any translators are deployed and does not perform any sort of library scanning to find translators.
Sources
The Embedded Server will still attempt to lookup the given JNDI connection factory names via JNDI. In most non-container environments it is likely that no such bindings exist. In this case the Embedded Server instance must have ConnectionFactoryProvider instances manually registered using the EmbeddedServer.addConnectionFactoryProvider method. Note that the Embedded Server does not have built-in pooling logic, so to make better use of a standard java.sql.DataSource or to enable proper use of javax.sql.XADataSource you must first configure the instance via a third-party connection pool.
EmbeddedServer es = new EmbeddedServer(); EmbeddedConfiguration ec = new EmbeddedConfiguration(); //set any configuration properties ec.setUseDisk(false); es.start(ec); //example of adding a translator by class - this will make a default instance available with the default name of oracle es.addTranslator(OracleExecutionFactory.class); //add a translator by instance - this is functionally equivalent to using a vdb.xml translator override OracleExecutionFactory oef = new OracleExecutionFactory(); //configure and start the instance oef.setDatabaseVersion("11.0"); oef.start(); es.addTranslator("my-oracle", oef); //add a connection factory provider if needed //the default is to perform a jndi lookup of the datasource names given //however out of a container you will likely need to manually inject the necessary connection factory ConnectionFactoryProvider<DataSource> cfp = new EmbeddedServer.SimpleConnectionFactoryProvider<DataSource>(...); es.addConnectionFactoryProvider("ora-ds", cfp); //add a vdb //physical model ModelMetaData mmd = new ModelMetaData(); mmd.setName("my-schema"); mmd.addSourceMapping("my-schema", "my-oracle", "ora-ds"); //virtual model ModelMetaData mmd1 = new ModelMetaData(); mmd1.setName("virt"); mmd1.setModelType(Type.VIRTUAL); mmd1.setSchemaSourceType("ddl"); mmd1.setSchemaText("create view \"my-view\" OPTIONS (UPDATABLE 'true') as select * from \"my-table\""); es.deployVDB("test", mmd, mmd1);
Transaction processing requires setting the TransactionManager in the EmbeddedConfiguration used to start the EmbeddedServer. A client facing javax.sql.DataSource is not provided for embedded. However the usage of provided java.sql.Driver should be sufficient as the embedded server is by default able to detect thread bound transactions and appropriately propagate the transaction to threads launched as part of request processing. The usage of local connections is also permitted.