2 Replies Latest reply on Aug 5, 2007 12:13 PM by thatrichard

    Post-injection hook (or how to avoid injection races?)

    thatrichard Newbie

      Consider this component

      @Name("personEditor")
      @Stateful
      @Scope(ScopeType.CONVERSATION)
      @Conversational
      public class PersonEditorBean implements PersonEditor {
      
       @In
       private Person person;
      
       @In
       public void setTitle(String title) {
       //modify the title
       person.setTitle(title);
       }
      
      


      This code will only work when "Person" is injected before "Title". What I think I need to do is to modify the setTitle method to store the value in a proxy and invoke another method, post-injection, to handle the modification, i.e.

       @In
       private Person person;
      
       private String titleProxy;
      
       @In
       public void setTitle(String title) {
       titleProxy = title;
       }
      
       private void updateTitle() {
       //modify titleProxy
       person.setTitle(titleProxy);
       }
      
      


      For this to work I need a way of invoking the "updateTitle" method after injection, i.e. a post-injection hook. I am sure Seam supports something like this, but I'm not finding it.

      Can someone point me in the right direction?

      Richard