本文整理汇总了Java中net.sf.cglib.proxy.Factory.setCallback方法的典型用法代码示例。如果您正苦于以下问题:Java Factory.setCallback方法的具体用法?Java Factory.setCallback怎么用?Java Factory.setCallback使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类net.sf.cglib.proxy.Factory
的用法示例。
在下文中一共展示了Factory.setCallback方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: create
import net.sf.cglib.proxy.Factory; //导入方法依赖的package包/类
/**
* Creates the scoped proxy object using the given provider.
*
* @param injector The injector.
* @return The scoped proxy object.
*/
@SuppressWarnings("unchecked")
public T create(Injector injector) {
Preconditions.checkNotNull(injector, "injector");
Preconditions.checkState(this.dispatcher != null, "no provider set");
this.enhancer.setCallbackType(this.dispatcher.getClass());
final Class<T> enhancedClass = this.enhancer.createClass();
final Errors errors = new Errors();
final T proxyInstance = this.constructionStrategy
.createInstance(enhancedClass, injector, errors);
errors.throwProvisionExceptionIfErrorsExist();
final Factory factory = (Factory) proxyInstance;
factory.setCallback(CALLBACK_INDEX, this.dispatcher);
return proxyInstance;
}
示例2: decorateInstance
import net.sf.cglib.proxy.Factory; //导入方法依赖的package包/类
@Override
protected void decorateInstance(T result, final MethodIntercept methodIntercept) {
MethodInterceptor methodInterceptor = new MethodInterceptor() {
public Object intercept(final Object proxy, Method method, Object[] args, final MethodProxy superProxy) throws Throwable {
return methodIntercept.intercept(proxy, new MethodAdapter(method), args, new MethodIntercept.SuperInvoker() {
public Object invokeSuper(Object[] superArgs) throws Throwable {
return superProxy.invokeSuper(proxy, superArgs);
}
});
}
};
Factory factory = (Factory) result;
int callbackCount = factory.getCallbacks().length;
for(int i = 0; i < callbackCount; i++) {
factory.setCallback(i, methodInterceptor);
}
}
示例3: createSearchEntity
import net.sf.cglib.proxy.Factory; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
public T createSearchEntity(MethodInterceptor interceptor) {
T entity = (T)_searchEnhancer.create();
final Factory factory = (Factory)entity;
factory.setCallback(0, interceptor);
return entity;
}
示例4: createSearchEntity
import net.sf.cglib.proxy.Factory; //导入方法依赖的package包/类
public T createSearchEntity(final MethodInterceptor interceptor) {
final T entity = (T) _searchEnhancer.create();
final Factory factory = (Factory) entity;
factory.setCallback(0, interceptor);
return entity;
}