本文整理汇总了Java中org.aspectj.lang.reflect.CodeSignature.getName方法的典型用法代码示例。如果您正苦于以下问题:Java CodeSignature.getName方法的具体用法?Java CodeSignature.getName怎么用?Java CodeSignature.getName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.aspectj.lang.reflect.CodeSignature
的用法示例。
在下文中一共展示了CodeSignature.getName方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: enterMethod
import org.aspectj.lang.reflect.CodeSignature; //导入方法依赖的package包/类
private void enterMethod(ProceedingJoinPoint joinPoint) {
CodeSignature signature = (CodeSignature) joinPoint.getSignature();
Class<?> clz = signature.getDeclaringType();
String methodName = signature.getName();
String[] paramNames = signature.getParameterNames();
Object[] paramValues = joinPoint.getArgs();
StringBuilder builder = new StringBuilder("\[email protected] Enter---------------------------------\n");
if (Looper.getMainLooper() != Looper.myLooper()) {
//非主线程,打印线程信息
builder.append("[").append(Thread.currentThread().getName()).append("] ");
}
builder.append(methodName).append(":\n");
for (int i = 0; i < paramValues.length; i++) {
//此处可以对类型进行判断,读出更有意义的信息
builder.append(paramNames[i])
.append("=")
.append(paramValues[i])
.append("\n");
}
builder.append("\[email protected] Enter end---------------------------------\n");
Log.d(clz.getSimpleName(), builder.toString());
}
示例2: getStageId
import org.aspectj.lang.reflect.CodeSignature; //导入方法依赖的package包/类
private StageId getStageId(MethodProfiling annotation, ProceedingJoinPoint joinPoint) {
if (!annotation.enabled()) {
return null;
}
ProfilerId profilerId = new ProfilerId(annotation.profilerName(), annotation.runsCounter());
String stageName = annotation.stageName();
if (stageName.isEmpty()) {
CodeSignature codeSignature = (CodeSignature) joinPoint.getSignature();
String className = codeSignature.getDeclaringType().getSimpleName();
String methodName = codeSignature.getName();
stageName = className + "." + methodName;
}
return new StageId(profilerId, stageName, annotation.stageOrder());
}
示例3: enter
import org.aspectj.lang.reflect.CodeSignature; //导入方法依赖的package包/类
/**
* Logs the start of method calls with the specified direction for end-to-end purposes.
*
* @param jp
* the join point during the execution of the method.
* @param direction
* the direction of the message being logged.
*/
protected void enter(JoinPoint jp, String direction) {
Logger logger = Logger.getLogger(getLoggerName(jp.getStaticPart()));
if (isLoggingEnabled(logger)) {
CodeSignature signature = (CodeSignature) jp.getSignature();
String threadName = Thread.currentThread().getName();
String declaringTypeName = signature.getDeclaringTypeName();
Class<?>[] argTypes = signature.getParameterTypes();
Object[] args = jp.getArgs();
// search for a byte array type in argTypes
// if it contains 1 or more byteArrays replace the content of the
// array args at the appropriate index
// with "byte[size]"
processArgs(argTypes, args);
String argsString = Arrays.deepToString(args);
String signName = signature.getName();
logger.info(String.format("%s: START %s: %s.%s(%s)", threadName, direction, declaringTypeName, signName, argsString));
}
}
示例4: execute
import org.aspectj.lang.reflect.CodeSignature; //导入方法依赖的package包/类
private void execute(JoinPoint joinPoint) {
CodeSignature codeSignature = (CodeSignature) joinPoint.getSignature();
Class<?> cls = codeSignature.getDeclaringType();
String methodName = codeSignature.getName();
Log.v(getTag(cls), "\u21E2 " + methodName);
}
示例5: enterMethod
import org.aspectj.lang.reflect.CodeSignature; //导入方法依赖的package包/类
private static void enterMethod(JoinPoint joinPoint) {
if (!enabled) return;
CodeSignature codeSignature = (CodeSignature) joinPoint.getSignature();
Class<?> cls = codeSignature.getDeclaringType();
String methodName = codeSignature.getName();
String[] parameterNames = codeSignature.getParameterNames();
Object[] parameterValues = joinPoint.getArgs();
StringBuilder builder = new StringBuilder("\u21E2 ");
builder.append(methodName).append('(');
for (int i = 0; i < parameterValues.length; i++) {
if (i > 0) {
builder.append(", ");
}
builder.append(parameterNames[i]).append('=');
builder.append(Strings.toString(parameterValues[i]));
}
builder.append(')');
/*// Log when current thread is not the main thread
if (Looper.myLooper() != Looper.getMainLooper()) {
builder.append(" [Thread:\"").append(Thread.currentThread().getName()).append("\"]");
}*/
// TODO : use a real Logger
System.out.println(asTag(cls) + " : " + builder.toString());
}
示例6: string
import org.aspectj.lang.reflect.CodeSignature; //导入方法依赖的package包/类
private static String string(ProceedingJoinPoint joinPoint, long start, long stop) {
CodeSignature signature = (CodeSignature) joinPoint.getSignature();
String className = signature.getDeclaringType().getSimpleName();
String methodName = signature.getName();
return new StringBuilder(className)
.append("#").append(methodName).append(" :: ")
.append("[").append(TimeUnit.NANOSECONDS.toMillis(stop - start)).append(" ms]").toString();
}
示例7: enterMethod
import org.aspectj.lang.reflect.CodeSignature; //导入方法依赖的package包/类
private static void enterMethod(JoinPoint joinPoint) {
if (!enabled) return;
CodeSignature codeSignature = (CodeSignature) joinPoint.getSignature();
Class<?> cls = codeSignature.getDeclaringType();
String methodName = codeSignature.getName();
String[] parameterNames = codeSignature.getParameterNames();
Object[] parameterValues = joinPoint.getArgs();
StringBuilder builder = new StringBuilder("\u21E2 ");
builder.append(methodName).append('(');
for (int i = 0; i < parameterValues.length; i++) {
if (i > 0) {
builder.append(", ");
}
builder.append(parameterNames[i]).append('=');
builder.append(Strings.toString(parameterValues[i]));
}
builder.append(')');
if (Looper.myLooper() != Looper.getMainLooper()) {
builder.append(" [Thread:\"").append(Thread.currentThread().getName()).append("\"]");
}
Log.v(asTag(cls), builder.toString());
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) {
final String section = builder.toString().substring(2);
Trace.beginSection(section);
}
}