当前位置: 首页>>代码示例>>Java>>正文


Java JoinPoint.getSignature方法代码示例

本文整理汇总了Java中org.aspectj.lang.JoinPoint.getSignature方法的典型用法代码示例。如果您正苦于以下问题:Java JoinPoint.getSignature方法的具体用法?Java JoinPoint.getSignature怎么用?Java JoinPoint.getSignature使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.aspectj.lang.JoinPoint的用法示例。


在下文中一共展示了JoinPoint.getSignature方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: afterReturn

import org.aspectj.lang.JoinPoint; //导入方法依赖的package包/类
/**
 * @param joinPoint
 */
@AfterReturning("logAnnoAspect()")

public void afterReturn(JoinPoint joinPoint) {
    MethodSignature methodSignature = (MethodSignature) joinPoint.getSignature();
    Method method = methodSignature.getMethod();
    LogDelete logDelete = method.getAnnotation(LogDelete.class);
    if (null != logDelete) {
        BaseEntity entity = (BaseEntity) joinPoint.getArgs()[0];
        Log log = new Log();
        log.setUserId(((User) SecurityUtils.getSubject().getSession().getAttribute("curUser")).getId());
        log.setAction(Constants.LOG_ACTION_DELETE + logDelete.resource());
        log.setResource(entity.getLogResource());
        log.setResourceId(entity.getId());
        logService.insert(log);
    }
}
 
开发者ID:melonlee,项目名称:PowerApi,代码行数:20,代码来源:LogDeleteAdvice.java

示例2: afterReturn

import org.aspectj.lang.JoinPoint; //导入方法依赖的package包/类
/**
 * @param joinPoint
 */
@AfterReturning("logAnnoAspect()")

public void afterReturn(JoinPoint joinPoint) {
    MethodSignature methodSignature = (MethodSignature) joinPoint.getSignature();
    Method method = methodSignature.getMethod();
    LogModify logModifyAnno = method.getAnnotation(LogModify.class);
    if (null != logModifyAnno) {

        BaseEntity entity = (BaseEntity) joinPoint.getArgs()[0];
        Log log = new Log();
        log.setUserId(((User) SecurityUtils.getSubject().getSession().getAttribute("curUser")).getId());
        log.setAction(ACTION + logModifyAnno.resource());
        log.setResource(entity.getLogResource());
        log.setResourceId(entity.getId());
        logService.insert(log);
    }
}
 
开发者ID:melonlee,项目名称:PowerApi,代码行数:21,代码来源:LogModifyAdvice.java

示例3: beforeTrans

import org.aspectj.lang.JoinPoint; //导入方法依赖的package包/类
public void beforeTrans(JoinPoint point) {
    Signature signature = point.getSignature();
    MethodSignature methodSignature = (MethodSignature) signature;
    Method method = methodSignature.getMethod();
    // 获取目标类
    Class<?> target = point.getTarget().getClass();
    Method targetMethod = null;
    try {
        targetMethod = target.getMethod(method.getName(), method.getParameterTypes());
    } catch (NoSuchMethodException e) {
        e.printStackTrace();
    }
    // 根据目标类方法中的注解,选择数据源
    if (targetMethod != null) {
        Transactional transactional = targetMethod.getAnnotation(Transactional.class);
        if (transactional != null) {
            SpecifyDS specifyDSCls = target.getAnnotation(SpecifyDS.class);
            SpecifyDS specifyDS = targetMethod.getAnnotation(SpecifyDS.class);
            if (specifyDS != null) {
                DataSourceHolder.setDataSource(specifyDS.value());
            } else if (specifyDSCls != null) {
                DataSourceHolder.setDataSource(specifyDSCls.value());
            } else {
                DataSourceHolder.setDataSource(defaultTransDb);
            }
        }
    }
}
 
开发者ID:xiachuanshou,项目名称:shop-manager,代码行数:29,代码来源:DataSourceAspect.java

示例4: saveSysLog

import org.aspectj.lang.JoinPoint; //导入方法依赖的package包/类
@Before("logPointCut()")
public void saveSysLog(JoinPoint joinPoint) {
    MethodSignature signature = (MethodSignature) joinPoint.getSignature();
    Method method = signature.getMethod();

    SysLogEntity sysLog = new SysLogEntity();
    SysLog syslog = method.getAnnotation(SysLog.class);
    if (syslog != null) {
        //注解上的描述
        sysLog.setOperation(syslog.value());
    }

    //请求的方法名
    String className = joinPoint.getTarget().getClass().getName();
    String methodName = signature.getName();
    sysLog.setMethod(className + "." + methodName + "()");

    //请求的参数
    Object[] args = joinPoint.getArgs();
    String params = new Gson().toJson(args[0]);
    sysLog.setParams(params);

    //获取request
    HttpServletRequest request = HttpContextUtils.getHttpServletRequest();
    //设置IP地址
    sysLog.setIp(IPUtils.getIpAddr(request));

    //用户名
    String username = ((SysUserEntity) SecurityUtils.getSubject().getPrincipal()).getUsername();
    sysLog.setUsername(username);

    sysLog.setCreateDate(LocalDateTime.now());
    //保存系统日志
    try {
        sysLogService.save(sysLog);
    } catch (Exception e) {
        log.error("保存日志异常", e);
    }
}
 
开发者ID:davichi11,项目名称:my-spring-boot-project,代码行数:40,代码来源:SysLogAspect.java

示例5: execute

import org.aspectj.lang.JoinPoint; //导入方法依赖的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);
}
 
开发者ID:daisuke-nomura,项目名称:crash,代码行数:8,代码来源:ExecuteOnMainThread.java

示例6: afterReturn

import org.aspectj.lang.JoinPoint; //导入方法依赖的package包/类
/**
 * @param joinPoint
 */
@AfterReturning("controllerAspect()")
public void afterReturn(JoinPoint joinPoint) {
    MethodSignature methodSignature = (MethodSignature) joinPoint.getSignature();
    Method method = methodSignature.getMethod();
    Log log = method.getAnnotation(Log.class);
    if (null != log) {
        logger.info(String.format("业务日志 : [%s]", log.value()));
    }
}
 
开发者ID:melonlee,项目名称:LazyREST,代码行数:13,代码来源:LogAdvice.java

示例7: after

import org.aspectj.lang.JoinPoint; //导入方法依赖的package包/类
@After("annotationPointCut()")
public void after(JoinPoint joinpoint) {
	MethodSignature signature = (MethodSignature) joinpoint.getSignature();
	Method method = signature.getMethod();
	Action action = method.getAnnotation(Action.class);
	System.out.println("注解式拦截 " + action.name());
}
 
开发者ID:zhazhapan,项目名称:hello-spring,代码行数:8,代码来源:LogAspect.java

示例8: before

import org.aspectj.lang.JoinPoint; //导入方法依赖的package包/类
/**
     * Before.
     *  前置通知
     * @param joinPoint the join point
     */
    @Before("pointcut()")
    public  void before(JoinPoint joinPoint){
        Signature signature=joinPoint.getSignature();

//        Object[] o = joinPoint.getArgs();
//        for (Object o1: o
//             ) {
//            System.out.println(o1.toString());
//        }
        logger.info("--------before execute method,method name is:'"+signature.getDeclaringType()+"."+signature.getName()+"'");
    }
 
开发者ID:Topview-us,项目名称:school-website,代码行数:17,代码来源:MyAdvice.java

示例9: getCallMethod

import org.aspectj.lang.JoinPoint; //导入方法依赖的package包/类
/**
 * Gets method description string from join point.
 *
 * @param joinPoint aspect join point
 * @return method description string from join point
 */
public static String getCallMethod(JoinPoint joinPoint) {
    if (joinPoint != null && joinPoint.getSignature() != null) {
        Class<?> declaringType = joinPoint.getSignature().getDeclaringType();
        String className = (declaringType != null) ? declaringType.getSimpleName() : PRINT_QUESTION;
        String methodName = joinPoint.getSignature().getName();
        return className + PRINT_SEMICOLON + methodName;
    }
    return PRINT_EMPTY_METHOD;
}
 
开发者ID:xm-online,项目名称:xm-commons,代码行数:16,代码来源:LogObjectPrinter.java

示例10: saveSysLog

import org.aspectj.lang.JoinPoint; //导入方法依赖的package包/类
@Before("logPointCut()")
public void saveSysLog(JoinPoint joinPoint) {
	MethodSignature signature = (MethodSignature) joinPoint.getSignature();
	Method method = signature.getMethod();
	
	SysLogEntity sysLog = new SysLogEntity();
	SysLog syslog = method.getAnnotation(SysLog.class);
	if(syslog != null){
		//注解上的描述 
		sysLog.setOperation(syslog.value());
	}
	
	//请求的方法名
	String className = joinPoint.getTarget().getClass().getName();
	String methodName = signature.getName();
	sysLog.setMethod(className + "." + methodName + "()");
	
	//请求的参数
	Object[] args = joinPoint.getArgs();
	String params = new Gson().toJson(args[0]);
	sysLog.setParams(params);
	
	//获取request
	HttpServletRequest request = HttpContextUtils.getHttpServletRequest();
	//设置IP地址
	sysLog.setIp(IPUtils.getIpAddr(request));
	
	//用户名
	String username = ((SysUserEntity) SecurityUtils.getSubject().getPrincipal()).getUsername();
	sysLog.setUsername(username);
	
	sysLog.setCreateDate(new Date());
	//保存系统日志
	sysLogService.save(sysLog);
}
 
开发者ID:zhaoqicheng,项目名称:renren-fast,代码行数:36,代码来源:SysLogAspect.java

示例11: withStepAnnotation

import org.aspectj.lang.JoinPoint; //导入方法依赖的package包/类
@Before("anyMethod() && withStepAnnotation()")
public void stepStart(final JoinPoint joinPoint) {
    final MethodSignature methodSignature = (MethodSignature) joinPoint.getSignature();
    final String uuid = UUID.randomUUID().toString();
    final StepResult result = new StepResult()
            .withName(createTitle(joinPoint))
            .withParameters(getParameters(methodSignature, joinPoint.getArgs()));

    getLifecycle().startStep(uuid, result);
}
 
开发者ID:allure-framework,项目名称:allure-java,代码行数:11,代码来源:Allure1StepsAspects.java

示例12: createTitle

import org.aspectj.lang.JoinPoint; //导入方法依赖的package包/类
public String createTitle(final JoinPoint joinPoint) {
    final MethodSignature methodSignature = (MethodSignature) joinPoint.getSignature();
    final Step step = methodSignature.getMethod().getAnnotation(Step.class);
    return step.value().isEmpty()
            ? getName(methodSignature.getName(), joinPoint.getArgs())
            : getTitle(step.value(), methodSignature.getName(), joinPoint.getThis(), joinPoint.getArgs());
}
 
开发者ID:allure-framework,项目名称:allure-java,代码行数:8,代码来源:Allure1StepsAspects.java

示例13: updateTestCase

import org.aspectj.lang.JoinPoint; //导入方法依赖的package包/类
private void updateTestCase(final JoinPoint joinPoint) {
    final MethodSignature signature = (MethodSignature) joinPoint.getSignature();
    final Object[] args = joinPoint.getArgs();
    final Object target = joinPoint.getTarget();
    final Allure1Annotations annotations = new Allure1Annotations(target, signature, args);
    getLifecycle().getCurrentTestCase().ifPresent(uuid -> {
        getLifecycle().updateTestCase(uuid, annotations::updateTitle);
        getLifecycle().updateTestCase(uuid, annotations::updateDescription);
        getLifecycle().updateTestCase(uuid, annotations::updateParameters);
        getLifecycle().updateTestCase(uuid, annotations::updateLabels);
        getLifecycle().updateTestCase(uuid, annotations::updateLinks);
    });
}
 
开发者ID:allure-framework,项目名称:allure-java,代码行数:14,代码来源:Allure1TestCaseAspects.java

示例14: findLoggable

import org.aspectj.lang.JoinPoint; //导入方法依赖的package包/类
@Nonnull
private static Loggable findLoggable(final JoinPoint joinPoint) {
    Loggable loggable = ((MethodSignature) joinPoint.getSignature()).getMethod().getAnnotation(Loggable.class);
    if (loggable == null) {
        loggable = (Loggable) joinPoint.getSignature().getDeclaringType().getAnnotation(Loggable.class);
    }

    if (loggable == null) {
        throw new RuntimeException("Internal error. No @Loggable found for: " + joinPoint.getSignature());
    }

    return loggable;
}
 
开发者ID:ivnik,项目名称:smartlog,代码行数:14,代码来源:LogAspect.java

示例15: toString

import org.aspectj.lang.JoinPoint; //导入方法依赖的package包/类
/**
 * To string string.
 *
 * @param jp the jp
 * @return the string
 */
public static String toString(JoinPoint jp) {
    StringBuilder sb = new StringBuilder();
    appendType(sb, getType(jp));
    Signature signature = jp.getSignature();
    if (signature instanceof MethodSignature) {
        MethodSignature ms = (MethodSignature) signature;
        sb.append("#");
        sb.append(ms.getMethod().getName());
        sb.append("(");
        appendTypes(sb, ms.getMethod().getParameterTypes());
        sb.append(")");
    }
    return sb.toString();
}
 
开发者ID:mhaddon,项目名称:Sound.je,代码行数:21,代码来源:JoinPointToStringHelper.java


注:本文中的org.aspectj.lang.JoinPoint.getSignature方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。