public class UriSelector extends ObjectSelector<Object,URI>
Selector
implementation that matches on various components of a full URI.
The UriSelector
will explode a URI into its component parts. If you use the following as a selector:
reactor.on(U("scheme://host/path"), ...);
Then any URI
or String that matches those elements will be matched.
It's not an exact string match but a match on components because you can pass parameters in the form of a query string. Consider the following example:
reactor.on(U("tcp://*:3000/topic"), consumer);
This means "match any URIs using scheme 'tcp' to port '3000' for the path '/topic' irregardless of host". When a URI
is sent as the key to a notify like this:
reactor.notify("tcp://user:ENCODEDPWD@192.168.0.10:3000/topic?param=value"), event);
The match will succeed and the headers will be set as follows:
scheme
: "tcp"authorization
: "user:ENCODEDPWD@192.168.0.10:3000"userInfo
: "user:ENCODEDPWD"host
: "192.168.0.10"port
: "3000"path
: "/topic"fragment
: null
query
: "param=value"param
: "value"
Wildcards can be used in place of host
, and path
. The former by replacing the host with '*' and the
latter by replacing the path with '/*'.
Constructor and Description |
---|
UriSelector(String uri) |
UriSelector(URI uri) |
Modifier and Type | Method and Description |
---|---|
HeaderResolver |
getHeaderResolver()
Return a component that can resolve headers from a key
|
boolean |
matches(Object key)
Indicates whether this Selector matches the
key . |
clone, getObject, objectSelector, test, toString
public UriSelector(String uri)
public UriSelector(URI uri)
public HeaderResolver getHeaderResolver()
Selector
getHeaderResolver
in interface Selector<Object>
getHeaderResolver
in class ObjectSelector<Object,URI>
HeaderResolver
applicable to this Selector
type.Copyright © 2016. All rights reserved.