List of usage examples for org.apache.commons.logging Log info
void info(Object message);
From source file:org.ops4j.gaderian.examples.panorama.startup.impl.TestTaskExecutor.java
public void testSuccess() { ExecutableFixture f1 = new ExecutableFixture("f1"); Task t1 = new Task(); t1.setExecutable(f1);//from www . j av a 2s.co m t1.setId("first"); t1.setAfter("second"); t1.setTitle("Fixture #1"); ExecutableFixture f2 = new ExecutableFixture("f2"); Task t2 = new Task(); t2.setExecutable(f2); t2.setId("second"); t2.setTitle("Fixture #2"); List<Task> tasks = new ArrayList<Task>(); tasks.add(t1); tasks.add(t2); Log log = createMock(Log.class); TaskExecutor e = new TaskExecutor(); ErrorLog errorLog = createMock(ErrorLog.class); e.setErrorLog(errorLog); e.setLog(log); e.setMessages(getMessages()); e.setTasks(tasks); // Note the ordering; explicitly set, to check that ordering does // take place. log.info(find("Executing task Fixture #2.")); log.info(find("Executing task Fixture #1.")); log.info(find("Executed 2 tasks \\(in \\d+ milliseconds\\)\\.")); replayAllRegisteredMocks(); e.run(); assertListsEqual(new String[] { "f2", "f1" }, _tokens); verifyAllRegisteredMocks(); }
From source file:org.ops4j.gaderian.examples.panorama.startup.impl.TestTaskExecutor.java
public void testFailure() { Executable f = new Executable() { public void execute() throws Exception { throw new ApplicationRuntimeException("Failure!"); }//from w ww .jav a2 s .c om }; Task t = new Task(); t.setExecutable(f); t.setId("failure"); t.setTitle("Failure"); List tasks = Collections.singletonList(t); Log log = createMock(Log.class); ErrorLog errorLog = createMock(ErrorLog.class); log.info("Executing task Failure."); errorLog.error(eq("Exception while executing task Failure: Failure!"), (Location) eq(null), isA(ApplicationRuntimeException.class)); log.info(find("Executed one task with one failure \\(in \\d+ milliseconds\\)\\.")); replayAllRegisteredMocks(); TaskExecutor e = new TaskExecutor(); e.setErrorLog(errorLog); e.setLog(log); e.setMessages(getMessages()); e.setTasks(tasks); e.run(); verifyAllRegisteredMocks(); }
From source file:org.ops4j.pax.logging.internal.Activator.java
public void start(BundleContext bundleContext) throws Exception { org.ops4j.pax.logging.slf4j.Slf4jLoggerFactory.setBundleContext(bundleContext); String name = getClass().getName(); org.slf4j.Logger slf4jLogger = org.slf4j.LoggerFactory.getLogger(name); Slf4jMDCAdapter.setBundleContext(bundleContext); slf4jLogger.info("Enabling SLF4J API support."); org.apache.commons.logging.LogFactory.setBundleContext(bundleContext); org.apache.commons.logging.Log commonsLogger = org.apache.commons.logging.LogFactory.getLog(name); commonsLogger.info("Enabling Jakarta Commons Logging API support."); org.apache.log4j.Logger.setBundleContext(bundleContext); org.apache.log4j.MDC.setBundleContext(bundleContext); org.apache.log4j.Logger log4jLogger = org.apache.log4j.Logger.getLogger(name); log4jLogger.info("Enabling Log4J API support."); org.ops4j.pax.logging.avalon.AvalonLogFactory.setBundleContext(bundleContext); org.apache.avalon.framework.logger.Logger avalonLogger = org.ops4j.pax.logging.avalon.AvalonLogFactory .getLogger(name);//from w ww.jav a2s.c o m avalonLogger.info("Enabling Avalon Logger API support."); org.apache.juli.logging.LogFactory.setBundleContext(bundleContext); org.apache.juli.logging.Log juliLogger = org.apache.juli.logging.LogFactory.getLog(name); juliLogger.info("Enabling JULI Logger API support."); }
From source file:org.ops4j.pax.logging.internal.Activator.java
public void stop(BundleContext bundleContext) throws Exception { String name = getClass().getName(); org.slf4j.Logger slf4jLogger = org.slf4j.LoggerFactory.getLogger(name); slf4jLogger.info("Disabling SLF4J API support."); org.apache.commons.logging.Log commonsLogger = org.apache.commons.logging.LogFactory.getLog(name); commonsLogger.info("Disabling Jakarta Commons Logging API support."); org.apache.log4j.Logger log4jLogger = org.apache.log4j.Logger.getLogger(name); log4jLogger.info("Disabling Log4J API support."); org.apache.avalon.framework.logger.Logger avalonLogger = org.ops4j.pax.logging.avalon.AvalonLogFactory .getLogger(name);/*from w w w . ja v a 2s.com*/ avalonLogger.info("Disabling Avalon Logger API support."); org.apache.juli.logging.Log juliLogger = org.apache.juli.logging.LogFactory.getLog(name); juliLogger.info("Disabling JULI Logger API support."); org.ops4j.pax.logging.slf4j.Slf4jLoggerFactory.dispose(); Slf4jMDCAdapter.dispose(); org.apache.commons.logging.LogFactory.dispose(); org.apache.log4j.Logger.dispose(); org.apache.log4j.MDC.dispose(); org.ops4j.pax.logging.avalon.AvalonLogFactory.dispose(); org.apache.juli.logging.LogFactory.dispose(); }
From source file:org.pentaho.platform.plugin.condition.javascript.ConditionalExecution.java
public boolean shouldExecute(final Map currentInputs, final Log logger) throws Exception { boolean shouldExecute = true; Context cx = ContextFactory.getGlobal().enterContext(); try {//w ww . j a v a2 s . c o m ScriptableObject scriptable = new RhinoScriptable(); // initialize the standard javascript objects Scriptable scope = cx.initStandardObjects(scriptable); ScriptableObject.defineClass(scope, JavaScriptResultSet.class); Object inputValue; IActionParameter inputParameter; String inputName; Iterator inputs = currentInputs.entrySet().iterator(); Map.Entry mapEntry; while (inputs.hasNext()) { mapEntry = (Map.Entry) inputs.next(); inputName = (String) mapEntry.getKey(); if (inputName.indexOf('-') >= 0) { logger.info("Ignoring Input: " + inputName); //$NON-NLS-1$ continue; } inputParameter = (IActionParameter) mapEntry.getValue(); inputValue = inputParameter.getValue(); Object wrapper; if (inputValue instanceof IPentahoResultSet) { JavaScriptResultSet results = new JavaScriptResultSet(); // Required as of Rhino 1.7R1 to resolve caching, base object // inheritance and property tree results.setPrototype(scriptable); results.setResultSet((IPentahoResultSet) inputValue); wrapper = Context.javaToJS(inputValue, results); } else { wrapper = Context.javaToJS(inputValue, scope); } ScriptableObject.putProperty(scope, inputName, wrapper); } Object wrappedOut = Context.javaToJS(System.out, scope); Object wrappedThis = Context.javaToJS(this, scope); ScriptableObject.putProperty(scope, "out", wrappedOut); //$NON-NLS-1$ ScriptableObject.putProperty(scope, "rule", wrappedThis); //$NON-NLS-1$ // evaluate the script Object resultObject = cx.evaluateString(scope, script, "<cmd>", 1, null); //$NON-NLS-1$ Object actualObject = null; if (resultObject instanceof org.mozilla.javascript.NativeJavaObject) { actualObject = ((org.mozilla.javascript.NativeJavaObject) resultObject).unwrap(); } else { actualObject = resultObject; } if (actualObject instanceof Boolean) { return ((Boolean) actualObject).booleanValue(); } else if (actualObject instanceof String) { return ("true".equalsIgnoreCase(actualObject.toString())) || ("yes".equalsIgnoreCase(actualObject.toString())); //$NON-NLS-1$ //$NON-NLS-2$ } else if (actualObject instanceof Number) { return ((Number) actualObject).intValue() > 0; } else if (actualObject instanceof IPentahoResultSet) { return ((IPentahoResultSet) actualObject).getRowCount() > 0; } // } catch (Exception e) { // logger.error("Error executing conditional execution script.", e); } finally { Context.exit(); } return shouldExecute; }
From source file:org.pentaho.platform.plugin.condition.scriptable.ScriptableCondition.java
public boolean shouldExecute(final Map currentInputs, final Log logger) throws Exception { boolean shouldExecute = this.getDefaultResult(); ScriptEngineManager mgr = new ScriptEngineManager(); ScriptEngine engine = mgr.getEngineByName(this.getScriptLanguage()); if (engine == null) { throw new IllegalArgumentException(Messages.getInstance().getErrorString( "ScriptableCondition.ERROR_0001_ENGINE_NOT_AVAILABLE", this.getScriptLanguage())); //$NON-NLS-1$ }//from w w w .j a va 2 s.c om Object inputValue; IActionParameter inputParameter; String inputName = null; Iterator inputs = currentInputs.entrySet().iterator(); Map.Entry mapEntry; while (inputs.hasNext()) { mapEntry = (Map.Entry) inputs.next(); inputName = (String) mapEntry.getKey(); if (this.getIgnoreInputNamesWithMinus() && inputName.indexOf('-') >= 0) { logger.info(Messages.getInstance().getString("ScriptableCondition.INFO_IGNORED_INPUT", inputName)); //$NON-NLS-1$ continue; } inputParameter = (IActionParameter) mapEntry.getValue(); inputValue = inputParameter.getValue(); engine.put(inputName, inputValue); // What happens to resultset objects I wonder... } engine.put("out", System.out); engine.put("rule", this); Object resultObject = engine.eval(this.getScript()); if (resultObject instanceof Boolean) { return ((Boolean) resultObject).booleanValue(); } else if (resultObject instanceof String) { return ("true".equalsIgnoreCase(resultObject.toString())) || ("yes".equalsIgnoreCase(resultObject.toString())); //$NON-NLS-1$ //$NON-NLS-2$ } else if (resultObject instanceof Number) { return ((Number) resultObject).intValue() > 0; } else if (resultObject instanceof IPentahoResultSet) { return ((IPentahoResultSet) resultObject).getRowCount() > 0; } logger.info(Messages.getInstance().getString("ScriptableCondition.INFO_DEFAULT_RESULT_RETURNED")); //$NON-NLS-1$ return shouldExecute; }
From source file:org.pentaho.platform.plugin.services.versionchecker.PentahoVersionCheckReflectHelper.java
public static String logVersionCheck(final List results, final Log logger) { String output = null;//from w ww . ja v a2 s. c om if ((results != null) && (results.size() > 0)) { String result = results.get(0).toString(); try { Document doc = XmlDom4JHelper.getDocFromString(result, new PentahoEntityResolver()); if (doc != null) { List nodes = doc.selectNodes("//update"); //$NON-NLS-1$ Iterator nodeIter = nodes.iterator(); while (nodeIter.hasNext()) { Element updateElement = (Element) nodeIter.next(); String title = updateElement.attributeValue("title"); //$NON-NLS-1$ String version = updateElement.attributeValue("version"); //$NON-NLS-1$ String type = updateElement.attributeValue("type"); //$NON-NLS-1$ String downloadurl = XmlDom4JHelper.getNodeText("downloadurl", updateElement); //$NON-NLS-1$ if (downloadurl != null) { downloadurl = downloadurl.trim(); } logger.info(Messages.getString("VersionCheck.UPDATE_MESSAGE", title, version, type, //$NON-NLS-1$ downloadurl)); } nodes = doc.selectNodes("//error"); //$NON-NLS-1$ nodeIter = nodes.iterator(); while (nodeIter.hasNext()) { Element errorElement = (Element) nodeIter.next(); String message = errorElement.getText(); logger.info(Messages.getString("VersionCheck.ERROR_MESSAGE", message)); //$NON-NLS-1$ } } output = result; } catch (Exception e) { output = "<vercheck><error><[!CDATA[" //$NON-NLS-1$ + Messages.getString("VersionCheck.ERROR_MESSAGE", e.getMessage()) //$NON-NLS-1$ + "]]></error></vercheck>"; //$NON-NLS-1$ } } else { output = "<vercheck><error><[!CDATA[" + Messages.getString("VersionCheck.NO_RESULT_MESSAGE") //$NON-NLS-1$//$NON-NLS-2$ + "]]></error></vercheck>"; //$NON-NLS-1$ } return output; }
From source file:org.pentaho.platform.util.versionchecker.PentahoVersionCheckReflectHelper.java
public static String logVersionCheck(final List results, final Log logger) { String output = null;//from w w w .j a v a 2s .com if ((results != null) && (results.size() > 0)) { String result = results.get(0).toString(); try { Document doc = XmlDom4JHelper.getDocFromString(result, new PentahoEntityResolver()); if (doc != null) { List nodes = doc.selectNodes("//update"); //$NON-NLS-1$ Iterator nodeIter = nodes.iterator(); while (nodeIter.hasNext()) { Element updateElement = (Element) nodeIter.next(); String title = updateElement.attributeValue("title"); //$NON-NLS-1$ String version = updateElement.attributeValue("version"); //$NON-NLS-1$ String type = updateElement.attributeValue("type"); //$NON-NLS-1$ String downloadurl = XmlDom4JHelper.getNodeText("downloadurl", updateElement); //$NON-NLS-1$ if (downloadurl != null) { downloadurl = downloadurl.trim(); } logger.info(Messages.getInstance().getString("VersionCheck.UPDATE_MESSAGE", title, version, //$NON-NLS-1$ type, downloadurl)); } nodes = doc.selectNodes("//error"); //$NON-NLS-1$ nodeIter = nodes.iterator(); while (nodeIter.hasNext()) { Element errorElement = (Element) nodeIter.next(); String message = errorElement.getText(); logger.info(Messages.getInstance().getString("VersionCheck.ERROR_MESSAGE", message)); //$NON-NLS-1$ } } output = result; } catch (Exception e) { output = "<vercheck><error><[!CDATA[" //$NON-NLS-1$ + Messages.getInstance().getString("VersionCheck.ERROR_MESSAGE", e.getMessage()) //$NON-NLS-1$ + "]]></error></vercheck>"; //$NON-NLS-1$ } } else { output = "<vercheck><error><[!CDATA[" //$NON-NLS-1$ + Messages.getInstance().getString("VersionCheck.NO_RESULT_MESSAGE") + "]]></error></vercheck>"; //$NON-NLS-1$ //$NON-NLS-2$ } return output; }
From source file:org.pentaho.reporting.platform.plugin.ReportContentUtil.java
/** * Apply inputs (if any) to corresponding report parameters, care is taken when * checking parameter types to perform any necessary casting and conversion. * * @param report The report to retrieve parameter definitions and values from. * @param context a ParameterContext for which the parameters will be under * @param validationResult the validation result that will hold the warnings. If null, a new one will be created. * @return the validation result containing any parameter validation errors. * @throws java.io.IOException if the report of this component could not be parsed. * @throws ResourceException if the report of this component could not be parsed. *///www .j a va 2s . c o m public static ValidationResult applyInputsToReportParameters(final MasterReport report, final ParameterContext context, final Map<String, Object> inputs, ValidationResult validationResult) throws IOException, ResourceException { if (validationResult == null) { validationResult = new ValidationResult(); } // apply inputs to report if (inputs != null) { final Log log = LogFactory.getLog(SimpleReportingComponent.class); final ParameterDefinitionEntry[] params = report.getParameterDefinition().getParameterDefinitions(); final ReportParameterValues parameterValues = report.getParameterValues(); for (final ParameterDefinitionEntry param : params) { final String paramName = param.getName(); try { final Object computedParameter = ReportContentUtil.computeParameterValue(context, param, inputs.get(paramName)); parameterValues.put(param.getName(), computedParameter); if (log.isInfoEnabled()) { log.info(Messages.getInstance().getString("ReportPlugin.infoParameterValues", //$NON-NLS-1$ paramName, String.valueOf(inputs.get(paramName)), String.valueOf(computedParameter))); } } catch (Exception e) { if (log.isWarnEnabled()) { log.warn(Messages.getInstance().getString("ReportPlugin.logErrorParametrization"), e); //$NON-NLS-1$ } validationResult.addError(paramName, new ValidationMessage(e.getMessage())); } } } return validationResult; }
From source file:org.pentaho.test.platform.web.SessionIT.java
public void testStandAloneSession() { startTest();//from w ww . j a va 2 s . co m SimpleParameterProvider parameters = new SimpleParameterProvider(); parameters.setParameter("actionname", "ViewAction"); //$NON-NLS-1$ //$NON-NLS-2$ StandaloneSession session = new StandaloneSession("BaseTest.DEBUG_JUNIT_SESSION"); //$NON-NLS-1$ Log log = session.getLogger(); System.out.println("Action Name for the Session is " + session.getActionName()); //$NON-NLS-1$ session.setNotAuthenticated(); log.info("Session is active"); //$NON-NLS-1$ session.destroy(); assertTrue(true); finishTest(); }