Class JettyRouteCondition
- java.lang.Object
-
- com.adaptris.core.services.conditional.conditions.ConditionImpl
-
- com.adaptris.core.http.jetty.JettyRouteCondition
-
- All Implemented Interfaces:
ComponentLifecycle
,Condition
@ComponentProfile(summary="Condition that evaluates based on the jettyURI and method", tag="condition,jetty", since="3.9.0") public class JettyRouteCondition extends ConditionImpl
Condition
implementation that evaulates based on the JettyURI and HTTP method.Designed to be used as part of a
Switch
service to branch based on the jettyURI and method and takes the metadata values associated withCoreConstants.HTTP_METHOD
andJettyConstants.JETTY_URI
and matches them against a its configured route. If a route matches the URI and the http method (if specified) then the evaluation is true.Since the URI itself may contain parameters that may need to be extracted as metadata, it is possible to do that as part of the matching process here. Given a URL of
/record/zeus/apollo
if you have a url-pattern/record/(.*)/(.*)
with metadata keysrecordId, childId
then that metadata will be set as part of the evaluation method. You could achieve the same effect with aExtractMetadataService
as part of your normal service execution chain.In the adapter configuration file this class is aliased as jetty-route-condition which is the preferred alternative to the fully qualified classname when building your configuration.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description class
JettyRouteCondition.JettyRoute
-
Field Summary
-
Fields inherited from class com.adaptris.core.services.conditional.conditions.ConditionImpl
log
-
-
Constructor Summary
Constructors Constructor Description JettyRouteCondition()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description JettyRouteCondition.JettyRoute
build(java.lang.String method, java.lang.String uri)
boolean
evaluate(AdaptrisMessage msg)
java.util.List<java.lang.String>
getMetadataKeys()
java.lang.String
getMethod()
java.lang.String
getUrlPattern()
void
init()
Initialises the component.void
setMetadataKeys(java.util.List<java.lang.String> s)
Specify the metadata that should be populated based on any captured groups in your url pattern.void
setMethod(java.lang.String method)
Specify a method to match against (optional).void
setUrlPattern(java.lang.String urlPattern)
Set the URL pattern that you want to match against.JettyRouteCondition
withMetadataKeys(java.lang.String... list)
JettyRouteCondition
withMetadataKeys(java.util.List<java.lang.String> list)
JettyRouteCondition
withMethod(java.lang.String m)
JettyRouteCondition
withUrlPattern(java.lang.String pattern)
-
Methods inherited from class com.adaptris.core.services.conditional.conditions.ConditionImpl
getAdditionalLogging, logCondition, setAdditionalLogging
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface com.adaptris.core.ComponentLifecycle
close, start, stop
-
-
-
-
Method Detail
-
evaluate
public boolean evaluate(AdaptrisMessage msg) throws CoreException
- Throws:
CoreException
-
init
public void init() throws CoreException
Description copied from interface:ComponentLifecycle
Initialises the component.Component initialisation includes config verification, creation of connections etc.
- Throws:
CoreException
- wrapping any underlyingException
s
-
getUrlPattern
public java.lang.String getUrlPattern()
-
setUrlPattern
public void setUrlPattern(java.lang.String urlPattern)
Set the URL pattern that you want to match against.- Parameters:
urlPattern
- the pattern.
-
withUrlPattern
public JettyRouteCondition withUrlPattern(java.lang.String pattern)
-
getMethod
public java.lang.String getMethod()
-
setMethod
public void setMethod(java.lang.String method)
Specify a method to match against (optional).- Parameters:
method
-
-
withMethod
public JettyRouteCondition withMethod(java.lang.String m)
-
getMetadataKeys
public java.util.List<java.lang.String> getMetadataKeys()
-
setMetadataKeys
public void setMetadataKeys(java.util.List<java.lang.String> s)
Specify the metadata that should be populated based on any captured groups in your url pattern.The list of keys is processed in order, against each capturing match group in order
- Parameters:
s
- list of keys.
-
withMetadataKeys
public JettyRouteCondition withMetadataKeys(java.util.List<java.lang.String> list)
-
withMetadataKeys
public JettyRouteCondition withMetadataKeys(java.lang.String... list)
-
build
public JettyRouteCondition.JettyRoute build(java.lang.String method, java.lang.String uri) throws CoreException
- Throws:
CoreException
-
-