From 104c944c9204d9095410d19293e3691bc159e816 Mon Sep 17 00:00:00 2001 From: mdb Date: Tue, 20 Nov 2001 21:32:34 +0000 Subject: [PATCH] Be smarter about extracting the servlet context from the application context reference. git-svn-id: https://samskivert.googlecode.com/svn/trunk@461 6335cc39-0255-0410-8fd6-9bcaacd3b74c --- .../com/samskivert/velocity/ServletContextLogger.java | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/projects/samskivert/src/java/com/samskivert/velocity/ServletContextLogger.java b/projects/samskivert/src/java/com/samskivert/velocity/ServletContextLogger.java index 96a0b7c4..7f227e06 100644 --- a/projects/samskivert/src/java/com/samskivert/velocity/ServletContextLogger.java +++ b/projects/samskivert/src/java/com/samskivert/velocity/ServletContextLogger.java @@ -1,5 +1,5 @@ // -// $Id: ServletContextLogger.java,v 1.2 2001/11/20 21:13:47 mdb Exp $ +// $Id: ServletContextLogger.java,v 1.3 2001/11/20 21:32:34 mdb Exp $ // // samskivert library - useful routines for java programs // Copyright (C) 2001 Michael Bayne @@ -54,7 +54,14 @@ public class ServletContextLogger implements LogSystem // if we weren't constructed with a servlet context, try to obtain // one via the application context if (_sctx == null) { - _sctx = (ServletContext)rsvc.getApplicationContext(); + Object context = rsvc.getApplicationContext(); + if (context != null) { + if (context instanceof Application) { + _sctx = ((Application)context).getServletContext(); + } else if (context instanceof ServletContext) { + _sctx = (ServletContext)context; + } + } } // if we still don't have one, complain