Accessing resource identifiers in the run-time ODA driver
For run time, the BIRT ODA run-time consumer passes its resource location information in the org.eclipse.datatools.connectivity.oda.util.ResourceIdentifiers instance in the appContext map. ODA run-time drivers can get the instance in any one of the setAppContext methods, such as IDriver.setAppContext:
To get the instance from the appContext map, pass the map key ResourceIdentifiers.ODA_APP_CONTEXT_KEY_CONSUMER_RESOURCE_IDS, defined by the class as a method argument.
To get the BIRT resource folder URI, call, getApplResourceBaseURI( ) method.
To get the URI of the associated report design file folder call getDesignResourceBaseURI( ) method. The URI is application‑dependent and it can be absolute or relative. If your application maintains relative URLs, call the getDesignResourceURILocator.resolve( ) method to get the absolute URI.
The code snippet on
Listing 24‑7 shows how to access the resource identifiers through the application context.
Listing 24‑7 Accessing resource identifiers at run time
URI resourcePath = null;
URI absolutePath = null;
Object obj = this.appContext.get( ResourceIdentifiers.ODA_APP_CONTEXT_KEY_CONSUMER_RESOURCE_IDS );
if ( obj != null )
{
ResourceIdentifiers identifier = (ResourceIdentifiers)obj;
if ( identifier.getDesignResourceBaseURI( ) != null )
{ resourcePath = identifier.getDesignResourceBaseURI();
if ( ! resourcePath.isAbsolute() )
absolutePath = identifier.getDesignResourceURILocator().resolve( resourcePath );
else
absolutePath = resourcePath;
}
}