本文整理了Java中net.sf.cglib.proxy.Factory.setCallback()
方法的一些代码示例,展示了Factory.setCallback()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Factory.setCallback()
方法的具体详情如下:
包路径:net.sf.cglib.proxy.Factory
类名称:Factory
方法名:setCallback
[英]Set the callback for this object for the given type.
[中]为给定类型设置此对象的回调。
代码示例来源:origin: apache/cloudstack
@SuppressWarnings("unchecked")
public T createSearchEntity(MethodInterceptor interceptor) {
T entity = (T)_searchEnhancer.create();
final Factory factory = (Factory)entity;
factory.setCallback(0, interceptor);
return entity;
}
代码示例来源:origin: zstackio/zstack
private void createEnhancer(Class<T> entityClass) {
Enhancer enhancer = getEnhancer(entityClass);
proxyEntity = (T) enhancer.create();
Factory f = (Factory) proxyEntity;
f.setCallback(0, new MethodInterceptor() {
@Override
public Object intercept(Object o, Method method, Object[] objects, MethodProxy methodProxy) throws Throwable {
return doInvoke(o, method, objects, methodProxy);
}
});
}
代码示例来源:origin: apache/cloudstack
T t = (T)en.create();
Factory factory = (Factory)t;
factory.setCallback(0, new MethodInterceptor() {
@Override
public Object intercept(Object arg0, Method arg1, Object[] arg2, MethodProxy arg3) throws Throwable {
代码示例来源:origin: apache/cloudstack
if (_entity != null) {
final Factory factory = (Factory)_entity;
factory.setCallback(0, null);
_entity = null;
代码示例来源:origin: MissionCriticalCloud/cosmic
public T createSearchEntity(final MethodInterceptor interceptor) {
final T entity = (T) _searchEnhancer.create();
final Factory factory = (Factory) entity;
factory.setCallback(0, interceptor);
return entity;
}
代码示例来源:origin: intermine/intermine
/**
* Create a new object given a class (not an interface). To create an object from interfaces
* use createObject(Set classes) or simpleCreateObject(Class).
*
* @param clazz the class of the object to instantiate
* @param <C> The type of the object that is expected
* @return the object
* @throws IllegalArgumentException if an error occurs
*/
public static <C extends FastPathObject> C createObject(Class<C> clazz) {
C retval = null;
try {
retval = clazz.newInstance();
} catch (Exception e) {
IllegalArgumentException e2 = new IllegalArgumentException();
e2.initCause(e);
throw e2;
}
if (retval instanceof Factory) {
((Factory) retval).setCallback(0, new DynamicBean());
}
return retval;
}
代码示例来源:origin: org.intermine/intermine-objectstore
/**
* Create a new object given a class (not an interface). To create an object from interfaces
* use createObject(Set classes) or simpleCreateObject(Class).
*
* @param clazz the class of the object to instantiate
* @param <C> The type of the object that is expected
* @return the object
* @throws IllegalArgumentException if an error occurs
*/
public static <C extends FastPathObject> C createObject(Class<C> clazz) {
C retval = null;
try {
retval = clazz.newInstance();
} catch (Exception e) {
IllegalArgumentException e2 = new IllegalArgumentException();
e2.initCause(e);
throw e2;
}
if (retval instanceof Factory) {
((Factory) retval).setCallback(0, new DynamicBean());
}
return retval;
}
代码示例来源:origin: MissionCriticalCloud/cosmic
public T getTarget() {
Class<?> clz = _targetObject.getClass();
final String clzName = clz.getName();
if (clzName.contains("EnhancerByCloudStack")) {
clz = clz.getSuperclass();
}
Enhancer en = null;
synchronized (enMap) {
en = enMap.get(clz);
if (en == null) {
en = new Enhancer();
en.setSuperclass(clz);
en.setCallback((MethodInterceptor) (arg0, arg1, arg2, arg3) -> null);
enMap.put(clz, en);
}
}
final T t = (T) en.create();
final Factory factory = (Factory) t;
factory.setCallback(0, (MethodInterceptor) (arg0, arg1, arg2, arg3) -> {
if (arg1.getParameterTypes().length == 0 && arg1.getName().equals("finalize")) {
return null;
} else {
_callbackMethod = arg1;
_callbackMethod.setAccessible(true);
return null;
}
});
return t;
}
代码示例来源:origin: de.alpharogroup/model-type-safe
@Override
public Object createInstance(final Class<?> proxyClass, final Callback callback)
{
Factory proxy = (Factory)objenesis.newInstance(proxyClass);
proxy.setCallback(0, new MethodInterceptorImplementation(callback));
return proxy;
}
代码示例来源:origin: MissionCriticalCloud/cosmic
if (_entity != null) {
final Factory factory = (Factory) _entity;
factory.setCallback(0, null);
_entity = null;
代码示例来源:origin: intermine/intermine
public void testConstructors() throws Exception {
Class c = DynamicUtil.composeClass(Company.class, Broke.class);
Company obj = (Company) c.newInstance();
((net.sf.cglib.proxy.Factory) obj).setCallback(0, new DynamicBean());
obj.setName("Fred");
assertEquals("Fred", obj.getName());
}
内容来源于网络,如有侵权,请联系作者删除!