You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by ac...@apache.org on 2018/09/26 06:29:12 UTC
[camel] branch master updated: Exposing isActive(),
getter and setter methods to extending classes. (#2534)
This is an automated email from the ASF dual-hosted git repository.
acosentino pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/camel.git
The following commit(s) were added to refs/heads/master by this push:
new 99ac4b6 Exposing isActive(), getter and setter methods to extending classes. (#2534)
99ac4b6 is described below
commit 99ac4b60e40131aecc33543cc1886e7228447e2e
Author: Max <ma...@maxf.net>
AuthorDate: Wed Sep 26 02:29:08 2018 -0400
Exposing isActive(), getter and setter methods to extending classes. (#2534)
* Allow exceptions to be thrown so that route control could be configured on application level.
* Allow exceptions to be thrown so that route control could be configured on application level.
* A protected method is needed to extend the behavior of checking if policy is active. I.e. Refresh configuration parameters prior to checking.
* Adding getters for state access.
* Clear out a resolvesTo list on every setResolvesTo call.
* Clear out a resolvesTo list on every setResolvesTo call.
---
.../camel/component/dns/policy/DnsActivation.java | 12 +++++++++++-
.../component/dns/policy/DnsActivationPolicy.java | 22 +++++++++++++++++++++-
2 files changed, 32 insertions(+), 2 deletions(-)
diff --git a/components/camel-dns/src/main/java/org/apache/camel/component/dns/policy/DnsActivation.java b/components/camel-dns/src/main/java/org/apache/camel/component/dns/policy/DnsActivation.java
index 8012079..26e2db9 100644
--- a/components/camel-dns/src/main/java/org/apache/camel/component/dns/policy/DnsActivation.java
+++ b/components/camel-dns/src/main/java/org/apache/camel/component/dns/policy/DnsActivation.java
@@ -40,7 +40,7 @@ public class DnsActivation {
private static final transient Logger LOG = LoggerFactory.getLogger(DnsActivation.class);
private String hostname;
- private final List<String> resolvesTo = new ArrayList<>();
+ private List<String> resolvesTo = new ArrayList<>();
public DnsActivation() {
}
@@ -54,14 +54,24 @@ public class DnsActivation {
this.hostname = hostname;
}
+ public String getHostname() {
+ return hostname;
+ }
+
public void setResolvesTo(List<String> resolvesTo) {
+ this.resolvesTo = new ArrayList<>();
this.resolvesTo.addAll(resolvesTo);
}
public void setResolvesTo(String resolvesTo) {
+ this.resolvesTo = new ArrayList<>();
this.resolvesTo.add(resolvesTo);
}
+ public List<String> getResolvesTo() {
+ return resolvesTo;
+ }
+
public boolean isActive() throws Exception {
if (resolvesTo.isEmpty()) {
try {
diff --git a/components/camel-dns/src/main/java/org/apache/camel/component/dns/policy/DnsActivationPolicy.java b/components/camel-dns/src/main/java/org/apache/camel/component/dns/policy/DnsActivationPolicy.java
index 7b76a70..161a427 100644
--- a/components/camel-dns/src/main/java/org/apache/camel/component/dns/policy/DnsActivationPolicy.java
+++ b/components/camel-dns/src/main/java/org/apache/camel/component/dns/policy/DnsActivationPolicy.java
@@ -121,6 +121,10 @@ public class DnsActivationPolicy extends RoutePolicySupport {
dnsActivation.setHostname(hostname);
}
+ public String getHostname() {
+ return dnsActivation.getHostname();
+ }
+
public void setResolvesTo(List<String> resolvesTo) {
dnsActivation.setResolvesTo(resolvesTo);
}
@@ -129,10 +133,22 @@ public class DnsActivationPolicy extends RoutePolicySupport {
dnsActivation.setResolvesTo(resolvesTo);
}
+ public List<String> getResolvesTo() {
+ return dnsActivation.getResolvesTo();
+ }
+
+ public void setTtl(long ttl) throws Exception {
+ this.ttl = ttl;
+ }
+
public void setTtl(String ttl) throws Exception {
this.ttl = Long.parseLong(ttl);
}
+ public long getTtl() throws Exception {
+ return ttl;
+ }
+
public void setStopRoutesOnException(String stopRoutesOnException) throws Exception {
this.stopRoutesOnException = Boolean.parseBoolean(stopRoutesOnException);
}
@@ -184,10 +200,14 @@ public class DnsActivationPolicy extends RoutePolicySupport {
}
}
+ protected boolean isActive() throws Exception {
+ return dnsActivation.isActive();
+ }
+
class DnsActivationTask extends TimerTask {
public void run() {
try {
- if (dnsActivation.isActive()) {
+ if (isActive()) {
startRoutes();
} else {
stopRoutes();