Friday, January 19, 2007

BIRT 2.2 Milestone 4 Features

The BIRT Team released milestone 4 of the BIRT 2.2 release a this week.
The project is proceeding well. In this milestone we now have a BIRT tag library that allows embedding the BIRT Viewer in an existing web application complete with the ability to create a custom requestor page. This feature along with the BIRT Web Project should help with deployment of BIRT reports.

BIRT now leverages the WTP XML editor to display the XML for a report design within the Designer perspective. It is nice to see project cross-pollination in action.

The Word Emitter is now available for review. It is still early, but this project is shaping up well. Download the M4 release and have a look. Remember M4 requires the Eclipse 3.3 stack, which has a minimum requirement of Java 1.5.

To read more about the Milestone 4 release, read the
New and Notable.

Tuesday, January 16, 2007

BIRT Connection Pooling Continued

Since writing a post on using a supplied connection with BIRT, many changes have occurred in the BIRT Project. Specifically connection pooling has been addressed with a JNDI property. This property can be set when using a JDBC data source.

To see how this can be used with Tomcat, see the

If this does not meet your needs, the Data Tools project now supplies an extension point that can be used to alter the behavior of the standard BIRT JDBC driver. This extension point named org.eclipse.datatools.connectivity.oda.consumer.driverBridge can be implemented to intercept calls made to the JDBC driver and override the standard ODA calls like getConnection. If a user did not wish to use JNDI for connection pooling, but wanted to supply a connection through another means, this could be implemented using this extension point.

The driverTye and bridgeId attributes must be supplied for the extension point. The driverType specifies the ODA driver to which the bridge is applied. For the JDBC driver this should be set to
The bridgeId specifies the element id of the extension that implements the ODA runtime. When using this to change the behavior of the JDBC driver this should be an extension that extends the JDBC runtime.

If you are using the Report Engine API to run reports, a connection object can be passed to engine using the application context as follows:

//Report Engine API snippet
HashMap contextMap = new HashMap();
contextMap.put( EngineConstants.APPCONTEXT_HTML_RENDER_CONTEXT, renderContext );

//add the connection object to the map
contextMap.put( "", myconnectionobject );

task.setAppContext( contextMap );

A plug-in could then be created that implements the driverBridge extension point
to retrieve and use this connection. This plug-in would implement two extension points. The first should be the driverBridge and have values similar to the following:



The driverType specifies that the bridge will be applied to the BIRT JDBC driver.
The bridgeId specifies an element id of testjdbc, which can be defined in the same plug-in.

defaultDisplayName="Sample Driver Bridge"

This extension must implement the org.eclipse.datatools.connectivity.oda.dataSource
extension point. This is the runtime portion of an ODA driver. Because this bridge is being applied to the BIRT JDBC driver we can just extend the OdaJdbcDriver and change the behavior of the setAppContext and getConnection methods. The code below illustrates retrieving the connection from the application context. If the connection object does not exist in the application context, the default JDBC driver is used to retrieve the connection. This will allow the plug-in to be used within the designer using the credentials supplied in the Data Source editor and when deployed to an application that supplies the connection through the application context.

import java.sql.Connection;
import java.util.HashMap;
import java.util.Properties;

import org.eclipse.datatools.connectivity.oda.IConnection;
import org.eclipse.datatools.connectivity.oda.OdaException;

public class MyJdbcDriver extends OdaJdbcDriver {

private Connection passedInConnection;

public void setAppContext( Object context ) throws OdaException
HashMap ctx = (HashMap)context;
passedInConnection = (java.sql.Connection)ctx.get("");


public IConnection getConnection(String connectionClassName) throws OdaException
if( passedInConnection != null){
return new appContextDBConnection();
return new;

private class appContextDBConnection extends

public void open(Properties connProperties) throws OdaException
super.jdbcConn = passedInConnection;


public void close( ) throws OdaException
if ( jdbcConn == null )
//should have call to return connection to the pool
jdbcConn = null;


The source for this plug-in is available here.