public class CommandableHttpService extends RestService
Commandable services require only 3 lines of code to implement a robust external HTTP-based remote interface.
### Configuration parameters ###
### References ###
HttpEndpoint reference
### Example ###
class MyCommandableHttpService extends CommandableHttpService {
public MyCommandableHttpService() {
super();
this._dependencyResolver.put(
"controller",
new Descriptor("mygroup","controller","*","*","1.0")
);
}
}
MyCommandableHttpService service = new MyCommandableHttpService();
service.configure(ConfigParams.fromTuples(
"connection.protocol", "http",
"connection.host", "localhost",
"connection.port", 8080
));
service.setReferences(References.fromTuples(
new Descriptor("mygroup","controller","default","default","1.0"), controller
));
service.open("123");
System.out.println("The REST service is running on port 8080");
RestService_baseRoute, _counters, _dependencyResolver, _endpoint, _logger, _server, _url| Constructor and Description |
|---|
CommandableHttpService(String baseRoute)
Creates a new instance of the service.
|
| Modifier and Type | Method and Description |
|---|---|
void |
register()
Registers all service routes in HTTP endpoint.
|
void |
setReferences(org.pipservices.commons.refer.IReferences references)
Sets references to dependent components.
|
close, configure, getBodyAsJson, getBodyAsString, getQueryParameter, instrument, isOpen, open, registerResource, registerRoute, sendCreatedResult, sendDeleted, sendEmptyResult, sendError, sendResult, unsetReferencespublic CommandableHttpService(String baseRoute)
baseRoute - a service base route.public void setReferences(org.pipservices.commons.refer.IReferences references)
throws org.pipservices.commons.refer.ReferenceException,
org.pipservices.commons.errors.ConfigException
setReferences in interface org.pipservices.commons.refer.IReferenceablesetReferences in class RestServicereferences - references to locate the component dependencies.org.pipservices.commons.refer.ReferenceException - when no found references.org.pipservices.commons.errors.ConfigException - when configuration is wrong.public void register()
Copyright © 2018. All rights reserved.