Adaptive Connections For ADFBC
Posted
by Duncan Mills
on Oracle Blogs
See other posts from Oracle Blogs
or by Duncan Mills
Published on Wed, 26 Jun 2013 14:07:10 +0000
Indexed on
2013/06/26
16:25 UTC
Read the original article
Hit count: 202
/ADF
To be clear, yes a single instance of an ADF Application Module is associated with a single connection but there is nothing to stop you from creating multiple instances of the same Application Module within the application, all pointing at different connections. If fact this has been possible for a long time using a custom extension point with code that which extends oracle.jbo.http.HttpSessionCookieFactory. This approach, however, involves writing code and no-one likes to write any more code than they need to, so, is there an easier way? Yes indeed. It is in fact a little publicized feature that's available in all versions of 11g, the ELEnvInfoProvider.
What Does it Do?
- First of all you'll need a managed bean of some sort – e.g. a sessionScoped bean defined in your ViewController project. This will need a getter method that returns the name of the connection. Now this connection itself needs to be defined in your Application Server, and can be managed through Enterprise Manager, WLST or through MBeans. (You may need to read the documentation [http://docs.oracle.com/cd/E28280_01/web.1111/b31974/deployment_topics.htm#CHDJGBDD] here on how to configure connections at runtime if you're not familiar with this)
- The EL expression (e.g. ${connectionManager.connection} is then defined in the configuration by editing the bc4j.xcfg file (there is a hyperlink directly to this file on the configuration editing screen in the Application Module editor). You simply replace the hardcoded JDBCName value with the expression. So your cfg file would end up looking something like this (notice the reference to the ELEnvInfoProvider that I talked about earlier)
<BC4JConfig version="11.1" xmlns="http://xmlns.oracle.com/bc4j/configuration"> <AppModuleConfigBag ApplicationName="oracle.demo.model.TargetAppModule"> <AppModuleConfig DeployPlatform="LOCAL" JDBCName="${connectionManager.connection}" jbo.project="oracle.demo.model.Model" name="TargetAppModuleLocal" ApplicationName="oracle.demo.model.TargetAppModule"> <AM-Pooling jbo.doconnectionpooling="true"/> <Database jbo.locking.mode="optimistic"> <Security AppModuleJndiName="oracle.demo.model.TargetAppModule"/> <Custom jbo.envinfoprovider="oracle.jbo.client.ELEnvInfoProvider"/> </AppModuleConfig> </AppModuleConfigBag> </BC4JConfig>
Still Don't Quite Get It?
However, think about it for a second. Under what circumstances does a new AM get instantiated? Well at the first reference of the AM within the application yes, but also whenever a Task Flow is entered - if the data control scope for the Task Flow is ISOLATED. So the reality is, that on a single screen you can embed multiple Task Flows, all of which are pointing at different database connections concurrently.
Hopefully you'll find this feature useful, let me know...
© Oracle Blogs or respective owner