David M Johnson wrote:
On May 3, 2006, at 4:35 PM, Allen Gilliland wrote:
is that really appropriate? that same exception should be thrown
automatically whenever someone tries to access the
RollerFactory.getRoller() method.
Perhaps not, but I'd like the check to run before *anything* else
happens. So, how about this. I'll add the check to RollerFactory, but
the first thing I'll do in RollerContext.initialize() is to call
RollerFactory.getRoller().
okay, but i guess i don't understand why that first part is necessary.
the first time someone calls getRoller() then the chosen RollerImpl is
constructed and initialized. in the case of the hibernate impl it is
going to try and initialize the hibernate SessionFactory, so if that
class is unavailable or loading the hibernate config fails then an
exception is thrown.
ahh, i see the problem: RollerFactory.java line 119
we need to take that exception and throw it again as a RuntimeException.
that way if there is an error initializing the Roller impl it makes it
back to whoever started that process.
also, you are exposing a persistence implementation detail in the
presentation layer. what if we switch away from Hibernate?
Obviously, we'll be changing that line of code (and many others) when we
switch away from Hibernate.
but that doesn't make any sense. what if we had 2 possible backends to
choose from?
-- Allen
- Dave
i think this one should be rolled back.
-- Allen
[EMAIL PROTECTED] wrote:
Author: snoopdave
Date: Wed May 3 13:29:46 2006
New Revision: 399407
URL: http://svn.apache.org/viewcvs?rev=399407&view=rev
Log:
Fail fast with appropriate error message when Hibernate is not found
Modified:
incubator/roller/trunk/src/org/apache/roller/presentation/RollerContext.java
Modified:
incubator/roller/trunk/src/org/apache/roller/presentation/RollerContext.java
URL:
http://svn.apache.org/viewcvs/incubator/roller/trunk/src/org/apache/roller/presentation/RollerContext.java?rev=399407&r1=399406&r2=399407&view=diff
==============================================================================
---
incubator/roller/trunk/src/org/apache/roller/presentation/RollerContext.java
(original)
+++
incubator/roller/trunk/src/org/apache/roller/presentation/RollerContext.java
Wed May 3 13:29:46 2006
@@ -133,6 +133,14 @@
*/
public void contextInitialized(ServletContextEvent sce) {
+ try {
+ Class.forName("org.hibernate.Session");
+ } catch (Throwable t) {
+ // if Hibernate is not available, we're hosed
+ throw new RuntimeException(
+ "FATAL ERROR: Hibernate not found, please refer to
the Roller Installation Guide for instructions on how to install the
required Hibernate jars");
+ }
+ mLogger.debug("RollerContext initializing");
// Save context in self and self in context