本文整理汇总了Java中org.springframework.cglib.core.Local类的典型用法代码示例。如果您正苦于以下问题:Java Local类的具体用法?Java Local怎么用?Java Local使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Local类属于org.springframework.cglib.core包,在下文中一共展示了Local类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: generateGet
import org.springframework.cglib.core.Local; //导入依赖的package包/类
private void generateGet(final Class target, final Method[] getters) {
CodeEmitter e = begin_method(Constants.ACC_PUBLIC, GET_PROPERTY_VALUES, null);
if (getters.length >= 0) {
e.load_arg(0);
e.checkcast(Type.getType(target));
Local bean = e.make_local();
e.store_local(bean);
for (int i = 0; i < getters.length; i++) {
if (getters[i] != null) {
MethodInfo getter = ReflectUtils.getMethodInfo(getters[i]);
e.load_arg(1);
e.push(i);
e.load_local(bean);
e.invoke(getter);
e.box(getter.getSignature().getReturnType());
e.aastore();
}
}
}
e.return_value();
e.end_method();
}
示例2: generateSet
import org.springframework.cglib.core.Local; //导入依赖的package包/类
private void generateSet(final Class target, final Method[] setters) {
// setPropertyValues
CodeEmitter e = begin_method(Constants.ACC_PUBLIC, SET_PROPERTY_VALUES, null);
if (setters.length > 0) {
Local index = e.make_local(Type.INT_TYPE);
e.push(0);
e.store_local(index);
e.load_arg(0);
e.checkcast(Type.getType(target));
e.load_arg(1);
Block handler = e.begin_block();
int lastIndex = 0;
for (int i = 0; i < setters.length; i++) {
if (setters[i] != null) {
MethodInfo setter = ReflectUtils.getMethodInfo(setters[i]);
int diff = i - lastIndex;
if (diff > 0) {
e.iinc(index, diff);
lastIndex = i;
}
e.dup2();
e.aaload(i);
e.unbox(setter.getSignature().getArgumentTypes()[0]);
e.invoke(setter);
}
}
handler.end();
e.return_value();
e.catch_exception(handler, Constants.TYPE_THROWABLE);
e.new_instance(BULK_BEAN_EXCEPTION);
e.dup_x1();
e.swap();
e.load_local(index);
e.invoke_constructor(BULK_BEAN_EXCEPTION, CSTRUCT_EXCEPTION);
e.athrow();
} else {
e.return_value();
}
e.end_method();
}
示例3: emitProxy
import org.springframework.cglib.core.Local; //导入依赖的package包/类
private void emitProxy(ClassEmitter ce, final MethodInfo method) {
int modifiers = Constants.ACC_PUBLIC;
if ((method.getModifiers() & Constants.ACC_VARARGS) == Constants.ACC_VARARGS) {
modifiers |= Constants.ACC_VARARGS;
}
final CodeEmitter e = EmitUtils.begin_method(ce, method, modifiers);
Type returnType = method.getSignature().getReturnType();
final boolean returns = returnType != Type.VOID_TYPE;
Local result = null;
if (returns) {
result = e.make_local(returnType);
e.zero_or_null(returnType);
e.store_local(result);
}
e.load_this();
e.super_getfield("targets", Constants.TYPE_OBJECT_ARRAY);
final Local result2 = result;
EmitUtils.process_array(e, Constants.TYPE_OBJECT_ARRAY, new ProcessArrayCallback() {
public void processElement(Type type) {
e.checkcast(Type.getType(iface));
e.load_args();
e.invoke(method);
if (returns) {
e.store_local(result2);
}
}
});
if (returns) {
e.load_local(result);
}
e.return_value();
e.end_method();
}
示例4: generateSwap
import org.springframework.cglib.core.Local; //导入依赖的package包/类
private void generateSwap(final Object[] arrays) {
CodeEmitter e = begin_method(Constants.ACC_PUBLIC, SWAP, null);
for (int i = 0; i < arrays.length; i++) {
Type type = Type.getType(arrays[i].getClass());
Type component = TypeUtils.getComponentType(type);
Local T = e.make_local(type);
e.load_this();
e.getfield(getFieldName(i));
e.store_local(T);
e.load_local(T);
e.load_arg(0);
e.load_local(T);
e.load_arg(1);
e.array_load(component);
e.load_local(T);
e.load_arg(1);
e.load_local(T);
e.load_arg(0);
e.array_load(component);
e.array_store(component);
e.array_store(component);
}
e.return_value();
e.end_method();
}
示例5: generateClass
import org.springframework.cglib.core.Local; //导入依赖的package包/类
public void generateClass(ClassVisitor v) {
Type sourceType = Type.getType(source);
Type targetType = Type.getType(target);
ClassEmitter ce = new ClassEmitter(v);
ce.begin_class(Constants.V1_6,
Constants.ACC_PUBLIC | Constants.ACC_SUPER,
getClassName(),
BEAN_COPIER,
null,
Constants.SOURCE_FILE);
EmitUtils.null_constructor(ce);
CodeEmitter e = ce.begin_method(Constants.ACC_PUBLIC, COPY, null);
PropertyDescriptor[] getters = ReflectUtils.getBeanGetters(source);
PropertyDescriptor[] setters = ReflectUtils.getBeanSetters(target);
Map names = new HashMap();
for (int i = 0; i < getters.length; i++) {
names.put(getters[i].getName(), getters[i]);
}
Local targetLocal = e.make_local();
Local sourceLocal = e.make_local();
if (useConverter) {
e.load_arg(1);
e.checkcast(targetType);
e.store_local(targetLocal);
e.load_arg(0);
e.checkcast(sourceType);
e.store_local(sourceLocal);
} else {
e.load_arg(1);
e.checkcast(targetType);
e.load_arg(0);
e.checkcast(sourceType);
}
for (int i = 0; i < setters.length; i++) {
PropertyDescriptor setter = setters[i];
PropertyDescriptor getter = (PropertyDescriptor)names.get(setter.getName());
if (getter != null) {
MethodInfo read = ReflectUtils.getMethodInfo(getter.getReadMethod());
MethodInfo write = ReflectUtils.getMethodInfo(setter.getWriteMethod());
if (useConverter) {
Type setterType = write.getSignature().getArgumentTypes()[0];
e.load_local(targetLocal);
e.load_arg(2);
e.load_local(sourceLocal);
e.invoke(read);
e.box(read.getSignature().getReturnType());
EmitUtils.load_class(e, setterType);
e.push(write.getSignature().getName());
e.invoke_interface(CONVERTER, CONVERT);
e.unbox_or_zero(setterType);
e.invoke(write);
} else if (compatible(getter, setter)) {
e.dup2();
e.invoke(read);
e.invoke(write);
}
}
}
e.return_value();
e.end_method();
ce.end_class();
}
示例6: emitBindCallbacks
import org.springframework.cglib.core.Local; //导入依赖的package包/类
private void emitBindCallbacks(ClassEmitter ce) {
CodeEmitter e = ce.begin_method(Constants.PRIVATE_FINAL_STATIC,
BIND_CALLBACKS,
null);
Local me = e.make_local();
e.load_arg(0);
e.checkcast_this();
e.store_local(me);
Label end = e.make_label();
e.load_local(me);
e.getfield(BOUND_FIELD);
e.if_jump(e.NE, end);
e.load_local(me);
e.push(1);
e.putfield(BOUND_FIELD);
e.getfield(THREAD_CALLBACKS_FIELD);
e.invoke_virtual(THREAD_LOCAL, THREAD_LOCAL_GET);
e.dup();
Label found_callback = e.make_label();
e.ifnonnull(found_callback);
e.pop();
e.getfield(STATIC_CALLBACKS_FIELD);
e.dup();
e.ifnonnull(found_callback);
e.pop();
e.goTo(end);
e.mark(found_callback);
e.checkcast(CALLBACK_ARRAY);
e.load_local(me);
e.swap();
for (int i = callbackTypes.length - 1; i >= 0; i--) {
if (i != 0) {
e.dup2();
}
e.aaload(i);
e.checkcast(callbackTypes[i]);
e.putfield(getCallbackField(i));
}
e.mark(end);
e.return_value();
e.end_method();
}