public class UriSelector extends ObjectSelector<java.net.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: nullquery: "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(java.lang.String uri) |
UriSelector(java.net.URI uri) |
| Modifier and Type | Method and Description |
|---|---|
HeaderResolver |
getHeaderResolver()
Return a component that can resolve headers from a key
|
boolean |
matches(java.lang.Object key)
Indicates whether this Selector matches the
key. |
clone, getObject, objectSelector, test, toStringpublic UriSelector(java.lang.String uri)
public UriSelector(java.net.URI uri)
public HeaderResolver getHeaderResolver()
SelectorgetHeaderResolver in interface SelectorgetHeaderResolver in class ObjectSelector<java.net.URI>HeaderResolver applicable to this Selector type.public boolean matches(java.lang.Object key)
Selectorkey.matches in interface Selectormatches in class ObjectSelector<java.net.URI>key - The key to matchtrue if there's a match, otherwise false.