com.jwebmp.guicedinjection.injections.ContextBinderGuice Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of guiced-injection Show documentation
Show all versions of guiced-injection Show documentation
Guice Injection allows you to access multiple Guice Binders and Modules across separate archives.
Allowing you to configure your applications with injection from multiple dependancies. Servlets, EJB's, and
Stand-Alone is supported. Requires JDK 8 or 10.
package com.jwebmp.guicedinjection.injections;
import com.google.inject.Singleton;
import com.jwebmp.guicedinjection.GuiceConfig;
import com.jwebmp.guicedinjection.GuiceContext;
import com.jwebmp.guicedinjection.abstractions.GuiceInjectorModule;
import com.jwebmp.guicedinjection.interfaces.IGuiceDefaultBinder;
import com.jwebmp.guicedinjection.properties.GlobalProperties;
import com.jwebmp.logger.LogFactory;
import io.github.classgraph.ScanResult;
import java.util.logging.Logger;
/**
* Binds the basic objects for the Guice Context to be injected everywhere
*/
@SuppressWarnings("unused")
public class ContextBinderGuice
implements IGuiceDefaultBinder
{
private static final Logger log = LogFactory.getLog("GuiceContextBinder");
public ContextBinderGuice()
{
//No config required
}
@Override
public void onBind(GuiceInjectorModule module)
{
ContextBinderGuice.log.fine("Bound GuiceConfig.class");
module.bind(GuiceConfig.class)
.toProvider(() -> GuiceContext.instance()
.getConfig())
.in(Singleton.class);
ContextBinderGuice.log.fine("Bound GlobalProperties.class");
module.bind(GlobalProperties.class)
.asEagerSingleton();
ContextBinderGuice.log.fine("Bound ScanResult.class");
module.bind(ScanResult.class)
.toProvider(() -> GuiceContext.instance()
.getScanResult())
.in(Singleton.class);
}
}