Uploaded image for project: 'Log4j 2'
  1. Log4j 2
  2. LOG4J2-596

Core should consistently use the Lifecycle class and Status enum

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Closed
    • Major
    • Resolution: Implemented
    • 2.0-rc1
    • None
    • Core

    Description

      Appenders, Filters, and LoggerContext already use the LifeCycle interface, but only LoggerContext has the idea of a volatile enum for its status. I think this would be a good idiom to use throughout all the LifeCycle implementations. There are other interfaces that would make sense to use the LifeCycle interface for as well:

      • Configuration (it already uses two of the three methods using the same exact signature)
      • Log4jWebInitializer (although the equivalent start() method here can throw an UnavailableException, this could be changed to a RuntimeException of some sort; it's already re-wrapped in one in the ServletContextListener implementation)
      • Possibly some other areas if applicable.

      The bigger refactoring I think would be useful really is the status enum usage. It would make things a bit more consistent. To compare this to OSGi, it has the lifecycle states: installed, resolved, starting, active, stopping, and uninstalled. A nice diagram can be found here describing the OSGi lifecycle. I think this could be a good way to implement generic lifecycle state in the relevant classes. This way, it will also make it simpler to use appenders, filters, etc., as OSGi declarative services (which doesn't require breaking everything up into bundles) which would help reduce the need for class loading hacks in OSGi.

      Attachments

        1. Proposed_lifecycle_refactor.patch
          62 kB
          Matt Sicker
        2. Proposed_lifecycle_refactor1.patch
          71 kB
          Matt Sicker

        Issue Links

          Activity

            People

              ggregory Gary D. Gregory
              mattsicker Matt Sicker
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: