public Dep3{
@Inject
public Dep3(List<Model> models){
for(Model model : models){
GrandChildDep3 deepdep = guiceProvidedFactory.createFor(model);
//...
}
}
}
public NotifyingSerializer extends RealSerializer{
ProgressBarUpdater updater;
@Override
public marshal(...){
updater.pushNewTask(/*speculate, or use meta about the model, to guess at how many child-tasks this one has*/ 45);
super.marshall(...);
updater.popTask();
}
//similar for unmarshal
}
binder().bindListener(
new AbstractMatcher<Binding<?>>() {
Set<Class> types = ImmutableSet.of(
(Class) RootItem.class, Dependency1.class,
Dependency2.class, Dependency3.class,
GrandChildDep2.class, GrandChildDep3.class);
@Override public boolean matches(Binding<?> binding) {
return types.contains(binding.getKey().getTypeLiteral().getRawType());
}
},
new ProvisionListener(){
Class provisionedType = provision.getBinding().getKey().getTypeLiteral().getRawType();
//do a filter to find out if this provision is just because of a factory call
if(provision.getDependenyChain().stream().filter(dep -> dep.getDependency().getKey().getTypeLiteral().getRawType().equals(provisionedTyped)).size() == 1){
updater.pushTask(/*use static knowledge to figure out how many subtasks this dep will have*/);
}
}
);
//...
public Class RootItem{
@Inject
public RootItem(Dependency1 dep1, Dependency2 dep2, Dependency3 dep3,
/*other misc items*/,
ProgressBarUpdater updater){
//... ctor-things
updater.popTask();
}
}
What I would really like is one of the following:
Is there something I'm missing? Is there an existing elegant way to, from withen guice, get a piece of code executed when a component has been constructed?
Thanks for any help,
-Geoff
--
You received this message because you are subscribed to the Google Groups "google-guice" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-guice...@googlegroups.com.
To post to this group, send email to google...@googlegroups.com.
Visit this group at http://groups.google.com/group/google-guice.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-guice/548d5336-e0a2-409b-b16f-e657ff688782%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.