nbubna 2003/03/19 22:07:27
Modified: src/java/org/apache/velocity/tools/view/servlet
ServletLogger.java VelocityViewServlet.java
WebappLoader.java
Log:
make WebappLoader and ServletLogger not explicitly dependent on the
VelocityViewServlet
Revision Changes Path
1.2 +7 -6
jakarta-velocity-tools/src/java/org/apache/velocity/tools/view/servlet/ServletLogger.java
Index: ServletLogger.java
===================================================================
RCS file:
/home/cvs/jakarta-velocity-tools/src/java/org/apache/velocity/tools/view/servlet/ServletLogger.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- ServletLogger.java 5 Mar 2003 06:13:03 -0000 1.1
+++ ServletLogger.java 20 Mar 2003 06:07:27 -0000 1.2
@@ -60,7 +60,7 @@
import org.apache.velocity.runtime.log.LogSystem;
import org.apache.velocity.runtime.RuntimeConstants;
import org.apache.velocity.runtime.RuntimeServices;
-import org.apache.velocity.tools.view.servlet.VelocityViewServlet;
+
/**
* Simple wrapper for the servlet log
@@ -74,10 +74,11 @@
public static final String PREFIX = " Velocity ";
/**
- * Construct a logger for VelocityViewServlets. Instances of this class
- * assume that the ServletContext will be available through the
- * Application Attributes of Velocity, under the
- * VelocityViewServlet.SERVLET_CONTEXT_KEY.
+ * Construct a simple logger for a servlet environment.
+ * <br>
+ * NOTE: this class expects that the ServletContext has already
+ * been placed in the runtime's application attributes
+ * under its full class name (i.e. "javax.servlet.ServletContext").
*/
public ServletLogger()
{
@@ -92,7 +93,7 @@
public void init( RuntimeServices rs )
throws Exception
{
- Object obj =
rs.getApplicationAttribute(VelocityViewServlet.SERVLET_CONTEXT_KEY);
+ Object obj = rs.getApplicationAttribute(ServletContext.class.getName());
if (obj == null)
{
throw new IllegalStateException("Could not retrieve ServletContext from
application attributes!");
1.6 +1 -1
jakarta-velocity-tools/src/java/org/apache/velocity/tools/view/servlet/VelocityViewServlet.java
Index: VelocityViewServlet.java
===================================================================
RCS file:
/home/cvs/jakarta-velocity-tools/src/java/org/apache/velocity/tools/view/servlet/VelocityViewServlet.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- VelocityViewServlet.java 20 Mar 2003 05:56:43 -0000 1.5
+++ VelocityViewServlet.java 20 Mar 2003 06:07:27 -0000 1.6
@@ -169,7 +169,7 @@
/**
* Key used to access the ServletContext in the Velocity
*/
- public static final String SERVLET_CONTEXT_KEY = "javax.servlet.ServletContext";
+ public static final String SERVLET_CONTEXT_KEY = ServletContext.class.getName();
/**
1.3 +10 -5
jakarta-velocity-tools/src/java/org/apache/velocity/tools/view/servlet/WebappLoader.java
Index: WebappLoader.java
===================================================================
RCS file:
/home/cvs/jakarta-velocity-tools/src/java/org/apache/velocity/tools/view/servlet/WebappLoader.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- WebappLoader.java 7 Mar 2003 03:44:38 -0000 1.2
+++ WebappLoader.java 20 Mar 2003 06:07:27 -0000 1.3
@@ -65,8 +65,6 @@
import org.apache.velocity.runtime.resource.Resource;
import org.apache.velocity.runtime.resource.loader.ResourceLoader;
-import org.apache.velocity.tools.view.servlet.VelocityViewServlet;
-
/**
*
* @author <a href="mailto:[EMAIL PROTECTED]">Geir Magnusson Jr.</a>
@@ -82,7 +80,14 @@
protected ServletContext servletContext = null;
/**
- * This is abstract in the base class, so we need it
+ * This is abstract in the base class, so we need it.
+ * <br>
+ * NOTE: this expects that the ServletContext has already
+ * been placed in the runtime's application attributes
+ * under its full class name (i.e. "javax.servlet.ServletContext").
+ *
+ * @param configuration the [EMAIL PROTECTED] ExtendedProperties} associated
with
+ * this resource loader.
*/
public void init( ExtendedProperties configuration)
{
@@ -105,7 +110,7 @@
}
// get the ServletContext
- Object obj =
rsvc.getApplicationAttribute(VelocityViewServlet.SERVLET_CONTEXT_KEY);
+ Object obj = rsvc.getApplicationAttribute(ServletContext.class.getName());
if (obj instanceof ServletContext)
{
servletContext = (ServletContext)obj;
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]