Of course I'm seeing that my idea can't hook up the logger to the calling class 
type which I dare say the Tapestry injection performs.

Is there another way? I don't want to wire the logger directly.
  ----- Original Message ----- 
  From: John 
  To: Tapestry users 
  Sent: Thursday, May 02, 2013 10:15 AM
  Subject: Re: SessionListener interacting with Tapestry services?


  this works 
      auditDAO = registry.getService(AuditDAO.class);

  but this does not
      log = registry.getService(Logger.class);

  [ERROR] TapestryModule.RequestExceptionHandler Processing of request failed 
with
   uncaught exception: No service implements the interface org.slf4j.Logger.
  java.lang.RuntimeException: No service implements the interface 
org.slf4j.Logger
    ----- Original Message ----- 
    From: Taha Hafeez Siddiqi 
    To: Tapestry users 
    Sent: Wednesday, May 01, 2013 9:55 AM
    Subject: Re: SessionListener interacting with Tapestry services?


    Hi John

    You can directly extract the registry from the ServetContext 

    using 
http://tapestry.apache.org/current/apidocs/org/apache/tapestry5/TapestryFilter.html#REGISTRY_CONTEXT_NAME


    Note: NOT TESTED

    public class MyListener implements HttpServletListener {
       
       public void sessionCreated(HttpServletRequest e){
          Registry registry = 
(Registry)e.getSession().getServletContext().getAttribute(TapestryFilter.REGISTRY_CONTEXT_NAME);
          MyDAO dao = registry.getService(MyDAO.class);
       }

    }

    regards
    Taha



    On 01-May-2013, at 2:19 PM, John <[email protected]> wrote:

    > I configure a SessionListener in web.xml:
    > 
    > <listener>
    > 
    > <listener-class>epulse.audit.manager.SessionListener</listener-class>
    > 
    > </listener>
    > 
    > And in the listener I have directly wired the Logger so:
    > 
    > public class SessionListener implements HttpSessionListener {
    > 
    > 
    > /** The log. */
    > 
    > private static Logger log = Logger.getLogger(SessionListener.class);
    > 
    > 
    > /** The audit log. */
    > 
    > @Inject
    > 
    > private AuditDAO auditDAO;    
    > 
    > 
    > I now want to inject a DAO to perform auditing but of course the 
SessionListener is managed by the web container, what to do?
    > 
    > As it happens at present the audit log is just a wrapper service for 
SLF4j so I can directly instantiate the audit logging the same as the regular 
log.
    > 
    > John

Reply via email to