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

Registering an Event Provider

Registering an event provider generates a class that implements the event provider interface. Enterprise Server provides the org.glassfish.flashlight.provider.ProbeProviderFactory factory class that generates the event provider class at runtime. To generate the class, Enterprise Server uses the ASM framework for manipulating and analyzing Java byte codes.

By default, a nonoperational implementation of the methods is created. If monitoring is not enabled, which means that no listeners are registered, the methods do not consume any computing resources, such as memory or processor cycles.

Note –

The ProbeProviderFactory.getProbeProvider method is an unstable interface and is subject to change.

To register an event provider, invoke the ProbeProviderFactory.getProbeProvider method in the class that represents your add-on component. In the invocation of the ProbeProviderFactory.getProbeProvider method, pass the following information as parameters to the method:


Your choice of name for the add-on component that is to send the event.


Your choice of name for the provider.


Your choice of name for the application that the add-on component represents. The application-name can be null.


The compiled class that is to implement your event provider interface. For example, if your event provider interface is named TxManager, specify the class as TxManager.class.

Example 5–2 Registering an Event Provider

This example shows the code for registering the event provider interface TxManager for the add-on component that is represented by the class TransactionManagerImpl. The definition of the TxManager interface is shown in Example 5–1. The component name is tx and the provider name is TxManager. No application name is specified.

import org.glassfish.flashlight.provider.ProbeProviderFactory;
public class TransactionManagerImpl {
    protected ProbeProviderFactory probeProviderFactory;
     TxManager txProvider = probeProviderFactory.getProbeProvider(
         "tx", "TxManager", null, TxManager.class);