public final class ServiceRegistry extends Object
Note: this class is not synchronized and must be synchronized externally.
Constructor and Description |
---|
ServiceRegistry()
Creates a new registry.
|
Modifier and Type | Method and Description |
---|---|
List<String> |
allows(String url)
Returns the list of HTTP methods allowed for this URL.
|
void |
clear()
Clears each generator mapping.
|
MatchingService |
get(String url)
Returns the list of content generators for this URL.
|
MatchingService |
get(String url,
HttpMethod method)
Returns the content generator for this URL and HTTP method.
|
MatchingService |
get(String url,
String method)
Returns the content generator for this URL and HTTP method.
|
HttpMethod |
getMethod(Service service)
Returns the HTTP method this service is mapped to.
|
Map<String,Service> |
getServiceMap(HttpMethod method)
Returns an unmodifiable map of services by URI Pattern for the specified HTTP method.
|
List<Service> |
getServices()
Returns the set of registered services.
|
List<Service> |
getServices(HttpMethod method)
Returns the list of services for the specified HTTP method.
|
List<String> |
matches(Service service)
Returns the list of URI Patterns that this service matches.
|
void |
register(Service service,
URIPattern pattern,
HttpMethod method)
Register the content generator.
|
protected void |
touch()
Changed the version of this registry.
|
long |
version() |
public void register(Service service, URIPattern pattern, HttpMethod method)
service
- the service to register.pattern
- the URL pattern to associate to this content generator.method
- the method for this URL pattern.NullPointerException
- If any argument is null
public MatchingService get(String url)
This method iterates over each HTTP method in the following order: GET, POST, PUT, DELETE.
url
- The URL.null
.public List<String> allows(String url)
If the GET method is supported, then the HEAD method is also supported and added to this list.
url
- The URL.public HttpMethod getMethod(Service service)
service
- The Berlioz service.null
.public List<String> matches(Service service)
service
- The Berlioz service.public MatchingService get(String url, String method)
If the HTTP method specified is HEAD, this method will return the service for a GET request.
url
- The URL.method
- The HTTP method.null
.public MatchingService get(String url, HttpMethod method)
If the HTTP method specified is HEAD, this method will return the service for a GET request.
url
- The URL.method
- The HTTP method.null
.public Map<String,Service> getServiceMap(HttpMethod method)
method
- the HTTP method.public List<Service> getServices()
public List<Service> getServices(HttpMethod method)
method
- the HTTP method.public void clear()
public long version()
protected void touch()
Copyright © 2016 Allette Systems. All rights reserved.