Syslog: White Paper FAQ Examples JavaDoc
Protomatter Classes v1.1.6

com.protomatter.syslog.xml
Class PerChannelPolicy_Helper

java.lang.Object
  |
  +--com.protomatter.syslog.xml.SimpleLogPolicy_Helper
        |
        +--com.protomatter.syslog.xml.PerChannelPolicy_Helper
All Implemented Interfaces:
XMLConfigHelper

public class PerChannelPolicy_Helper
extends SimpleLogPolicy_Helper

XML configuration helper for PerChannelPolicy.


Constructor Summary
PerChannelPolicy_Helper()
           
 
Method Summary
 void configure(java.lang.Object o, org.jdom.Element e)
          Configure this policy given the XML element.
 void configureGroup(PerChannelPolicy.PolicyGroup g, org.jdom.Element e)
           
 org.jdom.Element getConfiguration(java.lang.Object o, org.jdom.Element element)
          Encode the given object's configuration into the given XML element.
 org.jdom.Element getConfigurationGroup(PerChannelPolicy.PolicyGroup g, org.jdom.Element element)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PerChannelPolicy_Helper

public PerChannelPolicy_Helper()
Method Detail

configure

public void configure(java.lang.Object o,
                      org.jdom.Element e)
               throws SyslogInitException
Configure this policy given the XML element. This class inherits the policy element parameters that SimpleLogPolicy_Helper understands. The additional Policy elements should look like this:



  <Policy class="com.protomatter.syslog.PerChannelPolicy" >

    <!--
     Config params from SimpleLogPolicy_Helper can
     get inserted here.
    -->

    <PolicyGroup>

      <!--
       Config params from SimpleLogPolicy_Helper can
       get inserted here.
      -->

      <channelPattern>ChannelPattern-1</channelPattern>
      <channelPattern>ChannelPattern-2</channelPattern>
      ...
      <channelPattern>ChannelPattern-N</channelPattern>

      <channelName>ChannelName-1</channelName>
      <channelName>ChannelName-2</channelName>
      ...
      <channelName>ChannelName-N</channelName>
    </PolicyGroup>

    <!-- Insert more PolicyGroups here -->

  </Policy>
  

This class basically reads each <PolicyGroup> element and creates a new PolicyGroup instance and configures that instance with the <PolicyGroup> element.

If none of the pattern groups has anything to say about logging the message, the decision is deferred to the superclass and it makes the decision based on the log mask and channel information that was defined in the enclosing Policy element.

Element
name value required
PolicyGroup See PolicyGroup docs. no

The following example should explain things better:



  <Policy class="com.protomatter.syslog.PerChannelPolicy" >

    <!--
     Defaults -- if none of the groups below match,
     then only allow messages at or above the WARNING level.
    -->
    <logMask>WARNING</logMask>
    <channels>ALL_CHANNEL</channels>

    <!--
     Log DEBUG and above messages for messages coming from
     the com.protomatter.xml.* and com.protomatter.jdbc.*
     packages, and from the com.protomatter.util.Mutex channel.
    -->
    <PolicyGroup>
      <logMask>DEBUG</logMask>
      <channels></channels>

      <channelPattern>com.protomatter.xml.*</channelPattern>
      <channelPattern>com.protomatter.jdbc.*</channelPattern>

      <channelName>com.protomatter.util.Mutex</channelName>
    </PolicyGroup>

    <!--
     Log INFO and above messages for messages coming from
     the com.protomatter.pas.* and com.protomatter.util.*
     packages, and from the com.protomatter.jdbc.pool channel.
    -->
    <PolicyGroup>
      <logMask>INFO</logMask>
      <channels></channels>

      <channelPattern>com.protomatter.pas.*</channelPattern>
      <channelPattern>com.protomatter.util.*</channelPattern>

      <channelName>com.protomatter.jdbc.pool</channelName>
    </PolicyGroup>

    <!--
     If the channel name contains the word "Debug" then allow
     messages at or above the ERROR level.
    -->
    <PolicyGroup>
      <logMask>ERROR</logMask>
      <channels></channels>

      <channelPattern>*Debug*</channelPattern>
    </PolicyGroup>

  </Policy>
  

Overrides:
configure in class SimpleLogPolicy_Helper

configureGroup

public void configureGroup(PerChannelPolicy.PolicyGroup g,
                           org.jdom.Element e)
                    throws SyslogInitException

getConfiguration

public org.jdom.Element getConfiguration(java.lang.Object o,
                                         org.jdom.Element element)
Description copied from interface: XMLConfigHelper
Encode the given object's configuration into the given XML element.
Overrides:
getConfiguration in class SimpleLogPolicy_Helper

getConfigurationGroup

public org.jdom.Element getConfigurationGroup(PerChannelPolicy.PolicyGroup g,
                                              org.jdom.Element element)

Protomatter Classes v1.1.6
Copyright 1998-2001 Nate Sammons

Protomatter Classes v1.1.6 http://protomatter.sourceforge.net/1.1.6