private static ResourceGateway initializeCustomResourceGatewayInPrivilegedMode(final String className) throws PoolingException { Object result = AccessController.doPrivileged(new PrivilegedAction() { public Object run() { Object result = null; try { result = initializeCustomResourceGateway(className); } catch (Exception e) { _logger.log(Level.WARNING, "pool.resource.gateway.init.failure", className); _logger.log(Level.WARNING, "pool.resource.gateway.init.failure", e); } return result; } }); if (result != null) { return (ResourceGateway) result; } else { throw new PoolingException("Unable to initalize custom ResourceGateway : " + className); } }
private static PoolWaitQueue initializeCustomWaitQueueInPrivilegedMode(final String className) throws PoolingException { Object result = AccessController.doPrivileged(new PrivilegedAction() { public Object run() { Object result = null; try { result = initializeCustomWaitQueue(className); } catch (Exception e) { _logger.log(Level.WARNING, "pool.waitqueue.init.failure", className); _logger.log(Level.WARNING, "pool.waitqueue.init.failure.exception", e); } return result; } }); if (result != null) { return (PoolWaitQueue) result; } else { throw new PoolingException("Unable to initalize custom PoolWaitQueue : " + className); } }
private static DataStructure initializeCustomDataStructureInPrivilegedMode(final String className, final String parameters, final int maxPoolSize, final ResourceHandler handler, final String strategyClass) throws PoolingException { Object result = AccessController.doPrivileged(new PrivilegedAction() { public Object run() { Object result = null; try { result = initializeDataStructure(className, parameters, maxPoolSize, handler, strategyClass); } catch (Exception e) { _logger.log(Level.WARNING, "pool.datastructure.init.failure", className); _logger.log(Level.WARNING, "pool.datastructure.init.failure.exception", e); } return result; } }); if (result != null) { return (DataStructure) result; } else { throw new PoolingException("Unable to initalize custom DataStructure : " + className); } }
public void cleanup(ResourceHandle h) throws PoolingException { try { ManagedConnection mc = (ManagedConnection) h.getResource(); mc.cleanup(); } catch (Exception ex) { _logger.log(Level.WARNING, "managed_con.cleanup-failed", ex); throw new PoolingException(ex.toString(), ex); } }
protected void enlist( JavaEETransactionManager tm, Transaction tran, ResourceHandle h ) throws PoolingException { try { tm.enlistResource( tran, h ); } catch( Exception e ) { PoolingException pe = new PoolingException( e.getMessage() ); pe.initCause( e ); throw pe; } }
/** * Returns the transaction component is participating. * * @return Handle to the <code>Transaction</code> object. * @exception <code>PoolingException<code> If exception is thrown * while getting the transaction. */ public Transaction getTransaction() throws PoolingException { try { return ConnectorRuntime.getRuntime().getTransaction(); } catch (Exception ex) { _logger.log(Level.SEVERE,"poolmgr.unexpected_exception",ex); throw new PoolingException(ex.toString(), ex); } }
/** * {@inheritDoc} */ public int addResource(ResourceAllocator allocator, int count) throws PoolingException { int numResAdded = 0; writeLock.lock(); //for now, coarser lock. finer lock needs "resources.size() < maxSize()" once more. try { for (int i = 0; i < count && resources.size() < maxSize; i++) { ResourceHandle handle = handler.createResource(allocator); resources.add(handle); numResAdded++; } } catch (Exception e) { PoolingException pe = new PoolingException(e.getMessage()); pe.initCause(e); throw pe; } finally { writeLock.unlock(); } return numResAdded; }
public void destroyResource(ResourceHandle resource) throws PoolingException { try { ManagedConnection mc = (ManagedConnection) resource.getResource(); mc.destroy(); } catch (Exception ex) { throw new PoolingException(ex); } }
public void closeUserConnection(ResourceHandle resource) throws PoolingException { try { ManagedConnection mc = (ManagedConnection) resource.getResource(); mc.cleanup(); } catch (ResourceException ex) { throw new PoolingException(ex); } }
/** * Flush Connection pool by reinitializing the connections * established in the pool. * @param poolInfo * @throws com.sun.appserv.connectors.internal.api.PoolingException */ public boolean flushConnectionPool(PoolInfo poolInfo) throws PoolingException { boolean result = false; ResourcePool pool = getPool( poolInfo ); if(pool != null) { result = pool.flushConnectionPool(); } else { _logger.log(Level.WARNING, "poolmgr.flush_noop_pool_not_initialized", poolInfo); throw new PoolingException("Flush Connection Pool for pool " + poolInfo + " failed. Please see server.log for more details."); } return result; }
public void fillInResourceObjects(ResourceHandle resource) throws PoolingException { try { ManagedConnection mc = (ManagedConnection) resource.getResource(); Object con = mc.getConnection(subject, reqInfo); resource.fillInResourceObjects(con, null); } catch (ResourceException ex) { throw new PoolingException(ex); } }
public void destroyResource(ResourceHandle resource) throws PoolingException { try { closeUserConnection(resource); } catch (Exception ex) { // ignore error } try { ManagedConnection mc = (ManagedConnection) resource.getResource(); mc.destroy(); } catch (Exception ex) { throw new PoolingException(ex); } }
public void destroyResource(ResourceHandle resource) throws PoolingException { try { ManagedConnection mc = (ManagedConnection) resource.getResource(); ConnectorXAResource.freeListener(mc); XAResource xares = resource.getXAResource(); forceTransactionCompletion(xares); mc.destroy(); if (_logger.isLoggable(Level.FINEST)) { _logger.finest("destroyResource for LocalTxConnectorAllocator done"); } } catch (Exception ex) { throw new PoolingException(ex); } }
/** * Register the <code>ResourceHandle</code> in the transaction * * @param handle <code>ResourceHandle</code> object * @exception <code>PoolingException</code> If there is any error while * enlisting. */ public void enlistResource(ResourceHandle handle) throws PoolingException{ try { JavaEETransactionManager tm = ConnectorRuntime.getRuntime().getTransactionManager(); Transaction tran = tm.getTransaction(); if (tran != null) { tm.enlistResource(tran, handle); } } catch (Exception ex) { _logger.log(Level.SEVERE,"poolmgr.unexpected_exception",ex); throw new PoolingException(ex.toString(), ex); } }
protected ConnectorConnectionPool getPoolConfigurationFromJndi(Hashtable env) throws PoolingException { ConnectorConnectionPool poolResource; try { String jndiNameOfPool = ConnectorAdminServiceUtils.getReservePrefixedJNDINameForPool(poolInfo); poolResource = (ConnectorConnectionPool) ConnectorRuntime.getRuntime().getResourceNamingService().lookup(poolInfo, jndiNameOfPool, env); } catch (NamingException ex) { throw new PoolingException(ex); } return poolResource; }
public void fillInResourceObjects(ResourceHandle resource) throws PoolingException { try { ManagedConnection mc = (ManagedConnection) resource.getResource(); Object con = mc.getConnection(subject, reqInfo); resource.incrementCount(); XAResource xares = mc.getXAResource(); resource.fillInResourceObjects(con, xares); } catch (ResourceException ex) { throw new PoolingException(ex); } }
public void fillInResourceObjects(ResourceHandle resource) throws PoolingException { try { ManagedConnection mc = (ManagedConnection) resource.getResource(); Object con = mc.getConnection(subject, reqInfo); ConnectorXAResource xares = (ConnectorXAResource) resource.getXAResource(); xares.setUserHandle(con); resource.fillInResourceObjects(con, xares); } catch (ResourceException ex) { throw new PoolingException(ex); } }
public ResourceHandle createResource() throws PoolingException { try { ManagedConnection mc = mcf.createManagedConnection(subject, reqInfo); ResourceHandle resource = createResourceHandle(mc, spec, this, info); ConnectionEventListener l = new LocalTxConnectionEventListener(resource); mc.addConnectionEventListener(l); resource.setListener(l); XAResource xares = new ConnectorXAResource(resource, spec, this, info); resource.fillInResourceObjects(null, xares); return resource; } catch (ResourceException ex) { Object[] params = new Object[]{spec.getPoolInfo(), ex.toString()}; _logger.log(Level.WARNING, "poolmgr.create_resource_error", params); if(_logger.isLoggable(Level.FINE)) { _logger.log(Level.FINE, "Resource Exception while creating resource", ex); } if (ex.getLinkedException() != null) { _logger.log(Level.WARNING, "poolmgr.create_resource_linked_error", ex .getLinkedException().toString()); } throw new PoolingException(ex); } }
/** * Reinitialize connections established in the connection pool and * bring the pool to steady pool size. * * @throws com.sun.appserv.connectors.internal.api.PoolingException */ public synchronized boolean flushConnectionPool() throws PoolingException { logFine("Flush Connection Pool entered"); if(!poolInitialized) { _logger.log(Level.WARNING, "poolmgr.flush_noop_pool_not_initialized", getPoolInfo()); throw new PoolingException("Flush Connection Pool failed for " + getPoolInfo() + ". Please see server.log for more details."); } try { killExtraResources(ds.getResourcesSize()); increaseSteadyPoolSize(steadyPoolSize); } catch(PoolingException ex) { _logger.log(Level.WARNING, "pool.flush_pool_failure", new Object[] {getPoolInfo(), ex.getMessage()}); throw ex; } logFine("Flush Connection Pool done"); return true; }
@Override protected ResourceHandle getUnenlistedResource(ResourceSpec spec, ResourceAllocator alloc, Transaction tran) throws PoolingException { ResourceHandle handle = null; if(incrementPoolSize()){ try{ handle = createSingleResource(alloc); }catch (PoolingException ex){ decrementPoolSize(); throw ex; } ResourceState state = new ResourceState(); handle.setResourceState(state); state.setEnlisted(false); setResourceStateToBusy(handle); return handle; } _logger.info("Fail as poolSize : " + poolSize); String msg = localStrings.getStringWithDefault( "poolmgr.max.pool.size.reached", "In-use connections equal max-pool-size therefore cannot allocate any more connections."); throw new PoolingException(msg); }