Hello, every one. I met the following problem when trying to use tapestry-ioc in a standalone program. According to the tapestry official site, a service builder method should be invoked multiple times, if it is annotated with @Scope("perthread") and the service is used in multi threads. So I wrote the following program, trying to demonstrate it. In the program, ServiceA is used in two threads, but the builder method is invoked only one time. Why?
public class Main { public static void main(String[] args) { RegistryBuilder regBuilder = new RegistryBuilder(); regBuilder.add(ModuleA.class); final Registry reg = regBuilder.build(); final ServiceA a = reg.getService(ServiceA.class); a.print(); new Thread() { @Override public void run() { ServiceA aInAnotherThread = reg.getService(ServiceA.class); aInAnotherThread.print(); } }.start(); } } public class ServiceA { public ServiceA() { System.out.println("A new instance of ServiceA is under construction!"); } public void print() { System.out.println(this); } } public class ModuleA { @Scope("perthread") public static ServiceA builder() { System.out.println("Building a new instance of ServiceA ..."); return new ServiceA(); } } -- View this message in context: http://www.nabble.com/T5%3A-tapestry-ioc-scope-problem-in-a-standalone-program-tp19405294p19405294.html Sent from the Tapestry - User mailing list archive at Nabble.com. --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]