# Platform Development Studio - Developer’s Guide

# Creating an EDR Listener and Generating SNMP MIBs

The following section describes how to create an external EDR listener.

- Overview of External EDR listeners

- Example using a pure JMS listener
- Example using JMSListener utility with no filter
- Using JMSListener utility with a filter

- Description of EDR listener utility

- Class JMSListener
- Class EdrFilterFactory
- Class EdrData
- Class ConfigDescriptor
- Class EdrConfigDescriptor
- Class AlarmConfigDescriptor
- Class CdrConfigDescriptor

- Generating SNMP MIBs

## Overview of External EDR listeners

External EDR listeners are JMS topic subscribers.

The diagram below illustrates three different ways of listening for EDRs as a JMS listener.

Figure 14-1 Flow for external EDR, alarm, and CDR listeners

EDRs are published externally using a JMS topic. This makes it possible to implement language-independent listeners anywhere on the network in a standard way. It is possible to implement an EDR listener in several ways:

- Alternative 1: Using a pure JMS listener. Implement the javax.jms.MessageListener interface. It is up to the implementation class to implement any filtering mechanism needed.
- Alternative 2: Using a subclass of JMSListener with no filter specified. In that case, the JMSListener class will use a tag, if available in the EDR, to filter the EDR into a specific category: EDR, alarm or CDR.
- Alternative 3: Using a subclass of JMSListener with a specified filter. This filter is used to perform the filtering. If a default filter is used to perform the same filtering as Oracle Communications Services Gatekeeper, all classes used in the xml configuration files must be present in the current class loader. Otherwise, some EDRs will not be correctly filtered.

### Example using a pure JMS listener

Listing 14-1 Example using a pure JMS listener

    public class ClientJMSListener implements MessageListener {

      public void onMessage(Message msg) {

        // Extract the EdrData object or array

        if(o instanceof EdrData[]) {

          for(EdrData edr : (EdrData[])o) {

            //do something with each EDR

          }

        }

      }

    }

### Example using JMSListener utility with no filter

Listing 14-2 Example using a subclass of JMSListener with no filter specified

    public class SampleEdrJMSListener extends JMSListener {

      public SampleEdrJMSListener(String url) throws Exception {

        // Register in the JMS topic. No filter is specified so

        // the "tag" filtering mechanism will be used.

        register(url);

      }

      @Override

      public void onEdr(EdrData edr, ConfigDescriptor descriptor) {

        // The "tag" mechanism will filter the stream of EDRs according

        // to the internal filtering. To know which type of EDR is

        // actually provided in this method, we have to determine the

        // instance of the ConfigDescriptor as follow:

        if(descriptor instanceof EdrConfigDescriptor) {

          // do something with this EDR

        } else if(descriptor instanceof AlarmConfigDescriptor) {

          // do something with this alarm

        } else if(descriptor instanceof CdrConfigDescriptor) {

          // do something with this CDR

        }

      }

    }

### Using JMSListener utility with a filter

Listing 14-3 Using a subclass of JMSListener with a specified filter

    public class SampleEdrJMSListener extends JMSListener {

      public SampleEdrJMSListener(String url) throws Exception {

        // Register in the JMS topic. Use the default alarm filter.

        // Note that in this case all classes needed by the alarm.xml file

        // must be in the current class loader in order for the filtering

        // to work correctly.

        register(url, EdrFilterFactory.createDefaultFilterForAlarm());

      }

      @Override

      public void onEdr(EdrData edr, ConfigDescriptor descriptor) {

        // Only AlarmConfigDescriptor should be received here.

        // Just check before casting.

        if(descriptor instanceof AlarmConfigDescriptor) {

          ... do something with this alarm

        }

      }

    }

Note: | When using the JMSListener class, make sure that any modification to an EDR, CDR. or alarms descriptor in Oracle Communications Services Gatekeeper is also updated in the edrjmslistener.jar file.

## Description of EDR listener utility

The EDR listener utility contains a set of classes to use when creating an external JMS listener using the JMSListener.

The helper classes are found in the domain home directory in Oracle Communications Services Gatekeeper, in:

`$ET_Home/lib/edrjmslistener.jar`

### Class JMSListener

Table 14-1 JMSListener
Method | Description
--- | ---
public void register(String url) | Registers the JMS listener to the EDR topic using no filter. The filtering will be done using the tagging mechanism. The parameter url specifies the URL of a Network Tier server.
public void register(String url, EdrFilter filter) | Registers the JMS listener to the EDR topic using the specified filter.
public void onEdr(EdrData edr, ConfigDescriptor descriptor) | Method that the subclass can override to get notified each time an EDR is received. The descriptor will be a subclass of ConfigDescriptor that will identify the type of EDR: either EdrConfigDescriptor, AlarmConfigDescriptor or CdrConfigDescriptor.

### Class EdrFilterFactory

Table 14-2 EdrFilterFactory
Method | Description
--- | ---
public static EdrFilter createDefaultFilterForEdr() | Creates the default filter using in Oracle Communications Services Gatekeeper to filter the EDRs using the edr.xml file embedded in the edrjmslistener.jar file.
public static EdrFilter createDefaultFilterForAlarm() | Creates the default filter using in Oracle Communications Services Gatekeeper to filter the alarms using the alarm.xml file embedded in the edrjmslistener.jar file.
public static EdrFilter createDefaultFilterForCdr() | Creates the default filter using in Oracle Communications Services Gatekeeper to filter the CDRs using the cdr.xml file embedded in the edrjmslistener.jar file.

### Class EdrData

This class contains all the values that an EDR (alarm and CDR) have.

Table 14-3 EdrData
Method | Description
--- | ---
public String getValue(String key) | Gets the value associated with the specified key.
public List<String> getValues(String key) | Gets the values associated with the specified key.

### Class ConfigDescriptor

This class is the parent class of EdrConfigDescriptor, AlarmConfigDescriptor and CdrConfigDescriptor.

### Class EdrConfigDescriptor

This class contains the data that is specified in the descriptors in the edr.xml configuration file: the identifier and the description.

Table 14-4 EdrConfigDescriptor
Method | Description
--- | ---
public long getIdentifier() | Returns the identifier of the EDR.
public String getDescription() | Returns the description of the EDR.

### Class AlarmConfigDescriptor

This class contains the data that is specified in the descriptors in the alarm.xml configuration file: the identifier, the severity and the description.

Table 14-5 AlarmConfigDescriptor
Method | Description
--- | ---
public long getIdentifier() | Returns the identifier of the alarm.
public String getSeverity() | Returns the severity of the alarm.
public String getDescription() | Returns the description of the alarm.

### Class CdrConfigDescriptor

This class identifies a CDR. This descriptor does not contain any additional data.

## Updating EDR configuration files

If you are using external EDR listeners, and the alarm, CDR, or EDR descriptors have been updated in Oracle Communications Services Gatekeeper, the corresponding files need to be updated in `edrjmslistener.jar`. Update the corresponding xml file with the updated entries in the edr directory in `edrjmslistener.jar`.

## Generating SNMP MIBs

Alarms can be forwarded as SNMP traps, see Managing and Configuring the SNMP service in System Administrator’s Guide.

The MIB file that corresponds to the alarms can be generated using the ant task `mibgenerator` defined in `com.bea.wlcp.wlng.ant.MIBGeneratorTask`.

The ant task is packaged in `$PDS_HOME/wlng/lib/ant-mib-generator.jar`

There is an example build file that uses the an task in `$PDS_HOME/integration`

When the alarms descriptor is changed, a new MIB should be generated and distributed to the SNMP clients. Copy the contents of the alarm descriptor and paste it into an xml file. Use this xml file when generating the MIB file.