org.eclipse.hyades.logging.events.cbe.impl
Class EventXMLFileEventFactoryHomeImpl

java.lang.Object
  |
  +--org.eclipse.hyades.logging.events.cbe.impl.AbstractEventFactoryHome
        |
        +--org.eclipse.hyades.logging.events.cbe.impl.EventXMLFileEventFactoryHomeImpl
All Implemented Interfaces:
EventFactoryHome

public class EventXMLFileEventFactoryHomeImpl
extends AbstractEventFactoryHome

Concrete implementation of the AbstractEventFactoryHome abstract event factory home implementation used for populating events with properties from an event configuration template XML file.

This implementation contributes an associated ContentHandler implementation specific to this event factory home implementation. The associated ContentHandler is assigned to each event factory created using this event factory home implementation. When events are created from an event factory created using this event factory home implementation, the associated ContentHandler is assigned to the newly created event. The associated ContentHandler may be invoked on a newly created event to populate the event's properties with properties from ContentHandler's configuration template.

The ContentHandler implementation used in this implementation is the TemplateContentHandler. The TemplateContentHandler permits storing event configuration properties that are merged into an event upon event completion. These event configuration properties are resolved by this implementation from an event configuration template XML file.

The desired event configuration template XML file must by on the classpath and accessible by this class. The event configuration template XML file is loaded using the following look-up sequence:

  1. The EventXMLFileEventFactoryHomeImpl class' class loader is queried for the event configuration template XML file.
  2. The system's class loader is queried for the event configuration template XML file.
  3. The current thread's context class loader is queried for the event configuration template XML file.

This event factory home implementation consumes a configuration template XML file in the form of a template event XML file. This template event XML file is a well-formed XML document conforming to a predefined XML schema (e.g. templateEvent.xsd).

The naming convention used for the template Event XML file is:

<factory name>.event.xml

where is the unique dot-delimited name of the factory. For example, the template event XML file for the com.company.sample factory would be named com.company.sample.event.xml.

Configuration templates are located based on the hierarchal factory name, starting from the full factory name (e.g. all name-space segments) and iterating its ancestors to the highest ancestor (e.g. first name-space segment). For example, the com.company.sample factory name would cause the event factory home to attempt to locate the configuration template named com.company.sample. If this configuration template cannot be located, the event factory home would attempt to locate the configuration template named com.company, and so on all the way to the configuration template named com.

Since:
1.0.1
Version:
1.0.1
Author:
Paul E Slauenwhite
See Also:
AbstractEventFactoryHome, TemplateContentHandler

Field Summary
static java.lang.String XML_FILE_EXTENSION
          The file extension of the template Event XML file.
 
Constructor Summary
EventXMLFileEventFactoryHomeImpl()
           
 
Method Summary
 ContentHandler createContentHandler(java.lang.String factoryName)
          Creates an instance of the ContentHandler implementation which is tightly coupled to the type of the concrete implementation of this abstract class.
 ContentHandler resolveContentHandler()
          Resolves an instance of the ContentHandler implementation which is tightly coupled to the type of the concrete implementation of this abstract class.
 java.io.InputStream resolveTemplateXMLFileInputStream(java.lang.String fileName)
          Resolves the InputStream of the event configuration template XML file, based on the parameter file name.
 
Methods inherited from class org.eclipse.hyades.logging.events.cbe.impl.AbstractEventFactoryHome
checkAccess, getAnonymousEventFactory, getEventFactory, releaseEventFactory, updateAnonymousEventFactory, updateEventFactory
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

XML_FILE_EXTENSION

public static final java.lang.String XML_FILE_EXTENSION
The file extension of the template Event XML file.

The naming convention used for the template Event XML file is:

<factory name>.event.xml

See Also:
Constant Field Values
Constructor Detail

EventXMLFileEventFactoryHomeImpl

public EventXMLFileEventFactoryHomeImpl()
Method Detail

resolveContentHandler

public ContentHandler resolveContentHandler()
Description copied from class: AbstractEventFactoryHome
Resolves an instance of the ContentHandler implementation which is tightly coupled to the type of the concrete implementation of this abstract class.

It is assumed that implementations of the createContentHandler(String factoryName) method would reference the implementation of this method in the same concrete implementation of this abstract class when creating the returned ContentHandler.

Specified by:
resolveContentHandler in class AbstractEventFactoryHome
Returns:
An instance of the ContentHandler tightly coupled with this type of this event factory home implementation.
See Also:
AbstractEventFactoryHome.resolveContentHandler()

resolveTemplateXMLFileInputStream

public java.io.InputStream resolveTemplateXMLFileInputStream(java.lang.String fileName)
Resolves the InputStream of the event configuration template XML file, based on the parameter file name.

This API is used for scenarios where the event configuration template XML file is accessible by this class's class loader. Use cases where the event configuration template XML file is NOT accessible by this class (e.g. isolated class loaders) require this API to be extended.

The InputStream of the event configuration template XML file is resolved using the following class loader hierarchy:

  1. The current class' (e.g. EventXMLFileEventFactoryHomeImpl) class loader.
  2. The system's class loader.
  3. The current thread's context class loader.

Parameters:
fileName - The file name of the event configuration template XML file.
Returns:
The InputStream of the event configuration template XML file, otherwise null.

createContentHandler

public ContentHandler createContentHandler(java.lang.String factoryName)
Description copied from class: AbstractEventFactoryHome
Creates an instance of the ContentHandler implementation which is tightly coupled to the type of the concrete implementation of this abstract class.

The returned instance of the ContentHandler implementation is pre-configured with a event properties resolved from a source tightly coupled to the type of the concrete implementation of this abstract class.

It is assumed that implementations of this method would reference the implementation of the resolveContentHandler() method in the same concrete implementation of this abstract class when creating the returned ContentHandler.

Specified by:
createContentHandler in class AbstractEventFactoryHome
Parameters:
factoryName - The name of the event factory associated with the returned ContentHandler implementation.
Returns:
An instance of the ContentHandler pre-configured with a event properties.
See Also:
AbstractEventFactoryHome.createContentHandler(java.lang.String)