Package io.reactiverse.es4x
Class ESVerticleFactory
- java.lang.Object
-
- io.reactiverse.es4x.ESVerticleFactory
-
- All Implemented Interfaces:
io.vertx.core.spi.VerticleFactory
- Direct Known Subclasses:
JSVerticleFactory,MJSVerticleFactory
public abstract class ESVerticleFactory extends Object implements io.vertx.core.spi.VerticleFactory
An abstract verticle factory for EcmaScript verticles. All factories can extend this class and only need to implement the 2 abstract methods:createRuntime(ECMAEngine)to create the runtime where scripts will runcreateVerticle(Runtime, String)to create the verticle that wraps the script
-
-
Field Summary
Fields Modifier and Type Field Description protected ECMAEngineengine
-
Constructor Summary
Constructors Constructor Description ESVerticleFactory()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description voidclose()Close the factory.protected RuntimecreateRuntime(ECMAEngine engine)Create a runtime.protected abstract io.vertx.core.VerticlecreateVerticle(Runtime runtime, String fsVerticleName)Create a vertx verticle that wraps the script, it will use the runtime configured in thecreateRuntime(ECMAEngine)method.voidcreateVerticle(String verticleName, ClassLoader classLoader, io.vertx.core.Promise<Callable<io.vertx.core.Verticle>> promise)protected abstract String[]defaultExtensions()Declares the default extensions this verticle factory will use when looking up for modules without extension on the filesystem.voidinit(io.vertx.core.Vertx vertx)intorder()protected voidsetupVerticleMessaging(Runtime runtime, io.vertx.core.Vertx vertx, String address)protected io.vertx.core.Future<Void>waitFor(Runtime runtime, io.vertx.core.impl.ContextInternal context, String callback)
-
-
-
Field Detail
-
engine
protected ECMAEngine engine
-
-
Method Detail
-
init
public void init(io.vertx.core.Vertx vertx)
- Specified by:
initin interfaceio.vertx.core.spi.VerticleFactory
-
order
public int order()
- Specified by:
orderin interfaceio.vertx.core.spi.VerticleFactory
-
createRuntime
protected Runtime createRuntime(ECMAEngine engine)
Create a runtime. Use the methodECMAEngine.newContext(FileSystem, Source...)to create the runtime.This method allows the customization of the runtime (which initial scripts will be run, and add/remove objects to the global scope).
- Parameters:
engine- the graaljs engine.- Returns:
- the configured runtime.
-
createVerticle
protected abstract io.vertx.core.Verticle createVerticle(Runtime runtime, String fsVerticleName)
Create a vertx verticle that wraps the script, it will use the runtime configured in thecreateRuntime(ECMAEngine)method.- Parameters:
fsVerticleName- the name as provided during the application initialization.runtime- the runtime created before.- Returns:
- the configured verticle.
-
defaultExtensions
protected abstract String[] defaultExtensions()
Declares the default extensions this verticle factory will use when looking up for modules without extension on the filesystem.- Returns:
- array of string in the format
.EXTENSION
-
createVerticle
public final void createVerticle(String verticleName, ClassLoader classLoader, io.vertx.core.Promise<Callable<io.vertx.core.Verticle>> promise)
- Specified by:
createVerticlein interfaceio.vertx.core.spi.VerticleFactory
-
setupVerticleMessaging
protected void setupVerticleMessaging(Runtime runtime, io.vertx.core.Vertx vertx, String address)
-
waitFor
protected final io.vertx.core.Future<Void> waitFor(Runtime runtime, io.vertx.core.impl.ContextInternal context, String callback)
-
close
public void close()
Close the factory. The implementation must release all resources.- Specified by:
closein interfaceio.vertx.core.spi.VerticleFactory
-
-