Coverage Report - org.mule.transport.quartz.config.ScheduleConfigBuilder
 
Classes in this File Line Coverage Branch Coverage Complexity
ScheduleConfigBuilder
0%
0/23
N/A
1.111
 
 1  
 /*
 2  
  * $Id: ScheduleConfigBuilder.java 20321 2010-11-24 15:21:24Z dfeist $
 3  
  * --------------------------------------------------------------------------------------
 4  
  * Copyright (c) MuleSoft, Inc.  All rights reserved.  http://www.mulesoft.com
 5  
  *
 6  
  * The software in this package is published under the terms of the CPAL v1.0
 7  
  * license, a copy of which has been included with this distribution in the
 8  
  * LICENSE.txt file.
 9  
  */
 10  
 package org.mule.transport.quartz.config;
 11  
 
 12  
 import org.mule.MessageExchangePattern;
 13  
 import org.mule.api.MuleContext;
 14  
 import org.mule.api.MuleException;
 15  
 import org.mule.api.NamedObject;
 16  
 import org.mule.api.endpoint.EndpointBuilder;
 17  
 import org.mule.api.endpoint.InboundEndpoint;
 18  
 import org.mule.transport.quartz.QuartzConnector;
 19  
 
 20  
 import org.quartz.Scheduler;
 21  
 
 22  
 /**
 23  
  * TODO
 24  
  */
 25  
 public class ScheduleConfigBuilder implements NamedObject
 26  
 {
 27  
     private EndpointBuilder endpointBuilder;
 28  
     private QuartzConnector connector;
 29  
     private String scheduleId;
 30  
 
 31  
     public ScheduleConfigBuilder(String scheduleId, MuleContext muleContext) throws MuleException
 32  
     {
 33  0
         super();
 34  0
         this.scheduleId = scheduleId;
 35  0
             endpointBuilder = muleContext.getRegistry().lookupEndpointFactory()
 36  
                     .getEndpointBuilder("quartz://" + scheduleId);
 37  0
             endpointBuilder.setMuleContext(muleContext);
 38  0
             endpointBuilder.setName(scheduleId);
 39  
 
 40  0
             connector = new QuartzConnector(muleContext);
 41  0
         connector.setName(scheduleId);
 42  0
         endpointBuilder.setConnector(connector);
 43  0
         endpointBuilder.setExchangePattern(MessageExchangePattern.ONE_WAY);
 44  0
     }
 45  
 
 46  
     public ScheduleConfigBuilder addSchedulerFactoryProperty(String key, String value)
 47  
     {
 48  0
         connector.getFactoryProperties().put(key, value);
 49  0
         return this;
 50  
     }
 51  
 
 52  
     public ScheduleConfigBuilder setScheduler(Scheduler scheduler)
 53  
     {
 54  0
         connector.setQuartzScheduler(scheduler);
 55  0
         return this;
 56  
     }
 57  
 
 58  
     public ScheduleConfigBuilder setCron(String cron)
 59  
     {
 60  0
         endpointBuilder.setProperty(QuartzConnector.PROPERTY_CRON_EXPRESSION, cron);
 61  0
         return this;
 62  
     }
 63  
 
 64  
     public ScheduleConfigBuilder setInterval(long interval)
 65  
     {
 66  0
         endpointBuilder.setProperty(QuartzConnector.PROPERTY_REPEAT_INTERVAL, interval);
 67  0
         return this;
 68  
     }
 69  
 
 70  
     public ScheduleConfigBuilder setStartDelay(long delay)
 71  
     {
 72  0
         endpointBuilder.setProperty(QuartzConnector.PROPERTY_START_DELAY, delay);
 73  0
         return this;
 74  
     }
 75  
 
 76  
     public InboundEndpoint buildScheduler() throws MuleException
 77  
     {
 78  0
         return endpointBuilder.buildInboundEndpoint();
 79  
     }
 80  
 
 81  
     public void setName(String name)
 82  
     {
 83  0
         throw new UnsupportedOperationException("setName");
 84  
     }
 85  
 
 86  
     public String getName()
 87  
     {
 88  0
         return scheduleId + ".builder";
 89  
     }
 90  
 }