Package com.codingchili.core.context
Class SystemContext
java.lang.Object
com.codingchili.core.context.SystemContext
- All Implemented Interfaces:
CoreContext
- Direct Known Subclasses:
ContextMock,StorageContext
Implementation of the CoreContext, each context gets its own worker pool.
-
Field Summary
Fields -
Constructor Summary
ConstructorsModifierConstructorDescriptionCreates a new vertx instance to be used for this context.protectedSystemContext(CoreContext context)Creates a new system context that shares vertx instance with the given context. -
Method Summary
Modifier and TypeMethodDescription<T> voidblocking(io.vertx.core.Handler<io.vertx.core.Promise<T>> sync, boolean ordered, io.vertx.core.Handler<io.vertx.core.AsyncResult<T>> result)Call to execute the given blocking handler on a worker thread that is scoped to the current context.<T> voidblocking(io.vertx.core.Handler<io.vertx.core.Promise<T>> sync, io.vertx.core.Handler<io.vertx.core.AsyncResult<T>> result)Call to execute the given blocking handler on a worker thread that is scoped to the current context.io.vertx.core.eventbus.EventBusbus()voidcancel(long timer)Cancels a running timer.voidclose()Shuts down the context and underlying pools and connections.voidstatic voidclustered(io.vertx.core.Handler<io.vertx.core.AsyncResult<CoreContext>> handler)Creates a clustered instance of a context.io.vertx.core.Future<String>Instantiates an object of the given class identifier and determines the type that should be deployed.io.vertx.core.Future<String>handler(Supplier<CoreHandler> handler)Deploys a new handler in the cluster from given handler with a completion handler.io.vertx.core.Future<String>listener(Supplier<CoreListener> listener)Deploys the given verticle with a completion handler.metrics()Creates a new metric namespace using the registryName.voidperiodic(TimerSource timeout, io.vertx.core.Handler<Long> handler)Set a periodic timer that uses a timersource to adjust interval during runtime.io.vertx.core.Future<String>service(Supplier<CoreService> service)Deploys the given verticle with a completion handler.io.vertx.core.Future<io.vertx.core.CompositeFuture>stop()voidUndeploys a deployed handler by the deployment id.system()longSets a timer that executes the given handler after the given time.io.vertx.core.Vertxvertx()Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.codingchili.core.context.CoreContext
fileSystem
-
Field Details
-
vertx
protected io.vertx.core.Vertx vertx
-
-
Constructor Details
-
SystemContext
public SystemContext()Creates a new vertx instance to be used for this context. -
SystemContext
Creates a new system context that shares vertx instance with the given context.- Parameters:
context- context to clone vertx instance from.
-
-
Method Details
-
clustered
public static void clustered(io.vertx.core.Handler<io.vertx.core.AsyncResult<CoreContext>> handler)Creates a clustered instance of a context.- Parameters:
handler- called with the context on creation.
-
metrics
- Specified by:
metricsin interfaceCoreContext- Returns:
- the metrics collector.
-
metrics
Description copied from interface:CoreContextCreates a new metric namespace using the registryName.- Specified by:
metricsin interfaceCoreContext- Parameters:
registryName- the name of the registry to attach metrics to.- Returns:
- a new metric collector using the default timer.
-
bus
public io.vertx.core.eventbus.EventBus bus()- Specified by:
busin interfaceCoreContext- Returns:
- get the EventBus attached to the vertx instance.
-
system
- Specified by:
systemin interfaceCoreContext- Returns:
- the system configuration.
-
periodic
Description copied from interface:CoreContextSet a periodic timer that uses a timersource to adjust interval during runtime.- Specified by:
periodicin interfaceCoreContext- Parameters:
timeout- a timer source that may change period during runtime.handler- the handler to be invoked when each interval ends.
-
timer
Description copied from interface:CoreContextSets a timer that executes the given handler after the given time.- Specified by:
timerin interfaceCoreContext- Parameters:
ms- time unit in ms.handler- the handler to be invoken when the timer runs out.- Returns:
- the id of the created timer so that it may be cancelled.
-
cancel
public void cancel(long timer)Description copied from interface:CoreContextCancels a running timer.- Specified by:
cancelin interfaceCoreContext- Parameters:
timer- the id of the timer to be stopped.
-
deploy
Description copied from interface:CoreContextInstantiates an object of the given class identifier and determines the type that should be deployed. May be aCoreHandlerCoreServiceCoreListeneror a plainVerticle.- Specified by:
deployin interfaceCoreContext- Parameters:
target- the target class to deploy.- Returns:
- future completed on deployment.
-
handler
Description copied from interface:CoreContextDeploys a new handler in the cluster from given handler with a completion handler.- Specified by:
handlerin interfaceCoreContext- Parameters:
handler- the handler to be used to handle incoming requests.- Returns:
- a future to be completed on deployment completion.
-
listener
Description copied from interface:CoreContextDeploys the given verticle with a completion handler.- Specified by:
listenerin interfaceCoreContext- Parameters:
listener- the verticle to be deployed.- Returns:
- future completed on deployment completion.
-
service
Description copied from interface:CoreContextDeploys the given verticle with a completion handler.- Specified by:
servicein interfaceCoreContext- Parameters:
service- the verticle to be deployed.- Returns:
- future to be completed on deployment completion.
-
stop
Description copied from interface:CoreContextUndeploys a deployed handler by the deployment id.- Specified by:
stopin interfaceCoreContext- Parameters:
deploymentId- the id of the deployment to undeploy.
-
stop
public io.vertx.core.Future<io.vertx.core.CompositeFuture> stop()- Specified by:
stopin interfaceCoreContext
-
blocking
public <T> void blocking(io.vertx.core.Handler<io.vertx.core.Promise<T>> sync, io.vertx.core.Handler<io.vertx.core.AsyncResult<T>> result)Description copied from interface:CoreContextCall to execute the given blocking handler on a worker thread that is scoped to the current context.- Specified by:
blockingin interfaceCoreContext- Type Parameters:
T- type parameter.- Parameters:
sync- a method that is blocking, to be executed on worker thread.result- handler for the result of the blocking execution.
-
blocking
public <T> void blocking(io.vertx.core.Handler<io.vertx.core.Promise<T>> sync, boolean ordered, io.vertx.core.Handler<io.vertx.core.AsyncResult<T>> result)Description copied from interface:CoreContextCall to execute the given blocking handler on a worker thread that is scoped to the current context.- Specified by:
blockingin interfaceCoreContext- Type Parameters:
T- type parameter for the result- Parameters:
sync- a handler that executes blocking codeordered- if true, indicates that the tasks must be completed in the same order as they are started.result- handler for the result that is called asynchronously
-
logger
- Specified by:
loggerin interfaceCoreContext- Parameters:
aClass- added as metadata to all logged events.- Returns:
- get a new instance of a logger.
-
close
public void close()Description copied from interface:CoreContextShuts down the context and underlying pools and connections.- Specified by:
closein interfaceCoreContext
-
close
- Specified by:
closein interfaceCoreContext- Parameters:
handler- called when the context has closed or failed closing.
-
vertx
public io.vertx.core.Vertx vertx()- Specified by:
vertxin interfaceCoreContext- Returns:
- the vertx instance.
-