Search in sources :

Example 1 with BootstrapRunner

use of com.nexblocks.authguard.bootstrap.BootstrapRunner in project AuthGuard by AuthGuard.

the class ServerRunner method run.

public void run(final ConfigContext configContext) {
    // class search
    final Collection<String> searchPackages = configContext.getSubContext("injection").getAsCollection("packages", String.class);
    final ClassSearch classSearch = new ClassSearch(searchPackages);
    // injectors
    final Injector injector = Guice.createInjector(new MappersBinder(), new ConfigBinder(configContext), new ExchangesBinder(configContext, searchPackages), new ApiKeysExchangeBinder(configContext, searchPackages), new ApiRoutesBinder(searchPackages, configContext), new ServicesBinder(configContext), new JwtBinder(configContext), new DalBinder(configContext, searchPackages), new EmbBinder(searchPackages), new ExternalProvidersBinder(configContext, searchPackages));
    log.info("Initialed injection binders");
    // run bootstraps
    new BootstrapRunner(classSearch, injector).runAll();
    log.info("Completed bootstrap");
    // run the server
    final ImmutableServerConfig serverConfig = Optional.ofNullable(configContext.getAsConfigBean("server", ImmutableServerConfig.class)).orElseGet(() -> ImmutableServerConfig.builder().port(3000).build());
    new AuthGuardServer(injector).start(Javalin.create(config -> {
        config.enforceSsl = serverConfig.enforceSsl();
        config.server(() -> new JettyServerProvider(serverConfig).get());
        config.accessManager(new RolesAccessManager());
    }));
}
Also used : com.nexblocks.authguard.bindings(com.nexblocks.authguard.bindings) Logger(org.slf4j.Logger) Collection(java.util.Collection) LoggerFactory(org.slf4j.LoggerFactory) BootstrapRunner(com.nexblocks.authguard.bootstrap.BootstrapRunner) JettyServerProvider(com.nexblocks.authguard.rest.server.JettyServerProvider) MappersBinder(com.nexblocks.authguard.rest.bindings.MappersBinder) Javalin(io.javalin.Javalin) AuthGuardServer(com.nexblocks.authguard.rest.server.AuthGuardServer) ClassSearch(com.nexblocks.authguard.injection.ClassSearch) Injector(com.google.inject.Injector) RolesAccessManager(com.nexblocks.authguard.rest.access.RolesAccessManager) Guice(com.google.inject.Guice) Optional(java.util.Optional) ConfigContext(com.nexblocks.authguard.config.ConfigContext) ImmutableServerConfig(com.nexblocks.authguard.rest.config.ImmutableServerConfig) AuthGuardServer(com.nexblocks.authguard.rest.server.AuthGuardServer) MappersBinder(com.nexblocks.authguard.rest.bindings.MappersBinder) RolesAccessManager(com.nexblocks.authguard.rest.access.RolesAccessManager) JettyServerProvider(com.nexblocks.authguard.rest.server.JettyServerProvider) Injector(com.google.inject.Injector) ImmutableServerConfig(com.nexblocks.authguard.rest.config.ImmutableServerConfig) ClassSearch(com.nexblocks.authguard.injection.ClassSearch) BootstrapRunner(com.nexblocks.authguard.bootstrap.BootstrapRunner)

Aggregations

Guice (com.google.inject.Guice)1 Injector (com.google.inject.Injector)1 com.nexblocks.authguard.bindings (com.nexblocks.authguard.bindings)1 BootstrapRunner (com.nexblocks.authguard.bootstrap.BootstrapRunner)1 ConfigContext (com.nexblocks.authguard.config.ConfigContext)1 ClassSearch (com.nexblocks.authguard.injection.ClassSearch)1 RolesAccessManager (com.nexblocks.authguard.rest.access.RolesAccessManager)1 MappersBinder (com.nexblocks.authguard.rest.bindings.MappersBinder)1 ImmutableServerConfig (com.nexblocks.authguard.rest.config.ImmutableServerConfig)1 AuthGuardServer (com.nexblocks.authguard.rest.server.AuthGuardServer)1 JettyServerProvider (com.nexblocks.authguard.rest.server.JettyServerProvider)1 Javalin (io.javalin.Javalin)1 Collection (java.util.Collection)1 Optional (java.util.Optional)1 Logger (org.slf4j.Logger)1 LoggerFactory (org.slf4j.LoggerFactory)1