From ab81b469afef39f3290f702de6b45c522313ebfe Mon Sep 17 00:00:00 2001 From: boris Date: Mon, 2 Mar 2015 14:05:51 +0000 Subject: [PATCH] Controls the use of the dynamic host harvester with a property instead of an API call. --- src/org/ice4j/StackProperties.java | 7 +++++++ src/org/ice4j/ice/Agent.java | 33 +++++++++++++----------------- 2 files changed, 21 insertions(+), 19 deletions(-) diff --git a/src/org/ice4j/StackProperties.java b/src/org/ice4j/StackProperties.java index a7b5c94..c3bac37 100644 --- a/src/org/ice4j/StackProperties.java +++ b/src/org/ice4j/StackProperties.java @@ -178,6 +178,13 @@ public class StackProperties public static final String BLOCKED_ADDRESSES = "org.ice4j.ice.harvest.BLOCKED_ADDRESSES"; + /** + * The name of the property which specifies whether the dynamic port UDP + * host harvester should be used by Agent instances. + */ + public static final String USE_DYNAMIC_HOST_HARVESTER + = "org.ice4j.ice.harvest.USE_DYNAMIC_HOST_HARVESTER"; + /** * Returns the String value of the specified property (minus all * encompassing whitespaces)and null in case no property value was mapped diff --git a/src/org/ice4j/ice/Agent.java b/src/org/ice4j/ice/Agent.java index d5cf9a3..6ae2d5b 100644 --- a/src/org/ice4j/ice/Agent.java +++ b/src/org/ice4j/ice/Agent.java @@ -267,7 +267,7 @@ public class Agent * The flag which specifies whether {@link #hostCandidateHarvester} should * be used or not. */ - private boolean useHostHarvester = true; + private Boolean useHostHarvester = null; /** * Creates an empty Agent with no streams, and no address. @@ -427,7 +427,7 @@ public class Agent logger.info("Gather candidates for component " + component.toShortString()); - if (useHostHarvester) + if (useHostHarvester()) { hostCandidateHarvester.harvest( component, @@ -2460,25 +2460,20 @@ public class Agent } /** - * Checks whether using the dynamic UDP host harvester is enabled or not. - * - * @return true if using the dynamic UDP host harvester is enabled. + * Checks whether the dynamic host harvester should be used or not. + * @return true if the dynamic host harvester should be used and + * false otherwise. */ - public boolean dynamicHostHarvesterEnabled() + private boolean useHostHarvester() { + if (useHostHarvester == null) + { + useHostHarvester + = StackProperties.getBoolean( + StackProperties.USE_DYNAMIC_HOST_HARVESTER, + true); + } + return useHostHarvester; } - - /** - * Sets the flag to enable or disable the dynamic UDP host harvester. - * Note: to have the desired effect this needs to be called before any - * any Components are created using - * {@link #createComponent(IceMediaStream, org.ice4j.Transport, int, int, int)} - * @param enable the value to set. - */ - public void enableDynamicHostHarvester(boolean enable) - { - this.useHostHarvester = enable; - } - }