Class GenerateEntryPointTask
- All Implemented Interfaces:
Comparable<org.gradle.api.Task>,org.gradle.api.internal.DynamicObjectAware,org.gradle.api.internal.TaskInternal,org.gradle.api.Named,org.gradle.api.plugins.ExtensionAware,org.gradle.api.Task,org.gradle.util.Configurable<org.gradle.api.Task>
A separate class rather than a member of the handler, because a static method exported as
fetch cannot sit beside the instance fetch that Worker declares. Keeping
the generated glue out of the handler also leaves the handler a plain Java class with no
annotations on it.
Each exported method hands JavaScript a promise straight away and starts the handler on a fiber. That shape is what makes a blocking handler possible: a promise executor cannot suspend, and an entry point returning a value would return before the handler's suspensions finished.
The module's start-up work gets the same treatment. main starts a fiber that builds the
handler and registers the codecs, so a lock, a join or a get reached from the handler's constructor
or from a static initialiser it triggers can block. Run straight from main it would trap,
because a method TeaVM compiled as asynchronous needs a fiber under it. For the same reason the
handler is a plain field and not a static final one: an initialiser that can suspend would make
every export asynchronous too, and JavaScript cannot call those.
A Durable Object or a Workflow is built the same way: the export hands a factory to
DurableHandlers or WorkflowHandlers, which call it on the fiber they start, so the
constructor may block.
- Since:
- 1.0.0
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.gradle.api.Named
org.gradle.api.Named.Namer -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringThe generated class's simple name.static final StringThe class that installs%tforString.format, which has to run before the handler exists.static final StringThe package the generated entry point lives in.static final StringThe class that installs the recorded timezone history, which has to run before the handler exists.Fields inherited from interface org.gradle.api.Task
TASK_ACTION, TASK_CONSTRUCTOR_ARGS, TASK_DEPENDS_ON, TASK_DESCRIPTION, TASK_GROUP, TASK_NAME, TASK_OVERWRITE, TASK_TYPE -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidgenerate()Writes the entry point.abstract org.gradle.api.provider.Property<Boolean> Returns whether the entry point installs the%tconversions.abstract org.gradle.api.provider.ListProperty<String> Returns the Java classes exposed as Durable Objects.abstract org.gradle.api.provider.Property<String> Returns the handler class to route to.abstract org.gradle.api.file.ConfigurableFileCollectionReturns where to find the handler, so its interfaces can be read.abstract org.gradle.api.file.DirectoryPropertyReturns where the generated source goes.abstract org.gradle.api.provider.ListProperty<String> Returns the Java classes exposed as Workflows.abstract org.gradle.api.provider.Property<Boolean> Returns whether the entry point registers the recorded timezone history.Methods inherited from class org.gradle.api.DefaultTask
compareTo, configure, dependsOn, doFirst, doFirst, doFirst, doLast, doLast, doLast, finalizedBy, getActions, getAnt, getDependsOn, getDescription, getDestroyables, getDidWork, getEnabled, getExtensions, getFinalizedBy, getGroup, getInputs, getLocalState, getLogger, getLogging, getMustRunAfter, getName, getOutputs, getPath, getProject, getShouldRunAfter, getState, getTaskDependencies, getTemporaryDir, getTimeout, hasProperty, mustRunAfter, onlyIf, onlyIf, onlyIf, property, setActions, setDependsOn, setDescription, setDidWork, setEnabled, setFinalizedBy, setGroup, setMustRunAfter, setOnlyIf, setOnlyIf, setOnlyIf, setProperty, setShouldRunAfter, shouldRunAfter, usesServiceMethods inherited from class org.gradle.api.internal.AbstractTask
acceptServiceReferences, appendParallelSafeAction, doNotTrackState, doNotTrackStateIf, getAsDynamicObject, getIdentityPath, getImpliesSubProjects, getLifecycleDependencies, getOnlyIf, getReasonNotToTrackState, getReasonsNotToTrackState, getReasonTaskIsIncompatibleWithConfigurationCache, getRequiredServices, getServices, getSharedResources, getStandardOutputCapture, getTaskActions, getTaskIdentity, getTemporaryDirFactory, hasTaskActions, injectIntoNewInstance, isCompatibleWithConfigurationCache, isEnabled, isHasCustomActions, notCompatibleWithConfigurationCache, prependParallelSafeAction, restoreOnlyIf, restoreTaskActions, setImpliesSubProjectsMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.gradle.api.Task
doNotTrackState, notCompatibleWithConfigurationCache
-
Field Details
-
PACKAGE
The package the generated entry point lives in.- See Also:
-
CLASS_NAME
The generated class's simple name.- See Also:
-
ZONE_HISTORY
The class that installs the recorded timezone history, which has to run before the handler exists.- See Also:
-
DATES
The class that installs%tforString.format, which has to run before the handler exists.- See Also:
-
-
Constructor Details
-
GenerateEntryPointTask
public GenerateEntryPointTask()
-
-
Method Details
-
getHandlerClass
Returns the handler class to route to.- Returns:
- the handler class to route to
-
getDurableObjectClasses
Returns the Java classes exposed as Durable Objects.- Returns:
- the Java classes exposed as Durable Objects
-
getWorkflowClasses
Returns the Java classes exposed as Workflows.- Returns:
- the Java classes exposed as Workflows
-
getZoneHistory
Returns whether the entry point registers the recorded timezone history.- Returns:
- whether the entry point registers the recorded timezone history
-
getDateFormat
Returns whether the entry point installs the%tconversions.- Returns:
- whether the entry point installs the
%tconversions
-
getHandlerClasspath
@Classpath public abstract org.gradle.api.file.ConfigurableFileCollection getHandlerClasspath()Returns where to find the handler, so its interfaces can be read.- Returns:
- where to find the handler, so its interfaces can be read
-
getOutputDirectory
@OutputDirectory public abstract org.gradle.api.file.DirectoryProperty getOutputDirectory()Returns where the generated source goes.- Returns:
- where the generated source goes
-
generate
public void generate()Writes the entry point.
-