Java 7 removed any deterministic order of method declarations from
reflection apis (it was never guaranteed, it just happened to always
work out in declaration order, nearly all the time). So unless we were
to sort provides methods we cannot guarantee any order among them, and
alphabetical may well not be what anyone wants.
If you need order - dependency order is best. Can you not factor out a
commonality to ensure that what needs to be created first is actually
created first as a function of the dependency graph?
Christian.
On 23 Jan 2014, at 9:48, Alper Akture wrote:
In my app, I am binding an embedded HornetQServer instance. I do that
with
a @Provides in my module. I also bind a hornetq ClientSession object
with
an @Provides method in my module. The HornetQServer needs to be
initialized
before I can create a client session. Is there a way to control the
order
in which guice calls the @Provides methods? Is there other options,
i'm not
necessarily locked into the @Provides, but I also tried doing
explicitly
like this in the Module's configure method to no avail. Thanks for any
help.
@Override
protected void configure() {
bind(HornetQServer.class).toProvider(new
Provider<HornetQServer>() {
@Override
public HornetQServer get() {
//create it here
}
});
bind(ClientSession.class).toProvider(new
Provider<ClientSession>() {
@Override
public ClientSession get() {
//return null;
}
});
//more binding calls follow
--
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 [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/google-guice.
For more options, visit https://groups.google.com/groups/opt_out.
Christian Gruber :: Google, Inc. :: Java Core Libraries :: Dependency
Injection
email: [email protected] :::: mobile: +1 (646) 807-9839
--
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 [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/google-guice.
For more options, visit https://groups.google.com/groups/opt_out.