本文整理匯總了Java中javassist.bytecode.MethodInfo.addAttribute方法的典型用法代碼示例。如果您正苦於以下問題:Java MethodInfo.addAttribute方法的具體用法?Java MethodInfo.addAttribute怎麽用?Java MethodInfo.addAttribute使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類javassist.bytecode.MethodInfo
的用法示例。
在下文中一共展示了MethodInfo.addAttribute方法的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: updateClass
import javassist.bytecode.MethodInfo; //導入方法依賴的package包/類
public static void updateClass(MethodInfo info, List<String> names) {
// add the names to the class const pool
ConstPool constPool = info.getConstPool();
List<Integer> parameterNameIndices = new ArrayList<Integer>();
for (String name : names) {
if (name != null) {
parameterNameIndices.add(constPool.addUtf8Info(name));
} else {
parameterNameIndices.add(0);
}
}
// add the attribute to the method
info.addAttribute(new MethodParametersAttribute(constPool, parameterNameIndices));
}
示例2: updateClass
import javassist.bytecode.MethodInfo; //導入方法依賴的package包/類
public static void updateClass(MethodInfo info, List<String> names) {
// add the names to the class const pool
ConstPool constPool = info.getConstPool();
List<Integer> parameterNameIndices = new ArrayList<>();
for (String name : names) {
if (name != null) {
parameterNameIndices.add(constPool.addUtf8Info(name));
} else {
parameterNameIndices.add(0);
}
}
// add the attribute to the method
info.addAttribute(new MethodParametersAttribute(constPool, parameterNameIndices));
}
示例3: updateClass
import javassist.bytecode.MethodInfo; //導入方法依賴的package包/類
public static void updateClass(MethodInfo info, List<String> names)
{
// add the names to the class const pool
ConstPool constPool = info.getConstPool();
List<Integer> parameterNameIndices = new ArrayList<Integer>();
for(String name : names)
if(name != null)
parameterNameIndices.add(constPool.addUtf8Info(name));
else
parameterNameIndices.add(0);
// add the attribute to the method
info.addAttribute(new MethodParametersAttribute(constPool,
parameterNameIndices));
}
示例4: addEndpointMapping
import javassist.bytecode.MethodInfo; //導入方法依賴的package包/類
@Override
protected void addEndpointMapping(CtMethod ctMethod, String method, String request) {
MethodInfo methodInfo = ctMethod.getMethodInfo();
ConstPool constPool = methodInfo.getConstPool();
AnnotationsAttribute attr = new AnnotationsAttribute(constPool, AnnotationsAttribute.visibleTag);
Annotation requestMapping = new Annotation(RequestMapping.class.getName(), constPool);
ArrayMemberValue valueVals = new ArrayMemberValue(constPool);
StringMemberValue valueVal = new StringMemberValue(constPool);
valueVal.setValue(request);
valueVals.setValue(new MemberValue[]{valueVal});
requestMapping.addMemberValue("value", valueVals);
ArrayMemberValue methodVals = new ArrayMemberValue(constPool);
EnumMemberValue methodVal = new EnumMemberValue(constPool);
methodVal.setType(RequestMethod.class.getName());
methodVal.setValue(method);
methodVals.setValue(new MemberValue[]{methodVal});
requestMapping.addMemberValue("method", methodVals);
attr.addAnnotation(requestMapping);
methodInfo.addAttribute(attr);
}
示例5: addMethodAnnotations
import javassist.bytecode.MethodInfo; //導入方法依賴的package包/類
public static void addMethodAnnotations(CtMethod ctMethod, Method method) throws IllegalArgumentException, IllegalAccessException, InvocationTargetException {
if (method != null) {
MethodInfo methodInfo = ctMethod.getMethodInfo();
ConstPool constPool = methodInfo.getConstPool();
AnnotationsAttribute attr = new AnnotationsAttribute(constPool, AnnotationsAttribute.visibleTag);
methodInfo.addAttribute(attr);
for(java.lang.annotation.Annotation anno : method.getAnnotations()) {
// If it's a Transition skip
// TODO : Make this a parameterized set of Filters instead of hardcoding
//
Annotation clone = null;
if (anno instanceof Transitions || anno instanceof Transition) {
// skip
} else {
clone = cloneAnnotation(constPool, anno);
attr.addAnnotation(clone);
}
}
}
}
示例6: addConsumeAnnotation
import javassist.bytecode.MethodInfo; //導入方法依賴的package包/類
private void addConsumeAnnotation(CtMethod ctMethod, String uri) {
MethodInfo methodInfo = ctMethod.getMethodInfo();
ConstPool constPool = methodInfo.getConstPool();
Annotation consume = new Annotation(Consume.class.getName(), constPool);
StringMemberValue valueVal = new StringMemberValue(constPool);
valueVal.setValue(uri);
consume.addMemberValue("uri", valueVal);
AnnotationsAttribute attr = new AnnotationsAttribute(constPool, AnnotationsAttribute.visibleTag);
attr.addAnnotation(consume);
methodInfo.addAttribute(attr);
}
示例7: copyParameters
import javassist.bytecode.MethodInfo; //導入方法依賴的package包/類
protected void copyParameters(CtMethod ctMethod, Method method, ClassPool cp) throws NotFoundException, IllegalArgumentException, IllegalAccessException, InvocationTargetException, CannotCompileException {
String[] parmNames = (method != null) ? parmDiscover.getParameterNames(method) : null;
MethodInfo methodInfo = ctMethod.getMethodInfo();
ParameterAnnotationsAttribute paramAtrributeInfo =
new ParameterAnnotationsAttribute(
methodInfo.getConstPool(),
ParameterAnnotationsAttribute.visibleTag);
Annotation[][] paramArrays = new Annotation[method.getParameterTypes().length][];
java.lang.annotation.Annotation[][] parmAnnotations = method.getParameterAnnotations();
int parmIndex = 0;
for(Class<?> parm : method.getParameterTypes()) {
// Clone the parameter Class
//
CtClass ctParm = cp.get(parm.getName());
// Add the parameter to the method
//
ctMethod.addParameter(ctParm);
// Add the Parameter Annotations to the Method
//
String parmName = (parmNames != null && parmNames.length > parmIndex) ? parmNames[parmIndex] : null;
paramArrays[parmIndex] = createParameterAnnotations(
parmName,
ctMethod.getMethodInfo(),
parmAnnotations[parmIndex],
paramAtrributeInfo.getConstPool());
parmIndex++;
}
paramAtrributeInfo.setAnnotations(paramArrays);
methodInfo.addAttribute(paramAtrributeInfo);
}
示例8: addEndpointMapping
import javassist.bytecode.MethodInfo; //導入方法依賴的package包/類
@Override
protected void addEndpointMapping(
CtMethod ctMethod,
String method,
String request) {
// Add Path Annotation
//
MethodInfo methodInfo = ctMethod.getMethodInfo();
ConstPool constPool = methodInfo.getConstPool();
AnnotationsAttribute annoAttr = new AnnotationsAttribute(constPool, AnnotationsAttribute.visibleTag);
Annotation pathMapping = new Annotation(Path.class.getName(), constPool);
StringMemberValue valueVal = new StringMemberValue(constPool);
valueVal.setValue(request);
pathMapping.addMemberValue("value", valueVal);
annoAttr.addAnnotation(pathMapping);
// Add Verb Annotation (GET|POST|PUT|DELETE)
//
String verbClassName = "javax.ws.rs." + method;
Annotation verb = new Annotation(verbClassName, constPool);
annoAttr.addAnnotation(verb);
methodInfo.addAttribute(annoAttr);
}
示例9: addAttribute
import javassist.bytecode.MethodInfo; //導入方法依賴的package包/類
public static AttributeInfo addAttribute(MethodInfo to, AttributeInfo attr) {
attr = inPool(attr, to.getConstPool());
to.addAttribute(attr);
return attr;
}