- All Known Implementing Classes:
MatcherWatchdog.Default,MatcherWatchdog.Noop
public interface MatcherWatchdog
Provides an interface for protecting code that uses joni's
Matcher
against long-running operations.
Some implementations of this interface may use threads and timeouts, but the default implementations
here are simpler: there's a no-op implementation, and there's an implementation that relies on
the Matcher.setTimeout(long) method.
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic final classstatic final class -
Method Summary
Modifier and TypeMethodDescriptionlongstatic MatcherWatchdognewInstance(long maxExecutionTimeMillis) Returns an implementation that relies on theMatcher.setTimeout(long)method.static MatcherWatchdognoop()voidregister(org.joni.Matcher matcher) Registers a matcher.voidunregister(org.joni.Matcher matcher) Unregisters a matcher.
-
Method Details
-
register
void register(org.joni.Matcher matcher) Registers a matcher.- Parameters:
matcher- The matcher to register
-
maxExecutionTimeInMillis
long maxExecutionTimeInMillis()- Returns:
- The maximum allowed time in milliseconds for a thread to invoke
unregister(Matcher)afterregister(Matcher)has been invoked.
-
unregister
void unregister(org.joni.Matcher matcher) Unregisters a matcher.- Parameters:
matcher- The matcher to unregister
-
newInstance
Returns an implementation that relies on theMatcher.setTimeout(long)method.- Parameters:
maxExecutionTimeMillis- The time in millis that a matcher has to execute an operation.
-
noop
- Returns:
- A noop implementation that does not interrupt threads and is useful for testing and pre-defined grok expressions.
-