當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。