How to create PERTHREAD_SCOPE object?

2008-01-03 Thread Donyee
I want to create a new  object per request, and my code is like:

@Scope(IOCConstants.PERTHREAD_SCOPE)
public Encoder buildEncoder() {
System.out.println(new Encoder()...*);
   return new Encoder();
   }

when i request my page with IE and FireFox,
the output is new Encoder()...*, only print
once!
is there anything wrong with my code?


Re: How to create PERTHREAD_SCOPE object?

2008-01-03 Thread Massimo Lusetti
On Jan 3, 2008 10:49 AM, Donyee [EMAIL PROTECTED] wrote:

 is there anything wrong with my code?

You actually didn't show your code.

-- 
Massimo
http://meridio.blogspot.com

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



Re: How to create PERTHREAD_SCOPE object?

2008-01-03 Thread Donyee
In AppModule.java
@Scope(IOCConstants.PERTHREAD_SCOPE)
public Encoder buildEncoder() {
System.out.println(new Encoder()...*);

   return new Encoder();
   }

in my page class:
@Inject
private Encoder encoder;


2008/1/3, Massimo Lusetti [EMAIL PROTECTED]:

 On Jan 3, 2008 10:49 AM, Donyee [EMAIL PROTECTED] wrote:

  is there anything wrong with my code?

 You actually didn't show your code.

 --
 Massimo
 http://meridio.blogspot.com

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




-- 
徐 依伟


Re: How to create PERTHREAD_SCOPE object?

2008-01-03 Thread Massimo Lusetti
On Jan 3, 2008 1:44 PM, Donyee [EMAIL PROTECTED] wrote:

 In AppModule.java
 @Scope(IOCConstants.PERTHREAD_SCOPE)
 public Encoder buildEncoder() {
 System.out.println(new Encoder()...*);

return new Encoder();
}

 in my page class:
 @Inject
 private Encoder encoder;

Maybe this could help.

http://tapestry.apache.org/tapestry5/apidocs/org/apache/tapestry/ioc/ServiceBinder.html#bind(java.lang.Class)


-- 
Massimo
http://meridio.blogspot.com

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



Re: How to create PERTHREAD_SCOPE object?

2008-01-03 Thread Davor Hrg
you have to use an interface for this to work

Encoder + EncoderImpl


@Scope(IOCConstants.PERTHREAD_SCOPE)
   public Encoder buildEncoder() {
   System.out.println(new Encoder()...*);
  return new EncoderImpl();
  }

there is probably a warning in the log somewhere

Davor Hrg

On Jan 3, 2008 10:49 AM, Donyee [EMAIL PROTECTED] wrote:
 I want to create a new  object per request, and my code is like:

 @Scope(IOCConstants.PERTHREAD_SCOPE)
 public Encoder buildEncoder() {
 System.out.println(new Encoder()...*);
return new Encoder();
}

 when i request my page with IE and FireFox,
 the output is new Encoder()...*, only print
 once!
 is there anything wrong with my code?


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