Class GenerationFacade


  • public final class GenerationFacade
    extends Object
    Entry point to model transformation (aka generation) process. Populate with relevant context information: messages(IMessageHandler) to receive generator messages (optional); transients(TransientModelsProvider) where to keep transient models (mandatory); taskHandler(GeneratorTaskListener) get notified about progress (optional); trace(TraceFacility) to get trace events (optional); then fire off with process(ProgressMonitor, List) IMPLEMENTATION NOTE: transformation requires model read lock for a repository of transformed model. At certain moments, it also requires write lock on a repository with transient modules. Although I can (and would like to) hide appropriate locks inside TransientModelsProvider, now these are explicit and are outside of the class to avoid accidental 'can't write from read'. Shall investigate if there's true need to expose transient modules in a repository right from the very beginning. If yes, shall double efforts to get distinct repository for transient modules (so that only transient repo is write-locked, while input model's repo is read-locked).
    • Method Detail

      • canGenerate

        public static boolean canGenerate​(SModel sm)
      • transients

        public GenerationFacade transients​(@NotNull
                                           TransientModelsProvider transientModelsProvider)
        Register facility responsible for transient model handling, mandatory.
        Parameters:
        transientModelsProvider - transient model facility
        Returns:
        this for convenience
      • messages

        public GenerationFacade messages​(@Nullable
                                         IMessageHandler messages)
        Optional destination of all messages reported by generator, if none specified (or null), messages get discarded.
        Parameters:
        messages - destination of generator messages, or null
        Returns:
        this for convenience
      • process

        public GenerationStatus process​(@NotNull
                                        ProgressMonitor monitor,
                                        @NotNull
                                        SModel model)
        Generate single model. GenerationFacade instance can be reused then for other generation activities. IMPORTANT: unlike process(ProgressMonitor, List), requires model write lock (on a repository of TransientModelsProvider) as it needs to create and publish module with transient models.
        Parameters:
        monitor - report progress/cancellation
        model - input
        Returns:
        status object that describes generation outcome
      • process

        public void process​(@NotNull
                            ProgressMonitor monitor,
                            @NotNull
                            List<? extends GeneratorTask> tasks)
        Feed transformation process with sequence of task. Tasks are processed in the order given. If a task deals with a model from a repository, calling code shall ensure respective read lock.
        Parameters:
        monitor - report progress/cancellation
        tasks - models to generate