Add servlet context logger during servlet initialization phase. Allow
servlet context to be specified at construct time to servlet context logger. git-svn-id: https://samskivert.googlecode.com/svn/trunk@460 6335cc39-0255-0410-8fd6-9bcaacd3b74c
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
//
|
//
|
||||||
// $Id: DispatcherServlet.java,v 1.11 2001/11/06 20:55:51 mdb Exp $
|
// $Id: DispatcherServlet.java,v 1.12 2001/11/20 21:13:47 mdb Exp $
|
||||||
//
|
//
|
||||||
// samskivert library - useful routines for java programs
|
// samskivert library - useful routines for java programs
|
||||||
// Copyright (C) 2001 Michael Bayne
|
// Copyright (C) 2001 Michael Bayne
|
||||||
@@ -205,6 +205,10 @@ public class DispatcherServlet extends VelocityServlet
|
|||||||
// wire up our #import directive
|
// wire up our #import directive
|
||||||
props.put("userdirective", ImportDirective.class.getName());
|
props.put("userdirective", ImportDirective.class.getName());
|
||||||
|
|
||||||
|
// configure the servlet context logger
|
||||||
|
props.put(RuntimeSingleton.RUNTIME_LOG_LOGSYSTEM,
|
||||||
|
new ServletContextLogger(getServletContext()));
|
||||||
|
|
||||||
// now return our augmented properties
|
// now return our augmented properties
|
||||||
return props;
|
return props;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
//
|
//
|
||||||
// $Id: ServletContextLogger.java,v 1.1 2001/11/20 21:08:35 mdb Exp $
|
// $Id: ServletContextLogger.java,v 1.2 2001/11/20 21:13:47 mdb Exp $
|
||||||
//
|
//
|
||||||
// samskivert library - useful routines for java programs
|
// samskivert library - useful routines for java programs
|
||||||
// Copyright (C) 2001 Michael Bayne
|
// Copyright (C) 2001 Michael Bayne
|
||||||
@@ -30,12 +30,34 @@ import org.apache.velocity.runtime.log.LogSystem;
|
|||||||
*/
|
*/
|
||||||
public class ServletContextLogger implements LogSystem
|
public class ServletContextLogger implements LogSystem
|
||||||
{
|
{
|
||||||
|
/**
|
||||||
|
* Constructs a servlet context logger that will obtain its servlet
|
||||||
|
* context reference via {@link RuntimeServices#getApplicationContext}
|
||||||
|
* when initialized.
|
||||||
|
*/
|
||||||
|
public ServletContextLogger ()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructs a servlet context logger with the supplied servlet
|
||||||
|
* context.
|
||||||
|
*/
|
||||||
|
public ServletContextLogger (ServletContext sctx)
|
||||||
|
{
|
||||||
|
_sctx = sctx;
|
||||||
|
}
|
||||||
|
|
||||||
// documentation inherited
|
// documentation inherited
|
||||||
public void init (RuntimeServices rsvc)
|
public void init (RuntimeServices rsvc)
|
||||||
{
|
{
|
||||||
// the web framework was kind enough to slip this into the runtime
|
// if we weren't constructed with a servlet context, try to obtain
|
||||||
// instance when it started up
|
// one via the application context
|
||||||
_sctx = (ServletContext)rsvc.getApplicationContext();
|
if (_sctx == null) {
|
||||||
|
_sctx = (ServletContext)rsvc.getApplicationContext();
|
||||||
|
}
|
||||||
|
|
||||||
|
// if we still don't have one, complain
|
||||||
if (_sctx == null) {
|
if (_sctx == null) {
|
||||||
rsvc.warn("ServletContextLogger: servlet context was not " +
|
rsvc.warn("ServletContextLogger: servlet context was not " +
|
||||||
"supplied as application context. A user of the " +
|
"supplied as application context. A user of the " +
|
||||||
|
|||||||
Reference in New Issue
Block a user