Monday, August 31, 2009

Oracle ADF Tuning: Preventing SQL Query Execution on Page Load

While tuning Oracle ADF application in our team, we have discovered extremely good approach for application tuning on page load time. You can read about this problem in my previous blog post as well - Improving Performance in ADF Applications - Page Load Time in CRUD Forms.

Main idea of tuning approach is to prevent default query execution on page load and do it as easy as possible. We have achieved this by invoking executeEmptyRowSet() method for master View Object before opening page itself. We are performing invocation from Method Call activity in ADF Task Flow. Download sample application - ADFPageOpening.zip.

How it works: let's open our data entry page from main index page:


Data entry page opens in Insert mode. However, by default even page opens in Insert mode, framework still is sending default SQL query to database. If this query is complex and database performs many joins, it will take time to open your page. With this approach I'm describing today, no SQL query will be sent to database and page will open fast:


If user wants to edit data, ADF Query component should be used to filter data, only at that point SQL query will be sent to database:


How its implemented: ADF Task Flow contains Default Activity, this means it will be invoked each time when entering ADF Task Flow. This activity is Method Call:


This Method Call is invoking custom method implemented in Application Module implementation class - initPage() method:


Custom method implements call to executeEmptyRowSet() on master View Object and inserts new row. Method executeEmptyRowSet() prevents SQL query execution on page load by creating empty row set and in such way initializing iterator:


Spanish Summary:

En este artículo se explora una carateristica de ADF Business Componentes que permite evitar realizar consultas innecesarias a la base de datos mejorando la performance de las aplicaciones.

Tuesday, August 25, 2009

Integration in Oracle ADF with ADF Task Flows and ADF Security Configuration

Few weeks ago I was blogging about how you can split Oracle ADF application into smaller parts and optimize its structure. Read my previous post - Integration in Oracle ADF Through ADF Libraries and ADF Task Flows. Today I will show how you can add ADF Security and use it in integrated environment.

Download sample application updated from previous post - ADFIntegration2.zip. Its the same application described in my previous post, now updated with ADF Security.

I should say, currently there is no elegant approach for ADF Security integration from different applications. Its supposed to be possible to define multiple Policy Stores and declare them in JPS configuration file. I have tried this, however it always using first available Policy Store. Also I was thinking to put jazn-data.xml outside my ADF application, in order to reuse the same jazn-data.xml in multiple applications - but without success. Yes, its possible to specify custom jazn-data.xml file location in JPS configuration file, however current JDeveloper 11g release can't recognize it during design time. Most probably Oracle will fix it in their new JDeveloper 11g build and it will be very easy to split ADF Security across integrated applications. For now, we are using approach to have separate jazn-data.xml per application and in main application jazn-data.xml to store policies from all available jazn-data.xml files. We need to have Policy Stores in splitted applications, since we want to test ADF Security during development cycle.

Will describe how I have applied this approach in my sample application. First, I have configured one of splitted (RemoteSecondApp) application with ADF Security through standard wizard and set permission for ADF Task Flow:


I have declared RemoteSecondApp Policy Store for this application, where security role manager was defined and user scott granted with this role:


In the second splitted application (RemoteApp) I did the same action and declared permissions for ADF Task Flow. In this case, I have assigned to roles with grant to open ADF Task Flow:


Same again, specific Policy Store was defined - RemoteApp and two roles created - manager (scott user) and developer (john user):


Worth to mention, in this Policy Store I have defined permission for Entity Object - preventing unauthorized user from editing data. Its defined on Entity Object and grants permission to edit roles only for manager role:


Now let's see main application - LocalApp. I have defined there Policy Store as well, its called as you can predict - LocalApp. I have defined there new role employee and copied two roles from splitted applications - manager and developer:


I should mention - both users (scott and john) are granted with employee role, it allows them to open entry page from LocalApp application. As I said before, policies from splitted applications are copied there in order to make it work when we will run central application:


We can see grants in jazn-data.xml from central application, where ADF Task Flows imported through ADF Libraries are visible. Those grants are local, copied and read from local jazn-data.xml:


Now we can test ADF Security in both - splitted applications and central one, no difference. When I'm running central application and entering with user granted only developer and employee roles:


Table from integrated application, where I have declared permission for Entity Object will be rendered in read-only mode:


Since this user don't have permission to open ADF Task Flow from second integrated application, authorization error is shown, thats correct:


When entering with user assigned all roles:


Same table is rendered in editable mode:

Saturday, August 22, 2009

Business Events and ADF Business Components in Oracle Fusion 11g

I continue a series of posts, where I'm describing Oracle SOA Suite 11g and JDeveloper 11g functionality. Before reading this post, you might be interested to read my previous posts - Web Service Interface for ADF BC Application Module in Oracle Fusion 11g and Service-Enabled Entity Objects in Oracle Fusion 11g. My today post sample application is based on mentioned blog posts.

Business Events and Event Delivery Network (EDN), its something that makes Oracle SOA Suite 11g really strong integration platform. While discussing with customers, usually everyone is seriously concerned about loosely coupled integration, no one wants to integrate IT systems with strongly coupled services. Thats logical, because there are different systems and those systems constantly changing. Oracle SOA Suite 11g allows to implement loosely coupled integrations with Business Events. You can understand Business Event as a signal, that was sent by radio transmitter. Transmitter knows nothing about receivers, its receivers business to subscribe to particular event. Oracle SOA Suite 11g brings Event Delivery Network (EDN), space where Business Events can be raised and received across SOA infrastructure. Business Events in SOA Suite 11g can be raised not only from ADF Business Components, but from BPEL process for example as well.

Today I will use both applications from my previous posts mentioned above. I will add Business Event to application described in Service-Enabled Entity Objects in Oracle Fusion 11g post, you can download updated sample - SalaryUpdateRemote2.zip. Additionally for today post I have implemented SOA Composite where I'm subscribing to Business Event raised from ADF Business Components - SalaryManagement.zip. You can find more info about Business Events and EDN in Oracle SOA 11g Developer Guide Section 44 Using Business Events and Event Delivery Network, also check Edwin Biemond post - Events in ADF BC and handled by the SOA Suite Mediator.

Good news - we can declare Business Events on Service-Enabled Entity Objects, it works same as declared on normal Entity Object. Here is declaration:


In Business Event definition I have specified to track Salary attribute value changes. Along with changed Salary attribute value, I want to add to the payload EmployeeId attribute value. Event is published and will be raised during Update action based on Salary attribute change.

Thats all about Business Event definition in ADF Business Components, now I will develop SOA Composite where I will subscribe to Business Event. Implemented SOA Composite:


SOA Composite contains two Components (Mediator and BPEL process) and one External Reference (File Adapter):


Mediator subscribes to Business Event, and forwards it to BPEL process, where Business Event data is written to file system. In this post I'm focusing on Business Events from ADF Business Components, in my next post I will focus on BPEL process implementation. Mediator receives Business Event, BPEL process will manage it, this means Business Event schema transformation should be defined:


Schema transformation can be done automatically in JDeveloper 11g:


Basic BPEL process for today post, received Business Event data is stored in file system using File Adapter:


File adopter is defined with the same WSDL as BPEL process, means it will know Business Event input data format and will store information in C:/tmp folder:


I have deployed both applications (ADF application and SOA Composite) to Oracle SOA Suite 11g WebLogic server and opened ADF Application screen:


Data is retrieved through Service-Enabled Entity Object from Web Service. I will change Salary value and press Save button to update Salary attribute value:


Business Event was raised from ADF Business Components, subscribed Mediator from SOA Composite received it and forwarded to BPEL process where data was written to file system:


You can see that we received Employee Id and changed Salary attribute values.

Let's see process flow in Oracle Enterprise Manage Web console for Oracle SOA Suite 11g. We can see there log for all SOA Composite - SalaryUpdateComposite instances:


If I click on latest instance, I will get its trace log:


You can click on SalaryManagementProcess and open visual process flow:


And finally if you click on InvokeSalaryChangeLog BPEL Invoke activity, as well you will see there data from Business Event:


Spanish Summary:

Este post muestra una carateristica de integración entre Jdeveloper 11g and SOA Suite. En esta oportunidad se muestra el uso de los Business Events, para intercambiar y almacenar información de los salarios de los empleado usando SOA y los ADF Entity Objects.

Thursday, August 13, 2009

Service-Enabled Entity Objects in Oracle Fusion 11g

In Oracle Fusion 11g, JDeveloper provides great support for Application Integration Architecture (AIA) through Service-Enabled Entity Objects. It allows to build Enterprise Composite Applications (ECA) in Oracle ADF. Developer now can implement Entity Objects directly based on View Objects from remote application, exposed through Web Service. This means we can expose and consume Web Services on Model level using ADF Business Components, this gives more centralized integration approach. Its especially important for AIA, when building ECA. For more info, please read Section 11.3 Accessing Remote Data Over the Service-Enabled Application Module from Oracle Fusion Developer Guide. In this post I will describe some tips and tricks from my experience.

I have investigated Service-Enabled Entity Objects in greater detail and developed sample application. Sample is based on two JDeveloper 11g applications, first - SalaryUpdateRemote.zip is consuming remote Web Service on Entity Object level, second - SalaryControlService2.zip implements this Web Service. Application with Web Service implementation was developed in my previous post - Web Service Interface for ADF BC Application Module in Oracle Fusion 11g, where I have described how to expose through Web Service custom methods from Application Module implementation class. I have updated previously developed application in order to use it in current post, additionally have exposed View Object itself through Web Service.

I'm using Employees View Object from SalaryControlService application to be accessed through Web Service:


In SalaryControlService Application Module Service Interface, you can see EmployeesView1 exposed as View Instance:


I have declared three operations to be enabled for EmployeesView1. Find is required operation to retrieve data, Update operation will be used to edit employees data through remote Entity Object:


When Service Interface for View Object is defined, we can redeploy SalaryControlService. I have accessed redeployed application through Enterprise Manager console, updated list of operations is present now:


We need to note down WSDL URL, it will be needed soon, when we will define Entity based on Service Interface.

Its time to open application, where View Object is consumed over Web Service - SalaryUpdateRemote. Its pretty basic application:


Only one interesting thing - Employees Entity Object is based on Service Interface, we can see this from DataSource tag. This Entity Object is based on View Object exposed through Web Service, instead of Database table:


When you base Entity Object on Web Service interface, same as you generate it from Database table, all attributes are defined:


To create Entity Object based on Service Interface, in Create Entity Object wizard select Service Interface option for Data Source. You will be requested to provide WSDL URL for Web Service, available Service View Instances will be listed automatically:


All other steps are the same, as when creating Entity Object based on Database table. When I have created View Object referencing Service-Enabled Entity Object, I have noticed that Query section is empty:


Thats logical, because data will be retrieved on runtime through Web Service. However, this means that Service-Enabled Entity Objects can't participate in joins and can be used only as primary objects. For more info read Section 11.3.7 What You May Need to Know About Service-Enabled Business Component Restrictions from Oracle Fusion Developer Guide.

Finally, in order to test Service-Enabled functionality, as described in documentation you need to include common library from Web Service application:


And define service connection information in connections.xml file:


You can copy paste this information from Web Service application and just add couple parameters. In documentation they say we can access remote Web Service with Local or Remote Business Components Service configuration. Local can be used when Business Components Service runs local to the consuming application. However, I wasn't able to run with Local configuration, seems it was trying to load two Application Modules on Class Path and then conflicting. Good news, I was able to run with Remote configuration:


In jndiProviderURL I have specified IP and Port of my WebLogic domain extended with SOA support.

Now its time to run Application Module and test Service-Enabled Entity functionality:


Because I have enabled Find and Update operations, I can browse and edit data retrieved from Web Service View Object instance:


I have developed ViewController part as well, where I have implemented simple edit type form for Employees data. Finally, I have deployed application with Service-Enabled Entity Object to the same WebLogic domain with SOA support, where original ADF BC Web Service was deployed. I have noticed, if you want to use Service-Enabled Entity Object in ViewController, common library from Web Service application should be added to ViewController classpath:


But its not enough, additionally you should open deployment profile and in WEB-INF/lib Contributors section ensure that added common library is selected for deployment:


If its not selected, this means it will be not packaged into EAR there will be runtime exception when trying to access Web Service through Entity Object.

When SalaryUpdateRemote application is deployed:


We can access main page and retrieve Employees information through remote Web Service directly using ADF Business Components. Data can be edited and saved to database through Web Service:


Its very interesting and useful functionality, if there will be decision to implement Salary attribute validation rule, there is no need to implement it on Service-Enabled Entity:


It can be done directly on original Entity Object available in ADF Business Components exposed through Web Service - SalaryControlService application:


Data from consuming application will be sent to Web Service and validated there centrally. In case of invalid data, remote application will show error:


Spanish Summary:

Este post ofrece un ejemplo de una nueva caracteristica que ofrece Jdeveloper para permtir la creacion de entidades en base a ViewObjects que pertenecen a aplicaciones remotas, las cuales son accedidas por medio de WEB Services. De esta manera nuestras aplicaciones pueden implementar rápidamente Enterprise Composite Applications (ECA) usando ADF.