List of usage examples for org.aspectj.lang.reflect MethodSignature getMethod
Method getMethod();
From source file:ajia.transaction.AnnotationDrivenTransactionManagementAspect.java
License:Apache License
public TransactionAttributeWithRollbackRules getTransactionAttribute(JoinPoint jp) { MethodSignature jpSignature = (MethodSignature) jp.getSignature(); Transactional typeAnnotation = AnnotationUtils.findAnnotation(jpSignature.getDeclaringType(), Transactional.class); Transactional methodAnnotation = AnnotationUtils.findAnnotation(jpSignature.getMethod(), Transactional.class); return TransactionManagementUtil.createTransactionAttribute(typeAnnotation, methodAnnotation); }
From source file:ar.com.allium.rules.core.service.ExcecuteRuleService.java
License:Open Source License
private List<RuleResponse> executeSetOfRules(JoinPoint joinPoint, ExecuteRule excecuteRule) { String[] ruleSetList = excecuteRule.ruleSetName(); List<RuleResponse> ruleResponseList = new ArrayList<RuleResponse>(); if (ruleSetList != null && ruleSetList.length > 0) { for (String ruleSet : ruleSetList) { log.debug("excecute rule set: " + ruleSet); List<AlliumRule> rulesToExecuteList = this.getAlliumCoreRuleManager().getRuleList(ruleSet); if (rulesToExecuteList != null && rulesToExecuteList.size() > 0) { for (AlliumRule alliumRule : rulesToExecuteList) { MethodSignature signature = (MethodSignature) joinPoint.getSignature(); Method method = signature.getMethod(); log.debug("execute rule: " + alliumRule.getRuleName() + " from rule set: " + ruleSet); RuleResponse result = alliumRule .execute(new AlliumRuleEvaluateParameters(method, joinPoint.getArgs())); log.debug("execute rule: " + alliumRule.getRuleName() + " from rule set: " + ruleSet + " -- result: " + result.getRuleState()); if (RuleState.RULE_ERROR.equals(result.getRuleState())) { ruleResponseList.add(result); if (excecuteRule.onErrorStopProcess()) { throw new AlliumRuleException("error to process set allium rule: " + ruleSet, ruleResponseList); }/*from w ww .j a v a2s .co m*/ } } } } } return ruleResponseList; }
From source file:ar.com.allium.rules.core.service.ExcecuteRuleService.java
License:Open Source License
private List<RuleResponse> executeRules(JoinPoint joinPoint, ExecuteRule excecuteRule) { List<RuleResponse> ruleResponseList = new ArrayList<RuleResponse>(); Class<? extends AlliumRule>[] ruleList = excecuteRule.ruleClass(); for (Class<? extends AlliumRule> clazz : ruleList) { AlliumRule alliumRule = this.getAlliumCoreRuleManager().getRule(clazz); MethodSignature signature = (MethodSignature) joinPoint.getSignature(); Method method = signature.getMethod(); log.debug("execute rule: " + alliumRule.getRuleName()); RuleResponse result = alliumRule.execute(new AlliumRuleEvaluateParameters(method, joinPoint.getArgs())); log.debug("execute rule: " + alliumRule.getRuleName() + " -- result: " + result.getRuleState()); if (RuleState.RULE_ERROR.equals(result.getRuleState())) { ruleResponseList.add(result); if (excecuteRule.onErrorStopProcess()) { throw new AlliumRuleException( "error to process allium rule: " + alliumRule.getClass().getSimpleName(), ruleResponseList); }// w w w. java 2s.co m } } return ruleResponseList; }
From source file:ar.com.jrules.core.service.ExcecuteRuleService.java
License:Open Source License
private List<RuleResponse> executeSetOfRules(JoinPoint joinPoint, ExecuteRule excecuteRule) { String[] ruleSetList = excecuteRule.ruleSetName(); List<RuleResponse> ruleResponseList = new ArrayList<RuleResponse>(); if (ruleSetList != null && ruleSetList.length > 0) { for (String ruleSet : ruleSetList) { log.debug("excecute rule set: " + ruleSet); List<JRule> rulesToExecuteList = this.getJRulesCoreRuleManager().getRuleList(ruleSet); if (rulesToExecuteList != null && rulesToExecuteList.size() > 0) { for (JRule jRule : rulesToExecuteList) { MethodSignature signature = (MethodSignature) joinPoint.getSignature(); Method method = signature.getMethod(); log.debug("execute rule: " + jRule.getRuleName() + " from rule set: " + ruleSet); RuleResponse result = jRule .execute(new JRuleEvaluateParameters(method, joinPoint.getArgs())); log.debug("execute rule: " + jRule.getRuleName() + " from rule set: " + ruleSet + " -- result: " + result.getRuleState()); if (RuleState.RULE_ERROR.equals(result.getRuleState())) { ruleResponseList.add(result); if (excecuteRule.onErrorStopProcess()) { throw new JRuleException("error to process set jrule: " + ruleSet, ruleResponseList); }//from www.j a v a 2s . c o m } } } } } return ruleResponseList; }
From source file:ar.com.jrules.core.service.ExcecuteRuleService.java
License:Open Source License
private List<RuleResponse> executeRules(JoinPoint joinPoint, ExecuteRule excecuteRule) { List<RuleResponse> ruleResponseList = new ArrayList<RuleResponse>(); Class<? extends JRule>[] ruleList = excecuteRule.ruleClass(); for (Class<? extends JRule> clazz : ruleList) { JRule jRule = this.getJRulesCoreRuleManager().getRule(clazz); MethodSignature signature = (MethodSignature) joinPoint.getSignature(); Method method = signature.getMethod(); log.debug("execute rule: " + jRule.getRuleName()); RuleResponse result = jRule.execute(new JRuleEvaluateParameters(method, joinPoint.getArgs())); log.debug("execute rule: " + jRule.getRuleName() + " -- result: " + result.getRuleState()); if (RuleState.RULE_ERROR.equals(result.getRuleState())) { ruleResponseList.add(result); if (excecuteRule.onErrorStopProcess()) { throw new JRuleException("error to process jrule: " + jRule.getClass().getSimpleName(), ruleResponseList); }//from w w w .j a va 2 s . c om } } return ruleResponseList; }
From source file:be.nille.jwt.aspect.JWTAspect.java
private String replacePlaceholdersInExpression(final ProceedingJoinPoint joinPoint, String expression) { MethodSignature signature = (MethodSignature) joinPoint.getSignature(); Method method = signature.getMethod(); Object[] args = joinPoint.getArgs(); final Annotation[][] parameterAnnotations = method.getParameterAnnotations(); for (int i = 0; i < parameterAnnotations.length; i++) { final Annotation[] annotations = parameterAnnotations[i]; AnnotationService annotationService = new AnnotationServiceImpl(); final ClaimValue claimAnnotation = annotationService.getAnnotationByType(annotations, ClaimValue.class); if (claimAnnotation != null) { String claimValue = claimAnnotation.value(); String argument = (String) args[i]; expression = expression.replace("#" + claimValue, argument); log.debug(claimValue);/*from w ww. jav a 2 s. c o m*/ break; } } return expression; }
From source file:cn.com.xl.core.aop.BeforeAop.java
License:Apache License
@Around("cutBefore()") public Object doBefore(ProceedingJoinPoint point) throws Throwable { HttpServletRequest request = HttpKit.getRequest(); MethodSignature ms = (MethodSignature) point.getSignature(); Method method = ms.getMethod(); Object[] args = point.getArgs(); Class<?> clazz = point.getTarget().getClass(); Before before = method.getAnnotation(Before.class); Interceptor ic = before.value().newInstance(); Object result = ic.intercept(new Invocation(clazz, method, args, request)); if (null == result) { return point.proceed(); } else {//from w w w . ja v a2s. c o m return result; } }
From source file:cn.com.xl.core.aop.PermissionAop.java
License:Apache License
@Around("cutPermission()") public Object doPermission(ProceedingJoinPoint point) throws Throwable { MethodSignature ms = (MethodSignature) point.getSignature(); Method method = ms.getMethod(); Permission permission = method.getAnnotation(Permission.class); Object[] permissions = permission.value(); if ((permissions.length == 1 && Func.toStr(permissions[0]).equals("ALL")) || permissions == null || permissions.length == 0) { ///*from w w w. ja v a 2 s . c om*/ boolean result = PermissionCheckManager.checkAll(); if (result) { return point.proceed(); } else { throw new NoPermissionException(); } } else { // boolean result = PermissionCheckManager.check(permissions); if (result) { return point.proceed(); } else { throw new NoPermissionException(); } } }
From source file:cn.mypandora.log.MyLogAspect.java
License:Apache License
/** * ??//from ww w . ja va 2 s. co m * * @param point * @throws Throwable */ @After("pointcut()") public void afterSuccessLog(JoinPoint point) throws Throwable { // MethodSignature joinMethodSignature = (MethodSignature) point.getSignature(); //?? Method method = joinMethodSignature.getMethod(); String methodName = method.getName(); Class<?>[] parameterTypes = method.getParameterTypes(); // Object target = point.getTarget(); method = target.getClass().getMethod(methodName, parameterTypes); if (method != null) { boolean hasAnnotation = method.isAnnotationPresent(MyMethodAnno.class); if (hasAnnotation) { MyMethodAnno anno = method.getAnnotation(MyMethodAnno.class); BaseLog log = new BaseLog(); log.setCreateTime(new Timestamp(System.currentTimeMillis())); log.setName("???"); log.setIp("???"); log.setDescription(anno.description()); service.addLog(log); } } }
From source file:cn.powerdash.libsystem.common.validation.ValidateInterceptor.java
License:Open Source License
/** * validate the business logic before executing target method. *//*from ww w. ja v a2 s.co m*/ @Before("findValidateAnnotation()") public void validate(final JoinPoint jp) throws ConstraintViolationException { final Signature signature = jp.getSignature(); final Object[] args = jp.getArgs(); final MethodSignature methodSignature = (MethodSignature) signature; final Method targetMethod = methodSignature.getMethod(); Set<ConstraintViolation<?>> result = new HashSet<ConstraintViolation<?>>(); final Annotation[][] paraAnnotations = targetMethod.getParameterAnnotations();// get the parameters annotations if (paraAnnotations != null && paraAnnotations.length > 0) { for (int i = 0; i < paraAnnotations.length; i++) { int paraAnnotationLength = paraAnnotations[i].length;// current parameter annotation length if (paraAnnotationLength == 0) { // no annotation on current parameter continue; } for (int j = 0; j < paraAnnotationLength; j++) { if (paraAnnotations[i][j] instanceof OnValid) { OnValid validated = (OnValid) (paraAnnotations[i][j]); Class<?>[] groups = (validated.value()); Object validatedObj = args[i]; executeValidate(validatedObj, groups, result); break; } } } } if (!result.isEmpty()) { throw new ConstraintViolationException(result); } }