本文整理汇总了Java中net.sf.cglib.proxy.AdvancedProxy.createProxy方法的典型用法代码示例。如果您正苦于以下问题:Java AdvancedProxy.createProxy方法的具体用法?Java AdvancedProxy.createProxy怎么用?Java AdvancedProxy.createProxy使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类net.sf.cglib.proxy.AdvancedProxy
的用法示例。
在下文中一共展示了AdvancedProxy.createProxy方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: _mergeModels
import net.sf.cglib.proxy.AdvancedProxy; //导入方法依赖的package包/类
private <T> T _mergeModels(final Class<? super T> aClass, final MergingInvocationHandler<T> handler, final T... implementations) {
final Set<Class> commonClasses = getCommonClasses(new THashSet<Class>(), implementations);
commonClasses.add(MERGED_OBJECT_CLASS);
commonClasses.add(aClass);
final T t = AdvancedProxy.<T>createProxy(handler, null, commonClasses.toArray(new Class[commonClasses.size()]));
return t;
}
示例2: getProxy
import net.sf.cglib.proxy.AdvancedProxy; //导入方法依赖的package包/类
@NotNull
public final DomElement getProxy() {
DomElement proxy = myProxy;
if (proxy == null) {
Class<?> rawType = getRawType();
Class<? extends DomElement> implementation = myManager.getApplicationComponent().getImplementation(rawType);
final boolean isInterface = rawType.isInterface();
if (implementation == null && !isInterface) {
//noinspection unchecked
implementation = (Class<? extends DomElement>)rawType;
}
myProxy = proxy = AdvancedProxy.createProxy(this, implementation, isInterface ? new Class[]{rawType} : ArrayUtil.EMPTY_CLASS_ARRAY);
}
return proxy;
}
示例3: testExtendClass
import net.sf.cglib.proxy.AdvancedProxy; //导入方法依赖的package包/类
public void testExtendClass() throws Throwable {
final List<String> invocations = new ArrayList<String>();
Implementation implementation = AdvancedProxy.createProxy(Implementation.class, new Class[]{Interface3.class}, new InvocationHandler(){
@Override
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
invocations.add(method.getName());
if (Object.class.equals(method.getDeclaringClass())) {
return method.invoke(this, args);
}
return Implementation.class.getMethod("getField").invoke(proxy);
}
}, "239");
implementation.hashCode();
implementation.method();
assertEquals("239", implementation.getFoo());
implementation.setField("42");
assertEquals("42", implementation.getBar());
assertEquals("42", implementation.toString());
assertEquals(Arrays.asList("hashCode", "getFoo", "getFoo", "getBar"), invocations);
assertEquals("42", Interface1.class.getMethod("getFoo").invoke(implementation));
assertEquals("42", Interface3.class.getMethod("bar").invoke(implementation));
assertEquals("42", Interface1.class.getMethod("foo").invoke(implementation));
assertEquals("42", Interface2.class.getMethod("foo").invoke(implementation));
assertEquals("42", Interface2.class.getMethod("foo").invoke(implementation));
assertEquals("42", Implementation.class.getMethod("foo").invoke(implementation));
}
示例4: _mergeModels
import net.sf.cglib.proxy.AdvancedProxy; //导入方法依赖的package包/类
private <T> T _mergeModels(final Class<? super T> aClass, final MergingInvocationHandler<T> handler, final T... implementations) {
final Set<Class> commonClasses = getCommonClasses(new THashSet<Class>(), implementations);
commonClasses.add(MERGED_OBJECT_CLASS);
commonClasses.add(aClass);
final T t = AdvancedProxy.<T>createProxy(handler, null, commonClasses.toArray(new Class[commonClasses.size()]));
//myMergedMap.get(aClass).put(implementations, t);
return t;
}
示例5: DomInvocationHandler
import net.sf.cglib.proxy.AdvancedProxy; //导入方法依赖的package包/类
protected DomInvocationHandler(Type type, DomParentStrategy parentStrategy,
@NotNull final EvaluatedXmlName tagName,
final T childDescription,
final DomManagerImpl manager,
boolean dynamic,
@Nullable Stub stub) {
myManager = manager;
myParentStrategy = parentStrategy;
myTagName = tagName;
myChildDescription = childDescription;
myStub = stub;
myLastModCount = manager.getPsiModificationCount();
myType = narrowType(type);
final Class<?> rawType = getRawType();
myInvocationCache = manager.getApplicationComponent().getInvocationCache(rawType);
Class<? extends DomElement> implementation = manager.getApplicationComponent().getImplementation(rawType);
final boolean isInterface = ReflectionCache.isInterface(rawType);
if (implementation == null && !isInterface) {
implementation = (Class<? extends DomElement>)rawType;
}
myProxy = AdvancedProxy.createProxy(this, implementation, isInterface ? new Class[]{rawType} : ArrayUtil.EMPTY_CLASS_ARRAY);
refreshGenericInfo(dynamic);
if (stub != null) {
stub.setHandler(this);
}
}
示例6: DomInvocationHandler
import net.sf.cglib.proxy.AdvancedProxy; //导入方法依赖的package包/类
protected DomInvocationHandler(Type type, DomParentStrategy parentStrategy,
@NotNull final EvaluatedXmlName tagName,
final T childDescription,
final DomManagerImpl manager,
boolean dynamic,
@Nullable Stub stub) {
myManager = manager;
myParentStrategy = parentStrategy;
myTagName = tagName;
myChildDescription = childDescription;
myStub = stub;
myLastModCount = manager.getPsiModificationCount();
myType = narrowType(type);
final Class<?> rawType = getRawType();
myInvocationCache = manager.getApplicationComponent().getInvocationCache(rawType);
Class<? extends DomElement> implementation = manager.getApplicationComponent().getImplementation(rawType);
final boolean isInterface = rawType.isInterface();
if (implementation == null && !isInterface) {
implementation = (Class<? extends DomElement>)rawType;
}
myProxy = AdvancedProxy.createProxy(this, implementation, isInterface ? new Class[]{rawType} : ArrayUtil.EMPTY_CLASS_ARRAY);
refreshGenericInfo(dynamic);
if (stub != null) {
stub.setHandler(this);
}
}
示例7: testAddInterfaces
import net.sf.cglib.proxy.AdvancedProxy; //导入方法依赖的package包/类
public void testAddInterfaces() throws Throwable {
final BaseImpl proxy = AdvancedProxy.createProxy(BaseImpl.class, BaseIEx.class);
assertEquals(proxy.sayA(), "a");
assertEquals(((BaseI)proxy).sayA(), "a");
assertEquals(((BaseIEx)proxy).sayA(), "a");
}