Sun GlassFish Enterprise Server v3 Prelude Add-On Component Development Guide

Example of Defining an Event Provider


Example 5–1 Defining an Event Provider

This example shows the definition of the TxManager interface. This interface defines events for the start and end of transactions that are performed by a transaction manager.

The methods in this interface are as follows:

onTxBegin

This method sends an event to indicate the start of a transaction. The name of the event type that is associated with this method is begin. A parameter that is named txId is passed to the method.

onCompletion

This method sends an event to indicate the end of a transaction. The name of the event type that is associated with this method is the method name. A parameter that is named outcome is passed to the method.

import org.glassfish.flashlight.provider.annotations.ProbeName;
import org.glassfish.flashlight.provider.annotations.ProbeParam;

  public interface TxManager {
    
    @ProbeName("begin")
    public void onTxBegin(
        @ProbeParam("{txId}") String txId
    );

    public void onCompletion(
        @ProbeParam("{outcome}") boolean outcome
    );
 }