Example usage for org.aspectj.lang JoinPoint getArgs

List of usage examples for org.aspectj.lang JoinPoint getArgs

Introduction

In this page you can find the example usage for org.aspectj.lang JoinPoint getArgs.

Prototype

Object[] getArgs();

Source Link

Usage

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);
                        }//w w  w  .  ja v a2s  . c  o  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);
            }//from w  w  w  . j  av  a2 s. c  om

        }
    }

    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   ww  w  .jav a2s .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  www. j av a 2 s .  c  o m

        }
    }

    return ruleResponseList;
}

From source file:at.ac.tuwien.infosys.jcloudscale.server.aspects.eventing.ObjectLifecycleEventAspect.java

License:Apache License

@AfterReturning(pointcut = "execution(public String at.ac.tuwien.infosys.jcloudscale.server.JCloudScaleServer.createNewCloudObject(..))", returning = "ret")
public void matchObjectCreated(JoinPoint jp, String ret) throws JCloudScaleException {

    try {/*from   w  w  w .  j  ava2 s.  co  m*/
        ObjectCreatedEvent event = new ObjectCreatedEvent();
        initializeBaseEventProperties(event);
        UUID objectId = UUID.fromString(ret);
        event.setObjectId(objectId);
        JCloudScaleServer server = (JCloudScaleServer) jp.getThis();
        // XXX AbstractJCloudScaleServerRunner
        // UUID serverId = JCloudScaleServerRunner.getInstance().getId();
        UUID serverId = AbstractJCloudScaleServerRunner.getInstance().getId();
        event.setHostId(serverId);
        ClassLoader cl = server.getCloudObjectClassLoader(objectId);
        Class<?> theClazz = Class.forName((String) (jp.getArgs()[0]), true, cl);
        event.setObjectType(theClazz);
        getMqHelper().sendEvent(event);
        log.finer("Sent object created for object " + objectId.toString());
    } catch (Exception e) {
        e.printStackTrace();
        log.severe("Error while triggering ObjectCreatedEvent: " + e.getMessage());
    }

}

From source file:cn.com.infcn.superspider.service.impl.CheckHandlerImpl.java

/**
 * DB?//w  w  w .ja v  a 2 s  . c o m
 *
 * @author lihf
 * @date 2016420 ?6:28:01
 * @param joinPoint
 * @throws Exception
 */
@SuppressWarnings("null")
@Deprecated
@Override
public void checkDataBase(JoinPoint joinPoint) throws Exception {
    init();
    Date expireDate = this.license.getExpireDate();
    Date currentDay = new Date();
    SimpleDateFormat dataFormat = new SimpleDateFormat("yyyy-MM-dd");
    String currentDayStr = dataFormat.format(currentDay);
    Date toDay = dataFormat.parse(currentDayStr);
    boolean verifyFlag = toDay.after(expireDate);
    if (verifyFlag) {
        throw new Exception("??");
    }

    logger.debug("??" + joinPoint.getTarget().getClass().getName() + " ??"
            + joinPoint.getSignature().getName());
    logger.debug("-----------------DB?-------------------------------");
    Object[] args = joinPoint.getArgs();
    for (int i = 0; i < args.length; i++) {
        logger.debug(args[i]);
        if (args[i] instanceof DbConfig) {
            DbConfig dbConfig = (DbConfig) args[i];
            //            Map<String, Integer> map = licenseDb.getDbSupport();
            Map<String, Integer> map = null;
            String dbType = dbConfig.getDsType();
            Integer num = map.get(dbType);
            if (null == num) {
                throw new Exception("" + dbType + "??");
            }
            Map<String, Object> params = new HashMap<String, Object>();
            params.put("dsType", dbType);
            String hql = " select count(t.dsId) from DbSource t where t.dsType=:dsType ";
            long count = dbSourceDao.count(hql, params);
            if (count >= num.longValue()) {
                throw new Exception(
                        "" + dbType + "??" + num.longValue() + "?");
            }

        }
    }
    logger.debug("-----------------DB??-------------------------------");
}

From source file:cn.org.once.cstack.aspects.DeploymentAspect.java

License:Open Source License

@Before("execution(* cn.org.once.cstack.service.DeploymentService.create(..))")
public void beforeDeployment(JoinPoint joinPoint) throws MonitorException {
    try {//  w w w. j  av a 2 s  .  co m
        User user = this.getAuthentificatedUser();
        Application application = (Application) joinPoint.getArgs()[0];
        Message message = null;
        switch (joinPoint.getSignature().getName().toUpperCase()) {
        case createType:
            message = MessageUtils.writeBeforeDeploymentMessage(user, application, createType);
            break;
        }
        if (message != null) {
            logger.info(message.toString());
            messageService.create(message);
        }

    } catch (ServiceException e) {
        throw new MonitorException("Error afterReturningApplication", e);

    }
}

From source file:cn.org.once.cstack.aspects.FileExplorerAspect.java

License:Open Source License

@AfterReturning("execution(* cn.org.once.cstack.service.FileService.deleteFilesFromContainer(..))"
        + " || execution(* cn.org.once.cstack.service.FileService.sendFileToContainer(..))")
public void afterReturningFileExplorer(JoinPoint joinPoint) throws ServiceException {
    Message message = new Message();
    User user = getAuthentificatedUser();
    message.setDate(new Date());
    message.setType(Message.INFO);//from   w ww . j  a v a  2  s  .  c om
    message.setAuthor(user);
    message.setApplicationName((String) joinPoint.getArgs()[0]);

    switch (joinPoint.getSignature().getName().toUpperCase()) {
    case "DELETEFILESFROMCONTAINER":
        message.setEvent(user.getLogin() + " has removed this file : " + joinPoint.getArgs()[2]);
        break;
    }
    this.messageService.create(message);
}

From source file:cn.org.once.cstack.aspects.JsonInputLoggerAspect.java

License:Open Source License

@Before("execution(* cn.org.once.cstack.controller.*.*(cn.org.once.cstack.dto.JsonInput))")
public void traceAll(JoinPoint joinPoint) {
    Logger logger = LoggerFactory.getLogger(joinPoint.getClass());
    logger.debug(joinPoint.getArgs()[0].toString());
}

From source file:cn.org.once.cstack.aspects.ModuleAspect.java

License:Open Source License

@Before("execution(* cn.org.once.cstack.service.ModuleService.remove(..)) "
        + "|| execution(* cn.org.once.cstack.service.ModuleService.initModule(..))")
public void beforeModule(JoinPoint joinPoint) throws MonitorException, ServiceException {

    User user = getAuthentificatedUser();
    Message message = null;// ww  w .  j ava  2  s  . c o  m

    Module module = null;
    switch (joinPoint.getSignature().getName().toUpperCase()) {

    case initModule:
        Application application = (Application) joinPoint.getArgs()[0];
        module = (Module) joinPoint.getArgs()[1];
        message = MessageUtils.writeBeforeModuleMessage(user, module.getName(), application.getDisplayName(),
                createType);
        logger.info(message.toString());
        messageService.create(message);
        break;

    }

}