Package org.yamcs.http
Class HttpServer
- java.lang.Object
-
- com.google.common.util.concurrent.AbstractService
-
- org.yamcs.AbstractYamcsService
-
- org.yamcs.http.HttpServer
-
- All Implemented Interfaces:
com.google.common.util.concurrent.Service,YamcsService
public class HttpServer extends AbstractYamcsService
Server-wide HTTP server based on Netty that provides a number of Yamcs web services:- REST API
- WebSocket API
- Static file serving
-
-
Field Summary
Fields Modifier and Type Field Description static StringTYPE_URL_PREFIXstatic org.yamcs.api.HttpRouteWEBSOCKET_ROUTE-
Fields inherited from class org.yamcs.AbstractYamcsService
config, log, yamcsInstance
-
-
Constructor Summary
Constructors Constructor Description HttpServer()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddApi(org.yamcs.api.Api<Context> api)voidaddHandler(String pathSegment, Supplier<Handler> handlerSupplier)voidaddStaticRoot(Path staticRoot)voidcloseChannel(String id)protected voiddoStart()protected voiddoStop()List<Binding>getBindings()List<io.netty.channel.Channel>getClientChannels()StringgetContextPath()io.netty.handler.codec.http.cors.CorsConfiggetCorsConfig()com.google.protobuf.util.JsonFormat.ParsergetJsonParser()com.google.protobuf.util.JsonFormat.PrintergetJsonPrinter()com.codahale.metrics.MetricRegistrygetMetricRegistry()ProtobufRegistrygetProtobufRegistry()List<Route>getRoutes()SpecgetSpec()Returns the valid configuration options for this service.TokenStoregetTokenStore()List<Topic>getTopics()voidinit(String yamcsInstance, YConfiguration config)Initialize this service.voidstartServer()-
Methods inherited from class org.yamcs.AbstractYamcsService
getConfig, getYamcsInstance
-
Methods inherited from class com.google.common.util.concurrent.AbstractService
addListener, awaitRunning, awaitRunning, awaitTerminated, awaitTerminated, failureCause, isRunning, notifyFailed, notifyStarted, notifyStopped, startAsync, state, stopAsync, toString
-
-
-
-
Field Detail
-
WEBSOCKET_ROUTE
public static final org.yamcs.api.HttpRoute WEBSOCKET_ROUTE
-
TYPE_URL_PREFIX
public static final String TYPE_URL_PREFIX
- See Also:
- Constant Field Values
-
-
Method Detail
-
getSpec
public Spec getSpec()
Description copied from interface:YamcsServiceReturns the valid configuration options for this service.- Returns:
- the argument specification, or null if the args should not be validated.
-
init
public void init(String yamcsInstance, YConfiguration config) throws InitException
Description copied from interface:YamcsServiceInitialize this service. This is called before the service is started. All operations should finish fast.- Specified by:
initin interfaceYamcsService- Overrides:
initin classAbstractYamcsService- Parameters:
yamcsInstance- The yamcs instance, or null if this is a global service.config- The configured arguments for this service. IfYamcsService.getSpec()is implemented then this contains the arguments after being validated (including any defaults).- Throws:
InitException- When something goes wrong during the execution of this method.
-
addStaticRoot
public void addStaticRoot(Path staticRoot)
-
addApi
public void addApi(org.yamcs.api.Api<Context> api)
-
doStart
protected void doStart()
- Specified by:
doStartin classcom.google.common.util.concurrent.AbstractService
-
startServer
public void startServer() throws InterruptedException, SSLException, CertificateException, IOException
-
getTokenStore
public TokenStore getTokenStore()
-
getContextPath
public String getContextPath()
-
getProtobufRegistry
public ProtobufRegistry getProtobufRegistry()
-
getJsonParser
public com.google.protobuf.util.JsonFormat.Parser getJsonParser()
-
getJsonPrinter
public com.google.protobuf.util.JsonFormat.Printer getJsonPrinter()
-
getCorsConfig
public io.netty.handler.codec.http.cors.CorsConfig getCorsConfig()
-
getMetricRegistry
public com.codahale.metrics.MetricRegistry getMetricRegistry()
-
getClientChannels
public List<io.netty.channel.Channel> getClientChannels()
-
closeChannel
public void closeChannel(String id)
-
doStop
protected void doStop()
- Specified by:
doStopin classcom.google.common.util.concurrent.AbstractService
-
-