Skip to content

Commit

Permalink
Extend Main with entry point to boot application with additional bind…
Browse files Browse the repository at this point in the history
…ings (#50)

Signed-off-by: Benjamin Bentmann <[email protected]>
  • Loading branch information
bentmann authored Feb 3, 2022
1 parent 6889f81 commit 7d2a723
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion org.eclipse.sisu.inject/src/org/eclipse/sisu/launch/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,24 @@ public static <T> T boot( final Class<T> type, final String... args )
return boot( System.getProperties(), args ).getInstance( type );
}

public static <T> T boot( final Class<T> type, final String[] args, final Module... bindings )
{
return boot( System.getProperties(), args, bindings ).getInstance( type );
}

public static Injector boot( final Map<?, ?> properties, final String... args )
{
return boot( properties, args, new Module[0] );
}

public static Injector boot( final Map<?, ?> properties, final String[] args, final Module... bindings )
{
final Module[] modules = new Module[bindings.length + 1];
System.arraycopy( bindings, 0, modules, 1, bindings.length );
modules[0] = new Main( properties, args );

final BeanScanning scanning = BeanScanning.select( properties );
final Module app = wire( scanning, new Main( properties, args ) );
final Module app = wire( scanning, modules );
final Injector injector = Guice.createInjector( app );

return injector;
Expand Down

0 comments on commit 7d2a723

Please sign in to comment.