Saturday, June 29, 2013

Red Samurai - Indiana Jones Style in Africa

Red Samurai is known for ADF guru development around the globe. But there is a secret I want to share, in addition to Oracle work, we do special intelligence assignments and rescue missions.

Here you can view one leaked video, where we are in action during recent mission in Africa:


So, if you got any troubles and can't sleep peacefully, call us and we are here for your service. ADF bugs better keep away!

Tuesday, June 25, 2013

Create Row from the Standard ADF UI LOV Component

There is one less known feature of ADF UI LOV component. There is a way to enable additional built-in button for ADF UI LOV popup, this button is rendered as create type icon. Custom popup can be attached to that button and then we can render pretty much anything from that custom popup. I will show you how this is done, based on Oracle ADF UI developer guide - Create Icon in Toolbar of Popup Dialog. This is useful when you want to allow users to maintain the list directly from ADF UI LOV popup.

Sample application - LOVNewRowApp.zip contains LOV component for JOB_ID:


There is ADF UI LOV component property - CreatePopupId. You should set ID of your custom popup you want to be loaded from ADF UI LOV, button with create icon will be rendered out of the box for you once this ID is set:


My custom popup implements listeners to be executed on fetch and on cancel, this is needed to prepare new row when popup loads and roll it back in case of cancelation:


Set dialog listener to perform transaction commit and insert new record:


Source code for these listeners is pretty simple, it calls methods from bindings:


Here you can see regular ADF UI LOV rendered with create icon just above the results table:


Hit this create button and referenced custom popup through ID will get displayed. Popup fetch listener creates new row before popup is loaded, so we can see blank row inserted:


Type data for the new job and press OK:


Custom popup will be closed and newly inserted record will appear in the LOV list instantly (you may need to press Search button in the LOV window):

Monday, June 24, 2013

Announcement - Red Samurai Code Quality Tool Version 2.0

We are busy packaging new version of our Code Quality Tool. Previous version was posted almost 3 years back - Red Samurai Tool - JDeveloper 11g Extension to Validate ADF Code Quality Version 1.1. It is time to update it now, based on new experience from ADF projects. We are going to include only generic rules that possibly can be applied for variety of ADF projects.

Main new features:

1. Compatible with JDeveloper 11g R2

2. Based on standard JDeveloper OJAudit engine

3. Rules are executed and displayed instantly during design time, together with standard JDeveloper warnings and errors

4. Command line execution is possible through OJAudit profile

5. Automated fixing rules. These rules report code quality violation and do automatic fixing in batch

6. Easily extendable, new rules can be added anytime through separate Java class

7. Configurable through JDeveloper environment:


Stay tuned, download will be available soon.

Sunday, June 23, 2013

Calling ADF BC Web Service from BPM Process

This post is about calling ADF BC Web Service from BPM Process. In order to keep track of the steps executed in the process I will be calling ADF BC Web Service, passing task outcome and updating database table. This is quite handy, especially when identifying and recovering failed BPM process instances. You could implement process instance replay, when process instance execution data is stored in the DB. For this purpose I will pass process instance ID to the ADF BC Web Service in order to identify and assign current process task.

Run sample application - adfbpmapp_ps6_v3.zip and start new process:


We can see from BPM log - first task is completed and call to ADF BC Web Service is executed:


Same can be visualized in the process flow:


Database is updated through ADF BC Web Service with current process instance ID, payload ID and task outcome - started:


Push task further by submitting it for approval:


This will be visualized in the process flow - invoking status update through ADF BC Web Service and arriving to approve employee task:


Database is updated for the current process with the task executed set to be assigned:


Let's reject this task now:


Process flow comes back to original assigning task:


This is logged in the DB - status reject:


Start new task and you will see that record with new process instance ID will be created, assigned with different status:


Finally if first process instance gets approved:


We can see this updated in the DB - status approve:


This was quick description about how such functionality works, now I will describe important things from technical perspective.

First issue you will encounter when calling ADF BC Web Service from BPM process - Data Source driver compatibility. By default ADF BC is using non-XA data source driver, however this should be changed when calling ADF BC from BPM process. If you would use default non-XA driver, there will be error generated related to transaction failure and driver type:


Go and declare second driver for your ADF application, now XA type driver:


Make sure you select it for the application module configuration serving ADF BC Web Service:


ADF BC Web Service method itself executes View Criteria to search for process instance ID. If such ID was already logged, it updates the record, if not - creates new record:


Here we can see custom method from Application Module Implementation class exposed as ADF BC Web Service method:


Make sure to set additional listener class in weblogic.xml of ADF BC Web Service application, otherwise ADF BC Web Service method will not be located from BPM process. Add this listener - oracle.jbo.client.svc.ADFApplicationLifecycleListener:


You need to copy ADF BC Web Service WSDL URL and use it in BPM process to define service call:


Here you can see ADF BC Web Service invocation service call defined in BPM process:


Very important is to set correct Registry property for the service call defined on top of ADF BC Web Service. Registry property must start with ADF BC Web Service deployment application name and end with JBOServiceRegistry system keyword (there must be _ between these two).

ADF BC Web Service payload values are initialized through data association. Process instance ID is set from predefined BPM process variable - ecid:

Thursday, June 20, 2013

ADF BC 11g PS6 DB Pooling Threshold (New) Property

During OOW'12, it was announced by ADF BC team - new tuning property for ADF BC with DB pooling enabled, coming in the next releases - jbo.ampool.connection_threshold. The main idea is to keep connected JDBC connections until predefined threshold limit is reached, once limit is reached - ADF BC will be returning least used JDBC connections back to the pool. This would allow to keep less open JDBC connections and at the same time for active AM's it will not disconnect JDBC connection on each request. Currently with DB pooling enabled, JDBC connection is disconnected and returned back to the pool after each request (still it works quite well) - Stress Testing Oracle ADF BC Applications - Do Connection Pooling and TXN Disconnect Level.

As per Jobinesh post - Smart database connection pooling with new jbo.ampool.connection_threshold parameter, threshold property for ADF BC DB connection pooling was introduced already in ADF 11g PS6 (11.1.1.7). However there is no official documentation regarding this yet, at least in ADF 11g PS6 (11.1.1.7) developer guide.

You should keep in mind - connection threshold works only when DB pooling is turned off. I was expecting opposite behavior - to disable connection pooling until threshold limit is reached and then do connection pooling. While with threshold setting, ADF behaves in default way until limit is reached and only later after AM timeout it will start to release connections back to the DB pool.

So, I decided to give a test and see how it works. Download sample application test case - DBConnectionThresholdApp.zip.

The test is really simple to check if ADF BC in 11g PS6 is able to keep threshold of so called sticky DB connections. Set now new property jbo.ampool.connection_threshold = 5. You can set any number here, doesn't matter. I just set 5 to assume that threshold will be 5 sticky JDBC connections, and when there will be more than 5 AM instances created in parallel and JDBC connection usage will grow, some of the JDBC connections will be returned back to the pool:


I will be testing ADF application with 6 concurrent users, meaning 1 JDBC connection should be released and 5 will be reserved.

Open ADF application test case and click around. I have started 7 diffent sessions:


As I can see from the log, 7 DB connections were reserved:


Two of these connections will be released later, when AM pool monitor will be cleaning inactive AM's. This is good, but still it seems to be implicit DB pooling is better.

I will do stress test to compare threshold tuning vs. DB pooling and post results.

UPDATE 2013/06/21 - Property jbo.ampool.connection_threshold is an undocumented feature and there is no guarantee that it will work across all servers and platforms. And this is not for public use at the moment.

Monday, June 17, 2013

Fix for View Criteria Search Results with DB Pooling Enabled

In order to minimize DB connections usage and optimize ADF runtime performance, I often prefer to enable DB pooling and keep data between requests in memory (jbo.doconnectionpooling = true and jbo.txn.disconnect_level = 1). Read more in this post - Stress Testing Oracle ADF BC Applications - Do Connection Pooling and TXN Disconnect Level. There is one bug related to the View Criteria search results - rows are not always displayed correctly. I will describe the fix.

Sample application - SearchRefreshDBPoolApp.zip is enabled with DB pooling:


Disconnect level is set to 1 to keep data between requests in memory:


Do a search for the last employee in the rowset - Gietz:


As soon as results list will be filtered:


Clear up search criteria for the LastName and search again with blank criteria to get all rows:


Not all rows are retrieved to the UI, you can try to scroll up and down - still results list is incomplete. Only if you press Search button second time - then results list will be refreshed and bring correct results.

The fix is to set ContentDelivery=Immediate for the table component:


After repeating same test scenario, results list will be complete from the first time:

Saturday, June 15, 2013

Passing Payload Value from ADF to BPM Process Task

This post describes how to pass payload value from ADF programmatically and assign it to the BPM process task. This is one of the important points for ADF/BPM integration, along with programmatic process task initialization we are able to assign process task payload and pass dynamic values.

Sample process from demo BPM app -  adfbpmapp_ps6_v2.zip, works with Employee type payload. Employee data is submitted in the input and output of the process task:


Process is initialized programmatically, AssignEmployee task is process automatically by completing this step from ADF through BPM API. User is navigated to AssignEmployeeReview task automatically - this is how sample process works:


Once new process task is initialized, we are setting payload variable based on initialized task ID and processing the task. From the same bean, tasks table is refreshed by the ADF poll component to display latest changes. BPM process task starts asynchronously and ADF UI may not display it immediately:


Payload value is assigned by getting task payload XML element and setting value by ID. In this example only Employee ID variable is initialized for the payload:


BPM process works in the similar way as ADF Task Flow - navigation between process tasks is controlled by outcomes. As you can see SUBMIT outcome is defined in the task definition:


Finally ADF UI part defines ADF Poll component to reload tasks table automatically every 10 seconds to display asynchronously started BPM task list:


User redsam1 selects employee row - 101 in this test:


Goes to Assigned Tasks tab and from there starts new process (payload for Employee ID is retrieved from current row set in Employee Data tab):


As you can see from the screenshot above - task was created, but not yet displayed in the list. Since list is auto refreshed - it will be loaded in the next 10 seconds:


If you go to the standard workspace task flow and display associated human task UI for selected process task, it will display Employee ID 101 from process payload assigned by method in ADF:


Submit selected task for further processing, payload value will be transfered by BPM to the approver redsam2 user:


Through BPM process instance tracker we can double check - payload was set programmatically correctly, value 101 is displayed: