congrats Icon
New! Announcing Tabnine Chat Beta
Learn More
Tabnine Logo
GenericObjectPool.borrowObject
Code IndexAdd Tabnine to your IDE (free)

How to use
borrowObject
method
in
org.apache.commons.pool.impl.GenericObjectPool

Best Java code snippets using org.apache.commons.pool.impl.GenericObjectPool.borrowObject (Showing top 20 results out of 432)

origin: weibocom/motan

protected Channel borrowObject() throws Exception {
  Channel nettyChannel = (Channel) pool.borrowObject();
  if (nettyChannel != null && nettyChannel.isAvailable()) {
    return nettyChannel;
  }
  invalidateObject(nettyChannel);
  String errorMsg = this.getClass().getSimpleName() + " borrowObject Error: url=" + url.getUri();
  LoggerUtil.error(errorMsg);
  throw new MotanServiceException(errorMsg);
}
origin: banq/jdonframework

public Object acquirePoolable() throws Exception {
  return this.pool.borrowObject();
}
origin: geotools/geotools

if (transactional) {
  LOGGER.finest("Borrowing session from pool for transactional access");
  connection = (Session) pool.borrowObject();
} else {
  synchronized (openSessionsNonTransactional) {
                + Thread.currentThread().getName());
      connection = (Session) pool.borrowObject();
      if (LOGGER.isLoggable(Level.FINER)) {
        LOGGER.finer(
origin: geotools/geotools

preload[i] = (ISession) pool.borrowObject();
if (i == 0) {
  SeRelease seRelease = preload[i].getRelease();
origin: apache/jackrabbit-oak

/**
 * Gives a Unbound LdapConnection fetched from the pool.
 *
 * @return an LdapConnection object from pool
 * @throws Exception if an error occurs while obtaining a connection from the factory
 */
public LdapConnection getConnection() throws Exception {
  return super.borrowObject();
}
origin: org.apache.directory.client.ldap/ldap-client-api

/**
 * gives a LdapConnection fetched from the pool 
 *
 * @return an LdapConnection object from pool 
 * @throws Exception
 */
public LdapConnection getConnection() throws Exception
{
  return ( LdapConnection ) super.borrowObject();
}
origin: org.apache.openejb.patch/openjpa-kernel

private Socket getSocket()
  throws Exception {
  return (Socket) _socketPool.borrowObject();
}
origin: alexo/wro4j

/**
 * @return object from the pool.
 */
public T getObject() {
 try {
  return objectPool.borrowObject();
 } catch (final Exception e) {
  // should never happen
  throw new RuntimeException("Cannot get object from the pool", e);
 }
}
origin: datacleaner/DataCleaner

private Integer borrowObject() {
  try {
    return _connectionPool.borrowObject();
  } catch (final Exception e) {
    throw new IllegalStateException("Could not borrow pool object", e);
  }
}
origin: org.eobjects.analyzerbeans/AnalyzerBeans-core

private Integer borrowObject() {
  try {
    return _connectionPool.borrowObject();
  } catch (Exception e) {
    throw new IllegalStateException("Could not borrow pool object", e);
  }
}
origin: ro.isdc.wro4j/wro4j-extensions

/**
 * @return object from the pool.
 */
public T getObject() {
 try {
  return objectPool.borrowObject();
 } catch (final Exception e) {
  // should never happen
  throw new RuntimeException("Cannot get object from the pool", e);
 }
}
origin: com.atlassian.jira/jira-core

public Parser get()
{
  try
  {
    return (Parser) pool.borrowObject();
  }
  catch (Exception e)
  {
    throw new RuntimeException("Error borrowing a parser from the pool", e);
  }
}
origin: org.wso2.carbon.transport/org.wso2.carbon.transport.http.netty

@Override
public Object makeObject() throws Exception {
  TargetChannel targetChannel = (TargetChannel) this.genericObjectPool.borrowObject();
  log.debug("Created channel: {}", targetChannel);
  return targetChannel;
}
origin: org.mobicents.diameter/jdiameter-impl

protected TimerTaskHandle borrowTimerTaskHandle() {
 try {
  TimerTaskHandle timerTaskHandle = (TimerTaskHandle) pool.borrowObject();
  return timerTaskHandle;
 }
 catch (Exception e) {
  logger.error("", e);
 }
 return null;
}
origin: com.baidu.beidou/navi-pbrpc

/**
 * 从对象池获取一个可用对象
 * 
 * @return
 */
@SuppressWarnings("unchecked")
public T getResource() {
  try {
    return (T) internalPool.borrowObject();
  } catch (Exception e) {
    throw new PbrpcConnectionException("Could not get a resource from the pool", e);
  }
}
origin: org.mule/mule-core

public Object borrowObject() throws Exception
{
  if (pool != null)
  {
    return pool.borrowObject();
  }
  else
  {
    throw new InitialisationException(
      MessageFactory.createStaticMessage("Object pool has not been initialized."), this);
  }
}
origin: org.lasersonlab.apache.parquet/parquet-hadoop

public Object borrowDirectDecompressor(){
 Preconditions.checkArgument(supportDirectDecompressor, "Tried to get a direct Decompressor from a non-direct codec.");
 try {
  return directDecompressorPool.borrowObject();
 } catch (Exception e) {
  throw new ParquetCompressionCodecException(e);
 }
}
origin: apache/metamodel

public JdbcCompiledQueryLease borrowLease() {
  if (logger.isDebugEnabled()) {
    logger.debug("Borrowing lease. Leases (before): Active={}, Idle={}", getActiveLeases(), getIdleLeases());
  }
  try {
    return _pool.borrowObject();
  } catch (Exception e) {
    throw handleError(e, "borrow lease");
  }
}
origin: org.apache.parquet/parquet-hadoop

public Object borrowDirectDecompressor(){
 Preconditions.checkArgument(supportDirectDecompressor, "Tried to get a direct Decompressor from a non-direct codec.");
 try {
  return directDecompressorPool.borrowObject();
 } catch (Exception e) {
  throw new ParquetCompressionCodecException(e);
 }
}
origin: org.wso2.carbon.identity.agent.entitlement.mediator/org.wso2.carbon.identity.entitlement.proxy

private EntitlementServiceStub getEntitlementStub(String serverUrl) throws Exception {
  if (configurationContext == null) {
    throw new EntitlementProxyException("Cannot initialize EntitlementServiceStub with null Axis2 " +
                      "configuration context.");
  }
  if (serviceStubPool == null) {
    serviceStubPool = new GenericObjectPool(new EntitlementServiceStubFactory(
            configurationContext, serverUrl + ENTITLEMENT_SERVICE_NAME, authenticator));
  }
  return (EntitlementServiceStub) serviceStubPool.borrowObject();
}
org.apache.commons.pool.implGenericObjectPoolborrowObject

Javadoc

Borrows an object from the pool.

If there is an idle instance available in the pool, then either the most-recently returned (if #getLifo() == true) or "oldest" (lifo == false) instance sitting idle in the pool will be activated and returned. If activation fails, or #getTestOnBorrow() is set to true and validation fails, the instance is destroyed and the next available instance is examined. This continues until either a valid instance is returned or there are no more idle instances available.

If there are no idle instances available in the pool, behavior depends on the #getMaxActive()and (if applicable) #getWhenExhaustedAction() and #getMaxWait()properties. If the number of instances checked out from the pool is less than maxActive, a new instance is created, activated and (if applicable) validated and returned to the caller.

If the pool is exhausted (no available idle instances and no capacity to create new ones), this method will either block ( #WHEN_EXHAUSTED_BLOCK), throw a NoSuchElementException ( #WHEN_EXHAUSTED_FAIL), or grow ( #WHEN_EXHAUSTED_GROW - ignoring maxActive). The length of time that this method will block when whenExhaustedAction == WHEN_EXHAUSTED_BLOCK is determined by the #getMaxWait() property.

When the pool is exhausted, multiple calling threads may be simultaneously blocked waiting for instances to become available. As of pool 1.5, a "fairness" algorithm has been implemented to ensure that threads receive available instances in request arrival order.

Popular methods of GenericObjectPool

  • <init>
    Create a new GenericObjectPool using the specified values.
  • returnObject
    Returns an object instance to the pool. If #getMaxIdle() is set to a positive value and the number
  • setMaxActive
    Sets the cap on the number of objects that can be allocated by the pool (checked out to clients, or
  • close
    Closes the pool. Once the pool is closed, #borrowObject()will fail with IllegalStateException, but #
  • setMaxIdle
    Sets the cap on the number of "idle" instances in the pool. If maxIdle is set too low on heavily loa
  • setMinIdle
    Sets the minimum number of objects allowed in the pool before the evictor thread (if active) spawns
  • setTimeBetweenEvictionRunsMillis
    Sets the number of milliseconds to sleep between runs of the idle object evictor thread. When non-po
  • setMinEvictableIdleTimeMillis
    Sets the minimum amount of time an object may sit idle in the pool before it is eligible for evictio
  • setMaxWait
    Sets the maximum amount of time (in milliseconds) the #borrowObject method should block before throw
  • setTestOnBorrow
    When true, objects will be PoolableObjectFactory#validateObjectbefore being returned by the #borrowO
  • setWhenExhaustedAction
    Sets the action to take when the #borrowObject method is invoked when the pool is exhausted (the max
  • getNumActive
    Return the number of instances currently borrowed from this pool.
  • setWhenExhaustedAction,
  • getNumActive,
  • getNumIdle,
  • setTestWhileIdle,
  • setNumTestsPerEvictionRun,
  • setTestOnReturn,
  • invalidateObject,
  • clear,
  • addObject

Popular in Java

  • Reactive rest calls using spring rest template
  • scheduleAtFixedRate (ScheduledExecutorService)
  • getExternalFilesDir (Context)
  • getSupportFragmentManager (FragmentActivity)
  • FileReader (java.io)
    A specialized Reader that reads from a file in the file system. All read requests made by calling me
  • HttpURLConnection (java.net)
    An URLConnection for HTTP (RFC 2616 [http://tools.ietf.org/html/rfc2616]) used to send and receive d
  • Time (java.sql)
    Java representation of an SQL TIME value. Provides utilities to format and parse the time's represen
  • MessageFormat (java.text)
    Produces concatenated messages in language-neutral way. New code should probably use java.util.Forma
  • HttpServletRequest (javax.servlet.http)
    Extends the javax.servlet.ServletRequest interface to provide request information for HTTP servlets.
  • Response (javax.ws.rs.core)
    Defines the contract between a returned instance and the runtime when an application needs to provid
  • Top plugins for WebStorm
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now