本文整理汇总了Java中net.sf.cglib.proxy.MethodProxy.invokeSuper方法的典型用法代码示例。如果您正苦于以下问题:Java MethodProxy.invokeSuper方法的具体用法?Java MethodProxy.invokeSuper怎么用?Java MethodProxy.invokeSuper使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类net.sf.cglib.proxy.MethodProxy
的用法示例。
在下文中一共展示了MethodProxy.invokeSuper方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: intercept
import net.sf.cglib.proxy.MethodProxy; //导入方法依赖的package包/类
@Override
public Object intercept(Object obj, Method method, Object[] args, MethodProxy proxy) throws Throwable {
// Give our delegate a chance to intercept, and cache the decision
if(delegatedMethods.get(method, () -> method.getDeclaringClass() != Object.class &&
Methods.hasOverrideIn(Delegate.class, method))) {
return method.invoke(delegate, args);
}
// If we have a value for the property, return that
final Object value = values.get(method);
if(value != null) return value;
// If there's no value, then the method MUST be callable (or the code is broken).
// This can only fail for an abstract non-property method (which we should probably be checking for).
if(method.isDefault()) {
// invokeSuper doesn't understand default methods
return defaultMethodHandles.get(method)
.bindTo(obj)
.invokeWithArguments(args);
} else {
return proxy.invokeSuper(obj, args);
}
}
示例2: intercept
import net.sf.cglib.proxy.MethodProxy; //导入方法依赖的package包/类
@Override
public Object intercept(Object obj, Method method, Object[] args, MethodProxy methodProxy) throws Throwable {
if (args == null || args.length > 1 || args.length == 0) {
return methodProxy.invokeSuper(obj, args);
}
if (method.getName().contains("guiRender") || method.getName().contains("mouseClick")) {
Object arg0 = args[0];
if (arg0 instanceof GuiScreenEvent) {
GuiScreenEvent drawEvent = (GuiScreenEvent) arg0;
if (drawEvent.getGui() instanceof GuiMainMenu) {
// Don't invoke.
return methodProxy.getSignature().getReturnType().getOpcode(VOID);
}
}
}
return methodProxy.invokeSuper(obj, args);
}
示例3: intercept
import net.sf.cglib.proxy.MethodProxy; //导入方法依赖的package包/类
@Override
public Object intercept(Object obj, Method method, Object[] args, MethodProxy proxy) throws Throwable {
if(isDecorated(method)) {
// Decorated method
return proxy.invokeSuper(obj, args);
} else {
final T t = ((Decorator<T>) obj).delegate();
if(method.getDeclaringClass().isInstance(t)) {
// Forwarded method
return proxy.invoke(t, args);
} else {
// Forwarded method shadowed by an interface method in the decorator.
//
// This can happen if the decorator implements an interface that the
// base class doesn't, and that interface contains a method that shadows
// one on the base class. Java would allow the method to be called on the
// base anyway, but MethodProxy refuses to invoke it on something that
// is not assignable to the method's declaring type. So, unfortunately,
// we have to fall back to the JDK to handle this case.
return methodHandles.get(method, () ->
resolver.virtualHandle(t.getClass(), method).bindTo(t)
).invokeWithArguments(args);
}
}
}
示例4: intercept
import net.sf.cglib.proxy.MethodProxy; //导入方法依赖的package包/类
public Object intercept(
final Object obj,
final Method method,
final Object[] args,
final MethodProxy proxy)
throws Throwable {
if (constructed) {
Object result = invoke(method, args, obj);
if (result==INVOKE_IMPLEMENTATION) {
return proxy.invoke( getImplementation(), args );
}
else {
return result;
}
}
else {
//while constructor is running
return proxy.invokeSuper(obj, args);
}
}
示例5: intercept
import net.sf.cglib.proxy.MethodProxy; //导入方法依赖的package包/类
@Override
public Object intercept(Object obj, Method method, Object[] args, MethodProxy methodProxy) throws Throwable {
// 排除Object类中的toString等方法
boolean objFlag = method.getDeclaringClass().getName().equals("java.lang.Object");
if (!objFlag) {
System.out.println("before");
}
Object result = null;
// 我们一般使用proxy.invokeSuper(obj,args)方法。这个很好理解,就是执行原始类的方法。还有一个方法proxy.invoke(obj,args),这是执行生成子类的方法。
// 如果传入的obj就是子类的话,会发生内存溢出,因为子类的方法不挺地进入intercept方法,而这个方法又去调用子类的方法,两个方法直接循环调用了。
result = methodProxy.invokeSuper(obj, args);
// result = methodProxy.invoke(obj, args);
if (!objFlag) {
System.out.println("after");
}
return result;
}
示例6: intercept
import net.sf.cglib.proxy.MethodProxy; //导入方法依赖的package包/类
@Override
public Object intercept(Object obj, Method method, Object[] args, MethodProxy methodProxy) throws Throwable {
boolean shouldProxy = method.isAnnotationPresent(Transactional.class);
if (shouldProxy) {
Connection conn = dataSource.getConnection();
conn.setAutoCommit(false);
Object result;
try {
result = methodProxy.invokeSuper(obj, args);
conn.commit();
return result;
} catch (Exception e) {
conn.rollback();
throw e;
}
}
return methodProxy.invokeSuper(obj, args);
}
示例7: intercept
import net.sf.cglib.proxy.MethodProxy; //导入方法依赖的package包/类
@Override
public Object intercept(Object proxy, Method method, Object[] args,
MethodProxy methodProxy) throws Throwable {
/**
* �����������
*/
Object result = null;
methodBefore(proxy,args);
// System.out.println("���↑ʼ");
// ͨ����������ø����еķ���
result = methodProxy.invokeSuper(proxy, args);
methodAfter(result);
// System.out.println("�������");
// // �Խ�������˸��� ����ţ�������
// result = "2";
return result;
}
示例8: intercept
import net.sf.cglib.proxy.MethodProxy; //导入方法依赖的package包/类
@Override
public Object intercept(Object target, Method targetMethod, Object[] params,MethodProxy methodProxy) throws Throwable {
//当出现一个动态调用的时候,判断当前方法是不是接口中的方法,如果不是接口方法,直接使用原始的调用
//当spring在初始化的时候,会调用类型equals,hashCode等方法
if (!Modifier.isAbstract(targetMethod.getModifiers()))
{
return methodProxy.invokeSuper(target, params);
}
try{
return processor.process(targetMethod, params);
}catch(Exception e){
logger.error("httpService access error " , e);
}
return null;
}
示例9: intercept
import net.sf.cglib.proxy.MethodProxy; //导入方法依赖的package包/类
/**
* ����������
*/
public Object intercept(Object obj, Method method, Object[] args, MethodProxy proxy)
throws Throwable
{
try
{
Query qy = (Query)method.getAnnotation(Query.class);
if (qy == null)
{
return proxy.invokeSuper(obj, args);
}
else
{
return this.QueryInterceptor(obj, method, args, proxy);
}
}
catch (Exception e)
{
e.printStackTrace();
}
return null;
}
示例10: intercept
import net.sf.cglib.proxy.MethodProxy; //导入方法依赖的package包/类
public Object intercept(Object obj, Method method, Object[] args, MethodProxy proxy) throws Throwable {
if(args.length == 2){
String name = method.getName() ;
if("invokeProxiedMethod".equals(name)){//pass the proxy
MethodProxy mp = MethodProxy.find(obj.getClass(), ReflectUtils.getSignature((Member) args[0])) ;
return mp.invokeSuper(obj, (Object[]) args[1]) ;
}
}
String methodKey = this.getMethodKey(method) ;
//call stub method
Method stubMethod = this.stubMethods.get(methodKey) ;
if(stubMethod != null){
return stubMethod.invoke(stub, args) ;
}
//call this RPCServiceImpl's method
Method thisMethod = this.thisMethods.get(methodKey) ;
if(thisMethod != null){
return thisMethod.invoke(this, args) ;
}
throw new NoSuchMethodException(methodKey) ;
}
示例11: intercept
import net.sf.cglib.proxy.MethodProxy; //导入方法依赖的package包/类
@Override
public Object intercept(Object obj, Method method, Object[] args, MethodProxy proxy) throws Throwable {
if (!aroundInvoked
&& Modifier.isPublic(method.getModifiers())
&& !method.getDeclaringClass().equals(Object.class)
&& !"aroundSlimInvoke".equals(method.getName())) {
aroundInvoked = true;
try {
return ((InteractionAwareFixture) obj).aroundSlimInvoke(interaction, method, args);
} finally {
aroundInvoked = false;
}
} else {
return proxy.invokeSuper(obj, args);
}
}
示例12: intercept
import net.sf.cglib.proxy.MethodProxy; //导入方法依赖的package包/类
@SuppressWarnings({ "unchecked", "rawtypes" })
public Object intercept(Object obj, Method method, Object[] args,
MethodProxy proxy) throws Throwable {
if(!method.isAnnotationPresent(Lazyload.class)){
return proxy.invokeSuper(obj, args);
}
Lazyload lazyload = method.getAnnotation(Lazyload.class);
if(lazyload == null){
return proxy.invokeSuper(obj, args);
}
IEntityState iEntityState = (IEntityState)Enum.valueOf((Class)lazyload.enmuClass(), lazyload.state());
if(iEntityState == null){
return proxy.invokeSuper(obj, args);
}
if(obj instanceof Entity){
retrieve((Entity)obj,args,iEntityState);
}
return proxy.invokeSuper(obj, args);
}
示例13: intercept
import net.sf.cglib.proxy.MethodProxy; //导入方法依赖的package包/类
@Override
public Object intercept(Object obj, Method method, Object[] args, MethodProxy proxy)
throws Throwable { // NOSONAR because it's an overridden method
boolean activator = false;
List<String> currentPath = null;
if (!this.active) {
activator = true;
this.active = true;
currentPath = FrameSwitcher.getCurrentFramePath();
this.switchToFrame();
this.initElements(obj);
}
try {
return proxy.invokeSuper(obj, args);
} finally {
if (activator && this.active) {
this.active = false;
FrameSwitcher.switchToFramePath(currentPath);
}
}
}
示例14: intercept
import net.sf.cglib.proxy.MethodProxy; //导入方法依赖的package包/类
@Override
public Object intercept(Object o, Method method, Object[] objects, MethodProxy methodProxy) throws Throwable {
if(method.isBridge()){
return methodProxy.invokeSuper(o,objects);
}
return interceptor.intercept(o,method,objects,methodProxy);
}
示例15: intercept
import net.sf.cglib.proxy.MethodProxy; //导入方法依赖的package包/类
@Override
public Object intercept(Object obj, Method method, Object[] args, MethodProxy proxy) throws Throwable {
// System.out.println("前置代理: " + method.getName());
// 通过代理类调用父类中的方法
Object result = proxy.invokeSuper(obj, args);
// System.out.println("后置代理: " + method.getName());
return result;
}