At 09:23 PM 11/29/2004, Jacob Kjome wrote:
If JNDIUtil.getInitialContext() fails, then store that fact as a boolean member
variable which will be true by default, but be set to false in the catch
statement. We'd check the value of the boolean before attempting the
JNDIUtil.getInitialContext() stuff so, the next time getLoggerRepository() is
called, it would avoid doing any of the context stuff making the performance,
essentially, the same as the default selector. Why should this have anything
to do with classloader?
I think you've got the best of me. So what you are suggesting is this:
public class ContextJNDISelector implements RepositorySelector {....
// by default, assume is available booelan jndiAvailable=true;
public LoggerRepository getLoggerRepository() { String loggingContextName = null; Context ctx = null;
if(jndiAvailable) {
try {
ctx = JNDIUtil.getInitialContext();
} catch(NamingException ne) {
// a single failure in JNDIUtil.getInitialContext() will
// jndi lookups for good
jndiAvailable = false;
}// if JNDIUtil.getInitialContext() succeeds, the lookup may still
// fail if the user has not setup the Constants.JNDI_CONTEXT_NAME variable
// in JNDI, hence the two separate try/catch blocks
try {
loggingContextName = (String) JNDIUtil.lookup(ctx, Constants.JNDI_CONTEXT_NAME);
} catch (NamingException ne) {
// we can't log here
}
}
if (loggingContextName == null) {
return defaultRepository;
} else { ... }
}
}This would work beautifully as long as the "single-getInitialContext-exception-implies-no-NDI" hypothesis is universally true. Is it?
Jake
-- Ceki G�lc�
The complete log4j manual: http://qos.ch/eclm
Professional log4j support: http://qos.ch/log4jSupport
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
