Package com.codingchili.core.listener
Class MultiHandler
java.lang.Object
com.codingchili.core.listener.MultiHandler
- All Implemented Interfaces:
CoreDeployment
,CoreHandler
,Receiver<Request>
The MultiHandler is capable of routing a request into any
of the given handlers using the #
Request.target()
. The requests
target should match the address of the handler. If no handlers matching
the processed request is found, then a #HandlerMissingException
is thrown.-
Constructor Summary
ConstructorDescriptionMultiHandler(CoreHandler... handlers)
MultiHandler(List<CoreHandler> handlers)
-
Method Summary
Modifier and TypeMethodDescriptionio.vertx.core.Future<Void>
add(CoreHandler handler)
Adds a sub-handler to the MultiHandler, may be called when the MultiHandler is already deployed - but then it requires the handlers address not to be registered.address()
void
Handles an incoming request without exception handling.void
init(CoreContext core)
Init method that is called with the context that the service was deployed from.io.vertx.core.Future<Void>
Stops the given handler.setAddress(String address)
Set the address to use - required when deployed in a cluster listener.void
void
toString()
-
Constructor Details
-
MultiHandler
- Parameters:
handlers
- same as @see #MultiHandler(CoreHandler...)
-
MultiHandler
- Parameters:
handlers
- a list of handlers to mount on the multi-handler. When a request is processed the requests target will be used to lookup a CoreHandler with a matching address.
-
-
Method Details
-
setAddress
Set the address to use - required when deployed in a cluster listener.- Parameters:
address
- the address to listen on.- Returns:
- fluent.
-
add
Adds a sub-handler to the MultiHandler, may be called when the MultiHandler is already deployed - but then it requires the handlers address not to be registered.- Parameters:
handler
- the handler to add.- Returns:
- a Future that will be completed when the handler is started if the MultiHandler is already deployed. If the MultiHandler is not deployed - the future is completed.
-
remove
Stops the given handler.- Parameters:
address
- address of the handler to be removed - if the MultiHandler is started then the given handler will be stopped.- Returns:
- a future that is completed when the handler is removed. If the multihandler is not yet started - then the future will be completed.
-
init
Description copied from interface:CoreDeployment
Init method that is called with the context that the service was deployed from.- Specified by:
init
in interfaceCoreDeployment
- Parameters:
core
- the core context to use.
-
start
- Specified by:
start
in interfaceCoreDeployment
- Parameters:
start
- complete when asynchronous startup is completed.
-
stop
- Specified by:
stop
in interfaceCoreDeployment
- Parameters:
stop
- complete when asynchronous shutdown is completed.
-
handle
Description copied from interface:Receiver
Handles an incoming request without exception handling. -
address
- Specified by:
address
in interfaceCoreHandler
- Returns:
- the address of the handler. If not implemented the @Address
annotation will be used, if missing an error is thrown.
Could potentially lead to Runtime errors but is allowed here as this is called during deployment. Reconsider this decision later.
-
toString
-