3 Replies Latest reply on Dec 9, 2007 7:11 AM by pmuir

    using static modifier with Seam logger

    asookazian

      On pg. 254 of 2.0.0.GA ref pdf, it states the following regarding @Logger:

      "Specifies that a component field is to be injected with an instance of org.jboss.seam.log.Log"

      I noticed that in my SFSB, I may use the following code without error:

      @Logger
      private Log log;


      But if I use the same code in a Seam POJO used as an interceptor class I will get a NullPointerException (e.g. when log.info() is invoked).

      If I use the following code in a Seam POJO used as an interceptor class, there is no exception:

      @Logger
      private static Log log;


      Is this the correct behavior and what accounts for the difference?

        • 1. Re: using static modifier with Seam logger
          pmuir

          The injection for static loggers is different - static loggers are injected at component install, non static at component instantiation (think about what static means)

          • 2. Re: using static modifier with Seam logger
            asookazian

            well I understand the meaning of static (you don't need to instantiate the object manually to reference it, it's already instantiated). My question was wronngly worded. I meant to ask why do I need to use static (why doesn't it work without static, i.e. it's null object w/o static). In a SFSB this is not the case.

            You already indicated that it's not advisable to use a Seam POJO as an interceptor so perhaps this has something to do with it...

            • 3. Re: using static modifier with Seam logger
              pmuir

              The interceptor isn't instantiated as a seam component when used, but it is installed as a component.