List of usage examples for org.apache.commons.logging Log isDebugEnabled
boolean isDebugEnabled();
From source file:org.red5.io.utils.IOUtils.java
/** * Format debug message/*w ww.j a va 2 s . com*/ * @param log Logger * @param msg Message * @param buf Byte buffer to debug */ public static void debug(Log log, String msg, ByteBuffer buf) { if (log.isDebugEnabled()) { log.debug(msg); log.debug("Size: " + buf.remaining()); log.debug("Data:\n\n" + HexDump.formatHexDump(buf.getHexDump())); final String string = toString(buf); log.debug("\n" + string + "\n"); //log.debug("Data:\n\n" + b); } }
From source file:org.rhq.enterprise.gui.legacy.action.resource.common.monitor.alerts.RemoveAction.java
/** * removes alerts/*from w w w . j a v a 2 s . c o m*/ */ @Override public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { Log log = LogFactory.getLog(RemoveAction.class); log.debug("entering removeAlertsAction"); RemoveForm nwForm = (RemoveForm) form; Integer resourceId = nwForm.getId(); Map<String, Integer> params = new HashMap<String, Integer>(); params.put(ParamConstants.RESOURCE_ID_PARAM, resourceId); ActionForward forward = checkSubmit(request, mapping, form, params); // if the remove button was clicked, we are coming from // the alerts list page and just want to continue // processing ... if ((forward != null) && !forward.getName().equals(RetCodeConstants.REMOVE_URL)) { log.trace("returning " + forward); // if there is no resourceId -- go to dashboard on cancel if (forward.getName().equals(RetCodeConstants.CANCEL_URL) && (resourceId == null)) { return returnNoResource(request, mapping); } return forward; } Integer[] alertIds = nwForm.getAlerts(); if (log.isDebugEnabled()) { log.debug("removing: " + Arrays.asList(alertIds)); } if ((alertIds == null) || (alertIds.length == 0)) { return returnSuccess(request, mapping, params); } if (resourceId == null) return returnNoResource(request, mapping); AlertManagerLocal alertManager = LookupUtil.getAlertManager(); alertManager.deleteAlerts(WebUtility.getSubject(request), ArrayUtils.unwrapArray(alertIds)); if (log.isDebugEnabled()) log.debug("!!!!!!!!!!!!!!!! removing alerts!!!!!!!!!!!!"); return returnSuccess(request, mapping, params); }
From source file:org.rhq.enterprise.server.alert.engine.model.AvailabilityDurationCacheElement.java
/** * Each avail duration check is performed by triggering an execution of {@link AlertAvailabilityDurationJob}. * Note that each of the scheduled jobs is relevant to only 1 condition evaluation. * // ww w.jav a 2s . c om * @param cacheElement * @param resource */ private static void scheduleAvailabilityDurationCheck(AvailabilityDurationCacheElement cacheElement, Resource resource) { Log log = LogFactory.getLog(AvailabilityDurationCacheElement.class.getName()); String jobName = AlertAvailabilityDurationJob.class.getName(); String jobGroupName = AlertAvailabilityDurationJob.class.getName(); String operator = cacheElement.getAlertConditionOperator().name(); String triggerName = operator + "-" + resource.getId(); String duration = (String) cacheElement.getAlertConditionOperatorOption(); // convert from seconds to milliseconds Date jobTime = new Date(System.currentTimeMillis() + (Long.valueOf(duration).longValue() * 1000)); if (log.isDebugEnabled()) { log.debug("Scheduling availability duration job for [" + DateFormat.getDateTimeInstance().format(jobTime) + "]"); } JobDataMap jobDataMap = new JobDataMap(); // the condition id is needed to ensure we limit the future avail checking to the one relevant alert condition jobDataMap.put(AlertAvailabilityDurationJob.DATAMAP_CONDITION_ID, String.valueOf(cacheElement.getAlertConditionTriggerId())); jobDataMap.put(AlertAvailabilityDurationJob.DATAMAP_RESOURCE_ID, String.valueOf(resource.getId())); jobDataMap.put(AlertAvailabilityDurationJob.DATAMAP_OPERATOR, operator); jobDataMap.put(AlertAvailabilityDurationJob.DATAMAP_DURATION, duration); Trigger trigger = new SimpleTrigger(triggerName, jobGroupName, jobTime); trigger.setJobName(jobName); trigger.setJobGroup(jobGroupName); trigger.setJobDataMap(jobDataMap); try { LookupUtil.getSchedulerBean().scheduleJob(trigger); } catch (Throwable t) { log.warn("Unable to schedule availability duration job for [" + resource + "] with JobData [" + jobDataMap.values() + "]", t); } }
From source file:org.rhq.enterprise.server.xmlschema.ServerPluginDescriptorUtil.java
/** * Loads a plugin descriptor from the given plugin jar and returns it. If the given jar does not * have a server plugin descriptor, <code>null</code> will be returned, meaning this is not * a server plugin jar./*from w w w .j a v a2 s . c o m*/ * * @param pluginJarFileUrl URL to a plugin jar file * @return the plugin descriptor found in the given plugin jar file, or <code>null</code> if there * is no plugin descriptor in the jar file * @throws Exception if failed to parse the descriptor file found in the plugin jar */ public static ServerPluginDescriptorType loadPluginDescriptorFromUrl(URL pluginJarFileUrl) throws Exception { final Log logger = LogFactory.getLog(ServerPluginDescriptorUtil.class); if (pluginJarFileUrl == null) { throw new Exception("A valid plugin JAR URL must be supplied."); } if (logger.isDebugEnabled()) { logger.debug("Loading plugin descriptor from plugin jar at [" + pluginJarFileUrl + "]..."); } testPluginJarIsReadable(pluginJarFileUrl); JarInputStream jis = null; JarEntry descriptorEntry = null; try { jis = new JarInputStream(pluginJarFileUrl.openStream()); JarEntry nextEntry = jis.getNextJarEntry(); while (nextEntry != null && descriptorEntry == null) { if (PLUGIN_DESCRIPTOR_PATH.equals(nextEntry.getName())) { descriptorEntry = nextEntry; } else { jis.closeEntry(); nextEntry = jis.getNextJarEntry(); } } ServerPluginDescriptorType pluginDescriptor = null; if (descriptorEntry != null) { Unmarshaller unmarshaller = null; try { unmarshaller = getServerPluginDescriptorUnmarshaller(); Object jaxbElement = unmarshaller.unmarshal(jis); pluginDescriptor = ((JAXBElement<? extends ServerPluginDescriptorType>) jaxbElement).getValue(); } finally { if (unmarshaller != null) { ValidationEventCollector validationEventCollector = (ValidationEventCollector) unmarshaller .getEventHandler(); logValidationEvents(pluginJarFileUrl, validationEventCollector); } } } return pluginDescriptor; } catch (Exception e) { throw new Exception("Could not successfully parse the plugin descriptor [" + PLUGIN_DESCRIPTOR_PATH + "] found in plugin jar at [" + pluginJarFileUrl + "]", e); } finally { if (jis != null) { try { jis.close(); } catch (Exception e) { logger.warn("Cannot close jar stream [" + pluginJarFileUrl + "]. Cause: " + e); } } } }
From source file:org.sakaiproject.site.tool.AdminSitesAction.java
/** * Search for a {@link User} object by primary key (i.e. <code>User.id</code>). * //w w w .j av a 2 s .c om * @see UserDirectoryService#getUser(String) * @param userPk a String to be treated as a user's Sakai-internal primary key; * must not be <code>null</code> * @return a resolved {@link User} or <code>null</code>, signifying no results */ protected User findUserByPk(String userPk) { try { User user = UserDirectoryService.getUser(userPk); return user; } catch (UserNotDefinedException e) { if (Log.isDebugEnabled()) { Log.debug("chef", "Failed to find a user record by PK [pk = " + userPk + "]", e); } return null; } }
From source file:org.sakaiproject.site.tool.AdminSitesAction.java
/** * Search for a {@link User} object by user "enterprise identifier", * (i.e. <code>User.eid</code>). * /*w w w . ja v a 2s. c om*/ * @see UserDirectoryService#getUserByEid(String) * @param eid a String to be treated as a user's "enterprise identifier"; * must not be <code>null</code> * @return a resolved {@link User} or <code>null</code>, signifying no results */ protected User findUserByEid(String eid) { try { User user = UserDirectoryService.getUserByEid(eid); return user; } catch (UserNotDefinedException e) { if (Log.isDebugEnabled()) { Log.debug("chef", "Failed to find a user record by EID [eid = " + eid + "]", e); } return null; } }
From source file:org.sakaiproject.site.tool.AdminSitesAction.java
/** * Search for the given {@link User}'s workspace {@link Site}. * // w w w . j a v a 2 s . c o m * @param knownUser user having a Sakai primary key (doesn't necessarily * mean the user has actually signed in yet). Must not be <code>null</code> * @return the user's workspace site or <code>null<code> if no such thing, e.g. * if the user has not yet logged in. */ protected Site findUserSite(User knownUser) { String userDbId = knownUser.getId(); String userEid = knownUser.getEid(); String userMyWorkspaceSiteDbId = SiteService.getUserSiteId(userDbId); try { Site userSite = SiteService.getSite(userMyWorkspaceSiteDbId); // exceptional if no results return userSite; } catch (IdUnusedException e) { if (Log.isDebugEnabled()) { Log.debug("chef", "Failed to locate a workspace for user [user id = " + userDbId + "][user eid = " + userEid + "][site id = " + userMyWorkspaceSiteDbId + "]", e); } return null; } }
From source file:org.seasar.struts.action.impl.ActionFactoryImpl.java
public Object getActionInstance(HttpServletRequest request, HttpServletResponse response, ActionMapping mapping, Log log, MessageResources internal, ActionServlet servlet) throws IOException { Object actionInstance = null; S2Container container = SingletonS2ContainerFactory.getContainer(); try {//from w ww . j a v a 2s .com if (isCreateActionWithComponentName(mapping)) { String componentName = this.componentNameCreator.createComponentName(container, mapping); actionInstance = getActionWithComponentName(componentName, servlet); } else { String actionClassName = mapping.getType(); if (log.isDebugEnabled()) { log.debug(" Looking for Action instance for class " + actionClassName); } Class componentKey = this.classRegister.getClass(actionClassName); actionInstance = container.getComponent(componentKey); } } catch (Exception e) { processExceptionActionCreate(S2StrutsContextUtil.getResponse(container), mapping, log, internal, e); return null; } if (actionInstance instanceof Action) { setServlet((Action) actionInstance, servlet); } return actionInstance; }
From source file:org.soaplab.share.SoaplabException.java
/****************************************************************************** * Format given exception 'e' depending on how serious it it. In * same cases add stack trace. Log the result in the given * 'log'. <p>//from w ww .j a v a 2 s. c o m * * @param e an exception to be formatted and logged * @param log where to log it * ******************************************************************************/ public static void formatAndLog(Throwable e, org.apache.commons.logging.Log log) { boolean seriousError = (e instanceof java.lang.RuntimeException); if (seriousError || log.isDebugEnabled()) { StringWriter sw = new StringWriter(500); e.printStackTrace(new PrintWriter(sw)); if (seriousError) log.error(sw.toString()); else log.debug(sw.toString()); } else { log.error(e.getMessage()); } }
From source file:org.springframework.amqp.rabbit.connection.SSLConnectionTests.java
@Test public void testKSTS() throws Exception { RabbitConnectionFactoryBean fb = new RabbitConnectionFactoryBean(); Log logger = spy(TestUtils.getPropertyValue(fb, "logger", Log.class)); given(logger.isDebugEnabled()).willReturn(true); new DirectFieldAccessor(fb).setPropertyValue("logger", logger); fb.setUseSSL(true);//from w ww .j a va2 s. c om fb.setKeyStoreType("JKS"); fb.setKeyStoreResource(new ClassPathResource("test.ks")); fb.setKeyStorePassphrase("secret"); fb.setTrustStoreResource(new ClassPathResource("test.truststore.ks")); fb.setKeyStorePassphrase("secret"); fb.setSecureRandom(SecureRandom.getInstanceStrong()); fb.afterPropertiesSet(); fb.getObject(); ArgumentCaptor<String> captor = ArgumentCaptor.forClass(String.class); verify(logger).debug(captor.capture()); final String log = captor.getValue(); assertThat(log, allOf(containsString("KM: ["), containsString("TM: ["), containsString("random: java."))); }