com.peterphi.std.guice.thymeleaf.role.AutoThymeleafGuiceRole Maven / Gradle / Ivy
package com.peterphi.std.guice.thymeleaf.role;
import com.codahale.metrics.MetricRegistry;
import com.google.inject.Injector;
import com.google.inject.Module;
import com.google.inject.Stage;
import com.peterphi.std.guice.apploader.GuiceProperties;
import com.peterphi.std.guice.apploader.GuiceRole;
import com.peterphi.std.guice.apploader.GuiceSetup;
import com.peterphi.std.guice.common.ClassScanner;
import com.peterphi.std.guice.thymeleaf.ThymeleafModule;
import org.apache.commons.configuration.CompositeConfiguration;
import org.apache.commons.configuration.Configuration;
import org.apache.commons.configuration.PropertiesConfiguration;
import java.util.List;
import java.util.concurrent.atomic.AtomicReference;
public class AutoThymeleafGuiceRole implements GuiceRole
{
@Override
public void adjustConfigurations(final List configs)
{
}
@Override
public void register(final Stage stage,
final ClassScanner scanner,
final CompositeConfiguration config,
final PropertiesConfiguration overrides,
final GuiceSetup setup,
final List modules,
final AtomicReference injectorRef,
final MetricRegistry metrics)
{
if (config.getBoolean(GuiceProperties.ROLE_THYMELEAF_AUTO, true))
{
modules.add(new ThymeleafModule());
}
}
@Override
public void injectorCreated(final Stage stage,
final ClassScanner scanner,
final CompositeConfiguration config,
final PropertiesConfiguration overrides,
final GuiceSetup setup,
final List modules,
final AtomicReference injectorRef,
final MetricRegistry metrics)
{
}
}