Throughout the recipes in this chapter we saw quite a few lines of auditing (addAuditTrailEntry
). We did not explore them in any of the recipes, as this recipe is dedicated to exploring the possibilities of auditing in the Java Embedding activity.
Open the BPEL_and_Java_1_1
process and insert the Java Embedding activity (Auditing
).
We insert the code into a snippet as follows:
Object input_obj= getVariableData("Input_Txt_Var");
addAuditTrailEntry("Input data", input_obj);
try { Double whatNumber = Double.parseDouble((String)input_obj); addAuditTrailEntry("Number is:", whatNumber); } catch (NumberFormatException nfe) { addAuditTrailEntry("Not a number ?"); addAuditTrailEntry(nfe); }
The Java Embedding activity offers three addAuditTrailEntry
method signatures for auditing information:
void addAuditTrailEntry(String message)
void addAuditTrailEntry(String message, Object detail)
void addAuditTrailEntry(Throwable t)
We are able to audit a simple string message
. If we want to output information about the objects, we can use the auditing method with two parameters: a string message
and an object detail
. In cases of handling exceptions, we utilize the auditing method that accepts the throwable
parameter.
Let us now instantiate the BPEL process and enter a number as an input parameter. Inspect the Audit Trail to see the auditing information:
Additionally, run another instance of the BPEL process and enter the content of the parameter that is not a number (for example, abc). Check the Audit Trail now and check the auditing information of the exception: