创建定制的公共基本事件内容处理程序或模板来使特定事件的配置或值自动化。
开始之前
内容处理程序是一个对象,它根据您要使用的任意策略自动设置每个事件的属性值。
下列内容处理程序类已添加至
WebSphere® Application Server 以使公共基本事件基础结构的使用更容易:
类名 |
描述 |
WsContentHandlerImpl |
这提供了 org.eclipse.hyades.logging.events.cbe.ContentHandler 的实现,专门用在 WebSphere Application Server 环境中。该内容处理程序使用来自 WebSphere
Application Server 运行时的信息完成公共基本事件,并且它使用的内容处理程序与在完成用于日志记录的公共基本事件时
WebSphere Application Server 内部使用的内容处理程序相同。 |
WsTemplateContentHandlerImpl |
这提供了和 WsContentHandlerImpl 相同的功能,但它扩展了
org.eclipse.hyades.logging.events.cbe.impl.TemplateContentHandlerImpl
类以允许使用公共基本事件模板。万一模板数据指定值给与 WsContentHandlerImpl 所作的一样的公共基本事件字段,那么模板内容优先。 |
关于此任务
在某些情况下,您可能希望为创建的每个事件自动设置一些事件属性数据。此自动化是根据运行时环境提供的信息(像创建时间或线程信息),填入某些不更改的标准值(如应用程序名)或设置某些属性的一种方法。可以通过创建内容处理程序来自动设置属性数据。
过程
- 使用下列代码样本来实现 CustomContentHandler 类:
public class CustomContentHandler extends WsContentHandlerImpl {
public CustomContentHandler() {
super();
// TODO Custom initialization code goes here
}
public void completeEvent(CommonBaseEvent cbe) throws CompletionException {
// following code will add WAS content to the Content Base Event
super.completeEvent(cbe);
// TODO Custom content can be added to the Content Base Event here
}
}
- 以下说明如何实现 CustomTemplateContentHandler 类:
public class CustomTemplateContentHandler extends WsTemplateContentHandlerImpl {
public CustomTemplateContentHandler() {
super();
// TODO Custom initialization code goes here
}
public void completeEvent(CommonBaseEvent cbe) throws CompletionException {
// following code will add WAS content to the Content Base Event
super.completeEvent(cbe);
// TODO Custom content can be added to the Content Base Event here
}
}
结果
现在就具有了基于所指定的设置的内容处理程序或定制的内容处理程序模板。