Class ProjectLauncher

All Implemented Interfaces:
Constants, Registry, aQute.service.reporter.Report, aQute.service.reporter.Reporter, Closeable, AutoCloseable, Iterable<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.
  • Field Details

  • Constructor Details

  • Method Details

    • validate

      protected void validate()
      Validate some settings
    • updateFromProject

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

      public void addClasspath(Container container) throws Exception
      Throws:
      Exception
    • addClasspath

      protected void addClasspath(Container container, List<String> pathlist) throws Exception
      Throws:
      Exception
    • addClasspath

      protected void addClasspath(Collection<Container> path) throws Exception
      Throws:
      Exception
    • addRunBundle

      public void addRunBundle(String path)
    • getRunBundles

      public Collection<String> getRunBundles()
    • addRunVM

      public void addRunVM(String arg)
    • addRunProgramArgs

      public void addRunProgramArgs(String arg)
    • getRunpath

      public List<String> getRunpath()
    • getClasspath

      public Collection<String> getClasspath()
    • getRunVM

      public Collection<String> getRunVM()
    • getRunProgramArgs

      public Collection<String> getRunProgramArgs()
    • getRunProperties

      public Map<String,String> getRunProperties()
    • getStorageDir

      public File getStorageDir()
    • getMainTypeName

      public abstract String getMainTypeName()
    • update

      public void update() throws Exception
      Throws:
      Exception
    • onUpdate

      public void onUpdate(Runnable update)
    • getJavaExecutable

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

      public int launch() throws Exception
      Throws:
      Exception
    • start

      public int start(ClassLoader parent) throws Exception
      Throws:
      Exception
    • invoke

      protected int invoke(Class<?> main, String[] args) throws Exception
      Throws:
      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, TimeUnit unit)
    • getTimeout

      public long getTimeout()
    • cancel

      public void cancel() throws Exception
      Throws:
      Exception
    • getSystemPackages

      public Map<String,? extends Map<String,String>> getSystemPackages()
    • getSystemCapabilities

      public 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 Exception
      Should be called when all the changes to the launchers are set. Will calculate whatever is necessary for the launcher.
      Throws:
      Exception
    • getProject

      public Project getProject()
    • addActivator

      public boolean addActivator(String e)
    • getActivators

      public Collection<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(String defaultSpec) throws 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:
      Exception
    • executable

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

      public File getCwd()
    • setCwd

      public void setCwd(File cwd)
    • getRunJdb

      public String getRunJdb()
    • getRunEnv

      public Map<String,String> getRunEnv()
    • registerForNotifications

      public void registerForNotifications(ProjectLauncher.NotificationListener listener)
    • getNotificationListeners

      public Set<ProjectLauncher.NotificationListener> getNotificationListeners()
    • setStreams

      public void setStreams(Appendable out, 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(String text) throws Exception
      Write text to the debugged process as if it came from stdin.
      Parameters:
      text - the text to write
      Throws:
      Exception
    • getRunSessions

      public List<? extends RunSession> getRunSessions() throws 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:
      Exception
    • calculatedProperties

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

      public ProjectLauncher.LiveCoding liveCoding(Executor executor, ScheduledExecutorService scheduledExecutor) throws Exception
      Throws:
      Exception
    • isRunFrameworkRestart

      public boolean isRunFrameworkRestart()
    • renderArguments

      public static String renderArguments(Collection<String> arguments)
    • renderArguments

      public static String renderArguments(Collection<String> arguments, boolean isWin32)
    • renderArguments

      public static String renderArguments(String[] arguments)
    • renderArguments

      public static String renderArguments(String[] arguments, boolean isWin32)