WebSphere WebSphere Enterprise Service Bus, Version 6.0.1 Operating Systems: AIX, HP-UX, Linux, Solaris, Windows

Accessing event instance metadata

Accessing event instance metadata is done through the Java-based Eclipse Modeling Framework.

The org.eclipse.hyades.logging.events.cbe package, which provides the classes and interfaces required for working with event objects, is based on the Eclipse Modeling Framework (EMF). EMF is a Java framework used to generate application code based on a structured data model; it also provides interfaces in the generated code that can be used to access metadata describing the data model. (Refer to the Eclipse Modeling Framework documentation at http://www.eclipse.org/emf for more information about EMF.)

By using these interfaces, EMF-compatible tools can interact with CommonBaseEvent event data without any prior knowledge of the data model or access to the implementation. This makes it possible for development tools to generate code that transfers data from other data models into the CommonBaseEvent model. Application developers can then focus on writing code that uses the data rather than code that builds the data.

For example, consider an event source that monitors network events and describes its own data model in terms of EMF. With access to both data models, a development tool could display the fields of the event source data model alongside the fields of the CommonBaseEvent data model. A developer could then use a graphical interface to indicate how the fields in the event source model are mapped to fields in the CommonBaseEvent model; for example, a field called Workstation.name in the event source data model might correspond to the CommonBaseEvent.sourceComponentId.location field in the CommonBaseEvent data model. Because both data models are described using standard EMF interfaces, the tool could generate code that handles the transfer of data between the two models.

The following code fragment is a simple example of how a development tool might use EMF interfaces to query information about the CommonBaseEvent data model and then use that information to interact with an event instance. This example could be part of a simple event consumer; it iterates through all of the fields of an event instance and, for each one, prints the name and value of the field.

// event is a valid CommonBaseEvent instance

// Get list of event instance structural features (fields)
List features = event.eClass().getEAllStructuralFeatures();

// iterate through list; print names and values
for (int i = 0 ; i < features.size() ; i++)
  {
    EStructuralFeature feature = (EStructuralFeature)features.get(i);
    Object value = eObj.eGet(feature);
    System.out.println(feature.getName() + ":" + value);
  }

The CommonBaseEvent data model is described in the EMF files cbe.ecore and cbe.genmodel. These files are included with the Common Event Infrastructure SDK; you can import them into an Eclipse-based development environment and then use EMF to generate code that interacts with CommonBaseEvent objects.


Concept topic

Terms of Use | Rate this page

Timestamp iconLast updated: 13 Dec 2005
http://publib.boulder.ibm.com/infocenter/dmndhelp/v6rxmx/index.jsp?topic=/com.ibm.websphere.wesb.doc\doc\ccei_dev_eventMetadata.html

(C) Copyright IBM Corporation 2005. All Rights Reserved.
This information center is powered by Eclipse technology. (http://www.eclipse.org)