Author: davsclaus Date: Fri Jul 8 13:01:32 2011 New Revision: 1144301 URL: http://svn.apache.org/viewvc?rev=1144301&view=rev Log: CAMEL-4196: scheduled route policy should fail if misconfigured instead of WARN logging.
Modified: camel/trunk/components/camel-quartz/src/main/java/org/apache/camel/routepolicy/quartz/CronScheduledRoutePolicy.java camel/trunk/components/camel-quartz/src/main/java/org/apache/camel/routepolicy/quartz/ScheduledJob.java camel/trunk/components/camel-quartz/src/main/java/org/apache/camel/routepolicy/quartz/ScheduledRoutePolicy.java camel/trunk/components/camel-quartz/src/main/java/org/apache/camel/routepolicy/quartz/SimpleScheduledRoutePolicy.java Modified: camel/trunk/components/camel-quartz/src/main/java/org/apache/camel/routepolicy/quartz/CronScheduledRoutePolicy.java URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-quartz/src/main/java/org/apache/camel/routepolicy/quartz/CronScheduledRoutePolicy.java?rev=1144301&r1=1144300&r2=1144301&view=diff ============================================================================== --- camel/trunk/components/camel-quartz/src/main/java/org/apache/camel/routepolicy/quartz/CronScheduledRoutePolicy.java (original) +++ camel/trunk/components/camel-quartz/src/main/java/org/apache/camel/routepolicy/quartz/CronScheduledRoutePolicy.java Fri Jul 8 13:01:32 2011 @@ -45,11 +45,9 @@ public class CronScheduledRoutePolicy ex setTimeUnit(TimeUnit.MILLISECONDS); } + // validate time options has been configured if ((getRouteStartTime() == null) && (getRouteStopTime() == null) && (getRouteSuspendTime() == null) && (getRouteResumeTime() == null)) { - if (LOG.isWarnEnabled()) { - LOG.warn("Scheduled Route Policy for route " + route.getId() + " is not set since the no start, stop and/or suspend times are specified"); - } - return; + throw new IllegalArgumentException("Scheduled Route Policy for route {} has no stop/stop/suspend/resume times specified"); } if (scheduledRouteDetails == null) { @@ -94,9 +92,6 @@ public class CronScheduledRoutePolicy ex } } - /* (non-Javadoc) - * @see org.apache.camel.routepolicy.quartz.ScheduledRoutePolicy#createTrigger(org.apache.camel.routepolicy.quartz.ScheduledRoutePolicyConstants.Action) - */ @Override protected Trigger createTrigger(Action action, Route route) throws Exception { CronTrigger trigger = null; Modified: camel/trunk/components/camel-quartz/src/main/java/org/apache/camel/routepolicy/quartz/ScheduledJob.java URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-quartz/src/main/java/org/apache/camel/routepolicy/quartz/ScheduledJob.java?rev=1144301&r1=1144300&r2=1144301&view=diff ============================================================================== --- camel/trunk/components/camel-quartz/src/main/java/org/apache/camel/routepolicy/quartz/ScheduledJob.java (original) +++ camel/trunk/components/camel-quartz/src/main/java/org/apache/camel/routepolicy/quartz/ScheduledJob.java Fri Jul 8 13:01:32 2011 @@ -29,13 +29,8 @@ import org.quartz.SchedulerException; public class ScheduledJob implements Job, Serializable, ScheduledRoutePolicyConstants { private static final long serialVersionUID = 26L; - private Route storedRoute; - - /* (non-Javadoc) - * @see org.quartz.Job#execute(org.quartz.JobExecutionContext) - */ - public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException { + public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException { SchedulerContext schedulerContext; try { schedulerContext = jobExecutionContext.getScheduler().getContext(); @@ -45,7 +40,7 @@ public class ScheduledJob implements Job ScheduledJobState state = (ScheduledJobState) schedulerContext.get(jobExecutionContext.getJobDetail().getName()); Action storedAction = state.getAction(); - storedRoute = state.getRoute(); + Route storedRoute = state.getRoute(); List<RoutePolicy> policyList = storedRoute.getRouteContext().getRoutePolicyList(); for (RoutePolicy policy : policyList) { @@ -54,7 +49,8 @@ public class ScheduledJob implements Job ((ScheduledRoutePolicy)policy).onJobExecute(storedAction, storedRoute); } } catch (Exception e) { - throw new JobExecutionException("Failed to execute Scheduled Job for route " + storedRoute.getId() + " with trigger name: " + jobExecutionContext.getTrigger().getFullName()); + throw new JobExecutionException("Failed to execute Scheduled Job for route " + storedRoute.getId() + + " with trigger name: " + jobExecutionContext.getTrigger().getFullName(), e); } } } Modified: camel/trunk/components/camel-quartz/src/main/java/org/apache/camel/routepolicy/quartz/ScheduledRoutePolicy.java URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-quartz/src/main/java/org/apache/camel/routepolicy/quartz/ScheduledRoutePolicy.java?rev=1144301&r1=1144300&r2=1144301&view=diff ============================================================================== --- camel/trunk/components/camel-quartz/src/main/java/org/apache/camel/routepolicy/quartz/ScheduledRoutePolicy.java (original) +++ camel/trunk/components/camel-quartz/src/main/java/org/apache/camel/routepolicy/quartz/ScheduledRoutePolicy.java Fri Jul 8 13:01:32 2011 @@ -54,17 +54,13 @@ public abstract class ScheduledRoutePoli if (routeStatus == ServiceStatus.Started) { stopConsumer(route.getConsumer()); } else { - if (LOG.isWarnEnabled()) { - LOG.warn("Route is not in a started state and cannot be suspended. The current route state is " + routeStatus); - } + LOG.warn("Route is not in a started state and cannot be suspended. The current route state is {}", routeStatus); } } else if (action == Action.RESUME) { if (routeStatus == ServiceStatus.Started) { startConsumer(route.getConsumer()); } else { - if (LOG.isWarnEnabled()) { - LOG.warn("Route is not in a started state and cannot be resumed. The current route state is " + routeStatus); - } + LOG.warn("Route is not in a started state and cannot be resumed. The current route state is {}", routeStatus); } } } Modified: camel/trunk/components/camel-quartz/src/main/java/org/apache/camel/routepolicy/quartz/SimpleScheduledRoutePolicy.java URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-quartz/src/main/java/org/apache/camel/routepolicy/quartz/SimpleScheduledRoutePolicy.java?rev=1144301&r1=1144300&r2=1144301&view=diff ============================================================================== --- camel/trunk/components/camel-quartz/src/main/java/org/apache/camel/routepolicy/quartz/SimpleScheduledRoutePolicy.java (original) +++ camel/trunk/components/camel-quartz/src/main/java/org/apache/camel/routepolicy/quartz/SimpleScheduledRoutePolicy.java Fri Jul 8 13:01:32 2011 @@ -54,13 +54,11 @@ public class SimpleScheduledRoutePolicy setTimeUnit(TimeUnit.MILLISECONDS); } + // validate time options has been configured if ((getRouteStartDate() == null) && (getRouteStopDate() == null) && (getRouteSuspendDate() == null) && (getRouteResumeDate() == null)) { - if (LOG.isWarnEnabled()) { - LOG.warn("Scheduled Route Policy for route " + route.getId() + " is not set since the no start, stop and/or suspend times are specified"); - } - return; + throw new IllegalArgumentException("Scheduled Route Policy for route {} has no stop/stop/suspend/resume times specified"); } - + if (scheduledRouteDetails == null) { scheduledRouteDetails = new ScheduledRouteDetails(); scheduledRouteDetails.setRoute(route);