Chapter 9. Embedding Java Code Snippets

This chapter contains the following recipes:

  • Preparing the development sandbox for Java Embedding activity code in JDeveloper using the Java code placeholder in the BPEL process
  • Invoking Java code from the BPEL process
  • Reading the BPEL process variables
  • Setting the BPEL process variables
  • Invoking SessionBean from the BPEL process
  • Exploring the use of the utility functionality
  • Adding a log to the BPEL Audit Trail
  • Reading the process instance data
  • Getting the BPEL process status data

Introduction

The BPEL specification defines a finite set of activities. One of the options is to define our own functional activity via the Java Embedding activity. With the Java Embedding activity we can define any behavior in Java programming language. The Java Embedding activity can be used when we have some Java code that performs some small scale task, while we don't want to develop the complete solution as the Java application.

Tip

Note that Java Embedding is not defined by the BPEL specification. Rather, it is defined as the Oracle BPEL extension. Use this precaution when migrating the BPEL processes between different BPEL servers, as it may lead to incompatibility issues.

Inside the Java Embedding activity, we can use standard Java classes, methods exposed by the BPEL environment, and user defined extension classes. We will see this in this chapter. We can call it a session EJB3 bean.

From inside the Java Embedding activity we can access BPEL process variables. With an appropriate method, we can read variable content and set it as well. The activity provides us with methods to put a query in the BPEL process information.

In general, we use the Java Embedding activity to execute a small piece of the code. It is not intended to be used for business logic implementation. When we need to implement large business logic, it is recommended to develop the web service and then utilize it from the BPEL process.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset