本文整理匯總了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;
}