@Override public boolean apply(final MethodInfo methodInfo) { return methodInfo.isTopLevelMethod() && methodInfo.isPublicMethod(); } }
@Override public boolean apply(MethodInfo methodInfo) { return methodInfo.isTopLevelMethod(); }
@Override public boolean apply(MethodInfo methodInfo) { return methodInfo.isTopLevelMethod(); }
@Test void testInterfaceWrapper() throws Exception { Calc calc = new CalcImpl(); WrapperProxetta proxetta = Proxetta.wrapperProxetta().withAspect(new ProxyAspect(StatCounterAdvice.class, methodInfo -> methodInfo.isTopLevelMethod() && methodInfo.isPublicMethod())); //proxetta.setDebugFolder("/Users/igor"); // wrapper over INTERFACE // resulting object has ONE interface // only interface methods are wrapped WrapperProxettaFactory builder = proxetta.proxy().setTarget(Calc.class).setTargetProxyClassName(".CalcImpl3"); Class<Calc> calc2Class = builder.define(); Calc calc2 = calc2Class.newInstance(); builder.injectTargetIntoWrapper(calc, calc2); assertEquals(1, StatCounter.counter); // counter in static block !!! calc2.hello(); assertEquals(2, StatCounter.counter); assertEquals(10, calc2.calculate(3, 7)); assertEquals(3, StatCounter.counter); try { calc2Class.getMethod("customMethod"); fail("error"); } catch (Exception ex) { } }
assertEquals("Ljava/lang/String;", mi.getArgument(1).getName()); assertTrue(mi.isTopLevelMethod());
/** * Returns <code>true</code> if method is a top-level method. */ public boolean isTopLevelMethod(MethodInfo methodInfo) { return methodInfo.isTopLevelMethod(); }
@Override public boolean apply(final MethodInfo methodInfo) { return methodInfo.isTopLevelMethod() && methodInfo.isPublicMethod(); } }
public boolean apply(MethodInfo methodInfo) { int argumentsCount = methodInfo.getArgumentsCount(); char argumentType = 0; if (argumentsCount >= 1) { argumentType = methodInfo.getArgumentOpcodeType(1); } return methodInfo.getReturnOpcodeType() == 'V' && // void-returning method argumentType == 'I' && // first argument type methodInfo.isTopLevelMethod() && // top-level methodInfo.getMethodName().startsWith("set") && // set* (argumentsCount == 2 || argumentsCount == 3); // number of arguments } }));