Class PluginSkeleton

  • All Implemented Interfaces:
    Plugin, Component, org.apache.log4j.spi.OptionHandler
    Direct Known Subclasses:
    Receiver

    public abstract class PluginSkeleton
    extends ComponentBase
    implements Plugin
    A convienent abstract class for plugin subclasses that implements the basic methods of the Plugin interface. Subclasses are required to implement the isActive(), activateOptions(), and shutdown() methods.

    Developers are not required to subclass PluginSkeleton to develop their own plugins (they are only required to implement the Plugin interface), but it provides a convenient base class to start from.

    Contributors: Nicko Cadell
    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected boolean active
      Active state of plugin.
      protected java.lang.String name
      Name of this plugin.
      private java.beans.PropertyChangeSupport propertySupport
      This is a delegate that does all the PropertyChangeListener support.
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      protected PluginSkeleton()
      Construct new instance.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void addPropertyChangeListener​(java.beans.PropertyChangeListener listener)
      Add property change listener.
      void addPropertyChangeListener​(java.lang.String propertyName, java.beans.PropertyChangeListener listener)
      Add property change listener for one property only.
      protected void firePropertyChange​(java.beans.PropertyChangeEvent evt)
      Fire a property change event to appropriate listeners.
      protected void firePropertyChange​(java.lang.String propertyName, boolean oldValue, boolean newValue)
      Fire property change event to appropriate listeners.
      protected void firePropertyChange​(java.lang.String propertyName, int oldValue, int newValue)
      Fire property change event to appropriate listeners.
      protected void firePropertyChange​(java.lang.String propertyName, java.lang.Object oldValue, java.lang.Object newValue)
      Fire property change event to appropriate listeners.
      org.apache.log4j.spi.LoggerRepository getLoggerRepository()
      Gets the logger repository for this plugin.
      java.lang.String getName()
      Gets the name of the plugin.
      boolean isActive()
      Returns whether this plugin is Active or not.
      boolean isEquivalent​(Plugin testPlugin)
      Returns true if the plugin has the same name and logger repository as the testPlugin passed in.
      void removePropertyChangeListener​(java.beans.PropertyChangeListener listener)
      Remove property change listener.
      void removePropertyChangeListener​(java.lang.String propertyName, java.beans.PropertyChangeListener listener)
      Remove property change listener on a specific property.
      void setLoggerRepository​(org.apache.log4j.spi.LoggerRepository repository)
      Sets the logger repository used by this plugin and notifies a relevant PropertyChangeListeners registered.
      void setName​(java.lang.String newName)
      Sets the name of the plugin and notifies PropertyChangeListeners of the change.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
      • Methods inherited from interface org.apache.log4j.spi.OptionHandler

        activateOptions
      • Methods inherited from interface org.apache.log4j.plugins.Plugin

        shutdown
    • Field Detail

      • name

        protected java.lang.String name
        Name of this plugin.
      • active

        protected boolean active
        Active state of plugin.
      • propertySupport

        private java.beans.PropertyChangeSupport propertySupport
        This is a delegate that does all the PropertyChangeListener support.
    • Constructor Detail

      • PluginSkeleton

        protected PluginSkeleton()
        Construct new instance.
    • Method Detail

      • getName

        public java.lang.String getName()
        Gets the name of the plugin.
        Specified by:
        getName in interface Plugin
        Returns:
        String the name of the plugin.
      • setName

        public void setName​(java.lang.String newName)
        Sets the name of the plugin and notifies PropertyChangeListeners of the change.
        Specified by:
        setName in interface Plugin
        Parameters:
        newName - the name of the plugin to set.
      • getLoggerRepository

        public org.apache.log4j.spi.LoggerRepository getLoggerRepository()
        Gets the logger repository for this plugin.
        Specified by:
        getLoggerRepository in interface Plugin
        Overrides:
        getLoggerRepository in class ComponentBase
        Returns:
        LoggerRepository the logger repository this plugin will affect.
      • setLoggerRepository

        public void setLoggerRepository​(org.apache.log4j.spi.LoggerRepository repository)
        Sets the logger repository used by this plugin and notifies a relevant PropertyChangeListeners registered. This repository will be used by the plugin functionality.
        Specified by:
        setLoggerRepository in interface Component
        Specified by:
        setLoggerRepository in interface Plugin
        Overrides:
        setLoggerRepository in class ComponentBase
        Parameters:
        repository - the logger repository that this plugin should affect.
      • isActive

        public boolean isActive()
        Returns whether this plugin is Active or not.
        Specified by:
        isActive in interface Plugin
        Returns:
        true/false
      • isEquivalent

        public boolean isEquivalent​(Plugin testPlugin)
        Returns true if the plugin has the same name and logger repository as the testPlugin passed in.
        Specified by:
        isEquivalent in interface Plugin
        Parameters:
        testPlugin - The plugin to test equivalency against.
        Returns:
        Returns true if testPlugin is considered to be equivalent.
      • addPropertyChangeListener

        public final void addPropertyChangeListener​(java.beans.PropertyChangeListener listener)
        Add property change listener.
        Specified by:
        addPropertyChangeListener in interface Plugin
        Parameters:
        listener - listener.
      • addPropertyChangeListener

        public final void addPropertyChangeListener​(java.lang.String propertyName,
                                                    java.beans.PropertyChangeListener listener)
        Add property change listener for one property only.
        Specified by:
        addPropertyChangeListener in interface Plugin
        Parameters:
        propertyName - property name.
        listener - listener.
      • removePropertyChangeListener

        public final void removePropertyChangeListener​(java.beans.PropertyChangeListener listener)
        Remove property change listener.
        Specified by:
        removePropertyChangeListener in interface Plugin
        Parameters:
        listener - listener.
      • removePropertyChangeListener

        public final void removePropertyChangeListener​(java.lang.String propertyName,
                                                       java.beans.PropertyChangeListener listener)
        Remove property change listener on a specific property.
        Specified by:
        removePropertyChangeListener in interface Plugin
        Parameters:
        propertyName - property name.
        listener - listener.
      • firePropertyChange

        protected final void firePropertyChange​(java.beans.PropertyChangeEvent evt)
        Fire a property change event to appropriate listeners.
        Parameters:
        evt - change event.
      • firePropertyChange

        protected final void firePropertyChange​(java.lang.String propertyName,
                                                boolean oldValue,
                                                boolean newValue)
        Fire property change event to appropriate listeners.
        Parameters:
        propertyName - property name.
        oldValue - old value.
        newValue - new value.
      • firePropertyChange

        protected final void firePropertyChange​(java.lang.String propertyName,
                                                int oldValue,
                                                int newValue)
        Fire property change event to appropriate listeners.
        Parameters:
        propertyName - property name.
        oldValue - old value.
        newValue - new value.
      • firePropertyChange

        protected final void firePropertyChange​(java.lang.String propertyName,
                                                java.lang.Object oldValue,
                                                java.lang.Object newValue)
        Fire property change event to appropriate listeners.
        Parameters:
        propertyName - property name.
        oldValue - old value.
        newValue - new value.