All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.github.andyshao.proxy.DynamicPF Maven / Gradle / Ivy

The newest version!
package com.github.andyshao.proxy;

import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;
import java.lang.reflect.Proxy;

/**
 * 
 * Title:
* Descript:
* Copyright: Copryright(c) Oct 8, 2015
* Encoding:UNIX UTF-8 * * @author Andy.Shao * * @param the type of proxied class */ @FunctionalInterface public interface DynamicPF extends ProxyFactory { @Override public default T getProxy(T target) { return this.getProxy(target , (Object proxy , Method method , Object[] args) -> DynamicPF.this.invoke(target , method , args)); } /** * get proxy * @param target target object * @param invocationHandler proxy handler * @return new object */ @SuppressWarnings("unchecked") public default T getProxy(T target , InvocationHandler invocationHandler) { return (T) Proxy.newProxyInstance(target.getClass().getClassLoader() , this.proxyInterfaces(target) , invocationHandler); } /** * when the method which will be invoke should be proxy. * this method will be run. * * @param target the target which will be proxy * @param method the method which will be invoke * @param args the args of method * @return the answer of method * @throws Throwable andy exception when run this method */ public Object invoke(T target , Method method , Object[] args) throws Throwable; }




© 2015 - 2025 Weber Informatics LLC | Privacy Policy