Well, if you inject a perthread-scoped service into a normal
(singleton) service, you'll get the proxy.  Invoking methods on the
proxy will create the per-thread instance "behind the scenes", which
may be what you want.

On the other hand, you may be using something I tend to call a
"process object", an object that holds state and is passed around to a
number of stateless services.  In that case, you may want to follow
Kristian's advice and define a factory service that creates the
process object (thus hiding its internal structure, including any
injected dependencies).  And, of course, the process object should be
defined in terms of an interface.  This pattern is all over Tapestry.

On Tue, Apr 8, 2008 at 9:08 PM, Foror <[EMAIL PROTECTED]> wrote:
> // singleton
>  public IChatCoordinator buildChatCoordinator() {...}
>
>  @Scope(IOCConstants.PERTHREAD_SCOPE)
>  public IPerthredService buildPerthreadService(@Inject IOtherPerthredService) 
> {...}
>
>  ---
>
>  // singleton
>  public class ChatCoordinator implements IChatCoordinator {
>
>     // for every call this method needed new IPerthredService
>     public void someMethod() {
>        IPerthredService service = ? // who build new IPerthredService?
>     }
>  }
>
>  public class ChatJobSchedule extends TimerTask {
>
>   private IChatCoordinator op;
>
>   public ChatJobSchedule(IChatCoordinator op) {
>     this.op = op;
>   }
>
>   @Override
>   public void run() {
>     op.someMethod();
>   }
>  }
>
>
>  ---------------------------------------------------------------------
>  To unsubscribe, e-mail: [EMAIL PROTECTED]
>  For additional commands, e-mail: [EMAIL PROTECTED]
>
>



-- 
Howard M. Lewis Ship

Creator Apache Tapestry and Apache HiveMind

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to