Class Proxy
- All Implemented Interfaces:
org.omegazero.common.runtime.Application
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionclassA class used to queue tasks.classA class used for running the connection callbacks in a client session. -
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddHTTPEngineSelector(Function<org.omegazero.net.socket.SocketConnection, Class<? extends HTTPEngine>> selector) Deprecated.voidclose()org.omegazero.net.socket.SocketConnectionconnection(Class<? extends org.omegazero.net.client.NetClientManager> type, org.omegazero.net.client.params.ConnectionParameters parameters) Deprecated.Since 3.7.1, use.invalid reference
#connection(String, ConnectionParameters)org.omegazero.net.socket.SocketConnectionconnection(String cmid, org.omegazero.net.client.params.ConnectionParameters parameters, org.omegazero.net.socket.SocketConnection downstreamConnection) Creates a new connection instance for an outgoing proxy connection.debugStringForConnection(org.omegazero.net.socket.SocketConnection incoming, org.omegazero.net.socket.SocketConnection outgoing) booleandispatchBooleanEvent(org.omegazero.common.eventbus.Event event, boolean def, Object... args) Delegates the given event to this proxy'sEventBusand returns abooleanvalue returned by the event handlers.intdispatchEvent(org.omegazero.common.eventbus.Event event, Object... args) Delegates the given event to this proxy'sEventBus.org.omegazero.common.eventbus.EventResultdispatchEventRes(org.omegazero.common.eventbus.Event event, Object... args) Delegates the given event to this proxy'sEventBus.intReturns the amount of time in seconds a connection with no traffic should persist before it is closed.Calls.getRegistry().getDefaultErrdoc()Returns the default upstream server configured in the configuration file.Calls.getRegistry().getErrdoc(type)getErrdocForAccept(String accept) static ProxyReturns the currently active instance ofProxy, ornullif there is none.Returns theProxyRegistryfor this proxy.static org.omegazero.common.event.DelegatingTaskQueueExecutorReturns theTaskQueueExecutorused to execute asynchronous tasks.Returns theProxy.ApplicationWorkerProviderfor use by plugins for long-running tasks.getSessionWorkerProvider(org.omegazero.net.socket.SocketConnection client) Returns aProxy.SessionWorkerProviderfor the given client connection.Returns theSSLContextfor this proxygetState()getUpstreamServer(String host, String path) Deprecated.Since 3.9.1, this method always returns the value returned bygetDefaultUpstreamServer().static StringReturns the version string of omz-proxy.voidinit(org.omegazero.common.util.Args args) booleanisPluginLoaded(String id) Checks whether a plugins with the given id is loaded.booleanvoidregisterClientManager(String id, org.omegazero.net.client.NetClientManager mgr) Deprecated.Since 3.9.1, useinsteadgetRegistry().registerClientManager(id, mgr)voidregisterClientManager(org.omegazero.net.client.NetClientManager mgr) Deprecated.Since 3.7.1, useregisterClientManager(String, NetClientManager).voidregisterServerInstance(Class<? extends org.omegazero.net.server.NetServer> c) Deprecated.Since 3.9.1, useinsteadgetRegistry().registerServerInstance(c)voidregisterServerInstance(org.omegazero.net.server.NetServer server) Deprecated.Since 3.9.1, useinsteadgetRegistry().registerServerInstance(server)voidReloads the configuration from the configuration file and pushes the new configuration data to plugins.voidsetErrdoc(String type, HTTPErrdoc errdoc) Deprecated.Since 3.9.1, useinsteadgetRegistry().setErrdoc(type, errdoc)voidsetInstanceNameAppendage(String instanceNameAppendage) voidsetInstanceType(String instanceType) voidsetInstanceVersion(String instanceVersion) voidshutdown()voidstart(org.omegazero.common.util.Args args)
-
Field Details
-
VERSION
The version string of omz-proxy.- See Also:
-
-
Constructor Details
-
Proxy
public Proxy()
-
-
Method Details
-
start
- Specified by:
startin interfaceorg.omegazero.common.runtime.Application- Throws:
Exception
-
init
- Throws:
IOException
-
close
- Specified by:
closein interfaceorg.omegazero.common.runtime.Application- Throws:
IOException
-
shutdown
public void shutdown() -
registerServerInstance
@Deprecated public void registerServerInstance(Class<? extends org.omegazero.net.server.NetServer> c) Deprecated.Since 3.9.1, useinsteadgetRegistry().registerServerInstance(c)Registers a newNetServerinstance of the given type.A new instance of the given type is created and registered using
registerServerInstance(NetServer). This requires that the given type has a constructor with no parameters. If the type requires additional arguments in the constructor, useProxy.registerServerInstance(NetServer)directly instead.- Parameters:
c-
-
registerServerInstance
Deprecated.Since 3.9.1, useinsteadgetRegistry().registerServerInstance(server)Registers a newNetServerinstance. The instance is added to the list of registered instances and will be initialized at the beginning of the main initialization phase, meaning server instances must be registered during theProxyEvents.PREINITevent.- Parameters:
server-
-
addHTTPEngineSelector
@Deprecated public void addHTTPEngineSelector(Function<org.omegazero.net.socket.SocketConnection, Class<? extends HTTPEngine>> selector) Deprecated.Since 3.9.1, useinsteadgetRegistry().invalid reference
addHTTPEngineSelector(selector)Registers a newHTTPEngineselector.For incoming connections, an appropriate
HTTPEnginemust be selected. For this, every registered selector is called until one returns a non-nullvalue, which will be theHTTPEngineused for the connection. If all selectors returnnull, anUnsupportedOperationExceptionis thrown and the connection will be closed.- Parameters:
selector-
-
registerClientManager
Deprecated.Since 3.7.1, useregisterClientManager(String, NetClientManager). This method uses the full class name for the id parameter.Registers a newNetClientManagerfor outgoing connections.- Parameters:
mgr- The client manager
-
registerClientManager
@Deprecated public void registerClientManager(String id, org.omegazero.net.client.NetClientManager mgr) Deprecated.Since 3.9.1, useinsteadgetRegistry().registerClientManager(id, mgr)Registers a newNetClientManagerfor outgoing connections.- Parameters:
id- The identifier for the client managermgr- The client manager- Since:
- 3.7.1
-
reloadConfiguration
Reloads the configuration from the configuration file and pushes the new configuration data to plugins.If no configuration file was used, this method does nothing.
- Throws:
IOException
-
connection
@Deprecated public org.omegazero.net.socket.SocketConnection connection(Class<? extends org.omegazero.net.client.NetClientManager> type, org.omegazero.net.client.params.ConnectionParameters parameters) throws IOException Deprecated.Since 3.7.1, use. This method uses the full class name of the given type as the cmid parameter.invalid reference
#connection(String, ConnectionParameters)Creates a new connection instance for an outgoing proxy connection.- Parameters:
type- TheNetClientManagertype to use for this connectionparameters- Parameters for this connection- Returns:
- The new connection instance
- Throws:
IOExceptionIllegalArgumentException- If anNetClientManagertype was given for which there is no active instance- See Also:
-
connection
public org.omegazero.net.socket.SocketConnection connection(String cmid, org.omegazero.net.client.params.ConnectionParameters parameters, org.omegazero.net.socket.SocketConnection downstreamConnection) throws IOException Creates a new connection instance for an outgoing proxy connection.- Parameters:
cmid- The client manager ID passed inregisterClientManager(String, NetClientManager)parameters- Parameters for this connectiondownstreamConnection- The downstream connection, if available. Used to set the worker instance used for the new connection- Returns:
- The new connection instance
- Throws:
IOExceptionIllegalArgumentException- If cmid is invalid- Since:
- 3.7.1
- See Also:
-
dispatchEvent
Delegates the given event to this proxy'sEventBus.- Parameters:
event- The event to dispatch using this proxy's event busargs- The arguments to pass the event handlers- Returns:
- The number of handlers executed
- See Also:
-
dispatchEventRes
public org.omegazero.common.eventbus.EventResult dispatchEventRes(org.omegazero.common.eventbus.Event event, Object... args) Delegates the given event to this proxy'sEventBus.- Parameters:
event- The event to dispatch using this proxy's event busargs- The arguments to pass the event handlers- Returns:
- An
EventResultobject containing information about this event execution - See Also:
-
dispatchBooleanEvent
public boolean dispatchBooleanEvent(org.omegazero.common.eventbus.Event event, boolean def, Object... args) Delegates the given event to this proxy'sEventBusand returns abooleanvalue returned by the event handlers.If
Event.isIncludeAllReturns()isfalse, the return value of the first event handler that returns a non-nullvalue is returned. If all event handlers returnnullor there are none, def will be returned.
Otherwise, ifincludeAllReturnsistrue, all event handlers will be executed and the value of def is returned if all event handlers return eithernullor the same value as def. Otherwise, the return value of the first event handler is returned that does not match the def value.- Parameters:
event- The event to dispatch using this proxy's event busdef- The value to return if all event handlers return null or there are noneargs- The arguments to pass the event handlers- Returns:
- The
booleanvalue returned by the first event handler that returns a non-nullvalue, or def
-
debugStringForConnection
public String debugStringForConnection(org.omegazero.net.socket.SocketConnection incoming, org.omegazero.net.socket.SocketConnection outgoing) -
getState
-
isRunning
public boolean isRunning() -
getConfig
-
getInstanceType
-
setInstanceType
-
getInstanceVersion
-
setInstanceVersion
-
getInstanceNameAppendage
-
setInstanceNameAppendage
-
getInstanceName
-
isPluginLoaded
Checks whether a plugins with the given id is loaded.- Parameters:
id- The id of the plugin to search for- Returns:
trueif a plugin with the given id exists
-
getSslContext
Returns theSSLContextfor this proxy- Returns:
- The configured SSL context for this proxy
-
getServerWorkerProvider
Returns theProxy.ApplicationWorkerProviderfor use by plugins for long-running tasks.- Returns:
- The
ApplicationWorkerProvider
-
getSessionWorkerProvider
public Proxy.SessionWorkerProvider getSessionWorkerProvider(org.omegazero.net.socket.SocketConnection client) Returns aProxy.SessionWorkerProviderfor the given client connection. This method may be passed as a method reference to aNetworkApplicationBuilderas the worker creator.- Parameters:
client- The client connection- Returns:
- The
SessionWorkerProvider - Since:
- 3.7.1
-
getErrdoc
Calls.getRegistry().getErrdoc(type)- Parameters:
type- The MIME type of the error document- Returns:
- A
HTTPErrdocinstance of the given MIME type or the default error document if none was found
-
getDefaultErrdoc
Calls.getRegistry().getDefaultErrdoc()- Returns:
- The default error document
-
getErrdocForAccept
- Parameters:
accept- The value of an Accept HTTP header- Returns:
- A suitable
HTTPErrdoc, or the default errdoc if none was found - Since:
- 3.3.1
- See Also:
-
setErrdoc
Deprecated.Since 3.9.1, useinsteadgetRegistry().setErrdoc(type, errdoc)Sets an error document for the given MIME type.- Parameters:
type- The content type to set this error document forerrdoc- TheHTTPErrdocinstance
-
getConnectionIdleTimeout
public int getConnectionIdleTimeout()Returns the amount of time in seconds a connection with no traffic should persist before it is closed.- Returns:
- The time in seconds
-
getDefaultUpstreamServer
Returns the default upstream server configured in the configuration file. May benull.- Returns:
- The default upstream server
-
getUpstreamServer
Deprecated.Since 3.9.1, this method always returns the value returned bygetDefaultUpstreamServer(). TheselectUpstreamServerevent was replaced byonHTTPRequestSelectServerSelects an upstream server based on the given hostname and path.This method uses the EventBus event
selectUpstreamServer. If all event handlers returnnull, the default upstream server, which may also benull, is selected.- Parameters:
host- The hostname to choose a server forpath- The request path- Returns:
- The
UpstreamServerinstance for the given host, ornullif no appropriate server was found
-
getRegistry
Returns theProxyRegistryfor this proxy.- Returns:
- The registry
- Since:
- 3.9.1
-
getInstance
Returns the currently active instance ofProxy, ornullif there is none.- Returns:
- The instance
-
getVersion
Returns the version string of omz-proxy.- Returns:
- The version string
- Since:
- 3.7.1
-
getServerWorker
public static org.omegazero.common.event.DelegatingTaskQueueExecutor getServerWorker()Returns theTaskQueueExecutorused to execute asynchronous tasks.Plugins and other external components SHOULD NOT use this method to queue asynchronous tasks, but use Proxy.
getInstance().getServerWorkerProvider()instead.- Returns:
- The
TaskQueueExecutor - Since:
- 3.10.3
-
insteadgetRegistry().invalid reference