Sunday, November 28, 2010

Immediate Row Level Lock Management for ADF 11g Transactional Applications

Oracle ADF 11g framework is primarily designed for enterprise applications. Majority of enterprise applications are processing user transactions, it is important to preserve proper transaction state for every user. Oracle ADF 11g out of the box provides pessimistic and optimistic locking support - Optimistic and Pessimistic Locking in Oracle ADF BC. Generally, optimistic locking is recommended for Web applications, pessimistic locking mechanism will lock current record once user will edit it. However, for specific applications (especially bank and insurance sector), we have quite natural business requirement to lock record directly after this record was opened for editing. Such type of locking is stronger than pessimistic locking - it locks record even before user starts editing it. Its very important to understand how to tune and control ADF 11g runtime parameters, when implementing immediate locking solutions. Today I will describe how immediate locking use case can be implemented with ADF BC and ADF Task Flows. My next posts will provide information about ADF BC parameters tuning for reliable immediate row locking mechanism.

Download sample application - This sample contains one ADF task flow based on JSF fragments. Default activity represents read-only table with Employees data. When user hits employee editing button, navigation is passed to Method Call activity - it invokes method from Application Module Implementation class to lock current record from Employees VO. If current record is not locked by another user - lock is set and editing screen opens successfully. Otherwise, if current record is already locked by another user - we render information message and display data in read-only mode:

Immediate row locking mechanism is implemented by overriding AM and EO implementation classes:

Custom row locking method from AM implementation class is exposed through client interface:

This method retrieved current row from VO and invoked VO lock method. If current row is already locked by another user or lock fails, we catch exception and return negative parameter value into Controller layer:

If current row is already locked, we want to render it in read-only mode. This can be achieved by overriding isAttributeUpdateable(int i) method from EO implementation class. If attempt to lock current record failed, this means user can't edit any attributes - read-only mode:

Controller layer receives result of locking method from AM implementation class and stores into Page Flow Scope:

This value is used to render or not information message about failed locking attempt:

Rendered property is referencing value from Page Flow Scope:

If current row was not locked by another user and current user performs successful lock - lock will remain until user will commit or rollback his changes for current row. Its almost true, but not completely. What will happen if user will close browser without performing commit/rollback or even without doing proper logout action? Good news - obtained lock will be removed automatically, after web session times out. After web session time out, database connection still will remain open and can be reused by another AM instances. However current web session AM instance will be destroyed, this means database lock obtained by that session also will be removed. This means if user will forget to commit/rollback or logout, longest time when current row will remain locked is equal to web session time out time. You should keep this in mind, when configuring and tuning your ADF 11g application. Default web session time out - 30 minutes is sufficient in most of the cases.

In order to test locking behavior, I have set web session timeout to 5 minutes:

Let's experiment a bit and see how it works. User A logs in into application and opens Employees list screen:

User A select record and opens it for editing, lock is applied automatically:

We can see from the log, lock is successful for user A:

Another user B selects the same record:

And opens it for editing, however same record is already locked by user A - lock for user B fails and data is rendered in read-only mode with information message:

Lock for user B fails:

Lock from user A will remain until commit/rollback or logout. Let's say user A will not do any of mentioned actions and just will leave from his work place by closing browser or keeping it open. Two sessions, one for user A and another for user B are active:

Because of inactivity, user A session will timeout after 5 minutes (as it is set in web.xml) and AM instance will be released:

When user A will return to check his work, he will receive session timeout message and will be forced to login again - of course lock will be lost:

Next release of ADF 11g - PS3 provides user-friendly popup message for session timeout.

After waiting 5 minutes (session timeout for user A), user B will be able to lock released record and perform required changes:

Thursday, November 25, 2010

Navigation Between ADF Task Flow Template and Consuming ADF Task Flow

ADF task flow can be based on ADF task flow template by reference or by copy. If we base it by copy, this means template contents will be copied directly into consuming ADF task flow. All subsequent changes happening inside template, will not be propagated to consuming ADF task flow. In the opposite, when ADF task flow is using template by reference - all template changes will be reflected in consuming ADF task flow. I would recommend to follow template by reference option, however you need to understand few tricks with this approach. Today I will describe how to invoke navigation between ADF task flow template activity and custom activity from consuming ADF task flow.

Download sample application - When working with ADF task flow templates, first you should create ADF task flow template itself:

Template contents can be defined later, initially you can create ADF task flow based on that template by reference:

Specify Base on Template option and choose to update when ADF task flow template is changing - by reference:

Now we can define ADF task flow template contents. We will have one simple fragment activity for Jobs data. There is also one global activity, it points to Jobs fragment and defines details outcome. One important thing you must understand, is that we will override this outcome later inside consuming ADF task flow and will be able to point to custom fragment:

Jobs fragment from ADF task flow template contains Details button. This button is supposed to navigate based on details outcome:

It is using details outcome as navigation action:

Consuming ADF task flow, which is based on ADF task flow template is overriding details outcome name and point to employeesDetail fragment. This allows to navigate from ADF task flow template fragment to fragment defined directly inside consuming ADF task flow:

Fragment from consuming ADF task flow, brings Employees data based on currently selected Job - Master/Detail:

One more trick - we want to navigate back from Detail fragment to Master, this means we need to have navigation back to ADF task flow template fragment. Jobs button:

We will follow the same approach, and will define one more global navigation inside ADF task flow template - jobs. This navigation will not be overridden in consuming ADF task flow:

Jobs button from consuming ADF task flow fragment should use jobs outcome for navigation action:

Jobs fragment from ADF task flow template displays FI_ACCOUNT job data:

User can press Details button - it will execute overridden navigation and bring Employees fragment from consuming ADF task flow:

We can navigate back by pressing Jobs button, it will return to ADF task flow template fragment:

Friday, November 19, 2010

BPM Portal - How To Configure Oracle BPM 11g Process Portal on Oracle WebCenter Spaces 11g

Oracle BPM 11g is attractive product for enterprise customers, one of the reasons - it can be integrated with custom enterprise applications through portal - Oracle WebCenter Spaces 11g. I had chance to discuss with several interested customers, most of them are facing issues to setup and run both domains together - SOA/BPM and WebCenter. Time ago I have promised to discuss configuration process - Oracle BPM 11g Integration with ADF and WebCenter Suite - Quick Overview. It is very interesting and challenging topic. Chapter 3.2 Using Oracle Business Process Management Suite with WebCenter Spaces from Oracle BPM 11g Installation and Configuration guide is very abstract, without details. Its what I will try to fix today.

In order to get better understanding and to see sample screenshots of Oracle BPM 11g process portal, you can check Oracle BPM 11g User's guide chapter 9 Getting Started with Oracle Business Process Management Process Spaces (Process Spaces).

Finally, there is Oracle Fusion Middleware 11g Patching Guide, where you can find basic steps how to extend WebCenter Spaces 11g domain with Oracle BPM 11g functionality. Read section Enabling Process Spaces in a WebCenter Domain from this guide. In few words, you need to go to Oracle BPM 11g installation folder, extract process portal package, provide valid parameter values, run script and thats it. We will look today into these properties and will see how to extend WebCenter Spaces 11g.

You can download Oracle BPM 11g and WebCenter Spaces sample configuration properties from my environment -

Go to Oracle SOA 11g and BPM 11g domain installation and open bpm folder:

Extract process portal package, you will find file there:

Taskflows folder contains ADF Libraries with standard BPM 11g ADF task flows, we can copy into the same folder our task flows, if we want them to be available in WebCenter Spaces 11g process portal:

My process portal contains three ADF Libraries with custom ADF 11g task flows.

In order to make these ADF task flows visible in WebCenter Spaces 11g, go to util folder and edit DefaultGroupSpaceCatalog.xml file:

This file should include references to our custom ADF 11g task flows available in ADF Libraries. Same file contains declarations for standard BPM 11g task flows as well:

Now we are approaching towards main part of this blog post - process portal installation properties:

I will walk through and describe all important properties:

#Flag to decide whether to extend existing BPM domain or create a new one.

Default value is false, this means script will integrate Oracle SOA/BPM 11g and WebCenter Spaces 11g domains, also it will extend WebCenter Spaces 11g with standard ADF BPM 11g and custom ADF 11g task flows.

For initial script execution, always use false, once domains are integrated - always use true.

#webcenter spaces installation details
#If extendSoa flag is set to true, then configure the below two properties to point to BPM domain
#Flag to control whether to set domain realm password or not
#This is the password to setup trusted domains. Same password should be set on BPM domain as well

Provide installation details for WebCenter Spaces 11g domain. Ignore comment in the script about extendSoa flag. If you are running script for the first time (integrating SOA/BPM 11g and WebCenter Spaces 11g domains), make sure you are providing correct WebCenter Spaces 11g domain realm password, it must be same as it is set on SOA/BPM 11g domain. This will allow to communicate both SOA/BPM 11g and WebCenter Spaces 11g domains between each other. You can set domain trust password on SOA/BPM 11g domain manually, go to domain settings and select General section from Security tab:

Scroll down to the advanced section and change SOA/BPM 11g credentials, to the same value as you are planning to use for WebCenter Spaces 11g domain:

If Oracle Universal Content Management and Discussions are not configured yet on WebCenter Spaces 11g domain, you can configure them by providing following property:

#Flag to control whether to configure services

If these services already in place, set this property value to false.

Properties for Oracle UCM are pretty straightforward:

#content server details

Same for Oracle Discussions:


The rest of the properties, you can find in my sample installation properties file from above.

Execute install.xml script with ant:

This will configure and integrate SOA/BPM 11g and WebCenter Spaces 11g domains together or will extend WebCenter Spaces 11g domain with custom ADF 11g task flows, bases on extendSoa property value.

After few minutes, when configuration will be finished, you should restart WebCenter Spaces 11g managed server:

BPM 11g process portal - Process Workspace becomes available in WebCenter Spaces 11g:

Our custom ADF 11g task flows are available as well and can be added from the resource catalog:

Its how standard BPM 11g functionality can be integrated and accessed from portal environment, where our custom ADF 11g applications are accessible as well.

Sunday, November 14, 2010

Things You Must Know About ADF Faces Login Page

Oracle ADF 11g Developer Guide is primary source of information for every Oracle Fusion 11g developer. About security implementation, you can read from chapter 30.7 Creating a Login Page. What is the difference between smart and regular developer? Smart developer is proactive and always knows more than it is described in developer guide :) I will present today few aspects of ADF Login Page implementation you should keep in mind, when working with ADF Security.

I will use typical ADF Faces page to implement login screen - /faces/login.jspx:

I was using ADF Security wizard to define login page, just following documentation steps and I got strange behavior. When I'm running application, it redirects to login page - opening it, but just hangs and never brings login screen:

There are no errors or warnings in the log:

However, you should know - when ADF Faces page is defined as login page, even there is no page definition defined - it will be generated automatically:

When there is page definition, page will be automatically protected by ADF Security. Because there are no any grants by default for login page, it will be not accessible:

At the same time this page is defined as login page - framework is trying to load it, but fails because no permission defined. Its why application simply hangs.

In order to make it work, you need to specify anonymous role for login page - this will allow to render login screen:

When we are implementing ADF Faces login page, we can process username and password data, before doing authentication. We can set username to lower case, some LDAP systems are case sensitive - this will allow user to login, even he will type username in upper case:

If you are already working with new JDeveloper 11g PS3 beta release,  probably you have noticed that SimpleCallbackHandler class is deprecated:

Documentation still references deprecated SimpleCallbackHandler class for login action. Probably it will be update later with URLCallbackHandler class. Sample application for this post is using that class:

In order to test login functionality, I'm using mix of upper and lower case for username:

Login action is performed successfully with URLCallbackHandler class, username is converted to lower case:

Download sample application for this post -