rkoshy / guice-tools

Add tools for guice

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Guice Tools

Add auto scan component and configuration for Guice

<dependencies>
    <dependency>
        <groupId>com.talanlabs</groupId>
        <artifactId>guice-tools</artifactId>
        <version>1.0.0</version>
    </dependency>
</dependencies>

Usage Scan

Component

By default add @Component in bind class

@Component
public class MyExample {
    ...
}

And install scan module in guice module

install(new ComponentScanModule("com.example"));

Or change scan with @Singleton

install(new ComponentScanModule("com.example",Singleton.class));

Configuration

By defualt add @Configuration in install module

@Configuration
public class MyModule extends AbstractModule {
    ...
}

And install scan module in guice module

install(new ConfigurationScanModule("com.example"));

Usage Logger

Guice.createInjector(new LoggerModuler(),...);

Inject field

@InjectLogger
Logger logger;

Inject method

@InjectLogger
void setLogger(Logger logger) {
	
}

Change name, default is class name

@InjectLogger("test")

About

Add tools for guice

License:Other


Languages

Language:Java 100.0%