Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- INSIDE SERVLET:
- FondipFactory fondipFactory = (FondipFactory) getServletContext().getAttribute("FondipFactory");
- BusinessDelegate businessDelegate = new BusinessDelegateWorkPooled(fondipFactory.borrowFondipClient());
- AderenteTO aderente = businessDelegate.getAderente(codiceFiscale);
- ....
- fondipFactory.returnFondipClient(businessDelegate.getFondip()); //ERROR:
- java.lang.IllegalStateException: Returned object not currently part of this pool
- 15:03:52,681 ERROR [STDERR] at org.apache.commons.pool2.impl.GenericObjectPool.returnObject(GenericObjectPool.java:534)
- 15:03:52,681 ERROR [STDERR] at it.icbpi.fondip.ui.utili.FondipFactory.returnFondipClient(FondipFactory.java:39)
- 15:03:52,682 ERROR [STDERR] at it.icbpi.fondip.ui.servlet.ProfileServlet.doPost(ProfileServlet.java:66)
- FONDIPFACTORY CLASS:
- public class FondipFactory {
- private GenericObjectPool<Fondip> fondipPool;
- public FondipFactory(GenericObjectPool<Fondip> pool) {
- this.fondipPool = pool;
- this.fondipPool.setMaxTotal(10);
- //this.fondipPool.setMaxIdle(0);
- // setMaxActive(1000);
- }
- public ObjectPool<Fondip> getFondipPool() {
- return fondipPool;
- }
- public void setFondipPool(
- GenericObjectPool<Fondip> fondipPool) {
- this.fondipPool = fondipPool;
- }
- //extract from pool
- public Fondip borrowFondipClient() throws Exception {
- return fondipPool.borrowObject();
- }
- //return the object to the pool
- public void returnFondipClient(Fondip fondip) throws Exception {
- fondipPool.returnObject(fondip);
- }
- }
- CLASS BUSINESSDELEGATEWORKPOOLED
- public class BusinessDelegateWorkPooled implements BusinessDelegate {
- private Fondip fondip;
- public BusinessDelegateWorkPooled(Fondip fondip) {
- this.fondip = fondip;
- }
- public Fondip getFondip() {
- return fondip;
- }
- public AderenteTO getAderente(String codiceFiscale) {
- AderenteTO aderenteTO = fondip.getAderente(codiceFiscale);
- return aderenteTO;
- }
- ....
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement