Hi Andrey, "Thiago H. de Paula Figueiredo" <thiag...@gmail.com> wrote on 08/09/2009 15:51:14:
> Em Tue, 08 Sep 2009 11:27:06 -0300, Andrey Larionov <anlario...@gmail.com> > escreveu: > > > No, FactoryBean can create new instance on every call of getObject. > > Then you can create a new Tapestry-IoC scope (ServiceLifecycle > implementation) that creates a new object everytime an injection is made. Do you mean you want a service that acts like a "prototype" bean in Spring? You could create a new scope as Thiago suggests but you are likely to end up with a service that creates a new underlying object for every method call - and that probably isn't what you want. I suggest simply creating a service that is a Factory; maybe something like this: public final class AppModule { public static void bind(ServiceBinder binder) { binder.bind(ConnectionFactory.class, ConnectionFactoryWithPool. class); } } public interface ConnectionFactory { Connection createConnection(); } public class ConnectionFactoryWithPool implements ConnectionFactory { .... public Conection createConnection() { return pool.getConnection(); } } public class MyPage { @Inject private ConnectionFactory connectionFactory; public void myAction() { Connection connection = connectionFactory.createConnection(); try { ... } finally { connection.close(); } } } - Paul --- This e-mail may contain confidential and/or privileged information. If you are not the intended recipient (or have received this e-mail in error) please notify the sender immediately and delete this e-mail. Any unauthorized copying, disclosure or distribution of the material in this e-mail is strictly forbidden. Please refer to http://www.db.com/en/content/eu_disclosures.htm for additional EU corporate and regulatory disclosures.