List of usage examples for org.apache.commons.logging Log isDebugEnabled
boolean isDebugEnabled();
From source file:net.sf.jabb.util.ex.LoggedException.java
/** * Create a new instance, and at the same time, ensure the original exception is logged. * // w w w .j a v a 2 s . co m * @param log the log utility * @param level level of the log * @param message description * @param cause the original exception. If it is of type LoggedException, * then the newly created instance is a clone of itself. */ public LoggedException(Log log, int level, String message, Throwable cause) { super(cause instanceof LoggedException ? cause.getMessage() : message, cause instanceof LoggedException ? cause.getCause() : cause); if (!(cause instanceof LoggedException)) { switch (level) { case TRACE: if (log.isTraceEnabled()) { log.trace(message, cause); } break; case DEBUG: if (log.isDebugEnabled()) { log.debug(message, cause); } break; case WARN: if (log.isWarnEnabled()) { log.warn(message, cause); } break; case FATAL: log.fatal(message, cause); break; case INFO: log.info(message, cause); break; default: log.error(message, cause); } } }
From source file:de.betterform.agent.web.servlet.XFormsRepeater.java
protected void doSubmissionReplaceAll(HttpServletRequest request, HttpServletResponse response) throws IOException { final Log LOG = LogFactory.getLog(XFormsRepeater.class); HttpSession session = request.getSession(false); WebProcessor webProcessor = WebUtil.getWebProcessor(request, response, session); if (session != null && webProcessor != null) { if (LOG.isDebugEnabled()) { Enumeration keys = session.getAttributeNames(); if (keys.hasMoreElements()) { LOG.debug("--- existing keys in session --- "); }//from w w w . j a v a 2 s . c om while (keys.hasMoreElements()) { String s = (String) keys.nextElement(); LOG.debug("existing sessionkey: " + s + ":" + session.getAttribute(s)); } } Map submissionResponse = webProcessor.checkForExitEvent().getContextInfo(); if (submissionResponse != null) { if (LOG.isDebugEnabled()) { LOG.debug("handling submission/@replace='all'"); Enumeration keys = session.getAttributeNames(); if (keys.hasMoreElements()) { LOG.debug("--- existing keys in http session --- "); while (keys.hasMoreElements()) { String s = (String) keys.nextElement(); LOG.debug("existing sessionkey: " + s + ":" + session.getAttribute(s)); } } else { LOG.debug("--- no keys left in http session --- "); } } // copy header fields Map headerMap = (Map) submissionResponse.get("header"); String name; String value; Iterator iterator = headerMap.keySet().iterator(); while (iterator.hasNext()) { name = (String) iterator.next(); if (name.equalsIgnoreCase("Transfer-Encoding")) { // Some servers (e.g. WebSphere) may set a "Transfer-Encoding" // with the value "chunked". This may confuse the client since // XFormsServlet output is not encoded as "chunked", so this // header is ignored. continue; } value = (String) headerMap.get(name); if (LOG.isDebugEnabled()) { LOG.debug("added header: " + name + "=" + value); } response.setHeader(name, value); } // copy body stream InputStream bodyStream = (InputStream) submissionResponse.get("body"); OutputStream outputStream = new BufferedOutputStream(response.getOutputStream()); for (int b = bodyStream.read(); b > -1; b = bodyStream.read()) { outputStream.write(b); } // close streams bodyStream.close(); outputStream.close(); //kill XFormsSession WebUtil.removeSession(webProcessor.getKey()); return; } } response.sendError(HttpServletResponse.SC_FORBIDDEN, "no submission response available"); }
From source file:jp.terasoluna.fw.batch.util.BatchUtil.java
/** * ??//w w w . ja v a2 s .com * @param tranDef TransactionDefinition * @param tranMap PlatformTransactionManager * @param log Log * @return TransactionStatus */ public static Map<String, TransactionStatus> startTransactions(TransactionDefinition tranDef, Map<?, ?> tranMap, Log log) { Map<String, TransactionStatus> statMap = new LinkedHashMap<String, TransactionStatus>(); if (!tranMap.isEmpty()) { for (Map.Entry<?, ?> ent : tranMap.entrySet()) { String key = null; PlatformTransactionManager ptm = null; // ?? if (ent.getKey() instanceof String) { key = (String) ent.getKey(); } // ??? if (ent.getValue() instanceof PlatformTransactionManager) { ptm = (PlatformTransactionManager) ent.getValue(); } if (ptm != null) { if (log != null && log.isDebugEnabled()) { logDebug(log, LogId.DAL025033, key); if (tranDef != null) { logDebug(log, LogId.DAL025034, tranDef.getPropagationBehavior(), tranDef.getIsolationLevel(), tranDef.getTimeout(), tranDef.isReadOnly(), tranDef.getName()); } } // TransactionStatus trnStat = null; try { trnStat = ptm.getTransaction(tranDef); } catch (TransactionException e) { if (log != null && log.isErrorEnabled()) { logError(log, LogId.EAL025048, e, key); } endTransactions(tranMap, statMap, log); throw e; } // ? if (statMap != null) { statMap.put(key, trnStat); } if (log != null && log.isDebugEnabled()) { logDebug(log, LogId.DAL025035, key, trnStat); } } } } return statMap; }
From source file:interactivespaces.activity.component.route.ros.RosMessageRouterActivityComponent.java
/** * Handle a new route message./*from www . j a va2 s. co m*/ * * @param channelName * name of the channel the message came in on * @param message * the message that came in */ void handleNewMessage(final String channelName, final T message) { if (!getComponentContext().canHandlerRun()) { return; } try { getComponentContext().enterHandler(); long start = System.currentTimeMillis(); String handlerInvocationId = newHandlerInvocationId(); Log log = getComponentContext().getActivity().getLog(); if (log.isDebugEnabled()) { log.debug(String.format("Entering ROS route message handler invocation %s", handlerInvocationId)); } // Send the message out to the listener. messageListener.onNewRoutableInputMessage(channelName, message); if (log.isDebugEnabled()) { log.debug(String.format("Exiting ROS route message handler invocation %s in %d msecs", handlerInvocationId, System.currentTimeMillis() - start)); } } catch (Throwable e) { handleError(String.format("Error after receiving routing message for channel %s", channelName), e); } finally { getComponentContext().exitHandler(); } }
From source file:hotbeans.support.AbstractHotBeanModuleRepository.java
/** * Checks for obsolete modules.// w w w. j a v a 2 s. c om */ protected void checkForObsoleteModules() { Log logger = this.getLog(); if (logger.isDebugEnabled()) logger.debug("Checking for obsolete/inactive modules."); synchronized (this.lock) { String[] moduleNames = this.getHotBeanModuleNames(); for (int n = 0; n < moduleNames.length; n++) { this.checkForObsoleteModules(moduleNames[n]); } } }
From source file:hotbeans.support.AbstractHotBeanModuleRepository.java
/** * Registers a module revision./*from w ww . j av a 2s .co m*/ */ protected void registerHotBeanModule(final HotBeanModule module) { Log logger = this.getLog(); if (logger.isDebugEnabled()) logger.debug("Registering module " + module.toString(false) + "."); synchronized (this.lock) { final String moduleName = module.getName(); HotBeanModuleType hotBeanModuleType = this.getHotBeanModuleType(moduleName); if (hotBeanModuleType == null) { hotBeanModuleType = new HotBeanModuleType(moduleName); this.moduleRegistry.put(moduleName, hotBeanModuleType); } hotBeanModuleType.addModule(module); // Add as the last module revision } }
From source file:hotbeans.support.AbstractHotBeanModuleRepository.java
/** * Unregisters a module revision, and possibly the whole module type. *//* www. j a v a2s. c o m*/ protected void unregisterHotBeanModule(final HotBeanModule module) { Log logger = this.getLog(); if (logger.isDebugEnabled()) logger.debug("Unregistering module " + module.toString(false) + "."); synchronized (this.lock) { String moduleName = module.getName(); HotBeanModuleType hotBeanModuleType = this.getHotBeanModuleType(moduleName); if (hotBeanModuleType != null) { hotBeanModuleType.removeModule(module); if (hotBeanModuleType.moduleCount() == 0) this.moduleRegistry.remove(moduleName); // If no revisions left // - remove key } } }
From source file:hotbeans.support.AbstractHotBeanModuleRepository.java
/** * Called to validate a HotBeanProxyFactory and module and bean references. *//*from w w w . j ava 2 s. c om*/ public void validateHotBeanProxyFactory(final HotBeanProxyFactory hotBeanProxyFactory) { boolean hotModuleSwapped = false; HotBeanModule currentModule = hotBeanProxyFactory.getCurrentModule(); Log logger = this.getLog(); if (logger.isDebugEnabled()) logger.debug("Validating " + hotBeanProxyFactory + " - current module: " + currentModule + "."); if ((currentModule != null) && !currentModule.isActive()) currentModule = null; // If current module is // inactive... if (currentModule == null) { currentModule = this.getHotBeanModule(hotBeanProxyFactory.getModuleName()); hotModuleSwapped = true; } // Swap target if (hotModuleSwapped) { if (logger.isDebugEnabled()) logger.debug("Swapping module of " + hotBeanProxyFactory + " - new current module: " + currentModule + "."); Object hotBean = null; // Get bean from hot bean context if (currentModule != null) hotBean = currentModule.getHotBean(hotBeanProxyFactory.getBeanName()); hotBeanProxyFactory.updateHotBeanModuleAndBean(currentModule, hotBean); } }
From source file:hotbeans.support.AbstractHotBeanModuleRepository.java
/** * Checks for obsolete revisions of a specific module name. *//* w w w .j a v a 2 s . c om*/ protected void checkForObsoleteModules(final String moduleName) { Log logger = this.getLog(); if (logger.isDebugEnabled()) logger.debug("Checking for obsolete/inactive module revisions for module " + moduleName + "."); synchronized (this.lock) { HotBeanModule currentModule = this.getHotBeanModule(moduleName); // Get current module for name HotBeanModule[] modules = this.getHotBeanModules(moduleName); // Get all revisions for module name HotBeanModuleType moduleType = this.getHotBeanModuleType(moduleName); boolean isRemoveType = moduleType.isRemoveType(); for (int r = 0; r < modules.length; r++) { if (modules[r] != null) { synchronized (modules[r]) { if (logger.isDebugEnabled()) logger.debug("Checking module revision " + modules[r] + " - usage count: " + modules[r].getUsageCount()); if (modules[r].isActive() || modules[r].isInactive()) // Only check module if active or inactive (i.e // loaded) { boolean obsolete = !modules[r].equals(currentModule); // Module is obsolete if it isn't the // latest(current) if (isRemoveType) { if (logger.isDebugEnabled()) logger.debug("Unloading removed module " + modules[r].toString(false) + "."); modules[r].unload(); } else if (obsolete && modules[r].isActive()) // If module is obsolete... { if (logger.isDebugEnabled()) logger.debug("Marking obsolete module " + modules[r].toString(false) + " as inactive."); modules[r].inactivate(); // ...mark as inactive.... } else if (modules[r].isInactive() && !modules[r].inUse()) // ...and unload it during the next // check (and when no longer in use) { if (logger.isDebugEnabled()) logger.debug("Unloading inactive module " + modules[r].toString(false) + "."); modules[r].unload(); } } if (isRemoveType) // Unregister removed module { this.unregisterHotBeanModule(modules[r]); } } } } } }
From source file:com.dhcc.framework.web.context.DhccContextLoader.java
/** * Template method with default implementation (which may be overridden by a * subclass), to load or obtain an ApplicationContext instance which will be * used as the parent context of the root WebApplicationContext. If the * return value from the method is null, no parent context is set. * <p>The main reason to load a parent context here is to allow multiple root * web application contexts to all be children of a shared EAR context, or * alternately to also share the same parent context that is visible to * EJBs. For pure web applications, there is usually no need to worry about * having a parent context to the root web application context. * <p>The default implementation uses * {@link org.springframework.context.access.ContextSingletonBeanFactoryLocator}, * configured via {@link #LOCATOR_FACTORY_SELECTOR_PARAM} and * {@link #LOCATOR_FACTORY_KEY_PARAM}, to load a parent context * which will be shared by all other users of ContextsingletonBeanFactoryLocator * which also use the same configuration parameters. * @param servletContext current servlet context * @return the parent application context, or {@code null} if none * @see org.springframework.context.access.ContextSingletonBeanFactoryLocator *//* ww w . j a va 2s .c o m*/ protected ApplicationContext loadParentContext(ServletContext servletContext) { ApplicationContext parentContext = null; String locatorFactorySelector = servletContext.getInitParameter(LOCATOR_FACTORY_SELECTOR_PARAM); String parentContextKey = servletContext.getInitParameter(LOCATOR_FACTORY_KEY_PARAM); if (parentContextKey != null) { // locatorFactorySelector may be null, indicating the default "classpath*:beanRefContext.xml" BeanFactoryLocator locator = ContextSingletonBeanFactoryLocator.getInstance(locatorFactorySelector); Log logger = LogFactory.getLog(DhccContextLoader.class); if (logger.isDebugEnabled()) { logger.debug("Getting parent context definition: using parent context key of '" + parentContextKey + "' with BeanFactoryLocator"); } this.parentContextRef = locator.useBeanFactory(parentContextKey); parentContext = (ApplicationContext) this.parentContextRef.getFactory(); } return parentContext; }