Creating a custom component

The Generic Log Adapter provides a number of pre-defined components that can be used to create adapters to process application log files. If those components do not meet your requirements, the Generic Log Adapter can be extended by creating custom components that can be included in the context of an adapter configuration file.

Follow these steps to create a custom component:

Extract the Generic Log Adapter source code

If you want to reference the Generic Log Adapter source code as you develop your own generic log adapter component, check out the org.eclipse.hyades.logging.adapter plug-in project form the Eclipse CVS Repository. To do this:

Create a Java class

You need to create a Java class which contains the code for your new component:

  1. Create a plug-in project to contain the new component.
  2. Create a Java class within your project. Depending on the role the new component will play, it should implement one of the following interfaces defined in the package org.eclipse.hyades.logging.adapter:
    IProcessUnit
    extends IComponent with the methods to do the processing of the component. Object arrays are passed between components so the main processing method, processEventItems, takes an array of Objects as input and returns an array of Objects. All components must implement IProcessUnit. IComponent includes the getter and setter methods for all component properties, an update method for getting the component properties from the configuration, and methods to start and stop the component.
    ISensor
    extends IProcessUnit. Should be used when implementing a sensor component. The getNext method returns the next bunch of data from the source that is being sensed. The flush method flushes any remaining data from the source that has been cached by the sensor. The interface also includes a getter and setter for the type of sensor as defined in the sensor schema file sensor.xsd.
    IExtractor
    extends IProcessUnit. Should be used when implementing an extractor component. Since a sensor typically returns data as strings to the extractor and the extractor extracts complete messages from these strings, an extractor, must implement a processStrings method which takes as input an array of Strings and returns an array of MessageString objects. The MessageString class is also defined in the org.eclipse.hyades.logging.adapter package.
    IParser
    extends IProcessUnit. Should be used when implementing a parser component.
    IFormatter
    extends IProcessUnit. Should be used when implementing a formatter component.
    IOutputter
    extends IProcessUnit. Should be used when implementing an outputter component.

    Another option in creating a new component class is to extend the default implementation classes for IComponent, IProcessUnit, ISensor and IExtractor in the org.eclipse.hyades.logging.adapter.impl package. There are examples of the components in the associated component packages in the org.eclipse.hyades.logging.adapter project.

  3. Once you have completed the code, save the changes.

Add the plug-in dependencies

Since you are extending the Generic Log Adapter classes, you must include the Generic Log Adapter plug-in and its dependencies in your plug-in.

  1. Open the plugin.xml file, and add the following dependancies:
    org.eclipse.hyades.logging.adapter
    org.eclipse.hyades.logging.core

Configure the plug-in as an extension

To configure your plug-in as a component extension of the Generic Log Adapter:

  1. Add the following extension to the plugin.xml file:
    <extension 
       point="org.eclipse.hyades.logging.adapter.adapterComponent"> 
      <componentClassname 
            name="executable_class_name"> 
      </componentClassname> 
    </extension> 
    where executable_class_name is the name of the Java class that you created to implement your new Generic Log Adapter component.
  2. Save the plugin.xml file.

 

Related tasks
Testing the custom component