/** * Register the scheduler in the local MBeanServer. */ private void registerJMX() throws Exception { String jmxObjectName = resources.getJMXObjectName(); MBeanServer mbs = ManagementFactory.getPlatformMBeanServer(); jmxBean = new QuartzSchedulerMBeanImpl(this); mbs.registerMBean(jmxBean, new ObjectName(jmxObjectName)); }
private static void invokeSetter(Object target, String attribute, Object value) throws Exception { String setterName = "set" + Character.toUpperCase(attribute.charAt(0)) + attribute.substring(1); Class<?>[] argTypes = {value.getClass()}; Method setter = findMethod(target.getClass(), setterName, argTypes); if(setter != null) { setter.invoke(target, value); } else { throw new Exception("Unable to find setter for attribute '" + attribute + "' and value '" + value + "'"); } }
public Map<String, Long> getPerformanceMetrics() { Map<String, Long> result = new HashMap<String, Long>(); result.put("JobsCompleted", Long .valueOf(getJobsCompletedMostRecentSample())); result.put("JobsExecuted", Long .valueOf(getJobsExecutedMostRecentSample())); result.put("JobsScheduled", Long .valueOf(getJobsScheduledMostRecentSample())); return result; } }
public void jobWasExecuted(JobExecutionContext context, JobExecutionException jobException) { try { sendNotification(JOB_WAS_EXECUTED, JobExecutionContextSupport .toCompositeData(context)); } catch (Exception e) { throw new RuntimeException(newPlainException(e)); } }
public void schedulerShutdown() { scheduler.removeInternalSchedulerListener(this); scheduler.removeInternalJobListener(getName()); sendNotification(SCHEDULER_SHUTDOWN); }
public List<String> getCalendarNames() throws Exception { try { return scheduler.getCalendarNames(); } catch (Exception e) { throw newPlainException(e); } }
value = new JobDataMap((Map<?, ?>)value); invokeSetter(jobDetail, key, value); throw newPlainException(e);
/** * @see javax.management.NotificationBroadcasterSupport#getNotificationInfo() */ @Override public MBeanNotificationInfo[] getNotificationInfo() { return QuartzSchedulerMBeanImpl.this.getNotificationInfo(); } }
private static Method findMethod(Class<?> targetType, String methodName, Class<?>[] argTypes) throws IntrospectionException { BeanInfo beanInfo = Introspector.getBeanInfo(targetType); if (beanInfo != null) { for(MethodDescriptor methodDesc: beanInfo.getMethodDescriptors()) { Method method = methodDesc.getMethod(); Class<?>[] parameterTypes = method.getParameterTypes(); if (methodName.equals(method.getName()) && argTypes.length == parameterTypes.length) { boolean matchedArgTypes = true; for (int i = 0; i < argTypes.length; i++) { if (getWrapperIfPrimitive(argTypes[i]) != parameterTypes[i]) { matchedArgTypes = false; break; } } if (matchedArgTypes) { return method; } } } } return null; }
public void pauseAllTriggers() throws Exception { try { scheduler.pauseAll(); } catch (Exception e) { throw newPlainException(e); } }
public void jobToBeExecuted(JobExecutionContext context) { try { sendNotification(JOB_TO_BE_EXECUTED, JobExecutionContextSupport .toCompositeData(context)); } catch (Exception e) { throw new RuntimeException(newPlainException(e)); } }
value = new JobDataMap((Map<?, ?>)value); invokeSetter(trigger, key, value); value = new JobDataMap((Map<?, ?>)value); invokeSetter(jobDetail, key, value); scheduler.scheduleJob(jobDetail, trigger); } catch (Exception e) { throw newPlainException(e);
public void schedulerShutdown() { scheduler.removeInternalSchedulerListener(this); scheduler.removeInternalJobListener(getName()); sendNotification(SCHEDULER_SHUTDOWN); }
/** * @see javax.management.NotificationBroadcasterSupport#getNotificationInfo() */ @Override public MBeanNotificationInfo[] getNotificationInfo() { return QuartzSchedulerMBeanImpl.this.getNotificationInfo(); } }
private static Method findMethod(Class<?> targetType, String methodName, Class<?>[] argTypes) throws IntrospectionException { BeanInfo beanInfo = Introspector.getBeanInfo(targetType); if (beanInfo != null) { for(MethodDescriptor methodDesc: beanInfo.getMethodDescriptors()) { Method method = methodDesc.getMethod(); Class<?>[] parameterTypes = method.getParameterTypes(); if (methodName.equals(method.getName()) && argTypes.length == parameterTypes.length) { boolean matchedArgTypes = true; for (int i = 0; i < argTypes.length; i++) { if (getWrapperIfPrimitive(argTypes[i]) != parameterTypes[i]) { matchedArgTypes = false; break; } } if (matchedArgTypes) { return method; } } } } return null; }
public void resumeAllTriggers() throws Exception { try { scheduler.resumeAll(); } catch (Exception e) { throw newPlainException(e); } }
public void jobExecutionVetoed(JobExecutionContext context) { try { sendNotification(JOB_EXECUTION_VETOED, JobExecutionContextSupport .toCompositeData(context)); } catch (Exception e) { throw new RuntimeException(newPlainException(e)); } }
value = new JobDataMap((Map<?, ?>)value); invokeSetter(trigger, key, value); throw newPlainException(e);
public Map<String, Long> getPerformanceMetrics() { Map<String, Long> result = new HashMap<String, Long>(); result.put("JobsCompleted", Long .valueOf(getJobsCompletedMostRecentSample())); result.put("JobsExecuted", Long .valueOf(getJobsExecutedMostRecentSample())); result.put("JobsScheduled", Long .valueOf(getJobsScheduledMostRecentSample())); return result; } }
/** * Register the scheduler in the local MBeanServer. */ private void registerJMX() throws Exception { String jmxObjectName = resources.getJMXObjectName(); MBeanServer mbs = ManagementFactory.getPlatformMBeanServer(); jmxBean = new QuartzSchedulerMBeanImpl(this); mbs.registerMBean(jmxBean, new ObjectName(jmxObjectName)); }