本文整理汇总了Java中org.apache.tomcat.jdbc.pool.JdbcInterceptor类的典型用法代码示例。如果您正苦于以下问题:Java JdbcInterceptor类的具体用法?Java JdbcInterceptor怎么用?Java JdbcInterceptor使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
JdbcInterceptor类属于org.apache.tomcat.jdbc.pool包,在下文中一共展示了JdbcInterceptor类的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: lookupUrl
import org.apache.tomcat.jdbc.pool.JdbcInterceptor; //导入依赖的package包/类
private String lookupUrl() {
if (url == null) {
JdbcInterceptor interceptor = getNext();
while (interceptor != null) {
if (interceptor instanceof ProxyConnection) {
url = getUrlFromConnectionPool(((ProxyConnection) interceptor).getPool());
break;
}
interceptor = getNext();
}
if (url == null) {
throw new IllegalStateException("url must not be null after looking up the chain");
}
}
return url;
}
开发者ID:YanXs,项目名称:nighthawk,代码行数:17,代码来源:TomcatDataSourceTracingInterceptor.java
示例2: resetTimer
import org.apache.tomcat.jdbc.pool.JdbcInterceptor; //导入依赖的package包/类
public boolean resetTimer() {
boolean result = false;
JdbcInterceptor interceptor = this.getNext();
while (interceptor!=null && result==false) {
if (interceptor instanceof ProxyConnection) {
PooledConnection con = ((ProxyConnection)interceptor).getConnection();
if (con!=null) {
con.setTimestamp(System.currentTimeMillis());
result = true;
} else {
break;
}
}
interceptor = interceptor.getNext();
}
return result;
}
开发者ID:liaokailin,项目名称:tomcat7,代码行数:18,代码来源:ResetAbandonedTimer.java
示例3: invoke
import org.apache.tomcat.jdbc.pool.JdbcInterceptor; //导入依赖的package包/类
@Override
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
final String name = method.getName();
boolean close = compare(JdbcInterceptor.CLOSE_VAL, name);
if (close && closed) return null;
if (compare(JdbcInterceptor.ISCLOSED_VAL, name)) {
return closed;
}
if (closed) throw new SQLException("Statement closed.");
boolean process = isExecute(method, false);
StatementTracer tracer = getStatementTracer();
Object result = null;
Throwable error = null;
try {
if (process && tracer != null) {
tracer.beginTrace(sql, lookupUrl());
}
result = method.invoke(delegate, args);
} catch (Throwable t) {
error = t;
throw t;
} finally {
if (process && tracer != null) {
tracer.endTrace(0, error);
}
}
if (close) {
closed = true;
delegate = null;
}
return result;
}
开发者ID:YanXs,项目名称:nighthawk,代码行数:33,代码来源:TomcatDataSourceTracingInterceptor.java
示例4: findInterceptor
import org.apache.tomcat.jdbc.pool.JdbcInterceptor; //导入依赖的package包/类
/**
* Helper method that finds interceptor instance in interceptor chain of a
* proxied class.
*
* @param proxy
* Proxy class
* @param clazz
* Interceptor class that we are looking for
* @return Instance of <code>clazz</code>
*/
private static <T extends JdbcInterceptor> T findInterceptor(Object proxy,
Class<T> clazz) {
JdbcInterceptor interceptor = (JdbcInterceptor) Proxy
.getInvocationHandler(proxy);
while (interceptor != null) {
if (clazz.isInstance(interceptor)) {
return clazz.cast(interceptor);
}
interceptor = interceptor.getNext();
}
return null;
}
开发者ID:liaokailin,项目名称:tomcat7,代码行数:23,代码来源:TestStatementCache.java
示例5: invoke
import org.apache.tomcat.jdbc.pool.JdbcInterceptor; //导入依赖的package包/类
@Override
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
//get the name of the method for comparison
final String name = method.getName();
//was close invoked?
boolean close = compare(JdbcInterceptor.CLOSE_VAL,name);
//allow close to be called multiple times
if (close && closed) return null;
//are we calling isClosed?
if (compare(JdbcInterceptor.ISCLOSED_VAL,name)) return Boolean.valueOf(closed);
//if we are calling anything else, bail out
if (closed) throw new SQLException("Statement closed.");
//check to see if we are about to execute a query
final boolean process = isExecute(method);
Object result = null;
Subsegment subsegment = null;
if (process) {
subsegment = AWSXRay.beginSubsegment(hostname);
}
try {
if (process && null != subsegment) {
subsegment.putAllSql(additionalParams);
subsegment.setNamespace(Namespace.REMOTE.toString());
}
result = method.invoke(delegate,args); //execute the query
} catch (Throwable t) {
if (null != subsegment) {
subsegment.addException(t);
}
if (t instanceof InvocationTargetException && t.getCause() != null) {
throw t.getCause();
} else {
throw t;
}
} finally {
if (process && null != subsegment) {
AWSXRay.endSubsegment();
}
}
//perform close cleanup
if (close) {
closed = true;
delegate = null;
}
return result;
}
开发者ID:aws,项目名称:aws-xray-sdk-java,代码行数:49,代码来源:TracingInterceptor.java
注:本文中的org.apache.tomcat.jdbc.pool.JdbcInterceptor类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论