/** * Validates argument index. */ public static void checkArgumentIndex(final MethodInfo methodInfo, final int argIndex) { if ((argIndex < 1) || (argIndex > methodInfo.getArgumentsCount())) { throw new ProxettaException("Invalid argument index: " + argIndex); } }
/** * Returns <code>true</code> if method has a return type. */ default boolean hasReturnValue() { return getReturnType().getOpcode() != AsmUtil.TYPE_VOID; }
/** * Visits replacement code for {@link ProxyTarget#targetMethodAnnotation(String, String)}. */ public static void targetMethodAnnotation(final MethodVisitor mv, final MethodInfo methodInfo, final String[] args) { AnnotationInfo[] anns = methodInfo.getAnnotations(); if (anns != null) { targetAnnotation(mv, anns, args); } }
@Test void testMethodSignature10() throws IOException { MethodInfo msv = getMethodSignatureForSingleMethod(M10.class); assertEquals(2, msv.getArgumentsCount()); assertEquals(0, msv.getArgument(1).getAnnotations().length); assertEquals(1, msv.getArgument(2).getAnnotations().length); assertEquals("jodd.proxetta.fixtures.data.FooAnn", msv.getArgument(2).getAnnotations()[0].getAnnotationClassname()); assertEquals("macka", msv.getMethodName()); assertEquals(1, msv.getAnnotations().length); assertEquals("jodd.proxetta.fixtures.data.FooAnn", msv.getAnnotations()[0].getAnnotationClassname()); }
@Override public boolean apply(final MethodInfo methodInfo) { return methodInfo.isPublicMethod() && methodInfo.matchMethodName("set*") && methodInfo.hasOneArgument() ; } }
/** * Inserts total number of method's arguments. */ public static int argumentsCount() { throw new ProxettaException(); }
/** * Defines class or interface to wrap. * For setting the interface of the resulting class, * use {@link #setTargetInterface(Class)}. */ @Override public WrapperProxettaFactory setTarget(final Class target) { super.setTarget(target); this.targetClassOrInterface = target; return this; }
/** * Returns <code>true</code> if method has no argument. */ default boolean hasNoArguments() { return getArgumentsCount() == 0; }
public Object execute() throws Exception { Object returnValue = null; if (returnValue != null) { returnValue = "1"; } return ProxyTarget.returnValue(returnValue); } }
/** * Sets variable proxy class name so every time when new proxy class is created * its name will be different,so one classloader may load it without a problem. * Otherwise, sets constant proxy class name so each time created proxy * class will have the same name. Such class can be loaded only once by a classloader. * <p> * This prevents "<code>java.lang.LinkageError: duplicate class definition</code>" errors. */ public T setVariableClassName(final boolean variableClassName) { this.variableClassName = variableClassName; return _this(); }
/** * Returns proxy class name. */ public String getProxyClassName() { assertProxyIsCreated(); return proxyClassName; }
/** * Returns <code>true</code> if method's return type is <code>void</code>. */ default boolean hasNoReturnValue() { return getReturnType().getOpcode() == AsmUtil.TYPE_VOID; }
/** * Creates array of arguments values. It is more safely then to get one argument at time, since * the returned array has correct length. * Equals to: <code>new Object[] {arg1, arg2,...}</code> * @see #createArgumentsClassArray() * @see #argument(int) */ public static Object[] createArgumentsArray() { throw new ProxettaException(); }
/** * Delegates to aspects pointcut. */ boolean apply(final MethodInfo msign) { return pointcut.apply(msign); }
/** * Specifies custom classname suffix to be added to the class name of created proxy. * Warning: when class name suffix is not used, full classname has to be * specified that differs from target class name. */ public T setClassNameSuffix(final String suffix) { this.classNameSuffix = suffix; return _this(); }
/** * Inserts targets class annotation value. Inserts <code>null</code> * if annotation or element is missing. */ public static Object targetClassAnnotation(final String annotationClassName, final String element) { throw new ProxettaException(); }
/** * Specifies classloaders for loading created classes. * If classloader not specified, default one will be used. */ public T setClassLoader(final ClassLoader classLoader) { this.classLoader = classLoader; return _this(); }
/** * Inserts populated {@link jodd.proxetta.ProxyTargetInfo} instance. */ public static ProxyTargetInfo info() { throw new ProxettaException(); }
/** * Checks if target is not defined yet. */ private void assertTargetIsNotDefined() { if (targetInputStream != null) { throw new ProxettaException("Target already defined"); } }