Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>It seems it is not yet supported , so for everyone how wants this work , here is small solution.</p> <pre><code>public class PostConstructListener implements TypeListener{ private static Logger logger = Logger.getLogger(PostConstructListener.class); @Override public &lt;I&gt; void hear(TypeLiteral&lt;I&gt; iTypeLiteral,final TypeEncounter&lt;I&gt; iTypeEncounter) { Class&lt;? super I&gt; type = iTypeLiteral.getRawType(); ReflectionUtils.MethodFilter mf = new ReflectionUtils.MethodFilter() { @Override public boolean matches(Method method) { return method.isAnnotationPresent(PostConstruct.class); } }; ReflectionUtils.MethodCallback mc = new ReflectionUtils.MethodCallback() { @Override public void doWith(Method method) throws IllegalArgumentException, IllegalAccessException { if (!(method.getReturnType().equals(Void.TYPE) &amp;&amp; method.getParameterTypes().length == 0)) { logger.warn("Only VOID methods having 0 parameters are supported by the PostConstruct annotation!" + "method " + method.getName() + " skipped!"); return; } iTypeEncounter.register(new PostConstructInvoker&lt;I&gt;(method)); } }; ReflectionUtils.doWithMethods(type,mc,mf); } class PostConstructInvoker&lt;I&gt; implements InjectionListener&lt;I&gt;{ private Method method; public PostConstructInvoker(Method method) { this.method = method; } @Override public void afterInjection(I o) { try { method.invoke(o); } catch (Throwable e) { logger.error(e); } } } } </code></pre> <p>The <a href="http://apollo89.com/java/spring-framework-2.5.3/api/org/springframework/util/ReflectionUtils.html" rel="nofollow noreferrer">ReflectionUtils</a> package is defined in spring.</p> <p>Bind this listener to any event with :</p> <pre><code>bindListener(Matchers.any(),new PostConstructListener()); </code></pre> <p>in your guice module. Have fun</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload