Class AbstractJavaMole

    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      protected AbstractJavaMole​(java.util.Set<io.molr.commons.domain.Mission> availableMissions)  
    • Method Summary

      All Methods Instance Methods Abstract Methods Concrete Methods 
      Modifier and Type Method Description
      protected abstract MissionExecutor executorFor​(io.molr.commons.domain.Mission mission, java.util.Map<java.lang.String,​java.lang.Object> params)  
      reactor.core.publisher.Mono<io.molr.commons.domain.MissionHandle> instantiate​(io.molr.commons.domain.Mission mission, java.util.Map<java.lang.String,​java.lang.Object> params)
      Instantiates the given mission with the given parameters (Currently only string and integer parameters are supported).
      void instruct​(io.molr.commons.domain.MissionHandle handle, io.molr.commons.domain.MissionCommand command)
      Instruct the mole to execute a mission related command.
      void instruct​(io.molr.commons.domain.MissionHandle handle, io.molr.commons.domain.Strand strand, io.molr.commons.domain.StrandCommand command)
      Instructs the mission instance identified by the given handle to execute the given command on the given strand.
      void instructBlock​(io.molr.commons.domain.MissionHandle handle, java.lang.String blockId, io.molr.commons.domain.BlockCommand command)
      Instruct the mole to execute a block related command.
      void instructRoot​(io.molr.commons.domain.MissionHandle handle, io.molr.commons.domain.StrandCommand command)
      Instructs the root strand of the mission identified by the given handle to execute a given command.
      protected abstract io.molr.commons.domain.MissionParameterDescription missionParameterDescriptionOf​(io.molr.commons.domain.Mission mission)  
      protected abstract io.molr.commons.domain.MissionRepresentation missionRepresentationOf​(io.molr.commons.domain.Mission mission)  
      reactor.core.publisher.Flux<io.molr.commons.domain.MissionOutput> outputsFor​(io.molr.commons.domain.MissionHandle handle)
      Retrieves a stream of the actual output of one mission instance.
      reactor.core.publisher.Mono<io.molr.commons.domain.MissionParameterDescription> parameterDescriptionOf​(io.molr.commons.domain.Mission mission)
      Retrieves information on what parameters a mission expects (name, type, optional or mandatory).
      reactor.core.publisher.Mono<io.molr.commons.domain.MissionRepresentation> representationOf​(io.molr.commons.domain.Mission mission)
      Retrieves the initial (!) representation of a mission, meaning when the mission is not instantiated/running.
      reactor.core.publisher.Flux<io.molr.commons.domain.MissionRepresentation> representationsFor​(io.molr.commons.domain.MissionHandle handle)
      Delivers updates of the representation of the mission.
      reactor.core.publisher.Flux<io.molr.commons.domain.AgencyState> states()
      Retrieves a stream of the actual AgencyState.
      reactor.core.publisher.Flux<io.molr.commons.domain.MissionState> statesFor​(io.molr.commons.domain.MissionHandle handle)
      Retrieves a stream emitting new items anytime the state of the mission instance changes.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • AbstractJavaMole

        protected AbstractJavaMole​(java.util.Set<io.molr.commons.domain.Mission> availableMissions)
    • Method Detail

      • instantiate

        public reactor.core.publisher.Mono<io.molr.commons.domain.MissionHandle> instantiate​(io.molr.commons.domain.Mission mission,
                                                                                             java.util.Map<java.lang.String,​java.lang.Object> params)
        Description copied from interface: Mole
        Instantiates the given mission with the given parameters (Currently only string and integer parameters are supported). The returned mono shall only emit, as soon as the mission is available and more detailed states can be retrieved by other methods of the agency, if queried with the given handle. As soon as the mission is instantiated (the returned mono emits), then the mission instance shall be in a paused state with the cursor of the root Strand on its first (or only) Block.

        At this point in time, commands can be sent to the mission instance through the Mole.instruct(MissionHandle, Strand, StrandCommand) method (non-allowed commands shall be ignored by the agency and the underlying moles). The allowed commands (and other information) can be queried through the Mole.statesFor(MissionHandle) method.

        Specified by:
        instantiate in interface Mole
        Parameters:
        mission - the mission which shall be instantiated
        params - a map from parameter name to parameter value to instantiate the mission
        Returns:
        a mono of a new handle (unique throughout the lifetime of the agency), representing the instance of the mission and being emitted as soon as the mission instance is ready to receive commands.
      • parameterDescriptionOf

        public reactor.core.publisher.Mono<io.molr.commons.domain.MissionParameterDescription> parameterDescriptionOf​(io.molr.commons.domain.Mission mission)
        Description copied from interface: Mole
        Retrieves information on what parameters a mission expects (name, type, optional or mandatory). For interactive clients it is recommended to use this information to help the user to input only valid values.
        Specified by:
        parameterDescriptionOf in interface Mole
        Parameters:
        mission - the mission for which the information shall be queried.
        Returns:
        a stream emitting the information about expected parameters as soon as it is available (usually instantly).
      • states

        public reactor.core.publisher.Flux<io.molr.commons.domain.AgencyState> states()
        Description copied from interface: Mole
        Retrieves a stream of the actual AgencyState. This state contains information about all the available missions and those which are currently instantiated. The stream shall emit a new item whenever the state changes and shall be long-living, so basically never complete during the lifetime of the agency.
        Specified by:
        states in interface Mole
        Returns:
        a stream of states of the agency
      • statesFor

        public final reactor.core.publisher.Flux<io.molr.commons.domain.MissionState> statesFor​(io.molr.commons.domain.MissionHandle handle)
        Description copied from interface: Mole
        Retrieves a stream emitting new items anytime the state of the mission instance changes. Agency implementations (and underlying moles) shall guarantee that the stream emits at least once on new subscriptions. The mission state contains runtime information of the mission instance (for example, strands, cursor positions, run states of each strand and block).
        Specified by:
        statesFor in interface Mole
        Parameters:
        handle - a handle representing the mission instance for which the states shall be retrieved
        Returns:
        a stream of mission states, emitting each time when the state changes and being completed only at the end of the lifecycle of the mission instance.
      • outputsFor

        public final reactor.core.publisher.Flux<io.molr.commons.domain.MissionOutput> outputsFor​(io.molr.commons.domain.MissionHandle handle)
        Description copied from interface: Mole
        Retrieves a stream of the actual output of one mission instance. The items in the stream represent a 'snapshot' of the actually available output of the whole mission. The returned stream shall emit each time the output changes and at least once on subscription. An output basically contains a map of output values per block.
        Specified by:
        outputsFor in interface Mole
        Parameters:
        handle - a handle representing the mission instance for which the output shall be queried.
        Returns:
        a stream of the actually available output for the mission instance.
      • representationsFor

        public final reactor.core.publisher.Flux<io.molr.commons.domain.MissionRepresentation> representationsFor​(io.molr.commons.domain.MissionHandle handle)
        Description copied from interface: Mole
        Delivers updates of the representation of the mission. Implementations of the agency (and underlying moles) shall guarantee that the returned stream emits at least once for a newly subscribed client.
        Specified by:
        representationsFor in interface Mole
        Parameters:
        handle - the handle of the mission for which to retrieve representation updates
        Returns:
        a stream emitting whenever the representation changes, and at least once on subscription.
      • representationOf

        public reactor.core.publisher.Mono<io.molr.commons.domain.MissionRepresentation> representationOf​(io.molr.commons.domain.Mission mission)
        Description copied from interface: Mole
        Retrieves the initial (!) representation of a mission, meaning when the mission is not instantiated/running. This representation contains for example the tree structure of the mission. In many (or even most) cases, this information will be static (so not change over the lifecycle of a mission). So, for specific clients - when they know that the structure does not change - it might be sufficient to use this method only to determine the structure. However, for the general case (imagine for example a mission like a parametrized junit test), it is recommended to use this method only to get the initial representation (when no handle exists yet), and then subscribe to the stream provided Mole.representationsFor(MissionHandle), to be notified of any changes in the representation.
        Specified by:
        representationOf in interface Mole
        Parameters:
        mission - the mission for which to retrieve the initial (!) representation
        Returns:
        a mono, emitting the initial representation as soon as it is available (usually instantly).
      • instruct

        public final void instruct​(io.molr.commons.domain.MissionHandle handle,
                                   io.molr.commons.domain.Strand strand,
                                   io.molr.commons.domain.StrandCommand command)
        Description copied from interface: Mole
        Instructs the mission instance identified by the given handle to execute the given command on the given strand. The allowed commands can be 'guessed' by using the information from Mole.statesFor(MissionHandle). However, due to the asynchronous nature of the whole framework, it can never be guaranteed that the command is still allowed when sent. For that reason, non-allowed commands shall be ignored by the implementations of an agency and underlying moles.
        Specified by:
        instruct in interface Mole
        Parameters:
        handle - a handle representing the mission instance on which the command shall be executed
        strand - the strand of the mission instance on which the command shall be executed
        command - the command to execute
        See Also:
        StrandCommand, Strand
      • instructRoot

        public final void instructRoot​(io.molr.commons.domain.MissionHandle handle,
                                       io.molr.commons.domain.StrandCommand command)
        Description copied from interface: Mole
        Instructs the root strand of the mission identified by the given handle to execute a given command. This is mainly a convenience method to execute commands without knowing the actual strand structure, as there has to be always to be a root strand. This is e.g. useful if missions simply have to be run without any GUI interaction. This can be accomplished by sending a resume command through this method. The rest of the behaviour shall be identical to the Mole.instruct(MissionHandle, Strand, StrandCommand) method.
        Specified by:
        instructRoot in interface Mole
        Parameters:
        handle - a handle representing the mission instance on which the command shall be executed
        command - the command to execute.
      • instruct

        public void instruct​(io.molr.commons.domain.MissionHandle handle,
                             io.molr.commons.domain.MissionCommand command)
        Description copied from interface: Mole
        Instruct the mole to execute a mission related command.
        Specified by:
        instruct in interface Mole
        Parameters:
        handle - representing the mission instance
        command - the command to execute
      • instructBlock

        public final void instructBlock​(io.molr.commons.domain.MissionHandle handle,
                                        java.lang.String blockId,
                                        io.molr.commons.domain.BlockCommand command)
        Description copied from interface: Mole
        Instruct the mole to execute a block related command.
        Specified by:
        instructBlock in interface Mole
        Parameters:
        handle - representing the mission instance
        blockId - the id of the target block
        command - the command to execute
      • executorFor

        protected abstract MissionExecutor executorFor​(io.molr.commons.domain.Mission mission,
                                                       java.util.Map<java.lang.String,​java.lang.Object> params)
      • missionRepresentationOf

        protected abstract io.molr.commons.domain.MissionRepresentation missionRepresentationOf​(io.molr.commons.domain.Mission mission)
      • missionParameterDescriptionOf

        protected abstract io.molr.commons.domain.MissionParameterDescription missionParameterDescriptionOf​(io.molr.commons.domain.Mission mission)