ADF 11g: Debugging Task Flows embedded from ADF Libraries using source code jars

We have been struggling quite a bit with a good approach for modularizing our ADF web applications through the use of (stand alone) Task Flows that are developed in independent projects and assembled into a single Web Application from ADF Libraries. In theory, this is a very structured, decoupled way of developing potentially complex ADF Web Applications – while allowing for reuse. The contextual events mechanism in combination with the task flow input parameters allow definition of a clear interface through which to reuse the task flow. So all seems well.

However, when you try to put this theoretical bliss into actual practice, there are some limitations that you run into. One of the tricky issues we had to deal with is: how can we debug our web application when part of the source of the application is reused from ADF Libraries? How can we put breakpoints in the sources that are part of the ADF Library?

On closer inspection, there seems to be a relatively easy way for doing this – using an additional library definition in JDeveloper that refers to the sources that form the foundation of the ADF Library.

Let’s take a quick look at how this would work:

 

Create TaskFlow TaskOne and ADF Library

Steps:

1. Create New Fusion Web Application TaskOne.

ADF 11g: Debugging Task Flows embedded from ADF Libraries using source code jars createNewTaskOneApplication

All subsequent steps are for the ViewController project:

2. Create a class NumberGenerator that returns a list of Integers.

package nl.amis.app.taskone.view;

import java.util.ArrayList;
import java.util.List;

public class NumberGenerator {
 public List<Integer> getNumbers() {
 List<Integer> numbers = new ArrayList<Integer>();
 for (int i = 0; i < 4; i++) {
 numbers.add(i);
 }
 return numbers;
 }
}

3. Create a new task flow TaskOne.

ADF 11g: Debugging Task Flows embedded from ADF Libraries using source code jars createNewTaskOneTaskFlow

Configure a  managed bean in this task flow based on the NumberGenerator class.

ADF 11g: Debugging Task Flows embedded from ADF Libraries using source code jars configureNumberGeneratorBean

4. Add a View activity to the task flow;  call it numberView.

ADF 11g: Debugging Task Flows embedded from ADF Libraries using source code jars createNumberViewJFF

5. Edit the JSFF file. Add a panelHeader and inside a Table based on the list of integers returned by the managed bean based on NumberGenerator.

<af:panelHeader text="List of Numbers" id="ph1">
  <af:table value="#{numberGenerator.numbers}" var="row" rowBandingInterval="0" id="t1">
    <af:column id="c1">
      <af:outputText id="otc1" value="#{row}" />
    </af:column>
  </af:table>
</af:panelHeader>

6. Create a new deployment profile – of type ADF Library; pick some central directory (for example C:\ADF_LIBRARIES) as the deployment destination; set the name of the archive to TaskOneLibrary.

ADF 11g: Debugging Task Flows embedded from ADF Libraries using source code jars createADFLibraryTaskOneLibrary

7. special step: create another deployment profile – of type JAR – with only the Project Source Path as Contributor (as we only need sources in this jar file); set the name of this archive to TaskOneViewControllerSources.

ADF 11g: Debugging Task Flows embedded from ADF Libraries using source code jars createJARforTaskOneSource

8. Deploy according to both deployment profiles; this should create two JAR files.

ADF 11g: Debugging Task Flows embedded from ADF Libraries using source code jars deployADFLibraryAndSources

Expose ADF Library as reusable asset in JDeveloper

Steps:

1. Make the resource palette visible in JDeveloper (choose Resource Palette from the View menu)

2. Create a new File System connection in the Resource Palette; link this connection to the directory (for example c:\ADF_LIBRARIES) where you deployed the ADF Library to.

ADF 11g: Debugging Task Flows embedded from ADF Libraries using source code jars fileSystemConnection

3. The Resource palette should now show the TaskOneLibrary and the TaskOne task flow in it

Create Fusion Web Application using the ADF Library

Steps:

1. Create New Fusion Web Application BigWebApp.

All subsequent steps are for the ViewController project:

2. Create a new JSF page; add a PanelHeader; set a title for the page

3. Drag the TaskOne task flow in the TaskOneLibrary to the PanelHeader; when you drop it, you will be asked by JDeveloper whether to add the ADF Library to the project. Press Yes to accept this.

ADF 11g: Debugging Task Flows embedded from ADF Libraries using source code jars dragTaskFlowDropAsRegion

You can make libraries visible in the project navigator by checking the option Show Libraries in the dropdown in the header of the navigator.

ADF 11g: Debugging Task Flows embedded from ADF Libraries using source code jars showLibrariesInPrjNavigator

When that option has been enabled, the ADF Library node shows all resources available in the project from ADF Libraries such as the one just added>

ADF 11g: Debugging Task Flows embedded from ADF Libraries using source code jars adfLibraryTaskOneInBigWebApp

4. special step: open the project properties for the ViewController project; go to the Libraries and Classpath tab and add a new library (press add, then press new). Call the Library TaskOneLibrarySources. Click on the Source Path node; click on Add Entry and browse to the  TaskOneViewControllerSources.jar.

ADF 11g: Debugging Task Flows embedded from ADF Libraries using source code jars addLibraryBasedOnTaskOneSources

note that this library does not impact the compilation, build or deploy process in any way as it only contains sources; it provides a means to debug the ADF Library code by making the sources available to JDeveloper, that is all.

5. When the option to show libraries in the project navigator is active, the new library TaskOneLibrarySources should be visible. You can expand it to inspect all sources that are part of this library. Open the NumberGenerator class – and create a debug breakpoint in the method that returns the list of numbers.

ADF 11g: Debugging Task Flows embedded from ADF Libraries using source code jars TaskOneLibrarySourcesInPrjNavigator

6. Debug the BigWebApp application. You should see the debugger hitting the breakpoint that you added in the NumberGenerator class that is used in the task flow that we added from the ADF Library.

ADF 11g: Debugging Task Flows embedded from ADF Libraries using source code jars hittingTheBreakPoint

After resuming processing from the breakpoint, at long last the utterly unimpressive BigPage is shown in the browser:

ADF 11g: Debugging Task Flows embedded from ADF Libraries using source code jars bigpageRunning

Conclusion

Clearly, in this way we can debug sources for objects used inside reusable task flows that are shipped in ADF Libraries, as long as those sources are made available to us alongside the ADF Libraries themselves in source jars. Note that without the source jars, we can still use those ADF Libraries and the task flows inside them; we will just not be able to properly debug the web application in its entirety.

Resources

Download sources for the applications discussed in this article: DebugADFTaskFlowsInADFLibraries.zip.

One Response

  1. Name (required)RE August 8, 2011