本文整理了Java中java.lang.reflect.Proxy.getInvocationHandler()
方法的一些代码示例,展示了Proxy.getInvocationHandler()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Proxy.getInvocationHandler()
方法的具体详情如下:
包路径:java.lang.reflect.Proxy
类名称:Proxy
方法名:getInvocationHandler
[英]Returns the invocation handler of the specified proxy instance.
[中]返回指定代理实例的调用处理程序。
代码示例来源:origin: org.easymock/easymock
public InvocationHandler getInvocationHandler(Object mock) {
return Proxy.getInvocationHandler(mock);
}
}
代码示例来源:origin: spring-projects/spring-framework
private boolean isProxyForSameBshObject(Object other) {
if (!Proxy.isProxyClass(other.getClass())) {
return false;
}
InvocationHandler ih = Proxy.getInvocationHandler(other);
return (ih instanceof BshObjectInvocationHandler &&
this.xt.equals(((BshObjectInvocationHandler) ih).xt));
}
}
代码示例来源:origin: org.springframework/spring-context
private boolean isProxyForSameBshObject(Object other) {
if (!Proxy.isProxyClass(other.getClass())) {
return false;
}
InvocationHandler ih = Proxy.getInvocationHandler(other);
return (ih instanceof BshObjectInvocationHandler &&
this.xt.equals(((BshObjectInvocationHandler) ih).xt));
}
}
代码示例来源:origin: hibernate/hibernate-orm
private boolean needsWrapping(Session session) {
// try to make sure we don't wrap and already wrapped session
if ( Proxy.isProxyClass( session.getClass() ) ) {
final InvocationHandler invocationHandler = Proxy.getInvocationHandler( session );
if ( invocationHandler != null && TransactionProtectionWrapper.class.isInstance( invocationHandler ) ) {
return false;
}
}
return true;
}
代码示例来源:origin: wildfly/wildfly
/**
* Determine whether an object is indeed a valid EJB proxy object created by this API.
*
* @param object the object to test
* @return {@code true} if it is an EJB proxy, {@code false} otherwise
*/
public static boolean isEJBProxy(final Object object) {
return object != null && Proxy.isProxyClass(object.getClass()) && Proxy.getInvocationHandler(object) instanceof EJBInvocationHandler;
}
代码示例来源:origin: square/okhttp
@Override public @Nullable String getSelectedProtocol(SSLSocket socket) {
try {
AlpnProvider provider =
(AlpnProvider) Proxy.getInvocationHandler(getMethod.invoke(null, socket));
if (!provider.unsupported && provider.selected == null) {
Platform.get().log(INFO, "ALPN callback dropped: HTTP/2 is disabled. "
+ "Is alpn-boot on the boot class path?", null);
return null;
}
return provider.unsupported ? null : provider.selected;
} catch (InvocationTargetException | IllegalAccessException e) {
throw new AssertionError("failed to get ALPN selected protocol", e);
}
}
代码示例来源:origin: google/guava
@Override
public boolean equals(Object obj) {
if (NativeTypeVariableEquals.NATIVE_TYPE_VARIABLE_ONLY) {
// equal only to our TypeVariable implementation with identical bounds
if (obj != null
&& Proxy.isProxyClass(obj.getClass())
&& Proxy.getInvocationHandler(obj) instanceof TypeVariableInvocationHandler) {
TypeVariableInvocationHandler typeVariableInvocationHandler =
(TypeVariableInvocationHandler) Proxy.getInvocationHandler(obj);
TypeVariableImpl<?> that = typeVariableInvocationHandler.typeVariableImpl;
return name.equals(that.getName())
&& genericDeclaration.equals(that.getGenericDeclaration())
&& bounds.equals(that.bounds);
}
return false;
} else {
// equal to any TypeVariable implementation regardless of bounds
if (obj instanceof TypeVariable) {
TypeVariable<?> that = (TypeVariable<?>) obj;
return name.equals(that.getName())
&& genericDeclaration.equals(that.getGenericDeclaration());
}
return false;
}
}
}
代码示例来源:origin: javamelody/javamelody
private static boolean isProxyAlready(Object object) {
return Proxy.isProxyClass(object.getClass()) && Proxy.getInvocationHandler(object)
.getClass().getName().equals(DelegatingInvocationHandler.class.getName());
// utilisation de Proxy.getInvocationHandler(object).getClass().getName().equals(DelegatingInvocationHandler.class.getName())
// et non de Proxy.getInvocationHandler(object) instanceof DelegatingInvocationHandler
// pour issue 97 (classLoaders différents pour les classes DelegatingInvocationHandler)
}
代码示例来源:origin: spring-projects/spring-framework
InvocationHandler ih = Proxy.getInvocationHandler(other);
if (!(ih instanceof JdkDynamicAopProxy)) {
return false;
代码示例来源:origin: changmingxie/tcc-transaction
public static Object changeAnnotationValue(Annotation annotation, String key, Object newValue) throws NoSuchFieldException, SecurityException, IllegalArgumentException, IllegalAccessException {
Object handler = Proxy.getInvocationHandler(annotation);
Field f;
f = handler.getClass().getDeclaredField("memberValues");
f.setAccessible(true);
Map<String, Object> memberValues;
memberValues = (Map<String, Object>) f.get(handler);
Object oldValue = memberValues.get(key);
if (oldValue == null || oldValue.getClass() != newValue.getClass()) {
throw new IllegalArgumentException();
}
memberValues.put(key, newValue);
return oldValue;
}
代码示例来源:origin: wildfly/wildfly
@SuppressWarnings("unchecked")
static <T> EJBInvocationHandler<? extends T> forProxy(T proxy) {
InvocationHandler handler = Proxy.getInvocationHandler(proxy);
if (handler instanceof EJBInvocationHandler) {
return (EJBInvocationHandler<? extends T>) handler;
}
throw Logs.MAIN.proxyNotOurs(proxy, EJBClient.class.getName());
}
代码示例来源:origin: prestodb/presto
@Override public String getSelectedProtocol(SSLSocket socket) {
try {
JettyNegoProvider provider =
(JettyNegoProvider) Proxy.getInvocationHandler(getMethod.invoke(null, socket));
if (!provider.unsupported && provider.selected == null) {
Platform.get().log(INFO, "ALPN callback dropped: HTTP/2 is disabled. "
+ "Is alpn-boot on the boot class path?", null);
return null;
}
return provider.unsupported ? null : provider.selected;
} catch (InvocationTargetException | IllegalAccessException e) {
throw assertionError("unable to get selected protocol", e);
}
}
代码示例来源:origin: google/guava
&& equals(Proxy.getInvocationHandler(arg));
代码示例来源:origin: google/guava
public void testToString() {
List<String> proxy = newDelegatingList(LIST1);
assertEquals(Proxy.getInvocationHandler(proxy).toString(), proxy.toString());
}
代码示例来源:origin: neo4j/neo4j
public static void kill( Object subprocess )
{
( (Handler) Proxy.getInvocationHandler( subprocess ) ).kill( true );
}
代码示例来源:origin: neo4j/neo4j
public static void stop( Object subprocess )
{
( (Handler) Proxy.getInvocationHandler( subprocess ) ).stop( null, 0 );
}
代码示例来源:origin: neo4j/neo4j
public static void stop( Object subprocess, long timeout, TimeUnit unit )
{
( (Handler) Proxy.getInvocationHandler( subprocess ) ).stop( unit, timeout );
}
代码示例来源:origin: hibernate/hibernate-orm
public static String extractEntityName(Object object) {
if ( Proxy.isProxyClass( object.getClass() ) ) {
InvocationHandler handler = Proxy.getInvocationHandler(
object
);
if ( DataProxyHandler.class.isAssignableFrom( handler.getClass() ) ) {
DataProxyHandler myHandler = (DataProxyHandler) handler;
return myHandler.getEntityName();
}
}
return null;
}
}
代码示例来源:origin: hibernate/hibernate-orm
public static String extractEntityName(Object object) {
// Our custom java.lang.reflect.Proxy instances actually bundle
// their appropriate entity name, so we simply extract it from there
// if this represents one of our proxies; otherwise, we return null
if ( Proxy.isProxyClass( object.getClass() ) ) {
InvocationHandler handler = Proxy.getInvocationHandler( object );
if ( DataProxyHandler.class.isAssignableFrom( handler.getClass() ) ) {
DataProxyHandler myHandler = ( DataProxyHandler ) handler;
return myHandler.getEntityName();
}
}
return null;
}
}
代码示例来源:origin: android-hacker/VirtualXposed
public static IInterface createProxy(boolean external, String authority, IInterface provider) {
if (provider instanceof Proxy && Proxy.getInvocationHandler(provider) instanceof ProviderHook) {
return provider;
}
ProviderHook.HookFetcher fetcher = ProviderHook.fetchHook(authority);
if (fetcher != null) {
ProviderHook hook = fetcher.fetch(external, provider);
IInterface proxyProvider = ProviderHook.createProxy(provider, hook);
if (proxyProvider != null) {
provider = proxyProvider;
}
}
return provider;
}
内容来源于网络,如有侵权,请联系作者删除!