本文整理了Java中java.sql.Wrapper.isWrapperFor()
方法的一些代码示例,展示了Wrapper.isWrapperFor()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Wrapper.isWrapperFor()
方法的具体详情如下:
包路径:java.sql.Wrapper
类名称:Wrapper
方法名:isWrapperFor
[英]If the caller is a wrapper of the class or implements the given interface, the methods return false and vice versa.
[中]如果调用方是类的包装器或实现给定接口,则方法返回false,反之亦然。
代码示例来源:origin: alibaba/druid
@Override
public boolean isWrapperFor(Class<?> iface) throws SQLException {
if (null == wrapper) {
//Best to log error.
return false;
}
if (iface == null) {
return false;
}
if (iface == wrapper.getClass()) {
return true;
}
if (iface == this.getClass()) {
return true;
}
if (!(wrapper instanceof WrapperProxy)) {
if (iface.isInstance(wrapper)) {
return true;
}
}
return wrapper.isWrapperFor(iface);
}
代码示例来源:origin: alibaba/druid
@Override
public boolean isWrapperFor(Wrapper wrapper, Class<?> iface) throws SQLException {
if (this.pos < filterSize) {
return nextFilter()
.isWrapperFor(this, wrapper, iface);
}
// // if driver is for jdbc 3.0
if (iface.isInstance(wrapper)) {
return true;
}
return wrapper.isWrapperFor(iface);
}
代码示例来源:origin: codingapi/tx-lcn
@Override
public boolean isWrapperFor(Class<?> iface) throws SQLException {
if (iface.isAssignableFrom(getClass())) {
// if the proxy directly proxy the interface or extends it, return true
return true;
} else if (iface.isAssignableFrom(delegate.getClass())) {
// if the proxied object directly implements the interface or extends it, return true
return true;
} else if (Wrapper.class.isAssignableFrom(delegate.getClass())) {
// if the proxied object implements the wrapper interface, then
// return the result of it's isWrapperFor method.
return ((Wrapper) unwrapP6SpyProxy()).isWrapperFor(iface);
}
return false;
}
代码示例来源:origin: p6spy/p6spy
@Override
public boolean isWrapperFor(Class<?> iface) throws SQLException {
return ((Wrapper) realDataSource).isWrapperFor(iface);
}
代码示例来源:origin: p6spy/p6spy
@Override
public boolean isWrapperFor(Class<?> iface) throws SQLException {
if (iface.isAssignableFrom(getClass())) {
// if the proxy directly proxy the interface or extends it, return true
return true;
} else if (iface.isAssignableFrom(delegate.getClass())) {
// if the proxied object directly implements the interface or extends it, return true
return true;
} else if (Wrapper.class.isAssignableFrom(delegate.getClass())) {
// if the proxied object implements the wrapper interface, then
// return the result of it's isWrapperFor method.
return ((Wrapper) unwrapP6SpyProxy()).isWrapperFor(iface);
}
return false;
}
代码示例来源:origin: com.alibaba/druid
@Override
public boolean isWrapperFor(Class<?> iface) throws SQLException {
if (null == wrapper) {
//Best to log error.
return false;
}
if (iface == null) {
return false;
}
if (iface == wrapper.getClass()) {
return true;
}
if (iface == this.getClass()) {
return true;
}
if (!(wrapper instanceof WrapperProxy)) {
if (iface.isInstance(wrapper)) {
return true;
}
}
return wrapper.isWrapperFor(iface);
}
代码示例来源:origin: com.alibaba/druid
@Override
public boolean isWrapperFor(Wrapper wrapper, Class<?> iface) throws SQLException {
if (this.pos < filterSize) {
return nextFilter()
.isWrapperFor(this, wrapper, iface);
}
// // if driver is for jdbc 3.0
if (iface.isInstance(wrapper)) {
return true;
}
return wrapper.isWrapperFor(iface);
}
代码示例来源:origin: geotools/geotools
if (w.isWrapperFor(OracleConnection.class)) {
return w.unwrap(OracleConnection.class);
代码示例来源:origin: p6spy/p6spy
@Override
public boolean isWrapperFor(Class<?> iface) throws SQLException {
return ((Wrapper) realDataSource).isWrapperFor(iface);
}
代码示例来源:origin: stackoverflow.com
public boolean isWrapperFor(Class<?> cls) {
if (wrappedObj instanceof Wrapper) {
return ((Wrapper)wrappedObj).isWrapperFor(cls);
}
return cls.isInstance(wrappedObj);
}
代码示例来源:origin: kumuluz/kumuluzee
@Override
public boolean isWrapperFor(Class<?> iface) throws SQLException {
if (xaDataSource == null) {
throw new SQLException("The underlying XADataSource is invalid or cannot be found");
} else if (iface.isInstance(xaDataSource)) {
return true;
} else if (xaDataSource instanceof Wrapper) {
return ((java.sql.Wrapper) xaDataSource).isWrapperFor(iface);
}
return false;
}
代码示例来源:origin: com.kumuluz.ee/kumuluzee-common
@Override
public boolean isWrapperFor(Class<?> iface) throws SQLException {
if (xaDataSource == null) {
throw new SQLException("The underlying XADataSource is invalid or cannot be found");
} else if (iface.isInstance(xaDataSource)) {
return true;
} else if (xaDataSource instanceof Wrapper) {
return ((java.sql.Wrapper) xaDataSource).isWrapperFor(iface);
}
return false;
}
代码示例来源:origin: org.javasimon/javasimon-jdbc41
public boolean isWrapperFor(Class<?> iface) throws SQLException {
return delegateType.equals(iface) || delegate.isWrapperFor(iface);
}
代码示例来源:origin: com.sqlapp/sqlapp-core
@Override
public boolean isWrapperFor(Class<?> iface) throws SQLException {
if (iface.isAssignableFrom(this.getClass())) {
return true;
}
return nativeObject.isWrapperFor(iface);
}
代码示例来源:origin: stackoverflow.com
Context ic = new InitialContext();
DataSource ds = (DataSource)ic.lookup("jdbc/OracleDS");
Connection conn = ds.getConnection();
// Returns true if this either implements the interface argument
// or is directly or indirectly a wrapper for an object that does.
if (conn.isWrapperFor(oracle.jdbc.OracleConnection.class)) {
// Returns an object that implements the given interface to
// allow access to non-standard methods, or standard methods
// not exposed by the proxy.
oracle.jdbc.OracleConnection oraCon = conn.unwrap(oracle.jdbc.OracleConnection.class);
// Do some Oracle-specific work here.
}
代码示例来源:origin: stackoverflow.com
try (Connection hikariCon = dbConnect.getConnection()) {
if (hikariCon.isWrapperFor(OracleConnection.class)) {
OracleConnection connection = hikariCon.unwrap(OracleConnection.class);
:
:
}
代码示例来源:origin: p6spy/p6spy
@Override
public boolean isWrapperFor(Class<?> iface) throws SQLException {
if (iface.isAssignableFrom(getClass())) {
// if the proxy directly proxy the interface or extends it, return true
return true;
} else if (iface.isAssignableFrom(delegate.getClass())) {
// if the proxied object directly implements the interface or extends it, return true
return true;
} else if (Wrapper.class.isAssignableFrom(delegate.getClass())) {
// if the proxied object implements the wrapper interface, then
// return the result of it's isWrapperFor method.
return ((Wrapper) unwrapP6SpyProxy()).isWrapperFor(iface);
}
return false;
}
代码示例来源:origin: stackoverflow.com
Connection unwrapConnection = databaseSession.getServerPlatform()
.unwrapConnection(accessor.getConnection());
oracle.jdbc.OracleConnection connection = null;
try {
if (unwrapConnection.isWrapperFor(OracleConnection.class)) {
connection = unwrapConnection.unwrap(OracleConnection.class);
} else {
// recover, not an oracle connection
connection = (oracle.jdbc.OracleConnection) databaseSession.getServerPlatform()
.unwrapConnection(accessor.getConnection());
}
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
代码示例来源:origin: org.javasimon/javasimon-jdbc41
public <T> T unwrap(Class<T> iface) throws SQLException {
if (delegateType.equals(iface)) {
return delegate.isWrapperFor(iface) ? delegate.unwrap(iface) : iface.cast(delegate);
} else {
return delegate.unwrap(iface);
}
}
}
代码示例来源:origin: com.github.gquintana.metrics/metrics-sql
protected Object unwrap(MethodInvocation<T> methodInvocation) throws SQLException {
final Class iface = getClassArg(methodInvocation);
final Wrapper delegateWrapper = (Wrapper) delegate;
Object result;
if (isDelegateType(iface)) {
result = delegateWrapper.isWrapperFor(iface) ? delegateWrapper.unwrap(iface) : iface.cast(delegateWrapper);
} else {
result = delegateWrapper.unwrap(iface);
}
return result;
}
内容来源于网络,如有侵权,请联系作者删除!