public class EmbeddedWebServerImpl extends java.lang.Object implements EmbeddedWebServer
| Modifier and Type | Class and Description |
|---|---|
static class |
EmbeddedWebServerImpl.I18NWebResources
Represents the I18n web resources:
WebClient_en_US.json
...................
|
| Modifier and Type | Field and Description |
|---|---|
private static java.lang.String |
AJAX_TARGET
WebSocket target.
|
private org.eclipse.jetty.util.resource.Resource |
cpres
Classpath resource instance.
|
private java.lang.String |
externalHost
The external host, IP or domain used to access this server.
|
private org.eclipse.jetty.server.Handler[] |
hdlrs
Page handlers for our specific targets.
|
private static EmbeddedWebServerImpl.I18NWebResources |
I18N
Represents the I18n web resources for the web client
|
private static CentralLogger |
LOG
Logger.
|
private java.lang.String |
name
Driver name to use in logging.
|
private GenericWebServer |
server
Embedded web server instance.
|
private GenericWebSocketCreator |
sfact
WebSocket factory.
|
private static java.lang.String |
spec
URI format specification.
|
| Constructor and Description |
|---|
EmbeddedWebServerImpl(java.lang.String name,
GenericWebSocketCreator sfact,
org.eclipse.jetty.util.resource.Resource cpres,
org.eclipse.jetty.server.Handler[] hdlrs)
Create an instance.
|
| Modifier and Type | Method and Description |
|---|---|
void |
addHandler(org.eclipse.jetty.server.Handler handler)
Adds a custom handler.
|
static org.eclipse.jetty.util.resource.Resource |
calcResourceBase(java.lang.Class<?> origin,
java.lang.String path)
Calculate the path in the jar file for the given path as an extention of the origin
class' package and return that resource base as a classpath resource.
|
org.eclipse.jetty.server.HttpConfiguration |
getHttpConfiguration()
Returns the common http configuration.
|
java.lang.String |
getServerURI()
Get the embedded web server's URI.
|
static java.util.function.Supplier<java.util.Map.Entry<java.lang.String,java.lang.String>> |
getTranslations(java.lang.String lang,
java.util.Set<java.lang.String> cachedLanguages,
java.lang.String defaultValue)
Returns the supplier of a raw (unescaped) json string that holds all available translations
for the given language.
|
void |
removeHandler(org.eclipse.jetty.server.Handler handler)
Removes the handler from the list of handlers.
|
void |
shutdownServer()
Shutdown the embedded web server.
|
java.lang.String |
startupServer(ServerKeyStore keyStore,
BootstrapConfig config,
java.lang.String host,
int port)
Startup the embedded web server using the application server's
KeyStore to
build a suitable SSL context. |
void |
waitInitialization()
Wait for the page to notify that it has fully initialized its JS code.
|
void |
waitInitialization(WebClientProtocol webSocket)
Wait for the page to notify that it has fully initialized its JS code.
|
private static final CentralLogger LOG
private static final java.lang.String spec
private static final java.lang.String AJAX_TARGET
private static final EmbeddedWebServerImpl.I18NWebResources I18N
private GenericWebServer server
private java.lang.String name
private GenericWebSocketCreator sfact
private org.eclipse.jetty.util.resource.Resource cpres
private org.eclipse.jetty.server.Handler[] hdlrs
private java.lang.String externalHost
public EmbeddedWebServerImpl(java.lang.String name,
GenericWebSocketCreator sfact,
org.eclipse.jetty.util.resource.Resource cpres,
org.eclipse.jetty.server.Handler[] hdlrs)
name - Driver name to use in logging.sfact - WebSocket factory.cpres - Classpath resource instance.hdlrs - Page handlers for our specific targets.public java.lang.String startupServer(ServerKeyStore keyStore, BootstrapConfig config, java.lang.String host, int port)
KeyStore to
build a suitable SSL context.startupServer in interface EmbeddedWebServerkeyStore - The exported server KeyStore.config - Client configuration.port - An explicit port to start the web server or 0 to let the OS assign one.host - An explicit host to start the web server or null to use the server's
host.public void shutdownServer()
shutdownServer in interface EmbeddedWebServerpublic java.lang.String getServerURI()
getServerURI in interface EmbeddedWebServerpublic static org.eclipse.jetty.util.resource.Resource calcResourceBase(java.lang.Class<?> origin,
java.lang.String path)
origin - A class in the package being targeted as the starting path for the resource.
The package will be looked up from this class, any class in that package will
work as the class is not used for anything else.path - The relative sub-directory to add to the package to get the full base path.
This should NOT have either a leading or trailing path separator ('/') included.public static java.util.function.Supplier<java.util.Map.Entry<java.lang.String,java.lang.String>> getTranslations(java.lang.String lang,
java.util.Set<java.lang.String> cachedLanguages,
java.lang.String defaultValue)
lang - The language identifiercachedLanguages - The set of cached languagesdefaultValue - The default value if i18n resources is not found for the given languagepublic void waitInitialization()
This implementation is a no-op.
waitInitialization in interface EmbeddedWebServerpublic void addHandler(org.eclipse.jetty.server.Handler handler)
addHandler in interface EmbeddedWebServerhandler - The handler to add.public void removeHandler(org.eclipse.jetty.server.Handler handler)
removeHandler in interface EmbeddedWebServerhandler - The handler to remove.public org.eclipse.jetty.server.HttpConfiguration getHttpConfiguration()
public void waitInitialization(WebClientProtocol webSocket)
webSocket - The socket where to wait for a message.