Class ProjectLauncher

  • All Implemented Interfaces:
    Constants, Registry, aQute.service.reporter.Report, aQute.service.reporter.Reporter, java.io.Closeable, java.lang.AutoCloseable, java.lang.Iterable<java.lang.String>
    Direct Known Subclasses:
    JUnitLauncher

    public abstract class ProjectLauncher
    extends Processor
    A Project Launcher is a base class to be extended by launchers. Launchers are JARs that launch a framework and install a number of bundles and then run the framework. A launcher jar must specify a Launcher-Class manifest header. This class is instantiated and cast to a LauncherPlugin. This plug in is then asked to provide a ProjectLauncher. This project launcher is then used by the project to run the code. Launchers must extend this class.
    • Constructor Detail

      • ProjectLauncher

        public ProjectLauncher​(Project project)
                        throws java.lang.Exception
        Throws:
        java.lang.Exception
    • Method Detail

      • validate

        protected void validate()
        Validate some settings
      • updateFromProject

        protected void updateFromProject()
                                  throws java.lang.Exception
        Collect all the aspect from the project and set the local fields from them. Should be called after constructor has been called.
        Throws:
        java.lang.Exception
      • addClasspath

        public void addClasspath​(Container container)
                          throws java.lang.Exception
        Throws:
        java.lang.Exception
      • addClasspath

        protected void addClasspath​(Container container,
                                    java.util.List<java.lang.String> pathlist)
                             throws java.lang.Exception
        Throws:
        java.lang.Exception
      • addClasspath

        protected void addClasspath​(java.util.Collection<Container> path)
                             throws java.lang.Exception
        Throws:
        java.lang.Exception
      • addRunBundle

        public void addRunBundle​(java.lang.String path)
      • getRunBundles

        public java.util.Collection<java.lang.String> getRunBundles()
      • addRunVM

        public void addRunVM​(java.lang.String arg)
      • addRunProgramArgs

        public void addRunProgramArgs​(java.lang.String arg)
      • getRunpath

        public java.util.List<java.lang.String> getRunpath()
      • getClasspath

        public java.util.Collection<java.lang.String> getClasspath()
      • getRunVM

        public java.util.Collection<java.lang.String> getRunVM()
      • getRunProgramArgs

        public java.util.Collection<java.lang.String> getRunProgramArgs()
      • getRunProperties

        public java.util.Map<java.lang.String,​java.lang.String> getRunProperties()
      • getStorageDir

        public java.io.File getStorageDir()
      • getMainTypeName

        public abstract java.lang.String getMainTypeName()
      • update

        public void update()
                    throws java.lang.Exception
        Throws:
        java.lang.Exception
      • onUpdate

        public void onUpdate​(java.lang.Runnable update)
      • getJavaExecutable

        public java.lang.String getJavaExecutable​(java.lang.String java)
        Overrides:
        getJavaExecutable in class Processor
      • launch

        public int launch()
                   throws java.lang.Exception
        Throws:
        java.lang.Exception
      • start

        public int start​(java.lang.ClassLoader parent)
                  throws java.lang.Exception
        Throws:
        java.lang.Exception
      • invoke

        protected int invoke​(java.lang.Class<?> main,
                             java.lang.String[] args)
                      throws java.lang.Exception
        Throws:
        java.lang.Exception
      • cleanup

        public void cleanup()
        Is called after the process exists. Can you be used to cleanup the properties file.
      • reportResult

        protected void reportResult​(int result)
      • setTimeout

        public void setTimeout​(long timeout,
                               java.util.concurrent.TimeUnit unit)
      • getTimeout

        public long getTimeout()
      • cancel

        public void cancel()
                    throws java.lang.Exception
        Throws:
        java.lang.Exception
      • getSystemPackages

        public java.util.Map<java.lang.String,​? extends java.util.Map<java.lang.String,​java.lang.String>> getSystemPackages()
      • getSystemCapabilities

        public java.lang.String getSystemCapabilities()
      • getSystemCapabilitiesParameters

        public Parameters getSystemCapabilitiesParameters()
      • setKeep

        public void setKeep​(boolean keep)
      • isKeep

        public boolean isKeep()
      • setTrace

        public void setTrace​(boolean level)
        Overrides:
        setTrace in class Processor
      • getTrace

        public boolean getTrace()
      • prepare

        public void prepare()
                     throws java.lang.Exception
        Should be called when all the changes to the launchers are set. Will calculate whatever is necessary for the launcher.
        Throws:
        java.lang.Exception
      • getProject

        public Project getProject()
      • addActivator

        public boolean addActivator​(java.lang.String e)
      • getActivators

        public java.util.Collection<java.lang.String> getActivators()
      • getRunFramework

        public int getRunFramework()
        Either NONE or SERVICES to indicate how the remote end launches. NONE means it should not use the classpath to run a framework. This likely requires some dummy framework support. SERVICES means it should load the framework from the claspath.
      • setRunFramework

        public void setRunFramework​(int n)
      • addDefault

        public void addDefault​(java.lang.String defaultSpec)
                        throws java.lang.Exception
        Add the specification for a set of bundles the runpath if it does not already is included. This can be used by subclasses to ensure the proper jars are on the classpath.
        Parameters:
        defaultSpec - The default spec for default jars
        Throws:
        java.lang.Exception
      • executable

        public Jar executable()
                       throws java.lang.Exception
        Create a self executable.
        Throws:
        java.lang.Exception
      • getCwd

        public java.io.File getCwd()
      • setCwd

        public void setCwd​(java.io.File cwd)
      • getRunJdb

        public java.lang.String getRunJdb()
      • getRunEnv

        public java.util.Map<java.lang.String,​java.lang.String> getRunEnv()
      • setStreams

        public void setStreams​(java.lang.Appendable out,
                               java.lang.Appendable err)
        Set the stderr and stdout streams for the output process. The debugged process must append its output (i.e. write operation in the process under debug) to the given appendables.
        Parameters:
        out - std out
        err - std err
      • write

        public void write​(java.lang.String text)
                   throws java.lang.Exception
        Write text to the debugged process as if it came from stdin.
        Parameters:
        text - the text to write
        Throws:
        java.lang.Exception
      • getRunSessions

        public java.util.List<? extends RunSession> getRunSessions()
                                                            throws java.lang.Exception
        Get the run sessions. If this return null, then launch on this object should be used, otherwise each returned object provides a remote session.
        Throws:
        java.lang.Exception
      • calculatedProperties

        public void calculatedProperties​(java.util.Map<java.lang.String,​java.lang.String> properties)
                                  throws java.lang.Exception
        Utility to calculate the final framework properties from settings
        Throws:
        java.lang.Exception
      • liveCoding

        public ProjectLauncher.LiveCoding liveCoding​(java.util.concurrent.Executor executor,
                                                     java.util.concurrent.ScheduledExecutorService scheduledExecutor)
                                              throws java.lang.Exception
        Throws:
        java.lang.Exception
      • isRunFrameworkRestart

        public boolean isRunFrameworkRestart()
      • renderArguments

        public static java.lang.String renderArguments​(java.util.Collection<java.lang.String> arguments)
      • renderArguments

        public static java.lang.String renderArguments​(java.util.Collection<java.lang.String> arguments,
                                                       boolean isWin32)
      • renderArguments

        public static java.lang.String renderArguments​(java.lang.String[] arguments)
      • renderArguments

        public static java.lang.String renderArguments​(java.lang.String[] arguments,
                                                       boolean isWin32)