List of usage examples for org.apache.commons.logging Log warn
void warn(Object message);
From source file:eu.qualityontime.commons.MethodUtils.java
/** * Try to make the method accessible/* w w w . j a v a2 s . c o m*/ * * @param method * The source arguments */ private static void setMethodAccessible(final Method method) { try { // // XXX Default access superclass workaround // // When a public class has a default access superclass // with public methods, these methods are accessible. // Calling them from compiled code works fine. // // Unfortunately, using reflection to invoke these methods // seems to (wrongly) to prevent access even when the method // modifer is public. // // The following workaround solves the problem but will only // work from sufficiently privilages code. // // Better workarounds would be greatfully accepted. // if (!method.isAccessible()) { method.setAccessible(true); } } catch (final SecurityException se) { // log but continue just in case the method.invoke works anyway final Log log = LogFactory.getLog(MethodUtils.class); if (!loggedAccessibleWarning) { boolean vulnerableJVM = false; try { final String specVersion = System.getProperty("java.specification.version"); if (specVersion.charAt(0) == '1' && (specVersion.charAt(2) == '0' || specVersion.charAt(2) == '1' || specVersion.charAt(2) == '2' || specVersion.charAt(2) == '3')) { vulnerableJVM = true; } } catch (final SecurityException e) { // don't know - so display warning vulnerableJVM = true; } if (vulnerableJVM) { log.warn("Current Security Manager restricts use of workarounds for reflection bugs " + " in pre-1.4 JVMs."); } loggedAccessibleWarning = true; } log.debug("Cannot setAccessible on method. Therefore cannot use jvm access bug workaround.", se); } }
From source file:com.boylesoftware.web.AbstractWebApplication.java
/** * Clean-up the application object.//from w ww. j av a2 s . com */ private void cleanup() { // get the log final Log log = LogFactory.getLog(AbstractWebApplication.class); log.debug("destroying the web-application"); // shutdown the executors if (this.executors != null) { log.debug("shutting down the request processing executors..."); this.executors.shutdown(); try { boolean success = true; if (!this.executors.awaitTermination(30, TimeUnit.SECONDS)) { log.warn("could not shutdown the request processing" + " executors in 30 seconds, trying to force" + " shutdown..."); this.executors.shutdownNow(); if (!this.executors.awaitTermination(30, TimeUnit.SECONDS)) { log.error("could not shutdown the request processing" + " executors"); success = false; } } if (success) log.debug("request processing executors shut down"); } catch (final InterruptedException e) { log.warn("waiting for the request processing executors to" + " shutdown was interrupted"); this.executors.shutdownNow(); Thread.currentThread().interrupt(); } finally { this.executors = null; } } // destroy custom application log.debug("destroying custom application"); try { this.destroy(); } catch (final Exception e) { log.error("error destroying custom application", e); } // forget the router configuration this.routerConfiguration = null; // close and forget the entity manager factory final EntityManagerFactory emf = this.services.getEntityManagerFactory(); if (emf != null) { this.services.setEntityManagerFactory(null); try { log.debug("closing persistence manager factory"); emf.close(); } catch (final Exception e) { log.error("error shutting down the application", e); } } // forget user locale finder this.services.setUserLocaleFinder(null); // close and forget the validator factory final ValidatorFactory vf = this.services.getValidatorFactory(); if (vf != null) { this.services.setValidatorFactory(null); try { log.debug("closing validator factory"); vf.close(); } catch (final Exception e) { log.error("error shutting down the application", e); } } // forget the authentication service this.services.setAuthenticationService(null); }
From source file:com.timeinc.seleniumite.junit.SimpleSeleniumBuilderTest.java
public void testSeleniumIdeFile() throws Exception { String threaded = (runSingleThreaded) ? "Single-Thread" : "Multi-Threaded"; LOG.info("{} processing file : {}", threaded, testingEnvironment); List<String> failures = new LinkedList<>(); RetryingTestRun lastRun = null;/* w ww .j a v a 2s .co m*/ Log log = LogFactory.getFactory().getInstance(SimpleSeleniumBuilderTest.class); HashMap<String, String> driverConfig = testingEnvironment .createDriverConfig(DefaultRawGlobalTestConfiguration.getDefault()); Predicate<Exception> retryPredicate = createRetryPredicate(); RetryingTestRunFactory testRunFactory = new RetryingTestRunFactory(); for (Script script : testingEnvironment.createScripts()) { LoggingRemoteWebDriverFactory wdf = new LoggingRemoteWebDriverFactory( testingEnvironment.webDriverFactory(), script.name); LOG.info("Executing script {}", script.name); for (Map<String, String> data : script.dataRows) { Step currentStep = null; try { lastRun = testRunFactory.createTestRun(script, log, wdf, driverConfig, data, lastRun); Boolean lastStepResult = null; if (!lastRun.hasNext()) { LOG.warn("Has next is false and havent started yet"); } // Actually run the script while (lastRun.hasNext()) { lastStepResult = lastRun.nextWithRetry(3, 3, retryPredicate); // 3 tries with 3 second waits currentStep = lastRun.currentStep(); LOG.debug("{} for step : {}", lastStepResult, currentStep.toJSON()); } String sessionId = "SID:" + SessionRegistry.INSTANCE.lookup(script.name, driverConfig); String message = createMessage(lastStepResult, testingEnvironment, sessionId, currentStep); LOG.info(message); if (!Boolean.TRUE.equals(lastStepResult)) { failures.add(message); } } catch (Exception e) { Throwable throwableToLog = unwrapWebDriverException(e); String sessionId = "SID:" + SessionRegistry.INSTANCE.lookup(script.name, driverConfig); String message = createMessage(false, testingEnvironment, sessionId, currentStep, throwableToLog); LOG.info(message); failures.add(message); } // Run "finish" so that it'll shut down the driver if necessary try { if (lastRun != null) { lastRun.finish(); } } catch (Exception e) { LOG.debug("Error while trying to shut down", e); } } } if (failures.size() > 0) { LOG.info("Failing test with : {}", failures); Assert.fail("Test Failure : " + failures.toString()); } }
From source file:interactivespaces.service.comm.serial.xbee.internal.SimpleResponseXBeeFrameHandler.java
@Override public void handle(XBeeCommunicationEndpoint endpoint, EscapedXBeeFrameReader reader, List<XBeeResponseListener> listeners, Log log) throws InterruptedException { int packetLength = reader.readPacketLength(); int frameType = reader.readByte(); int bytesLeft = packetLength - 1; switch (frameType) { case XBeeApiConstants.FRAME_TYPE_AT_LOCAL_RESPONSE: signalAtLocalResponse(endpoint, parser.parseAtLocalResponse(reader, bytesLeft, log), listeners, log); break;// w w w.j a v a 2 s. c om case XBeeApiConstants.FRAME_TYPE_AT_REMOTE_RESPONSE: signalAtRemoteResponse(endpoint, parser.parseAtRemoteResponse(reader, bytesLeft, log), listeners, log); break; case XBeeApiConstants.FRAME_TYPE_TX_STATUS: signalTxStatus(endpoint, parser.parseTxStatus(reader, bytesLeft, log), listeners, log); break; case XBeeApiConstants.FRAME_TYPE_RX_RECEIVE: signalRxResponse(endpoint, parser.parseRxResponse(reader, bytesLeft, log), listeners, log); break; case XBeeApiConstants.FRAME_TYPE_RX_IO: signalRxIoResponse(endpoint, parser.parseIoSampleResponse(reader, bytesLeft, log), listeners, log); break; default: log.warn(String.format("Unknown frame type %d\n", frameType)); } }
From source file:net.sourceforge.eclipsetrader.charts.ChartsPlugin.java
public static Chart createDefaultChart() { Log logger = LogFactory.getLog(ChartsPlugin.class); SimpleDateFormat dateTimeFormat = new SimpleDateFormat("dd/MM/yyyy HH:mm:ss"); //$NON-NLS-1$ Chart chart = new Chart(); File file = ChartsPlugin.getDefault().getStateLocation().append("defaultChart.xml").toFile(); //$NON-NLS-1$ if (file.exists() == true) { try {/* w w w .j ava 2s .com*/ DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); DocumentBuilder builder = factory.newDocumentBuilder(); Document document = builder.parse(file); NodeList firstNode = document.getFirstChild().getChildNodes(); for (int r = 0; r < firstNode.getLength(); r++) { Node item = firstNode.item(r); Node valueNode = item.getFirstChild(); String nodeName = item.getNodeName(); if (valueNode != null) { if (nodeName.equalsIgnoreCase("compression") == true) //$NON-NLS-1$ chart.setCompression(Integer.parseInt(valueNode.getNodeValue())); else if (nodeName.equalsIgnoreCase("period") == true) //$NON-NLS-1$ chart.setPeriod(Integer.parseInt(valueNode.getNodeValue())); else if (nodeName.equalsIgnoreCase("autoScale") == true) //$NON-NLS-1$ chart.setAutoScale(new Boolean(valueNode.getNodeValue()).booleanValue()); else if (nodeName.equalsIgnoreCase("begin") == true) //$NON-NLS-1$ { try { chart.setBeginDate(dateTimeFormat.parse(valueNode.getNodeValue())); } catch (Exception e) { logger.warn(e.toString()); } } else if (nodeName.equalsIgnoreCase("end") == true) //$NON-NLS-1$ { try { chart.setEndDate(dateTimeFormat.parse(valueNode.getNodeValue())); } catch (Exception e) { logger.warn(e.toString()); } } } if (nodeName.equalsIgnoreCase("row")) //$NON-NLS-1$ { ChartRow row = new ChartRow(new Integer(r)); row.setParent(chart); NodeList tabList = item.getChildNodes(); for (int t = 0; t < tabList.getLength(); t++) { item = tabList.item(t); nodeName = item.getNodeName(); if (nodeName.equalsIgnoreCase("tab")) //$NON-NLS-1$ { ChartTab tab = new ChartTab(new Integer(t)); tab.setParent(row); tab.setLabel(((Node) item).getAttributes().getNamedItem("label").getNodeValue()); //$NON-NLS-1$ NodeList indicatorList = item.getChildNodes(); for (int i = 0; i < indicatorList.getLength(); i++) { item = indicatorList.item(i); nodeName = item.getNodeName(); if (nodeName.equalsIgnoreCase("indicator")) //$NON-NLS-1$ { ChartIndicator indicator = new ChartIndicator(new Integer(i)); indicator.setParent(tab); indicator.setPluginId(((Node) item).getAttributes().getNamedItem("pluginId") //$NON-NLS-1$ .getNodeValue()); NodeList parametersList = item.getChildNodes(); for (int p = 0; p < parametersList.getLength(); p++) { item = parametersList.item(p); nodeName = item.getNodeName(); if (nodeName.equalsIgnoreCase("param")) //$NON-NLS-1$ { String key = ((Node) item).getAttributes().getNamedItem("key") //$NON-NLS-1$ .getNodeValue(); String value = ((Node) item).getAttributes().getNamedItem("value") //$NON-NLS-1$ .getNodeValue(); indicator.getParameters().put(key, value); } } tab.getIndicators().add(indicator); } else if (nodeName.equalsIgnoreCase("object")) //$NON-NLS-1$ { ChartObject object = new ChartObject(new Integer(i)); object.setParent(tab); object.setPluginId(((Node) item).getAttributes().getNamedItem("pluginId") //$NON-NLS-1$ .getNodeValue()); NodeList parametersList = item.getChildNodes(); for (int p = 0; p < parametersList.getLength(); p++) { item = parametersList.item(p); nodeName = item.getNodeName(); if (nodeName.equalsIgnoreCase("param")) //$NON-NLS-1$ { String key = ((Node) item).getAttributes().getNamedItem("key") //$NON-NLS-1$ .getNodeValue(); String value = ((Node) item).getAttributes().getNamedItem("value") //$NON-NLS-1$ .getNodeValue(); object.getParameters().put(key, value); } } tab.getObjects().add(object); } } row.getTabs().add(tab); } } chart.getRows().add(row); } } } catch (Exception e) { logger.error(e.toString(), e); } } chart.clearChanged(); return chart; }
From source file:interactivespaces.system.bootstrap.osgi.GeneralInteractiveSpacesSupportActivator.java
/** * Get the time provider to use./*from w w w. j ava 2s .com*/ * * @param containerProperties * properties to use for configuration * @param log * logger for messages * * @return the time provider to use */ public TimeProvider getTimeProvider(Map<String, String> containerProperties, Log log) { String provider = containerProperties.get(InteractiveSpacesEnvironment.CONFIGURATION_PROVIDER_TIME); if (provider == null) { provider = InteractiveSpacesEnvironment.CONFIGURATION_VALUE_PROVIDER_TIME_DEFAULT; } if (InteractiveSpacesEnvironment.CONFIGURATION_VALUE_PROVIDER_TIME_NTP.equals(provider)) { String host = containerProperties.get(InteractiveSpacesEnvironment.CONFIGURATION_PROVIDER_TIME_NTP_URL); if (host != null) { InetAddress ntpAddress = InetAddressFactory.newFromHostString(host); // TODO(keith): Make sure got valid address. Also, move copy of // factory class into IS. return new NtpTimeProvider(ntpAddress, NTP_UPDATE_PERIOD_SECONDS, TimeUnit.SECONDS, executorService, log); } else { log.warn(String.format("Could not find host for NTP time provider. No value for configuration %s", InteractiveSpacesEnvironment.CONFIGURATION_PROVIDER_TIME_NTP_URL)); return new LocalTimeProvider(); } } else { return new LocalTimeProvider(); } }
From source file:io.smartspaces.system.bootstrap.osgi.GeneralSmartSpacesSupportActivator.java
/** * Get the time provider to use./*from w w w.ja va2 s. co m*/ * * @param containerProperties * properties to use for configuration * @param log * logger for messages * * @return the time provider to use */ public TimeProvider getTimeProvider(Map<String, String> containerProperties, Log log) { String provider = containerProperties.get(SmartSpacesEnvironment.CONFIGURATION_NAME_PROVIDER_TIME); if (provider == null) { provider = SmartSpacesEnvironment.CONFIGURATION_VALUE_PROVIDER_TIME_DEFAULT; } if (SmartSpacesEnvironment.CONFIGURATION_VALUE_PROVIDER_TIME_NTP.equals(provider)) { String host = containerProperties.get(SmartSpacesEnvironment.CONFIGURATION_NAME_PROVIDER_TIME_NTP_URL); if (host != null) { InetAddress ntpAddress = InetAddressFactory.newFromHostString(host); // TODO(keith): Make sure got valid address. Also, move copy of // factory class into SS. return new NtpTimeProvider(ntpAddress, NTP_UPDATE_PERIOD_SECONDS, TimeUnit.SECONDS, executorService, log); } else { log.warn(String.format("Could not find host for NTP time provider. No value for configuration %s", SmartSpacesEnvironment.CONFIGURATION_NAME_PROVIDER_TIME_NTP_URL)); return new LocalTimeProvider(); } } else { return new LocalTimeProvider(); } }
From source file:com.flexive.shared.exceptions.FxApplicationException.java
/** * Log a message at a given level (or error if no level given) * * @param log Log to use//w w w . ja v a 2s .c o m * @param message message to LOG * @param level log4j level to apply */ private void logMessage(Log log, String message, LogLevel level) { this.messageLogged = true; if (FxContext.get() != null && FxContext.get().isTestDivision()) return; //dont log exception traces during automated tests final Throwable cause = getCause() != null ? getCause() : this; if (level == null) log.error(message, cause); else { switch (level) { case DEBUG: if (log.isDebugEnabled()) log.debug(message); break; case ERROR: if (log.isErrorEnabled()) log.error(message, cause); break; case FATAL: if (log.isFatalEnabled()) log.fatal(message, cause); break; case INFO: if (log.isInfoEnabled()) log.info(message); break; // case Level.WARN_INT: default: if (log.isWarnEnabled()) log.warn(message); } } }
From source file:eu.qualityontime.commons.QPropertyUtilsBean.java
/** * Returns a <code>Method<code> allowing access to * {@link Throwable#initCause(Throwable)} method of {@link Throwable}, * or <code>null</code> if the method does not exist. * * @return A <code>Method<code> for <code>Throwable.initCause</code>, or * <code>null</code> if unavailable. *//*from w w w . ja v a2 s . co m*/ private static Method getInitCauseMethod() { try { final Class<?>[] paramsClasses = new Class<?>[] { Throwable.class }; return Throwable.class.getMethod("initCause", paramsClasses); } catch (final NoSuchMethodException e) { final Log log = LogFactory.getLog(QPropertyUtils.class); if (log.isWarnEnabled()) { log.warn("Throwable does not have initCause() method in JDK 1.3"); } return null; } catch (final Throwable e) { final Log log = LogFactory.getLog(QPropertyUtils.class); if (log.isWarnEnabled()) { log.warn("Error getting the Throwable initCause() method", e); } return null; } }
From source file:edu.stanford.muse.util.Util.java
public static void warnIf(boolean b, String message, Log log) { if (b) {//w w w. jav a2s .co m log.warn("REAL WARNING: " + message + "\n"); breakpoint(); } }