jodd-proxetta/src/main/java/jodd/proxetta/advice/DelegateAdviceUtil.java
public static <T> T applyAdvice(final Class<T> targetClass) {
		Class adviceClass = cache.get(targetClass);

		if (adviceClass == null) {
			// advice not yet created

			adviceClass = PROXY_PROXETTA.proxy().setTarget(targetClass).define();

			cache.put(targetClass, adviceClass);
		}

		// create new advice instance and injects target instance to it

		try {
			Object advice = ClassUtil.newInstance(adviceClass);

			Field field = adviceClass.getField("$___target$0");

			field.set(advice, targetClass);

			return (T) advice;
		} catch (Exception ex) {
			throw new ProxettaException(ex);
		}
	}
public static <T> T applyAdvice(final Class<T> targetClass) {
		Class adviceClass = cache.get(targetClass);

		if (adviceClass == null) {
			// advice not yet created

			adviceClass = PROXY_PROXETTA.proxy().setTarget(targetClass).define();

			cache.put(targetClass, adviceClass);
		}

		// create new advice instance and injects target instance to it

		try {
			Object advice = ClassUtil.newInstance(adviceClass);

			Field field = adviceClass.getField("$___target$0");

			field.set(advice, targetClass);

			return (T) advice;
		} catch (Exception ex) {
			throw new ProxettaException(ex);
		}
	}
public static < T > T applyAdvice ( final Class < T > targetClass ) { Class adviceClass = cache . get ( targetClass ) ; if ( adviceClass == null ) { // advice not yet created adviceClass = PROXY_PROXETTA . proxy ( ) . setTarget ( targetClass ) . define ( ) ; cache . put ( targetClass , adviceClass ) ; } // create new advice instance and injects target instance to it try { Object advice = ClassUtil . newInstance ( adviceClass ) ; Field field = adviceClass . getField ( "$___target$0" ) ; field . set ( advice , targetClass ) ; return ( T ) advice ; } catch ( Exception ex ) { throw new ProxettaException ( ex ) ; } }
Applies advice on given target class and returns proxy instance.
Applies advice on given target class and returns proxy instance .