• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java SwallowedExceptionListener类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.apache.commons.pool2.SwallowedExceptionListener的典型用法代码示例。如果您正苦于以下问题:Java SwallowedExceptionListener类的具体用法?Java SwallowedExceptionListener怎么用?Java SwallowedExceptionListener使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



SwallowedExceptionListener类属于org.apache.commons.pool2包,在下文中一共展示了SwallowedExceptionListener类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: swallowException

import org.apache.commons.pool2.SwallowedExceptionListener; //导入依赖的package包/类
/**
 * Swallows an exception and notifies the configured listener for swallowed
 * exceptions queue.
 *
 * @param e exception to be swallowed
 */
final void swallowException(Exception e) {
    SwallowedExceptionListener listener = getSwallowedExceptionListener();

    if (listener == null) {
        return;
    }

    try {
        listener.onSwallowException(e);
    } catch (OutOfMemoryError oome) {
        throw oome;
    } catch (VirtualMachineError vme) {
        throw vme;
    } catch (Throwable t) {
        // Ignore. Enjoy the irony.
    }
}
 
开发者ID:EdwardLee03,项目名称:commons-pool2-sr,代码行数:24,代码来源:BaseGenericObjectPool.java


示例2: swallowException

import org.apache.commons.pool2.SwallowedExceptionListener; //导入依赖的package包/类
/**
 * Swallows an exception and notifies the configured listener for swallowed
 * exceptions queue.
 *
 * @param e exception to be swallowed
 */
final void swallowException(final Exception e) {
    final SwallowedExceptionListener listener = getSwallowedExceptionListener();

    if (listener == null) {
        return;
    }

    try {
        listener.onSwallowException(e);
    } catch (final OutOfMemoryError oome) {
        throw oome;
    } catch (final VirtualMachineError vme) {
        throw vme;
    } catch (final Throwable t) {
        // Ignore. Enjoy the irony.
    }
}
 
开发者ID:apache,项目名称:commons-pool,代码行数:24,代码来源:BaseGenericObjectPool.java


示例3: createProcessPool

import org.apache.commons.pool2.SwallowedExceptionListener; //导入依赖的package包/类
private GenericObjectPool<PhantomJSProcess> createProcessPool(JRPropertiesUtil properties)
{
	ProcessFactory processFactory = new ProcessFactory(this, properties);
	GenericObjectPool<PhantomJSProcess> pool = new GenericObjectPool<>(processFactory);
	pool.setLifo(true);
	
	int maxProcessCount = properties.getIntegerProperty(PhantomJS.PROPERTY_PHANTOMJS_MAX_PROCESS_COUNT, 
			PhantomJS.DEFAULT_PHANTOMJS_MAX_PROCESS_COUNT);
	pool.setMaxTotal(maxProcessCount);
	pool.setMaxIdle(maxProcessCount);
	
	int borrowTimeout = properties.getIntegerProperty(PhantomJS.PROPERTY_PHANTOMJS_POOL_BORROW_TIMEOUT, 
			PhantomJS.DEFAULT_PHANTOMJS_POOL_BORROW_TIMEOUT);
	pool.setMaxWaitMillis(borrowTimeout);
	
	int idleTimeout = properties.getIntegerProperty(PhantomJS.PROPERTY_PHANTOMJS_IDLE_TIMEOUT, 
			PhantomJS.DEFAULT_PHANTOMJS_IDLE_TIMEOUT);
	pool.setMinEvictableIdleTimeMillis(idleTimeout);
	
	pool.setTimeBetweenEvictionRunsMillis(idlePingInterval);
	
	pool.setTestWhileIdle(true);
	pool.setNumTestsPerEvictionRun(Integer.MAX_VALUE);
	
	pool.setSwallowedExceptionListener(new SwallowedExceptionListener()
	{
		@Override
		public void onSwallowException(Exception e)
		{
			if (log.isDebugEnabled())
			{
				log.debug("Pool exception", e);
			}
		}
	});
	
	return pool;
}
 
开发者ID:TIBCOSoftware,项目名称:jasperreports,代码行数:39,代码来源:ProcessDirector.java


示例4: testSwallowedExceptionListener

import org.apache.commons.pool2.SwallowedExceptionListener; //导入依赖的package包/类
@Test
public void testSwallowedExceptionListener() {
    genericObjectPool.setSwallowedExceptionListener(null); // must simply return
    final List<Exception> swallowedExceptions = new ArrayList<>();
    /*
     * A simple listener, that will throw a OOM on 3rd exception.
     */
    final SwallowedExceptionListener listener = new SwallowedExceptionListener() {
        @Override
        public void onSwallowException(final Exception e) {
            if (swallowedExceptions.size() == 2) {
                throw new OutOfMemoryError();
            }
            swallowedExceptions.add(e);
        }
    };
    genericObjectPool.setSwallowedExceptionListener(listener);

    final Exception e1 = new Exception();
    final Exception e2 = new ArrayIndexOutOfBoundsException();

    genericObjectPool.swallowException(e1);
    genericObjectPool.swallowException(e2);

    try {
        genericObjectPool.swallowException(e1);
        fail("Not supposed to get here");
    } catch (final OutOfMemoryError oom) {
        // expected
    }

    assertEquals(2, swallowedExceptions.size());
}
 
开发者ID:apache,项目名称:commons-pool,代码行数:34,代码来源:TestGenericObjectPool.java


示例5: reconstructConnectionPool

import org.apache.commons.pool2.SwallowedExceptionListener; //导入依赖的package包/类
private static void reconstructConnectionPool() {
    connectionFactory = new ModbusSlaveConnectionFactoryImpl();
    GenericKeyedObjectPool<ModbusSlaveEndpoint, ModbusSlaveConnection> genericKeyedObjectPool = new GenericKeyedObjectPool<>(
            connectionFactory, poolConfig);
    genericKeyedObjectPool.setSwallowedExceptionListener(new SwallowedExceptionListener() {

        @Override
        public void onSwallowException(Exception e) {
            logger.error("Connection pool swallowed unexpected exception: {}", e.getMessage());

        }
    });
    connectionPool = genericKeyedObjectPool;
}
 
开发者ID:openhab,项目名称:openhab1-addons,代码行数:15,代码来源:ModbusBinding.java


示例6: getSwallowedExceptionListener

import org.apache.commons.pool2.SwallowedExceptionListener; //导入依赖的package包/类
/**
 * The listener used (if any) to receive notifications of exceptions
 * unavoidably swallowed by the pool.
 *
 * @return The listener or <code>null</code> for no listener
 */
public final SwallowedExceptionListener getSwallowedExceptionListener() {
    return swallowedExceptionListener;
}
 
开发者ID:EdwardLee03,项目名称:commons-pool2-sr,代码行数:10,代码来源:BaseGenericObjectPool.java


示例7: setSwallowedExceptionListener

import org.apache.commons.pool2.SwallowedExceptionListener; //导入依赖的package包/类
/**
 * The listener used (if any) to receive notifications of exceptions
 * unavoidably swallowed by the pool.
 *
 * @param swallowedExceptionListener    The listener or <code>null</code>
 *                                      for no listener
 */
public final void setSwallowedExceptionListener(
        SwallowedExceptionListener swallowedExceptionListener) {
    this.swallowedExceptionListener = swallowedExceptionListener;
}
 
开发者ID:EdwardLee03,项目名称:commons-pool2-sr,代码行数:12,代码来源:BaseGenericObjectPool.java


示例8: setSwallowedExceptionListener

import org.apache.commons.pool2.SwallowedExceptionListener; //导入依赖的package包/类
/**
 * The listener used (if any) to receive notifications of exceptions
 * unavoidably swallowed by the pool.
 *
 * @param swallowedExceptionListener    The listener or <code>null</code>
 *                                      for no listener
 */
public final void setSwallowedExceptionListener(
        final SwallowedExceptionListener swallowedExceptionListener) {
    this.swallowedExceptionListener = swallowedExceptionListener;
}
 
开发者ID:apache,项目名称:commons-pool,代码行数:12,代码来源:BaseGenericObjectPool.java



注:本文中的org.apache.commons.pool2.SwallowedExceptionListener类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java VideoCapture类代码示例发布时间:2022-05-22
下一篇:
Java MemberUp类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap