As a side note, if you don't have a required inheritance hierarchy in your context, you can make an AbstractInitableWidget which has a default, overridable init() and implements IInitableAfterCreation, just to cut down on boilerplate. It would be good if Matching on the subclassesOf bit works though, as the above is sort of janky.

c.

On 21 Aug 2013, at 3:55, [email protected] wrote:

Let me a couple of days (this weekend) and I will try to simply my original issue to a test case. I still think that maybe something funny is going on
under some specific conditions.


On Tuesday, August 20, 2013 10:57:47 PM UTC-4, Sam Berlin wrote:

Interesting. I haven't fully digested it, but if its causing surprising behavior that you're having trouble explaining, then I think a test case would be useful. If only so we can examine it more closely and figure out
if there is indeed a bug.
On Aug 20, 2013 9:20 PM, <[email protected] <javascript:>> wrote:

Sorry that I'm still not 100% sure, and I do not have a test case to
show, but I'm pretty sure I did find the main cause of this "issue" in my
application.

I created an interface :

-------------
public interface IInitableAfterCreation
{
public void init();
}
-------------

And this is what I check in the *Matcher* of my *InjectionListener* :

-------------
@Override
public boolean matches(Binding<?> t)
{
return
IInitableAfterCreation.class.isAssignableFrom(t.getKey().getTypeLiteral().getRawType());
}
-------------

The problem is that I was using this *IInitableAfterCreation* interface on my *implementations* objects, not on their interfaces. For example :

-------------
public class MyWidget implements IMyWidget, IInitableAfterCreation
{
@Override
public void init()
{
}
// ...
}
-------------

This doesn't work! But if I make the* IMyWidge*t *interface* extend *IInitableAfterCreation
*, then it works :

-------------
public interface IMyWidget extends IInitableAfterCreation {}

public class MyWidget implements IMyWidget
{
@Override
public void init()
{
}
// ...
}
-------------

Is this the way it should work? Some of my *IMyWidget* implementations that don't need to be initialized at startup will still have to implement
the *init()* method?

Anyway, the issue seems less important than what I though, that's good
news! :-)

Let me know if you still want a test case or if this is not a real
problem actually (I would appreciate to better understand the way it works
though!). Thanks!


********

--
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] <javascript:>.
To post to this group, send email to [email protected]<javascript:>
.
Visit this group at http://groups.google.com/group/google-guice.
For more options, visit https://groups.google.com/groups/opt_out.



--
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.

Reply via email to