List of usage examples for org.apache.commons.logging Log info
void info(Object message);
From source file:org.quartz.examples.example7.InterruptExample.java
public void run() throws Exception { final Log log = LogFactory.getLog(InterruptExample.class); log.info("------- Initializing ----------------------"); // First we must get a reference to a scheduler SchedulerFactory sf = new StdSchedulerFactory(); Scheduler sched = sf.getScheduler(); log.info("------- Initialization Complete -----------"); log.info("------- Scheduling Jobs -------------------"); // get a "nice round" time a few seconds in the future... long ts = TriggerUtils.getNextGivenSecondDate(null, 15).getTime(); JobDetail job = new JobDetail("interruptableJob1", "group1", DumbInterruptableJob.class); SimpleTrigger trigger = new SimpleTrigger("trigger1", "group1", new Date(ts), null, SimpleTrigger.REPEAT_INDEFINITELY, 5000L); Date ft = sched.scheduleJob(job, trigger); log.info(job.getFullName() + " will run at: " + ft + " and repeat: " + trigger.getRepeatCount() + " times, every " + trigger.getRepeatInterval() / 1000 + " seconds"); // start up the scheduler (jobs do not start to fire until // the scheduler has been started) sched.start();//from w w w . j a v a2s. co m log.info("------- Started Scheduler -----------------"); log.info("------- Starting loop to interrupt job every 7 seconds ----------"); for (int i = 0; i < 50; i++) { try { Thread.sleep(7000L); // tell the scheduler to interrupt our job sched.interrupt(job.getName(), job.getGroup()); } catch (Exception e) { } } log.info("------- Shutting Down ---------------------"); sched.shutdown(true); log.info("------- Shutdown Complete -----------------"); SchedulerMetaData metaData = sched.getMetaData(); log.info("Executed " + metaData.getNumberOfJobsExecuted() + " jobs."); }
From source file:org.quartz.examples.example8.CalendarExample.java
public void run() throws Exception { final Log log = LogFactory.getLog(CalendarExample.class); log.info("------- Initializing ----------------------"); // First we must get a reference to a scheduler SchedulerFactory sf = new StdSchedulerFactory(); Scheduler sched = sf.getScheduler(); log.info("------- Initialization Complete -----------"); log.info("------- Scheduling Jobs -------------------"); // Add the holiday calendar to the schedule AnnualCalendar holidays = new AnnualCalendar(); // fourth of July (July 4) Calendar fourthOfJuly = new GregorianCalendar(2005, 6, 4); holidays.setDayExcluded(fourthOfJuly, true); // halloween (Oct 31) Calendar halloween = new GregorianCalendar(2005, 9, 31); holidays.setDayExcluded(halloween, true); // christmas (Dec 25) Calendar christmas = new GregorianCalendar(2005, 11, 25); holidays.setDayExcluded(christmas, true); // tell the schedule about our holiday calendar sched.addCalendar("holidays", holidays, false, false); // schedule a job to run hourly, starting on halloween // at 10 am/*from www. j a v a2s . co m*/ Date runDate = TriggerUtils.getDateOf(0, 0, 10, 31, 10); JobDetail job = new JobDetail("job1", "group1", SimpleJob.class); SimpleTrigger trigger = new SimpleTrigger("trigger1", "group1", runDate, null, SimpleTrigger.REPEAT_INDEFINITELY, 60L * 60L * 1000L); // tell the trigger to obey the Holidays calendar! trigger.setCalendarName("holidays"); // schedule the job and print the first run date Date firstRunTime = sched.scheduleJob(job, trigger); // print out the first execution date. // Note: Since Halloween (Oct 31) is a holiday, then // we will not run unti the next day! (Nov 1) log.info(job.getFullName() + " will run at: " + firstRunTime + " and repeat: " + trigger.getRepeatCount() + " times, every " + trigger.getRepeatInterval() / 1000 + " seconds"); // All of the jobs have been added to the scheduler, but none of the jobs // will run until the scheduler has been started log.info("------- Starting Scheduler ----------------"); sched.start(); // wait 30 seconds: // note: nothing will run log.info("------- Waiting 30 seconds... --------------"); try { // wait 30 seconds to show jobs Thread.sleep(30L * 1000L); // executing... } catch (Exception e) { } // shut down the scheduler log.info("------- Shutting Down ---------------------"); sched.shutdown(true); log.info("------- Shutdown Complete -----------------"); SchedulerMetaData metaData = sched.getMetaData(); log.info("Executed " + metaData.getNumberOfJobsExecuted() + " jobs."); }
From source file:org.quartz.examples.example9.ListenerExample.java
public void run() throws Exception { Log log = LogFactory.getLog(ListenerExample.class); log.info("------- Initializing ----------------------"); // First we must get a reference to a scheduler SchedulerFactory sf = new StdSchedulerFactory(); Scheduler sched = sf.getScheduler(); log.info("------- Initialization Complete -----------"); log.info("------- Scheduling Jobs -------------------"); // schedule a job to run immediately JobDetail job = new JobDetail("job1", "group1", SimpleJob.class); SimpleTrigger trigger = new SimpleTrigger("trigger1", "group1", new Date(), null, 0, 0); // Set up the listener JobListener listener = new Job1Listener(); sched.addJobListener(listener);/*from w ww. ja v a2 s. c om*/ // make sure the listener is associated with the job job.addJobListener(listener.getName()); // schedule the job to run sched.scheduleJob(job, trigger); // All of the jobs have been added to the scheduler, but none of the jobs // will run until the scheduler has been started log.info("------- Starting Scheduler ----------------"); sched.start(); // wait 30 seconds: // note: nothing will run log.info("------- Waiting 30 seconds... --------------"); try { // wait 30 seconds to show jobs Thread.sleep(30L * 1000L); // executing... } catch (Exception e) { } // shut down the scheduler log.info("------- Shutting Down ---------------------"); sched.shutdown(true); log.info("------- Shutdown Complete -----------------"); SchedulerMetaData metaData = sched.getMetaData(); log.info("Executed " + metaData.getNumberOfJobsExecuted() + " jobs."); }
From source file:org.restsql.core.impl.RequestLoggerImpl.java
private void logComplete(final Log logger, final String access, final String responseBody, final Exception exception) { logger.info(access); if (httpAttributes.getRequestBody() != null) { logger.info(" request:"); logger.info(httpAttributes.getRequestBody()); }// w ww . j a va 2 s . c o m if (sqls != null && sqls.size() > 0) { logger.info(" sql:"); for (final String sql : sqls) { logger.info(sql); } } logger.info(" response:"); if (responseBody != null) { logger.info(responseBody); } else if (exception != null) { // should always be null at this point logger.info(exception.getMessage()); } logger.info("---------------------"); }
From source file:org.rhq.enterprise.gui.authentication.AuthenticateUserAction.java
/** * @see TilesAction#execute(ActionMapping, ActionForm, HttpServletRequest, HttpServletResponse) */// ww w.ja va 2 s .c o m @Override public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { Log log = LogFactory.getLog(AuthenticateUserAction.class.getName()); HttpSession session = request.getSession(true); LogonForm logonForm = (LogonForm) form; ServletContext ctx = getServlet().getServletContext(); WebUser webUser = null; Map<String, Boolean> userGlobalPermissionsMap = new HashMap<String, Boolean>(); boolean needsRegistration = false; try { // authenticate the credentials SubjectManagerLocal subjectManager = LookupUtil.getSubjectManager(); Subject subject = subjectManager.login(logonForm.getJ_username(), logonForm.getJ_password()); Integer sessionId = subject.getSessionId(); // this is the RHQ session ID, not related to the HTTP session log.debug("Logged in as [" + logonForm.getJ_username() + "] with session id [" + sessionId + "]"); boolean hasPrincipal = true; if (subject.getId() == 0) { // Subject with a ID of 0 means the subject wasn't in the database but the login succeeded. // This means the login method detected that LDAP authenticated the user and just gave us a dummy subject. // Set the needs-registration flag so we can eventually steer the user to the LDAP registration workflow. needsRegistration = true; } if (!needsRegistration) { subject = subjectManager.loadUserConfiguration(subject.getId()); subject.setSessionId(sessionId); // put the transient data back into our new subject if (subject.getUserConfiguration() == null) { subject.setUserConfiguration((Configuration) ctx.getAttribute(Constants.DEF_USER_PREFS)); subject = subjectManager.updateSubject(subject, subject); subject.setSessionId(sessionId); // put the transient data back into our new subject } // look up the user's permissions Set<Permission> all_permissions = LookupUtil.getAuthorizationManager() .getExplicitGlobalPermissions(subject); for (Permission permission : all_permissions) { userGlobalPermissionsMap.put(permission.toString(), Boolean.TRUE); } } webUser = new WebUser(subject, hasPrincipal); } catch (Exception e) { String msg = e.getMessage().toLowerCase(); if ((msg.indexOf("username") >= 0) || (msg.indexOf("password") >= 0)) { request.setAttribute(Constants.LOGON_STATUS, "login.info.bad"); } else { log.error("Could not log into the web application", e); request.setAttribute(Constants.LOGON_STATUS, "login.bad.backend"); } return (mapping.findForward("bad")); } // compute the post-login destination ActionForward af; if (needsRegistration) { // Since we are authenticating the user with LDAP and the user has never logged in before, // that user has no subject record yet. We need to send him through the LDAP registration workflow. log.debug("LDAP registration required for user [" + logonForm.getJ_username() + "]"); af = new ActionForward(URL_REGISTER); } else { // if the user's session timed out, we "bookmarked" the url that he was going to // so that we can send him there after login. otherwise, he gets the dashboard. String url = getBookmarkedUrl(session); if ((url == null) || url.equals("/Logout.do")) { url = URL_DASHBOARD; } if (url.toLowerCase().indexOf("ajax") != -1) { // we can't return to a URL that was a partial page request // because the view no longer exists, and will blow up. // instead, redirect back to the last saved URL url = webUser.getWebPreferences().getLastVisitedURL(2); log.info("Bypassing partial-page with " + url); } af = new ActionForward(url); } af.setRedirect(true); // now that we've constructed a forward to the bookmarked url, // if any, forget the old session and start a new one, // setting the web user to show that we're logged in session.invalidate(); session = request.getSession(true); SessionUtils.setWebUser(session, webUser); session.setAttribute(Constants.USER_OPERATIONS_ATTR, userGlobalPermissionsMap); if (needsRegistration) { // will be cleaned out during registration session.setAttribute(Constants.PASSWORD_SES_ATTR, logonForm.getJ_password()); } return af; }
From source file:org.rhq.enterprise.server.plugin.pc.alert.AlertPluginValidator.java
public boolean validate(ServerPluginEnvironment env) { Log log = LogFactory.getLog(AlertPluginValidator.class); AlertPluginDescriptorType type = (AlertPluginDescriptorType) env.getPluginDescriptor(); String className = type.getPluginClass(); if (!className.contains(".")) { className = type.getPackage() + "." + className; }//from w w w . j a va2s. com try { Class.forName(className, false, env.getPluginClassLoader()); } catch (Exception e) { log.error("Can't find pluginClass " + className + " for plugin " + env.getPluginKey().getPluginName()); return false; } // The short name is basically the key into the plugin String shortName = type.getShortName(); // // Ok, we have a valid plugin class, so we can look for other things // and store the info // String uiSnippetPath; String beanName; CustomUi customUI = type.getCustomUi(); if (customUI != null) { uiSnippetPath = customUI.getUiSnippetName(); try { URL uiSnippetUrl = env.getPluginClassLoader().getResource(uiSnippetPath); log.info("UI snipped for " + shortName + " is at " + uiSnippetUrl); } catch (Exception e) { log.error("No valid ui snippet provided, but <custom-ui> given for sender plugin " + shortName + "Error is " + e.getMessage()); return false; } // Get the backing bean class className = customUI.getBackingBeanClass(); if (!className.contains(".")) { className = type.getPackage() + "." + className; } try { Class.forName(className, true, env.getPluginClassLoader()); } catch (Throwable t) { log.error("Backing bean " + className + " not found for plugin " + shortName); return false; } } return true; }
From source file:org.romaframework.aspect.logging.loggers.FileLogger.java
public void print(int level, String category, String message) { Log logger = LogFactory.getLog(category); if (level == LoggingConstants.LEVEL_DEBUG) { logger.debug(message);/*from w w w .j a va 2 s . co m*/ } else if (level == LoggingConstants.LEVEL_WARNING) { logger.warn(message); } else if (level == LoggingConstants.LEVEL_ERROR) { logger.error(message); } else if (level == LoggingConstants.LEVEL_FATAL) { logger.fatal(message); } else if (level == LoggingConstants.LEVEL_INFO) { logger.info(message); } }
From source file:org.ros.nxt_rosjava.Device.java
@Override public void onStart(final Node node) { final Log log = node.getLog(); ParameterTree param = node.newParameterTree(); GraphName paramNamespace = new GraphName(param.getString("parameter_namespace")); NameResolver resolver = node.getResolver().newChild(paramNamespace); Map setttings_map = param.getMap(resolver.resolve("setttings")); Object[] list = param.getList(resolver.resolve("list")).toArray(); lst_devices = new ArrayList<Device>(); for (int i = 0; i < list.length; i++) { String type = (String) ((Map) setttings_map.get(list[i])).get("type"); String name_dev = (String) ((Map) setttings_map.get(list[i])).get("name"); String frame_id = (String) ((Map) setttings_map.get(list[i])).get("frame_id"); double tmp_port = (Double) ((Map) setttings_map.get(list[i])).get("port"); int port = (int) tmp_port; double desired_frequency = (Double) ((Map) setttings_map.get(list[i])).get("desired_frequency"); log.info("Device: " + list[i] + " type: " + type + " frequency: " + desired_frequency); if (type.contains("ultrasonic")) { UltraSonicSensorNXT dev = new UltraSonicSensorNXT(port, desired_frequency, node, name_dev, frame_id);//from ww w . j a v a 2s . c o m lst_devices.add(dev); } if (type.contains("motor")) { MotorNXT dev = new MotorNXT(port, (int) desired_frequency, node, name_dev); lst_devices.add(dev); } if (type.contains("touch")) { TouchSensorNXT dev = new TouchSensorNXT(port, (int) desired_frequency, node, name_dev, frame_id); lst_devices.add(dev); } } // This CancellableLoop will be canceled automatically when the Node shuts // down. node.executeCancellableLoop(new CancellableLoop() { private int sequenceNumber; @Override protected void setup() { sequenceNumber = 0; } @Override protected void loop() throws InterruptedException { for (int i = 0; i < lst_devices.size(); i++) { Device curDevice = lst_devices.get(i); //log.info("Check device:"+curDevice.name); if (curDevice.needs_trigger(log)) { //log.info("Trigger device:"+curDevice.name); curDevice.do_trigger(); } } Thread.sleep(10); } }); }
From source file:org.ros.ParameterServerTestNode.java
@SuppressWarnings("rawtypes") @Override// w w w .j ava 2 s . c o m public void onStart(Node node) { final Publisher<org.ros.message.std_msgs.String> pub_tilde = node.newPublisher("tilde", "std_msgs/String"); final Publisher<org.ros.message.std_msgs.String> pub_string = node.newPublisher("string", "std_msgs/String"); final Publisher<Int64> pub_int = node.newPublisher("int", "std_msgs/Int64"); final Publisher<Bool> pub_bool = node.newPublisher("bool", "std_msgs/Bool"); final Publisher<Float64> pub_float = node.newPublisher("float", "std_msgs/Float64"); final Publisher<Composite> pub_composite = node.newPublisher("composite", "test_ros/Composite"); final Publisher<TestArrays> pub_list = node.newPublisher("list", "test_ros/TestArrays"); ParameterTree param = node.newParameterTree(); Log log = node.getLog(); final org.ros.message.std_msgs.String tilde_m = new org.ros.message.std_msgs.String(); tilde_m.data = param.getString(node.resolveName("~tilde").toString()); log.info("tilde: " + tilde_m.data); GraphName paramNamespace = new GraphName(param.getString("parameter_namespace")); GraphName targetNamespace = new GraphName(param.getString("target_namespace")); log.info("parameter_namespace: " + paramNamespace); log.info("target_namespace: " + targetNamespace); NameResolver resolver = node.getResolver().newChild(paramNamespace); NameResolver setResolver = node.getResolver().newChild(targetNamespace); final org.ros.message.std_msgs.String string_m = new org.ros.message.std_msgs.String(); string_m.data = param.getString(resolver.resolve("string")); log.info("string: " + string_m.data); final Int64 int_m = new org.ros.message.std_msgs.Int64(); int_m.data = param.getInteger(resolver.resolve("int")); log.info("int: " + int_m.data); final Bool bool_m = new org.ros.message.std_msgs.Bool(); bool_m.data = param.getBoolean(resolver.resolve("bool")); log.info("bool: " + bool_m.data); final Float64 float_m = new org.ros.message.std_msgs.Float64(); float_m.data = param.getDouble(resolver.resolve("float")); log.info("float: " + float_m.data); final Composite composite_m = new org.ros.message.test_ros.Composite(); Map composite_map = param.getMap(resolver.resolve("composite")); composite_m.a.w = (Double) ((Map) composite_map.get("a")).get("w"); composite_m.a.x = (Double) ((Map) composite_map.get("a")).get("x"); composite_m.a.y = (Double) ((Map) composite_map.get("a")).get("y"); composite_m.a.z = (Double) ((Map) composite_map.get("a")).get("z"); composite_m.b.x = (Double) ((Map) composite_map.get("b")).get("x"); composite_m.b.y = (Double) ((Map) composite_map.get("b")).get("y"); composite_m.b.z = (Double) ((Map) composite_map.get("b")).get("z"); final TestArrays list_m = new org.ros.message.test_ros.TestArrays(); // only using the integer part for easier (non-float) comparison Object[] list = param.getList(resolver.resolve("list")).toArray(); list_m.int32_array = new int[list.length]; for (int i = 0; i < list.length; i++) { list_m.int32_array[i] = (Integer) list[i]; } // Set parameters param.set(setResolver.resolve("string"), string_m.data); param.set(setResolver.resolve("int"), (int) int_m.data); param.set(setResolver.resolve("float"), float_m.data); param.set(setResolver.resolve("bool"), bool_m.data); param.set(setResolver.resolve("composite"), composite_map); param.set(setResolver.resolve("list"), Arrays.asList(list)); node.executeCancellableLoop(new CancellableLoop() { @Override protected void loop() throws InterruptedException { pub_tilde.publish(tilde_m); pub_string.publish(string_m); pub_int.publish(int_m); pub_bool.publish(bool_m); pub_float.publish(float_m); pub_composite.publish(composite_m); pub_list.publish(list_m); Thread.sleep(100); } }); }
From source file:org.ros.tutorials.poark.Basic.java
@Override public void main(Node node) throws Exception { Preconditions.checkState(this.node == null); this.node = node; try {/*from ww w . ja va 2 s . c om*/ final Log log = node.getLog(); // Attach the client to the node and add some pin listeners. poarkClient = new PoarkClient(Poark.BoardLayout.MegaLayout, node); poarkClient.addPinChangeListener(kButton1, new PinChangeListener() { @Override public void onPinStateChange(byte pin, int new_value) { log.info("Pushed the button : \"" + pin + " - " + new_value + "\""); } }); poarkClient.setPinMode(kLedPin, Poark.OUT, Poark.HIGH); Thread.sleep(1000); // Setup the Poark I/O. poarkClient.setPinsMode(new byte[] { kLedPin, kButton1 }, new byte[] { Poark.OUT, Poark.IN }, new byte[] { Poark.LOW, Poark.HIGH }); // Start blinking the light. byte light = Poark.LOW; while (true) { light = (byte) (Poark.HIGH - light); poarkClient.setPinState(kLedPin, light); Thread.sleep(1000); } } catch (Exception e) { if (node != null) { node.getLog().fatal(e); } else { e.printStackTrace(); } } }