| 1 |
|
|
| 2 |
|
|
| 3 |
|
|
| 4 |
|
|
| 5 |
|
|
| 6 |
|
|
| 7 |
|
|
| 8 |
|
|
| 9 |
|
|
| 10 |
|
|
| 11 |
|
|
| 12 |
|
|
| 13 |
|
|
| 14 |
|
|
| 15 |
|
|
| 16 |
|
|
| 17 |
|
package org.apache.camel.component.pojo.timer; |
| 18 |
|
|
| 19 |
|
import java.net.URI; |
| 20 |
|
import java.net.URISyntaxException; |
| 21 |
|
import java.util.Date; |
| 22 |
|
import java.util.Map; |
| 23 |
|
|
| 24 |
|
import org.apache.camel.Consumer; |
| 25 |
|
import org.apache.camel.Processor; |
| 26 |
|
import org.apache.camel.Producer; |
| 27 |
|
import org.apache.camel.RuntimeCamelException; |
| 28 |
|
import org.apache.camel.component.pojo.PojoExchange; |
| 29 |
|
import org.apache.camel.impl.DefaultEndpoint; |
| 30 |
|
import org.apache.camel.util.IntrospectionSupport; |
| 31 |
|
import org.apache.camel.util.URISupport; |
| 32 |
|
|
| 33 |
|
|
| 34 |
|
|
| 35 |
|
|
| 36 |
|
|
| 37 |
|
|
| 38 |
5 |
public class TimerEndpoint extends DefaultEndpoint<PojoExchange> { |
| 39 |
|
|
| 40 |
|
private final TimerComponent component; |
| 41 |
|
private final String timerName; |
| 42 |
|
private Date time; |
| 43 |
1 |
private long period=-1; |
| 44 |
1 |
private long delay=-1; |
| 45 |
|
private boolean fixedRate; |
| 46 |
1 |
private boolean daemon=true; |
| 47 |
|
|
| 48 |
|
|
| 49 |
|
public TimerEndpoint(String fullURI, TimerComponent component, String timerPartURI) throws URISyntaxException { |
| 50 |
1 |
super(fullURI, component); |
| 51 |
1 |
this.component = component; |
| 52 |
|
|
| 53 |
|
|
| 54 |
1 |
URI u = new URI(timerPartURI); |
| 55 |
1 |
Map options = URISupport.parseParamters(u); |
| 56 |
1 |
IntrospectionSupport.setProperties(this, options); |
| 57 |
1 |
this.timerName = u.getPath(); |
| 58 |
|
|
| 59 |
1 |
} |
| 60 |
|
|
| 61 |
|
public Producer<PojoExchange> createProducer() throws Exception { |
| 62 |
0 |
throw new RuntimeCamelException("Cannot produce to a TimerEndpoint: "+getEndpointUri()); |
| 63 |
|
} |
| 64 |
|
|
| 65 |
|
public Consumer<PojoExchange> createConsumer(Processor processor) throws Exception { |
| 66 |
1 |
return new TimerConsumer(this, processor); |
| 67 |
|
} |
| 68 |
|
|
| 69 |
|
public PojoExchange createExchange() { |
| 70 |
5 |
return new PojoExchange(getContext()); |
| 71 |
|
} |
| 72 |
|
|
| 73 |
|
public TimerComponent getComponent() { |
| 74 |
2 |
return component; |
| 75 |
|
} |
| 76 |
|
|
| 77 |
|
public String getTimerName() { |
| 78 |
1 |
return timerName; |
| 79 |
|
} |
| 80 |
|
|
| 81 |
|
public boolean isDaemon() { |
| 82 |
1 |
return daemon; |
| 83 |
|
} |
| 84 |
|
|
| 85 |
|
public void setDaemon(boolean daemon) { |
| 86 |
0 |
this.daemon = daemon; |
| 87 |
0 |
} |
| 88 |
|
|
| 89 |
|
public long getDelay() { |
| 90 |
1 |
return delay; |
| 91 |
|
} |
| 92 |
|
|
| 93 |
|
public void setDelay(long delay) { |
| 94 |
1 |
this.delay = delay; |
| 95 |
1 |
} |
| 96 |
|
|
| 97 |
|
public boolean isFixedRate() { |
| 98 |
1 |
return fixedRate; |
| 99 |
|
} |
| 100 |
|
|
| 101 |
|
public void setFixedRate(boolean fixedRate) { |
| 102 |
1 |
this.fixedRate = fixedRate; |
| 103 |
1 |
} |
| 104 |
|
|
| 105 |
|
public long getPeriod() { |
| 106 |
1 |
return period; |
| 107 |
|
} |
| 108 |
|
|
| 109 |
|
public void setPeriod(long period) { |
| 110 |
1 |
this.period = period; |
| 111 |
1 |
} |
| 112 |
|
|
| 113 |
|
public Date getTime() { |
| 114 |
1 |
return time; |
| 115 |
|
} |
| 116 |
|
|
| 117 |
|
public void setTime(Date time) { |
| 118 |
0 |
this.time = time; |
| 119 |
0 |
} |
| 120 |
|
|
| 121 |
|
public boolean isSingleton() { |
| 122 |
1 |
return true; |
| 123 |
|
} |
| 124 |
|
|
| 125 |
|
} |