本文整理汇总了Java中org.springframework.asm.Type类的典型用法代码示例。如果您正苦于以下问题:Java Type类的具体用法?Java Type怎么用?Java Type使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Type类属于org.springframework.asm包,在下文中一共展示了Type类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: LazyEntityGenerator
import org.springframework.asm.Type; //导入依赖的package包/类
public LazyEntityGenerator(Class<?> entityType) {
this.writer = new ClassWriter(ClassWriter.COMPUTE_MAXS);
this.emitter = new ClassEmitter(writer);
this.entityType = entityType;
this.proxyClassName = entityType.getName() + "$$Hibatis$Lazy";
this.metadata = EntityMetadata.get(entityType);
// 开始声明类
this.beginClass();
// 加入属性
addField(Opcodes.ACC_PRIVATE, "$target", Type.getType(Object.class).getDescriptor() , null);
addField(Opcodes.ACC_PRIVATE, "$source", Type.getType(HibatisEntity.class).getDescriptor() , null);
addField(Opcodes.ACC_PRIVATE, "$association", Type.getType(AssociationProperty.class).getDescriptor() , null);
// 重写属性
this.overrideProperties();
// 结束声明类
this.emitter.visitEnd();
}
示例2: generateGet
import org.springframework.asm.Type; //导入依赖的package包/类
private void generateGet(Class type, final Map getters) {
final CodeEmitter e = begin_method(Constants.ACC_PUBLIC, BEAN_MAP_GET, null);
e.load_arg(0);
e.checkcast(Type.getType(type));
e.load_arg(1);
e.checkcast(Constants.TYPE_STRING);
EmitUtils.string_switch(e, getNames(getters), Constants.SWITCH_STYLE_HASH, new ObjectSwitchCallback() {
public void processCase(Object key, Label end) {
PropertyDescriptor pd = (PropertyDescriptor)getters.get(key);
MethodInfo method = ReflectUtils.getMethodInfo(pd.getReadMethod());
e.invoke(method);
e.box(method.getSignature().getReturnType());
e.return_value();
}
public void processDefault() {
e.aconst_null();
e.return_value();
}
});
e.end_method();
}
示例3: generateGetPropertyType
import org.springframework.asm.Type; //导入依赖的package包/类
private void generateGetPropertyType(final Map allProps, String[] allNames) {
final CodeEmitter e = begin_method(Constants.ACC_PUBLIC, GET_PROPERTY_TYPE, null);
e.load_arg(0);
EmitUtils.string_switch(e, allNames, Constants.SWITCH_STYLE_HASH, new ObjectSwitchCallback() {
public void processCase(Object key, Label end) {
PropertyDescriptor pd = (PropertyDescriptor)allProps.get(key);
EmitUtils.load_class(e, Type.getType(pd.getPropertyType()));
e.return_value();
}
public void processDefault() {
e.aconst_null();
e.return_value();
}
});
e.end_method();
}
示例4: generateClass
import org.springframework.asm.Type; //导入依赖的package包/类
public void generateClass(ClassVisitor v) throws Exception {
int size = props.size();
String[] names = (String[])props.keySet().toArray(new String[size]);
Type[] types = new Type[size];
for (int i = 0; i < size; i++) {
types[i] = (Type)props.get(names[i]);
}
ClassEmitter ce = new ClassEmitter(v);
ce.begin_class(Constants.V1_6,
Constants.ACC_PUBLIC | Constants.ACC_SUPER,
getClassName(),
superclass != null ? Type.getType(superclass) : Constants.TYPE_OBJECT,
null,
null);
EmitUtils.null_constructor(ce);
EmitUtils.add_properties(ce, names, types);
ce.end_class();
}
示例5: generateGet
import org.springframework.asm.Type; //导入依赖的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();
}
示例6: generateClass
import org.springframework.asm.Type; //导入依赖的package包/类
public void generateClass(ClassVisitor v) throws Exception {
ClassEmitter ce = new ClassEmitter(v);
ce.begin_class(Constants.V1_6,
Constants.ACC_PUBLIC | Constants.ACC_SUPER | Constants.ACC_INTERFACE,
getClassName(),
null,
null,
Constants.SOURCE_FILE);
for (Iterator it = signatures.keySet().iterator(); it.hasNext();) {
Signature sig = (Signature)it.next();
Type[] exceptions = (Type[])signatures.get(sig);
ce.begin_method(Constants.ACC_PUBLIC | Constants.ACC_ABSTRACT,
sig,
exceptions).end_method();
}
ce.end_class();
}
示例7: generateConstructor
import org.springframework.asm.Type; //导入依赖的package包/类
private void generateConstructor(Object[] arrays) {
CodeEmitter e = begin_method(Constants.ACC_PUBLIC, CSTRUCT_OBJECT_ARRAY, null);
e.load_this();
e.super_invoke_constructor();
e.load_this();
e.load_arg(0);
e.super_putfield("a", Constants.TYPE_OBJECT_ARRAY);
for (int i = 0; i < arrays.length; i++) {
Type type = Type.getType(arrays[i].getClass());
declare_field(Constants.ACC_PRIVATE, getFieldName(i), type, null);
e.load_this();
e.load_arg(0);
e.push(i);
e.aaload();
e.checkcast(type);
e.putfield(getFieldName(i));
}
e.return_value();
e.end_method();
}
示例8: generateClass
import org.springframework.asm.Type; //导入依赖的package包/类
@Override
public void generateClass(ClassVisitor classVisitor) throws Exception {
ClassEmitter classEmitter = new ClassEmitter(classVisitor);
classEmitter.begin_class(Constants.V1_5,
Constants.ACC_PUBLIC,
makeProxyClassName(),
Constants.TYPE_OBJECT,
new Type[] { Type.getType(EventSubscriberProxy.class) },
null);
createDelegateField(classEmitter);
createConstructor(classEmitter);
createGetEventTypeMethod(classEmitter);
createIsAsyncMethod(classEmitter);
createHandleMessageMethod(classEmitter);
classEmitter.end_class();
}
开发者ID:unbroken-dome,项目名称:spring-integration-eventbus,代码行数:20,代码来源:CglibSubscriberProxyClassGenerator.java
示例9: createHandleMessageMethod
import org.springframework.asm.Type; //导入依赖的package包/类
private void createHandleMessageMethod(ClassEmitter classEmitter) {
Signature signature = new Signature(
"handleMessage", Type.VOID_TYPE, new Type[] { MESSAGE_TYPE });
Signature subscriberMethodSignature = new Signature(
subscriberInfo.getSubscriberMethodName(),
Type.VOID_TYPE,
new Type[] { Type.getType(subscriberInfo.getEventType()) });
CodeEmitter emitter = classEmitter.begin_method(Constants.ACC_PUBLIC, signature, null);
emitter.load_this();
emitter.getfield("delegate");
emitter.load_arg(0);
emitter.invoke_interface(MESSAGE_TYPE, GETPAYLOAD_SIGNATURE);
emitter.checkcast(Type.getType(subscriberInfo.getEventType()));
emitter.invoke_virtual(Type.getType(subscriberInfo.getBeanClass()), subscriberMethodSignature);
emitter.return_value();
emitter.end_method();
}
开发者ID:unbroken-dome,项目名称:spring-integration-eventbus,代码行数:21,代码来源:CglibSubscriberProxyClassGenerator.java
示例10: transform
import org.springframework.asm.Type; //导入依赖的package包/类
@Override
protected ClassGenerator transform(ClassGenerator cg) throws Exception {
ClassEmitterTransformer transformer = new ClassEmitterTransformer() {
@Override
public void end_class() {
declare_field(Constants.ACC_PUBLIC, BEAN_FACTORY_FIELD, Type.getType(BeanFactory.class), null);
super.end_class();
}
};
return new TransformingClassGenerator(cg, transformer);
}
示例11: ProxyClassGenerator
import org.springframework.asm.Type; //导入依赖的package包/类
public ProxyClassGenerator(Class<?> entityType , boolean overrideProperties) {
this.writer = new ClassWriter(ClassWriter.COMPUTE_MAXS);
this.emitter = new ClassEmitter(writer);
this.entityType = entityType;
this.proxyClassName = entityType.getName() + "$$Hibatis";
this.proxyClassPath = proxyClassName.replace(".", "/");
this.entityClassPath = entityType.getName().replace(".", "/");
this.metadata = EntityMetadata.get(entityType);
// 开始声明类
this.beginClass();
// 声明字段
Long serialVersionUID = new Long(proxyClassName.hashCode());
int access = Opcodes.ACC_PRIVATE | Opcodes.ACC_STATIC | Opcodes.ACC_FINAL;
this.addField(access, "serialVersionUID", "J", serialVersionUID);
// 加入字段
this.addField(Opcodes.ACC_PRIVATE, "$propertyChanges", Type.getDescriptor(List.class), null);
// 加入属性
this.addProperty("$version", Type.getType(String.class), false, false); // 版本
this.addProperty("$state", Type.getType(EntityState.class), false, false); // 状态
this.addProperty("$type", Type.getType(Class.class), false, false); // 类型
// 重写所有的属性
if(overrideProperties){
this.overrideProperties();
}
// 结束声明类
this.emitter.visitEnd();
}
示例12: beginClass
import org.springframework.asm.Type; //导入依赖的package包/类
private void beginClass() {
Type supperType = Type.getType(entityType);
Type[] interfaceTypes = new Type[] { Type.getType(Serializable.class), Type.getType(HibatisEntity.class) };
this.emitter.begin_class(Opcodes.V1_5, Opcodes.ACC_PUBLIC, proxyClassName, supperType, interfaceTypes,
null);
addConstructor();
}
示例13: putNewField
import org.springframework.asm.Type; //导入依赖的package包/类
private void putNewField(CodeEmitter e, String name, Class<?> realType, Class<?> interfaceType) {
String realTypePath = realType.getName().replace(".", "/");
e.visitVarInsn(Opcodes.ALOAD, 0);
e.visitTypeInsn(Opcodes.NEW, realTypePath);
e.visitInsn(Opcodes.DUP);
e.visitMethodInsn(Opcodes.INVOKESPECIAL, realTypePath, "<init>", "()V", false);
e.visitFieldInsn(Opcodes.PUTFIELD, proxyClassPath, name, Type.getDescriptor(interfaceType));
}
示例14: getKey
import org.springframework.asm.Type; //导入依赖的package包/类
public static String getKey(Method method, Class targetClass) {
StringBuilder sb = new StringBuilder();
sb.append(method.getDeclaringClass().getName());
sb.append('.');
sb.append(method.getName());
sb.append(Type.getMethodDescriptor(method));
if (targetClass != null) {
sb.append('_');
sb.append(targetClass.getName());
}
return sb.toString();
}
示例15: LocalVariableTableVisitor
import org.springframework.asm.Type; //导入依赖的package包/类
public LocalVariableTableVisitor(Class<?> clazz, Map<Member, String[]> map, String name, String desc, boolean isStatic) {
super(SpringAsmInfo.ASM_VERSION);
this.clazz = clazz;
this.memberMap = map;
this.name = name;
this.args = Type.getArgumentTypes(desc);
this.parameterNames = new String[this.args.length];
this.isStatic = isStatic;
this.lvtSlotIndex = computeLvtSlotIndices(isStatic, this.args);
}
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:11,代码来源:LocalVariableTableParameterNameDiscoverer.java