org.springframework.boot.loader
Class Launcher

java.lang.Object
  extended by org.springframework.boot.loader.Launcher
Direct Known Subclasses:
JarLauncher, WarLauncher

public abstract class Launcher
extends Object

Base class for launchers that can start an application with a fully configured classpath.

Author:
Phillip Webb

Constructor Summary
Launcher()
           
 
Method Summary
protected  ClassLoader createClassLoader(List<Archive> lib)
          Create a classloader for the specified lib.
protected  ClassLoader createClassLoader(URL[] urls)
          Create a classloader for the specified URLs
protected  Runnable createMainMethodRunner(String mainClass, String[] args, ClassLoader classLoader)
          Create the MainMethodRunner used to launch the application.
protected  String getMainClass(Archive archive)
          Obtain the main class that should be used to launch the application.
protected abstract  boolean isNestedArchive(Archive.Entry jarEntry)
          Determine if the specified JarEntry is a nested item that should be added to the classpath.
 void launch(String[] args)
          Launch the application.
protected  void launch(String[] args, Archive archive)
          Launch the application given the archive file
protected  void launch(String[] args, Archive archive, ClassLoader classLoader)
          Launch the application given the archive file and a fully configured classloader.
protected  void launch(String[] args, ProtectionDomain protectionDomain)
          Launch the application given the protection domain.
protected  void postProcessLib(Archive archive, List<Archive> lib)
          Called to post-process lib entries before they are used.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Launcher

public Launcher()
Method Detail

launch

public void launch(String[] args)
Launch the application. This method is the initial entry point that should be called by a subclass public static void main(String[] args) method.

Parameters:
args - the incoming arguments

launch

protected void launch(String[] args,
                      ProtectionDomain protectionDomain)
               throws Exception
Launch the application given the protection domain.

Parameters:
args - the incoming arguments
protectionDomain - the protection domain
Throws:
Exception

launch

protected void launch(String[] args,
                      Archive archive)
               throws Exception
Launch the application given the archive file

Parameters:
args - the incoming arguments
archive - the underlying (zip/war/jar) archive
Throws:
Exception

isNestedArchive

protected abstract boolean isNestedArchive(Archive.Entry jarEntry)
Determine if the specified JarEntry is a nested item that should be added to the classpath. The method is called once for each entry.

Parameters:
jarEntry - the jar entry
Returns:
true if the entry is a nested item (jar or folder)

postProcessLib

protected void postProcessLib(Archive archive,
                              List<Archive> lib)
                       throws Exception
Called to post-process lib entries before they are used. Implementations can add and remove entries.

Parameters:
archive - the archive
lib - the existing lib
Throws:
Exception

createClassLoader

protected ClassLoader createClassLoader(List<Archive> lib)
                                 throws Exception
Create a classloader for the specified lib.

Parameters:
lib - the lib
Returns:
the classloader
Throws:
Exception

createClassLoader

protected ClassLoader createClassLoader(URL[] urls)
                                 throws Exception
Create a classloader for the specified URLs

Parameters:
urls - the URLs
Returns:
the classloader
Throws:
Exception

launch

protected void launch(String[] args,
                      Archive archive,
                      ClassLoader classLoader)
               throws Exception
Launch the application given the archive file and a fully configured classloader.

Parameters:
args - the incoming arguments
archive - the archive
classLoader - the classloader
Throws:
Exception

getMainClass

protected String getMainClass(Archive archive)
                       throws Exception
Obtain the main class that should be used to launch the application. By default this method uses a Start-Class manifest entry.

Parameters:
archive - the archive
Returns:
the main class
Throws:
Exception

createMainMethodRunner

protected Runnable createMainMethodRunner(String mainClass,
                                          String[] args,
                                          ClassLoader classLoader)
                                   throws Exception
Create the MainMethodRunner used to launch the application.

Parameters:
mainClass - the main class
args - the incoming arguments
classLoader - the classloader
Returns:
a runnable used to start the application
Throws:
Exception


Copyright © 2013. All Rights Reserved.