Skip to content

Commit

Permalink
TEIID-2423 added an xml (inputstream) based deployment option and a
Browse files Browse the repository at this point in the history
simplier method for adding a connection factory
  • Loading branch information
shawkins committed Mar 25, 2013
1 parent ac4d4be commit 73a331e
Show file tree
Hide file tree
Showing 6 changed files with 57 additions and 3 deletions.
3 changes: 2 additions & 1 deletion build/kits/jboss-as7/docs/teiid/teiid-releasenotes.html
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ <H2>Overview</H2>
</UL>
<H2><A NAME="Highlights"></A>Highlights</H2>
<ul>

<li>TEIID-2429 Improved sort performance for large data sets especially under heavy load.
<li>TEIID-2423 Added an xml deployment option for Teiid Embedded.
</ul>

<h2><a name="Compatibility">Compatibility Issues</a></h2>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,16 @@ public ConnectorManagerException(Throwable t) {
}
}

/**
* Provides {@link ExecutionFactory}s to the {@link ConnectorManagerRepository}
*/
public interface ExecutionFactoryProvider {
/**
*
* @param name
* @return the named {@link ExecutionFactory} or throw a {@link ConnectorManagerException} if it does not exist
* @throws ConnectorManagerException
*/
ExecutionFactory<Object, Object> getExecutionFactory(String name) throws ConnectorManagerException;
}

Expand Down
28 changes: 28 additions & 0 deletions runtime/src/main/java/org/teiid/runtime/EmbeddedServer.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
package org.teiid.runtime;


import java.io.InputStream;
import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;
import java.lang.reflect.Proxy;
Expand All @@ -36,10 +37,12 @@
import java.util.concurrent.atomic.AtomicInteger;

import javax.transaction.TransactionManager;
import javax.xml.stream.XMLStreamException;

import org.teiid.adminapi.VDB.Status;
import org.teiid.adminapi.impl.ModelMetaData;
import org.teiid.adminapi.impl.VDBMetaData;
import org.teiid.adminapi.impl.VDBMetadataParser;
import org.teiid.client.DQP;
import org.teiid.client.security.ILogon;
import org.teiid.common.buffer.BufferManager;
Expand Down Expand Up @@ -257,6 +260,15 @@ public void addConnectionFactoryProvider(String name,
this.connectionFactoryProviders.put(name, connectionFactoryProvider);
}

/**
* Adds the object as the named connection factory to replace the default JNDI lookup strategy.
* @param name
* @param connectionFactoryr
*/
public void addConnectionFactory(String name, Object connectionFactory) {
this.connectionFactoryProviders.put(name, new SimpleConnectionFactoryProvider<Object>(connectionFactory));
}

public synchronized void start(@SuppressWarnings("hiding") EmbeddedConfiguration config) {
if (running != null) {
throw new IllegalStateException();
Expand Down Expand Up @@ -473,9 +485,25 @@ public void deployVDB(String name, ModelMetaData... models)
deployVDB(vdb);
}

/**
* Deploy a vdb.xml file. The name and version will be derived from the xml.
* @param is which will be closed by this deployment
* @throws XMLStreamException
* @throws TranslatorException
* @throws ConnectorManagerException
* @throws VirtualDatabaseException
*/
public void deployVDB(InputStream is) throws XMLStreamException, VirtualDatabaseException, ConnectorManagerException, TranslatorException {
VDBMetaData metadata = VDBMetadataParser.unmarshell(is);
deployVDB(metadata);
}

protected void deployVDB(VDBMetaData vdb)
throws ConnectorManagerException, VirtualDatabaseException, TranslatorException {
checkStarted();
if (!vdb.getOverrideTranslators().isEmpty()) {
throw new VirtualDatabaseException(RuntimePlugin.Event.TEIID40106, RuntimePlugin.Util.gs(RuntimePlugin.Event.TEIID40106, vdb.getName()));
}
cmr.createConnectorManagers(vdb, this);
MetadataStore metadataStore = new MetadataStore();
UDFMetaData udfMetaData = new UDFMetaData();
Expand Down
3 changes: 2 additions & 1 deletion runtime/src/main/java/org/teiid/runtime/RuntimePlugin.java
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ public static enum Event implements BundleUtil.Event{
TEIID40102,
TEIID40103,
TEIID40104,
TEIID40105
TEIID40105,
TEIID40106, //override translators not allowed in embedded
}
}
3 changes: 2 additions & 1 deletion runtime/src/main/resources/org/teiid/runtime/i18n.properties
Original file line number Diff line number Diff line change
Expand Up @@ -105,4 +105,5 @@ TEIID40099=Cache system has been shutdown
TEIID40101=error setting state {0}
TEIID40102= {0} Failed to Pull {1}
TEIID40103={0} timeout pulling {1}
TEIID40105=Unsupported ODBC client encoding {0}
TEIID40105=Unsupported ODBC client encoding {0}
TEIID40106=VDB {0} deployment failed. Override translators are not allowed in embedded mode.
14 changes: 14 additions & 0 deletions runtime/src/test/java/org/teiid/runtime/TestEmbeddedServer.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@

import static org.junit.Assert.*;

import java.io.ByteArrayInputStream;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
Expand Down Expand Up @@ -288,6 +289,19 @@ public int[] getUpdateCounts() throws DataNotAvailableException,
assertNull(es.getSchemaDdl("empty", "xxx"));
}

@Test public void testXMLDeploy() throws Exception {
es.start(new EmbeddedConfiguration());
es.deployVDB(new ByteArrayInputStream("<vdb name=\"test\" version=\"1\"><model name=\"test\" type=\"VIRTUAL\"><metadata type=\"DDL\"><![CDATA[CREATE VIEW helloworld as SELECT 'HELLO WORLD';]]> </metadata></model></vdb>".getBytes()));
ResultSet rs =es.getDriver().connect("jdbc:teiid:test", null).createStatement().executeQuery("select * from helloworld");
rs.next();
assertEquals("HELLO WORLD", rs.getString(1));
}

@Test(expected=VirtualDatabaseException.class) public void testXMLDeployFails() throws Exception {
es.start(new EmbeddedConfiguration());
es.deployVDB(new ByteArrayInputStream("<vdb name=\"test\" version=\"1\"><model name=\"test\" type=\"VIRTUAL\"><metadata type=\"DDL\"><![CDATA[CREATE VIEW helloworld as SELECT 'HELLO WORLD';]]> </metadata></model><translator name=\"foo\" type=\"h2\"></translator></vdb>".getBytes()));
}

@Test(expected=VirtualDatabaseException.class) public void testDeploymentError() throws Exception {
EmbeddedConfiguration ec = new EmbeddedConfiguration();
ec.setUseDisk(false);
Expand Down

0 comments on commit 73a331e

Please sign in to comment.