@ -31,6 +31,7 @@ import org.springframework.boot.cli.command.core.HintCommand;
import org.springframework.boot.cli.command.core.VersionCommand ;
import org.springframework.boot.cli.command.core.VersionCommand ;
import org.springframework.boot.cli.command.shell.ShellCommand ;
import org.springframework.boot.cli.command.shell.ShellCommand ;
import org.springframework.boot.loader.tools.LogbackInitializer ;
import org.springframework.boot.loader.tools.LogbackInitializer ;
import org.springframework.util.ClassUtils ;
import org.springframework.util.SystemPropertyUtils ;
import org.springframework.util.SystemPropertyUtils ;
/ * *
/ * *
@ -51,6 +52,7 @@ public final class SpringCli {
LogbackInitializer . initialize ( ) ;
LogbackInitializer . initialize ( ) ;
CommandRunner runner = new CommandRunner ( "spring" ) ;
CommandRunner runner = new CommandRunner ( "spring" ) ;
ClassUtils . overrideThreadContextClassLoader ( createExtendedClassLoader ( runner ) ) ;
runner . addCommand ( new HelpCommand ( runner ) ) ;
runner . addCommand ( new HelpCommand ( runner ) ) ;
addServiceLoaderCommands ( runner ) ;
addServiceLoaderCommands ( runner ) ;
runner . addCommand ( new ShellCommand ( ) ) ;
runner . addCommand ( new ShellCommand ( ) ) ;
@ -66,14 +68,14 @@ public final class SpringCli {
}
}
private static void addServiceLoaderCommands ( CommandRunner runner ) {
private static void addServiceLoaderCommands ( CommandRunner runner ) {
ServiceLoader < CommandFactory > factories = ServiceLoader . load ( CommandFactory . class ,
ServiceLoader < CommandFactory > factories = ServiceLoader
createCommandClassLoader ( runner ) ) ;
. load ( CommandFactory . class ) ;
for ( CommandFactory factory : factories ) {
for ( CommandFactory factory : factories ) {
runner . addCommands ( factory . getCommands ( ) ) ;
runner . addCommands ( factory . getCommands ( ) ) ;
}
}
}
}
private static URLClassLoader create Comman dClassLoader( CommandRunner runner ) {
private static URLClassLoader create Extende dClassLoader( CommandRunner runner ) {
return new URLClassLoader ( getExtensionURLs ( ) , runner . getClass ( ) . getClassLoader ( ) ) ;
return new URLClassLoader ( getExtensionURLs ( ) , runner . getClass ( ) . getClassLoader ( ) ) ;
}
}