You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jetspeed-dev@portals.apache.org by rw...@apache.org on 2005/12/07 00:58:56 UTC
svn commit: r354621 -
/portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/velocity/JetspeedVelocityViewServlet.java
Author: rwatler
Date: Tue Dec 6 15:58:53 2005
New Revision: 354621
URL: http://svn.apache.org/viewcvs?rev=354621&view=rev
Log:
properly initialized default velocity engine
Modified:
portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/velocity/JetspeedVelocityViewServlet.java
Modified: portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/velocity/JetspeedVelocityViewServlet.java
URL: http://svn.apache.org/viewcvs/portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/velocity/JetspeedVelocityViewServlet.java?rev=354621&r1=354620&r2=354621&view=diff
==============================================================================
--- portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/velocity/JetspeedVelocityViewServlet.java (original)
+++ portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/velocity/JetspeedVelocityViewServlet.java Tue Dec 6 15:58:53 2005
@@ -120,6 +120,9 @@
/** cache validation interval */
private long cacheValidationInterval;
+ /** default velocity engine */
+ private VelocityEngine defaultVelocityEngine;
+
/**
* Initialize servlet, BridgesVelocityViewServlet, and VelocityViewServlet.
*
@@ -247,8 +250,8 @@
}
}
- // fallback to global velocity engine singleton
- return super.getTemplate(name);
+ // no velocity engine available
+ throw new Exception("No velocity engine available for request context.");
}
/**
@@ -279,8 +282,8 @@
}
}
- // fallback to global velocity engine singleton
- return super.getTemplate(name, encoding);
+ // no velocity engine available
+ throw new Exception("No velocity engine available for request context.");
}
/** velocity engine logging adapter */
@@ -412,7 +415,16 @@
}
else
{
- return null;
+ // use default velocity engine
+ synchronized (this)
+ {
+ // construct and cache default velocity engine
+ if (defaultVelocityEngine != null)
+ {
+ defaultVelocityEngine = initVelocity((TemplateDescriptor)null);
+ }
+ return defaultVelocityEngine;
+ }
}
}
@@ -567,6 +579,20 @@
}
}
}
+
+ // fallback to default velocity engine
+ if (velocity == null)
+ {
+ synchronized (this)
+ {
+ // construct and cache default velocity engine
+ if (defaultVelocityEngine != null)
+ {
+ defaultVelocityEngine = initVelocity((TemplateDescriptor)null);
+ }
+ velocity = defaultVelocityEngine;
+ }
+ }
// return velocity engine for validated configuration
return velocity;
@@ -595,13 +621,23 @@
velocity.setApplicationAttribute(SERVLET_CONTEXT_KEY, getServletContext());
velocity.setProperty(VelocityEngine.RUNTIME_LOG_LOGSYSTEM_CLASS, "org.apache.velocity.tools.view.servlet.ServletLogger");
ExtendedProperties configuration = loadConfiguration(getServletConfig());
- configuration.addProperty("velocimacro.library", macros.getAppRelativePath());
+ if (macros != null)
+ {
+ configuration.addProperty("velocimacro.library", macros.getAppRelativePath());
+ }
configuration.setProperty("file.resource.loader.path", getServletContext().getRealPath("/"));
velocity.setExtendedProperties(configuration);
// initialize and return velocity engine
velocity.init();
- log.debug("initVelocity(): create new VelocityEngine instance to support " + macros.getAppRelativePath() + " decoration template macros");
+ if (macros != null)
+ {
+ log.debug("initVelocity(): create new VelocityEngine instance to support " + macros.getAppRelativePath() + " decoration template macros");
+ }
+ else
+ {
+ log.debug("initVelocity(): create new default VelocityEngine instance");
+ }
return velocity;
}
catch (Exception e)
---------------------------------------------------------------------
To unsubscribe, e-mail: jetspeed-dev-unsubscribe@portals.apache.org
For additional commands, e-mail: jetspeed-dev-help@portals.apache.org