public class HttpEndpoint extends Object implements org.pipservices.commons.run.IOpenable, org.pipservices.commons.config.IConfigurable, org.pipservices.commons.refer.IReferenceable
### Configuration parameters ###
Parameters to pass to the configure() method for component configuration:
### References ###
A logger, counters, and a connection resolver can be referenced by passing the
following references to the object's setReferences() method:
"*:logger:*:*:1.0";
"*:counters:*:*:1.0";
"*:discovery:*:*:1.0" (for the connection resolver).
### Examples ###
public MyMethod(String correlationId, ConfigParams _config, IReferences _references) {
HttpEndpoint endpoint = new HttpEndpoint();
if (this._config)
endpoint.configure(this._config);
if (this._references)
endpoint.setReferences(this._references);
...
this._endpoint.open(correlationId);
...
}
| Modifier and Type | Field and Description |
|---|---|
protected HttpConnectionResolver |
_connectionResolver |
protected org.pipservices.components.count.CompositeCounters |
_counters |
protected org.pipservices.commons.refer.DependencyResolver |
_dependencyResolver |
protected org.pipservices.components.log.CompositeLogger |
_logger |
| Constructor and Description |
|---|
HttpEndpoint() |
| Modifier and Type | Method and Description |
|---|---|
void |
close(String correlationId)
Closes this endpoint and the REST server (service) that was opened earlier.
|
void |
configure(org.pipservices.commons.config.ConfigParams config)
Configures this HttpEndpoint using the given configuration parameters.
|
protected org.pipservices.components.count.Timing |
Instrument(String correlationId,
String name)
Adds instrumentation to log calls and measure call time.
|
boolean |
isOpen()
Checks if the component is opened.
|
void |
open(String correlationId)
Opens a connection using the parameters resolved by the referenced connection
resolver and creates a REST server (service) using the set options and
parameters.
|
void |
register(IRegisterable registration)
Registers a registerable object for dynamic endpoint discovery.
|
void |
registerResource(org.glassfish.jersey.server.model.Resource resource)
Registers resource in this objects Rest service.
|
void |
registerRoute(String method,
String route,
org.glassfish.jersey.process.Inflector<javax.ws.rs.container.ContainerRequestContext,javax.ws.rs.core.Response> action)
Registers an action in this objects REST server (service) by the given method
and route.
|
void |
setReferences(org.pipservices.commons.refer.IReferences references)
Sets references to this endpoint's logger, counters, and connection resolver.
|
void |
unregister(IRegisterable registration)
Unregisters a registerable object, so that it is no longer used in dynamic
endpoint discovery.
|
protected HttpConnectionResolver _connectionResolver
protected org.pipservices.components.log.CompositeLogger _logger
protected org.pipservices.components.count.CompositeCounters _counters
protected org.pipservices.commons.refer.DependencyResolver _dependencyResolver
public void configure(org.pipservices.commons.config.ConfigParams config)
throws org.pipservices.commons.errors.ConfigException
configure in interface org.pipservices.commons.config.IConfigurableconfig - configuration parameters, containing a "connection(s)" section.org.pipservices.commons.errors.ConfigException - when configuration is wrong.ConfigParamspublic void setReferences(org.pipservices.commons.refer.IReferences references)
throws org.pipservices.commons.refer.ReferenceException
"\*:logger:\*:\*:1.0" - counters:
"\*:counters:\*:\*:1.0" - discovery:
"\*:discovery:\*:\*:1.0" (for the connection resolver)setReferences in interface org.pipservices.commons.refer.IReferenceablereferences - an IReferences object, containing references to a logger,
counters, and a connection resolver.org.pipservices.commons.refer.ReferenceException - when no found references.IReferencesprotected org.pipservices.components.count.Timing Instrument(String correlationId, String name)
correlationId - (optional) transaction id to trace execution through
call chain.name - a method name.public boolean isOpen()
isOpen in interface org.pipservices.commons.run.IOpenablepublic void open(String correlationId) throws org.pipservices.commons.errors.ApplicationException
open in interface org.pipservices.commons.run.IOpenablecorrelationId - (optional) transaction id to trace execution through
call chain.org.pipservices.commons.errors.ApplicationException - when error occured.public void close(String correlationId) throws org.pipservices.commons.errors.ApplicationException
close in interface org.pipservices.commons.run.IClosablecorrelationId - (optional) transaction id to trace execution through
call chain.org.pipservices.commons.errors.ApplicationException - when error occured.public void register(IRegisterable registration)
registration - the registration to add.IRegisterablepublic void unregister(IRegisterable registration)
registration - the registration to remove.IRegisterablepublic void registerRoute(String method, String route, org.glassfish.jersey.process.Inflector<javax.ws.rs.container.ContainerRequestContext,javax.ws.rs.core.Response> action)
method - the HTTP method of the route.route - the route to register in this object's REST server (service).action - the action to perform at the given route.public void registerResource(org.glassfish.jersey.server.model.Resource resource)
resource - resource for registrationCopyright © 2018. All rights reserved.