Class 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 with CoreConstants.HTTP_METHOD and JettyConstants.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 keys recordId, childId then that metadata will be set as part of the evaluation method. You could achieve the same effect with a ExtractMetadataService 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.

    • Constructor Detail

      • JettyRouteCondition

        public JettyRouteCondition()
    • Method Detail

      • 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 underlying Exceptions
      • 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.
      • getMethod

        public java.lang.String getMethod()
      • setMethod

        public void setMethod​(java.lang.String method)
        Specify a method to match against (optional).
        Parameters:
        method -
      • 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)