Thursday, March 15, 2012

Use Case for ADF BC With No Database Connection

There is very good sample application from Steve Muench - #147 ADFBC Application With No Database Connection (not yet documented). I was using it to implement recent request from the project, its why I would like to document it. We had a discussion with SOA developers and they were wondering if its possible to run ADF BC application, without DB access. This is quite common use case in SOA projects, there is no direct access to DB and we need to consume data through Web Service layer, as for example. Yes its possible and I see quite strong advantage of ADF BC, even when working with non DB data sources - its easy to centralize data access through programmatic VO's, its fast to expose programmatic VO through Data Control and finally is easy to capture user data input, use out of the box functions to process user data (getting current row from VO, iterating over row set, creating new rows, deleting rows, etc.). This can be as alternative for Web Service Data Control.

Sample application - ADFBCNoDatabaseWSApp.zip use case is described in this diagram:


ADF BC application is disabled from creating database connection, instead it contains programmatic VO to retrieve data from alternate data source.

I would recommend to check Steve Muench sample #147 (see link above), for this use case I took original code and migrated it to JDev 11g R2:


If you want to disable database access for ADF BC application, you will need to update bc4j.xcfg with proper entries. I would recommend to update this file from outside, not from JDeveloper - otherwise you may experience errors - seems like JDeveloper IDE is constantly scanning changes from bc4j.xcfg. Make sure to update bc4j.xcfg as from sample application, for example RequiresConnection=false and other settings:


Default Connection Strategy is extended to disable database connection:


Application Pool is disabled to perform passivation:


Handle Commit and Handle Rollback methods are disabled:


We are done with extending framework. Now I can describe simple use case - programmatic VO to retrieve user roles from WebLogic security provider (based on my previous post). Programmatic VO is reading data from WebLogic security provider:


View Object doesn't have any SQL statement, obviously it retrieves data from non database source:


When building ViewController, we can use regular Data Control - same as we would have from standard ADF BC:


Data is rendered successfully on ADF UI:


In this case, application runs independently of database and we still can use all powerful ADF BC data processing features.

9 comments:

kkchopra said...

Awesome....Thanks for sharing this

Rajdeep Chaudhary said...

How can we add viewcriteria to such programmaticVO ?
Any directions ?

Valon Sejdini said...

Thanks for the great share.

Does this support pagination on af:table scroll ?

Regards,

Valon

Andrejus Baranovskis said...

Nope. Pagination is coming with the new ADF release.

Andrejus

Srikanth Irukulla said...

Hi Andrejus,

You are very right in mentioning that in a SOA landscape, clients expect the applications (ADF-BC in this case) to be based on Webservices, and all the CRUD operations happen through services and zero db connectivity.

In such case, I see that most of the performance tuning to be done at the web service layer, as BC4J gets very much light-weight with not Connection/data source worries.

From your experience, Could you pls suggest what performance measures to be taken from ADF (Binding + BC4J layers) perspective?

Thanks,
Sri

Jaime said...

Hi Andrejus,

Does this implementation supports Query? I mean like ADF Query component, where you could search some fields and display it in the table. I know this can be done using EBJ or with usual data binding(with database). Just looking for your approach if this can be done, as I found it the most easiest in my case/requirements.

Hoping for your reply.

Thanks in advance!

Andrejus Baranovskis said...

This should be possible, you could define View Criteria and catch parameter in executeQuery method in View Impl class.

Regards,
Andrejus

Don Kleppinger said...

Can Sample be ported to 11.1.1.4? I get deployment error.
weblogic.descriptor.BeanAlreadyExistsException: Bean already exists: "weblogic.j2ee.descriptor.wl.SecurityRoleAssignmentBeanImpl@57d2982a(/SecurityRoleAssignments[valid-users])"

Andrejus Baranovskis said...

It could be, JDEV corrupts ADF config files. I assume it should work, but I don't have version 11.1.1.4 installed anymore to test.

Regards,
Andrejus