New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add EmbulkService#newInjector #239
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
why don't you override EmbulkService#getAdditionalModules? |
Since import com.google.inject.Binder;
import com.google.inject.Guice;
import com.google.inject.Inject;
import com.google.inject.Injector;
import com.google.inject.Module;
import com.google.inject.util.Modules;
public class InjectorTest
{
public interface InfA { void doIt(); }
public interface InfB { void doIt(); }
public interface InfC { void doIt(); }
public static class ConcA
implements InfA
{
@Inject
public ConcA(InfB b, InfC c)
{
b.doIt();
c.doIt();
}
public void doIt() { System.out.println("hellp A"); }
}
public static class ConcB
implements InfB
{
public void doIt() { System.out.println("hello B"); }
}
public static class ConcC
implements InfC
{
public void doIt() { System.out.println("hello C"); }
}
public static class ConcC2
implements InfC
{
public void doIt() { System.out.println("hello C2"); }
}
public static class ProdMod1
implements Module
{
public void configure(Binder binder)
{
binder.bind(InfA.class).to(ConcA.class);
binder.bind(InfB.class).to(ConcB.class);
}
}
public static class ProdMod2
implements Module
{
public void configure(Binder binder) {
binder.bind(InfC.class).to(ConcC.class);
}
}
public static class ProdMod3
implements Module
{
public void configure(Binder binder) {
binder.bind(InfC.class).to(ConcC2.class);
}
}
public static void main(String[] args) throws Exception
{
/*
// outout:
// hello B
// hello C
// hello A
Injector injector = Guice.createInjector(new ProdMod1(), new ProdMod2());
ConcA a = injector.getInstance(ConcA.class);
a.doIt();
*/
/*
// output:
// Exception in thread "main" com.google.inject.ConfigurationException: Guice configuration errors:
//
// 1) No implementation for InjectorTest$InfB was bound.
// while locating InjectorTest$InfB
// for parameter 0 at InjectorTest$ConcA.<init>(InjectorTest.java:21)
// while locating InjectorTest$ConcA
//
// 1 error
// at com.google.inject.internal.InjectorImpl.getProvider(InjectorImpl.java:1042)
// at com.google.inject.internal.InjectorImpl.getProvider(InjectorImpl.java:1001)
// at com.google.inject.internal.InjectorImpl.getInstance(InjectorImpl.java:1051)
Injector injector2 = Guice.createInjector(Modules.override(new ProdMod2()).with(new ProdMod3()));
ConcA a2 = injector2.getInstance(ConcA.class);
a2.doIt();
*/
// outout:
// hello B
// hello C2
// hello A
Injector injector3 = Guice.createInjector(Modules.override(new ProdMod1(), new ProdMod2()).with(new ProdMod3()));
//Injector injector3 = Guice.createInjector(Modules.override(new ProdMod2(), new ProdMod1()).with(new ProdMod3()));
ConcA a3 = injector3.getInstance(ConcA.class);
a3.doIt();
}
} |
frsyuki
added a commit
that referenced
this pull request
Jul 22, 2015
Thank you for fixing. LocalThreadExecutor works fine. I will also check the behavior of MapReduceExecutor. |
I checked the behavior of MapReduceExecutor. This fix works fine. |
GJ 👍 |
frsyuki
added a commit
that referenced
this pull request
Jul 23, 2015
…ervice Add EmbulkService#newInjector
frsyuki
added a commit
that referenced
this pull request
Jul 23, 2015
add EmbulkService.overrideModules so that apps can use Modules.override [#239]
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
To override binding, this method is useful like: