當前位置: 首頁>>代碼示例>>Java>>正文


Java MethodInfo.addAttribute方法代碼示例

本文整理匯總了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));
}
 
開發者ID:cccssw,項目名稱:enigma-vk,代碼行數:17,代碼來源:MethodParametersAttribute.java

示例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));
    }
 
開發者ID:OpenModLoader,項目名稱:Enigma,代碼行數:17,代碼來源:MethodParametersAttribute.java

示例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));
}
 
開發者ID:Wurst-Imperium,項目名稱:Wurst-Enigma,代碼行數:17,代碼來源:MethodParametersAttribute.java

示例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);
}
 
開發者ID:statefulj,項目名稱:statefulj,代碼行數:26,代碼來源:SpringMVCBinder.java

示例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);
			}
		}
	}
}
 
開發者ID:statefulj,項目名稱:statefulj,代碼行數:22,代碼來源:JavassistUtils.java

示例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);
}
 
開發者ID:statefulj,項目名稱:statefulj,代碼行數:14,代碼來源:CamelBinder.java

示例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);
}
 
開發者ID:statefulj,項目名稱:statefulj,代碼行數:35,代碼來源:AbstractRestfulBinder.java

示例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);
}
 
開發者ID:statefulj,項目名稱:statefulj,代碼行數:30,代碼來源:JerseyBinder.java

示例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;
}
 
開發者ID:OvercastNetwork,項目名稱:ProjectAres,代碼行數:6,代碼來源:Javassists.java


注:本文中的javassist.bytecode.MethodInfo.addAttribute方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。