Example usage for org.aspectj.lang ProceedingJoinPoint getTarget

List of usage examples for org.aspectj.lang ProceedingJoinPoint getTarget

Introduction

In this page you can find the example usage for org.aspectj.lang ProceedingJoinPoint getTarget.

Prototype

Object getTarget();

Source Link

Document

Returns the target object.

Usage

From source file:com.skplanet.tcloud.common.OmcLogAdvice.java

License:Open Source License

/**
 * <pre>/*from   w  w  w  .j  a  va  2  s  .  com*/
 *  ? ?? ?? ? .
 * </pre>
 * @param joinPoint AOP ? ?(logging,exception,etc...) ? ?     ?
 * @return {@link Object} 
 * @throws Throwable
 */
public Object invoke(ProceedingJoinPoint joinPoint) throws Throwable {

    long startTime = System.currentTimeMillis(); //  
    String startTimeStr = ""; // 
    Map<String, Object> inResutlMap = new HashMap<String, Object>(); //    
    Map<String, Object> outResutlMap = new HashMap<String, Object>(); //    
    Map<String, Object> etcResutlMap = new HashMap<String, Object>(); //    
    StopWatch stopWatch = new StopWatch(); // ?  
    Signature signature = joinPoint.getSignature(); // 
    String targetClassName = joinPoint.getTarget().getClass().getName(); // Class Name
    Object returnObj = null;
    // String hostAddress = "";
    HttpServletRequest request = null;
    String key1 = "";

    try {
        // Service ?    - ETC
        SimpleDateFormat sdfYMDHMS = new SimpleDateFormat("yyyyMMddHHmmss");
        startTimeStr = sdfYMDHMS.format(new Date(startTime));
        etcResutlMap.put("serviceName", OmcLogAdvice.JobConstants.SERVICE_NAME);
        etcResutlMap.put("startTimeStr", startTimeStr);
        //         etcResutlMap.put("hostName", hostName+" / "+hostAddress);
        etcResutlMap.put("hostName", localHostName);
        etcResutlMap.put("direction", OmcLogAdvice.JobConstants.DIRECTION_REP);

        // Service   
        inResutlMap = getMakeIn(targetClassName, signature.getName(), joinPoint.getArgs(), request);
        stopWatch.start(joinPoint.toShortString()); // ? 

        // Access ?  IP?   ? .
        //         if (isAccessIp(inResutlMap.get("sysModule"), inResutlMap.get("clientIp"))) {
        if (true) {
            returnObj = joinPoint.proceed(); // Service ? 
            if (stopWatch.isRunning()) {
                stopWatch.stop(); // ? 
            }

            // Service   
            outResutlMap = getMakeOut(returnObj, inResutlMap);
            outResutlMap.put("totalTimeSeconds", stopWatch.getTotalTimeMillis()); // 

            if (inResutlMap.get("requestUrl").toString().contains("regMemberTOI") || // sjsim@20120920
                    inResutlMap.get("requestUrl").toString().contains("regIdpMemberTOI")
                    || inResutlMap.get("requestUrl").toString().contains("modifyMemberIdTOI")
                    || inResutlMap.get("requestUrl").toString().contains("ssoLoginTOI")
                    || inResutlMap.get("signatureName").toString().contains("getSendEmail")) { // sjsim@20130207

                String keyStr = inResutlMap.get("key1").toString();

                if (JobConstants.SERVICE_RESULT_CODE_SUCC.equals(outResutlMap.get("resultCode"))) {
                    if (keyStr.length() >= 5) {
                        if (!keyStr.subSequence(0, 5).equals("memNo")) {
                            ModelAndView mav = (ModelAndView) returnObj;
                            String memNo = mav.getModel().get("memNo").toString();
                            inResutlMap.put("key1", "memNo=" + memNo);
                        }
                    }
                } else {
                    if (keyStr.length() >= 7) {
                        if (!keyStr.subSequence(0, 7).equals("loginId")) {
                            ModelAndView mav = (ModelAndView) returnObj;
                            String loginId = mav.getModel().get("loginId").toString();
                            inResutlMap.put("key1", "loginId=" + loginId);
                        }
                    }
                }

            } else if (JobConstants.SERVICE_SYS_NAME_REQUEST.equals(inResutlMap.get("signatureName"))) {
                if (JobConstants.SERVICE_RESULT_CODE_SUCC.equals(outResutlMap.get("resultCode"))) {
                    if (!inResutlMap.get("key1").toString().subSequence(0, 5).equals("memNo")) {
                        ModelAndView mav = (ModelAndView) returnObj;
                        String memNo = mav.getModel().get("memNo").toString();
                        key1 = "memNo=" + memNo;
                        inResutlMap.put("key1", key1);
                    }
                } else {
                    if (!inResutlMap.get("key1").toString().subSequence(0, 7).equals("loginId")) {
                        ModelAndView mav = (ModelAndView) returnObj;
                        String loginId = mav.getModel().get("loginId").toString();
                        key1 = "loginId=" + loginId;
                        inResutlMap.put("key1", key1);
                    }
                }

                // ? ? ?  KEY1 ? sjsim@20130104
                // ? ? , ?  Key1 ? ?   2013.01.22. jhkwon 
            } else if ("joinMdn".equals(signature.getName()) || "loginMdn".equals(signature.getName())
                    || "secedeMdn".equals(signature.getName())) {
                ModelAndView mav = (ModelAndView) returnObj;
                String memNo = mav.getModel().get("memNo").toString();
                key1 = "memNo=" + memNo;
                inResutlMap.put("key1", key1);
            } else if ("loginMdnEx".equals(signature.getName())) {
                ModelAndView mav = (ModelAndView) returnObj;
                String memNo = mav.getModel().get("memNo").toString();
                key1 = "memNo=" + memNo;
                inResutlMap.put("key1", key1);
                String userMdn = "userMdn="
                        + StringUtils.defaultString(mav.getModel().get("userMdn").toString());
                String etc = userMdn;
                inResutlMap.put("etc", etc);

            } else if ("getSmsKey".equals(signature.getName()) || "getSmsKeyTOI".equals(signature.getName())) {
                ModelAndView mav = (ModelAndView) returnObj;
                String gubun = ",";
                String mdn = key1 + gubun + "mdn="
                        + StringUtils.defaultString(mav.getModel().get("mdn").toString());
                String userMdnType = "userMdnType="
                        + StringUtils.defaultString(mav.getModel().get("userMdnType").toString());
                //String smsAuthKey = "smsAuthKey="+StringUtils.defaultString(mav.getModel().get("smsAuthKey").toString());
                //String etc=mdn+gubun+userMdnType+gubun+smsAuthKey;
                String etc = mdn + gubun + userMdnType + gubun;

                inResutlMap.put("etc", etc);

            } else if (inResutlMap.get("signatureName").toString().contains("startup")) { // dikey@20130220
                for (Object object : joinPoint.getArgs()) {
                    if (object instanceof HttpServletRequest) {
                        request = (HttpServletRequest) object;
                    }
                }

                // key1? ? ?? key2? T store? ? mdn
                if (request != null) {
                    String etc = (String) inResutlMap.get("etc");
                    String deviceId = request.getParameter("deviceId") == null ? ""
                            : request.getParameter("deviceId");
                    etc = etc + "|deviceId=" + deviceId;

                    String userAgent = null;
                    userAgent = request.getHeader("user-agent");
                    if (userAgent != null && !userAgent.trim().isEmpty()) {

                        if (userAgent.contains("T store")) {
                            etc = etc + new StringBuffer("|mdn=").append(
                                    request.getParameter("mdn") == null ? "" : request.getParameter("mdn"))
                                    .toString();
                        }
                    }
                    /*
                     * Tstore -Tcloud?  
                     * - T store? T cloud? ? ?? T cloud ? UV -
                     *    startup.do ? etc? tctd-src? ?? append
                     * 2013-11-26 jung-su.jang  
                     */
                    ModelAndView mav = (ModelAndView) returnObj;
                    if (mav != null && mav.getModel() != null && mav.getModel().get("tcdSrc") != null) {
                        String tcdSrc = mav.getModel().get("tcdSrc").toString();
                        etc += tcdSrc != null ? "|tcd-src=" + tcdSrc : "";
                    }

                    String referer = request.getParameter("referer") == null ? ""
                            : request.getParameter("referer");
                    etc = etc + "|referer=" + referer;

                    String pushId = request.getParameter("pushId");
                    if (pushId != null && !"".equals(pushId)) {
                        etc = etc + "|pushId=" + pushId;
                    }

                    inResutlMap.put("etc", etc);
                }

            } else if ("deviceToDevice".equals(signature.getName())) { // sjsim@20130402
                String etc = (String) inResutlMap.get("etc");
                ModelAndView mav = (ModelAndView) returnObj;
                String medTyCd = mav.getModel().get("medTyCd").toString();

                etc += "|medTyCd=" + medTyCd;
                inResutlMap.put("etc", etc);
            } else if ("omcLog".equals(signature.getName()) || "omcDetailLog".equals(signature.getName())) { // dikey@20130423
                ModelAndView mav = (ModelAndView) returnObj;
                inResutlMap.put("key2", mav.getModel().get("key2").toString());
            }

            String requestUrl = inResutlMap.get("requestUrl") == null ? ""
                    : inResutlMap.get("requestUrl").toString();

            if (requestUrl.contains("regMemberTOI.do") || requestUrl.contains("mdnJoin.do")
                    || requestUrl.contains("regIdpMemberTOI.do")) {
                ModelAndView mav = (ModelAndView) returnObj;

                if (mav.getModel().get("key2") != null)
                    inResutlMap.put("key2", mav.getModel().get("key2").toString());
            }

            /* Tstore-Tcloud ?   omc  ?? ??  ??  
             * ? requestHeader? ? ?   ?? ??  ?   
             *      ? ? put  2013-11-14 jung-su.Jang
             */
            if ("sync".equals(signature.getName())) {
                HttpServletRequest syncRequest = null;
                Object[] args = joinPoint.getArgs();
                for (Object object : args) {
                    if (object instanceof HttpServletRequest) {
                        syncRequest = (HttpServletRequest) object;
                    }
                }
                String tcdSrc = (String) syncRequest.getAttribute("tcdSrc");
                if (tcdSrc != null && !"".equals(tcdSrc)) {
                    String etc = (String) inResutlMap.get("etc");
                    etc += "|tcd-src=" + tcdSrc;
                    inResutlMap.put("etc", etc);
                }
            }
            if ("startupsc".equals(signature.getName())) {
                ModelAndView mav = (ModelAndView) returnObj;
                if (mav != null && mav.getModel() != null) {
                    inResutlMap.put("sessionID",
                            mav.getModel().get("sessionID") != null
                                    && mav.getModel().get("sessionID").toString() != null
                                            ? mav.getModel().get("sessionID").toString()
                                            : "");
                    inResutlMap.put("key1",
                            "memNo=" + mav.getModel().get("key1") != null
                                    && mav.getModel().get("key1").toString() != null
                                            ? mav.getModel().get("key1").toString()
                                            : "memNo=");
                    inResutlMap.put("etc",
                            mav.getModel().get("etc") != null && mav.getModel().get("etc").toString() != null
                                    ? mav.getModel().get("etc").toString()
                                    : "tcd-src=1");
                }
            }
            if ("checkJoinMdn".equals(signature.getName())) {
                ModelAndView mav = (ModelAndView) returnObj;
                if (mav != null && mav.getModel() != null) {
                    inResutlMap.put("etc",
                            "uesrMdn=" + StringUtils.defaultString(mav.getModel().get("userMdn").toString()));
                }
            }

            // ? ? ??  log .
            /* Tstore-Tcloud ? mdnJoinNew ? ? OMC  ? ?? 
             * && !"mdnJoinNew".equals(signature.getName()) 
             * 2013.11.18 jung-su.Jang 
             */
            // ? ? ??  log .
            if (!"".equals(inResutlMap.get("sysModule"))
                    && !(inResutlMap.get("sysModule").equals(JobConstants.SERVICE_SYS_NAME_SAMPLE))
                    && !"mdnJoinNew".equals(signature.getName())
                    && !"mdnJoinNewForm".equals(signature.getName())) {
                //logger.info(makeLogString(inResutlMap, outResutlMap, etcResutlMap, true));
                // artf120005 Token Expire ?  OMC Log ?   by jaeyeon.hwang 2014.03.13
                if (!CodeMessage.RESPONSE_CODE_EXPIRED_TOKEN.equals(outResutlMap.get("resultCode"))) {
                    logger.info(getFilterOmc(makeLogString(inResutlMap, outResutlMap, etcResutlMap, true)));
                }
            }
        }
        return returnObj;

    } catch (UserHandleableException ue) {
        if (!JobConstants.SERVICE_RESULT_UNAUTHORIZED_IP.equals(ue.getErrorCode())) { //   IP?   
            if (stopWatch.isRunning()) {
                stopWatch.stop(); //  ?  
            }
            outResutlMap.put("totalTimeSeconds", stopWatch.getTotalTimeMillis()); // 
            outResutlMap.put("resultCode", ue.getErrorCode());

            /* Tstore-Tcloud ?   omc  ?? ??  ??  
             * ? requestHeader? ? ?   ?? ??  ?   
             *      ? ? put  2013-11-14 jung-su.Jang
             *  */
            if ("startupsc".equals(signature.getName()) || "mdnJoinNew".equals(signature.getName())) {
                inResutlMap.put("etc", "tcd-src=1");
                if ("startupsc".equals(signature.getName())) {
                    outResutlMap.put("resultCode", CodeMessage.RESPONSE_CODE_FAIL);
                    logger.error(makeLogString(inResutlMap, outResutlMap, etcResutlMap, false));
                }
            }
            /* artf113224 mdnLogin - TOKEN Expire ?? memNo     by  
             * Token Expired  AOP ? OMC  ?
             * jaeyeon.hwang 2014.02.18 */
            if (!"startupsc".equals(signature.getName())
                    //artf120005 TokenExpire ?   OMC Log   by jaeyeon.hwang  2014.03.13
                    && !CodeMessage.RESPONSE_CODE_EXPIRED_TOKEN.equals(ue.getErrorCode())) {
                if (JobConstants.SERVICE_RESULT_CODE_FAIL.equals(ue.getErrorCode())) {
                    logger.error(makeLogString(inResutlMap, outResutlMap, etcResutlMap, false));
                } else {
                    logger.error(makeLogString(inResutlMap, outResutlMap, etcResutlMap, true));
                }
            }
        }

        throw new Exception(ue);
    } catch (Exception e) {
        if (stopWatch.isRunning()) {
            stopWatch.stop(); //  ?  
        }
        outResutlMap.put("totalTimeSeconds", stopWatch.getTotalTimeMillis()); // 
        outResutlMap.put("resultCode", JobConstants.SERVICE_RESULT_CODE_FAIL);

        /* Tstore-Tcloud ?   omc  ?? ??  ??  
         * ? requestHeader? ? ?   ?? ??  ?   
         *      ? ? put  2013-11-14 jung-su.Jang
         *  */
        if ("startupsc".equals(signature.getName()) || "mdnJoinNew".equals(signature.getName())) {
            inResutlMap.put("etc", "tcd-src=1");
            if ("startupsc".equals(signature.getName())) {
                outResutlMap.put("resultCode", CodeMessage.RESPONSE_CODE_FAIL);
            }
        } else {
            logger.error(makeLogString(inResutlMap, outResutlMap, etcResutlMap, false));
        }
        throw new Exception(e);
    }
}

From source file:com.skplanet.tcloud.common.ParamAdvice.java

License:Open Source License

public Object doParamFilter(ProceedingJoinPoint joinPoint) throws Throwable {
    TCParam controllerTcParam = joinPoint.getTarget().getClass().getAnnotation(TCParam.class);
    String targetMethodName = StringUtils.nvlStr(joinPoint.getSignature().getName()); // ex) 
    Object[] argObjs = joinPoint.getArgs(); //  ? ? ??
    //boolean isProceed            = false;                                 //  ? 
    String[] filterTypes = null;/*from   ww w  .j  a  va2  s. c  o m*/
    String[] methodNames = null;

    logger.debug("controllerTcParam : " + controllerTcParam + " >> targetMethodName : " + targetMethodName);

    try {
        if (controllerTcParam != null) {
            filterTypes = controllerTcParam.filterTypes();
            methodNames = controllerTcParam.methodNames();

            for (String methodName : methodNames) {
                if (targetMethodName.contains(methodName))
                    doParamProcess(filterTypes, argObjs);
            }
        }
    } catch (Exception e) {
        logger.error("? AOP  !!!", e);
    }

    return joinPoint.proceed();
}

From source file:com.smallchill.core.aop.BeforeAop.java

License:Apache License

@Around("cutBefore()")
public Object doBefore(ProceedingJoinPoint point) throws Throwable {
    HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes())
            .getRequest();/*  w ww  .ja v a  2s.  c  om*/
    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 {
        return result;
    }
}

From source file:com.spidertracks.datanucleus.spring.ConsistencyLevelAspect.java

License:Open Source License

/**
 * Validates any method that has the valid annotation on it and is wired as
 * a spring service/*  w ww.  java2s  .  c  om*/
 * 
 * @param jp
 * @throws Throwable
 */
@Around("@annotation(com.spidertracks.datanucleus.spring.Consistency)")
public Object setConsistency(ProceedingJoinPoint pjp) throws Throwable {

    logger.debug("Invoking before advice for @Consistency annotation.  Target object is {} on method {}",
            pjp.getTarget(), pjp.getSignature());

    MethodSignature sig = (MethodSignature) pjp.getSignature();

    Object[] args = pjp.getArgs();

    Method signatureMethod = sig.getMethod();

    Class<?>[] signatureTypes = signatureMethod.getParameterTypes();

    // we do this because we want to get the best match from the child
    // classes
    Class<?>[] runtimeArgs = new Class<?>[signatureTypes.length];

    for (int i = 0; i < signatureTypes.length; i++) {

        if (args[i] != null) {
            runtimeArgs[i] = args[i].getClass();
        } else {
            runtimeArgs[i] = signatureTypes[i];
        }
    }

    Class<?> runtimeClass = pjp.getTarget().getClass();

    // check if this is annotated, if not proceed and execute it

    ConsistencyLevel level = consistency(runtimeClass, signatureMethod.getName(), runtimeArgs);

    if (level == null) {
        return pjp.proceed(args);
    }

    Stack<ConsistencyLevel> stack = threadStack.get();

    stack.push(level);
    com.spidertracks.datanucleus.client.Consistency.set(level);

    Object result = null;

    try {
        result = pjp.proceed(args);
    } finally {
        stack.pop();

        if (stack.size() > 0) {
            com.spidertracks.datanucleus.client.Consistency.set(stack.peek());
        } else {
            com.spidertracks.datanucleus.client.Consistency.remove();
        }

    }

    return result;
}

From source file:com.spstudio.modules.permission.controller.LoginControlAspect.java

@Around("@annotation(com.spstudio.modules.permission.controller.UserSessionValidator)")
public Object sessionValidationAdvice(ProceedingJoinPoint pjp) throws GenericException, Throwable {
    Object args[] = pjp.getArgs();
    Object result = null;// w ww .  jav  a2  s.c  o  m
    String targetName = pjp.getTarget().getClass().getSimpleName();
    String methodName = pjp.getSignature().getName();
    logger.info("----------------MethodName-----------------");
    logger.info("Class:" + targetName + " Method:" + methodName);

    //HttpSession session = SysContent.getSession();  
    if (session.getAttribute("username") != null) {

        //Logic to check user priviledge
        Privilege checkingFuncationPrivilege = permissionService.findPrivilegeByFuncationName(methodName);

        String userName = (String) session.getAttribute("username");
        LoginUser loginUser = permissionService.getLoginUserByLoginName(userName);

        if (loginUser != null) {
            Set<Privilege> permissionedPrivileges = permissionService.listPrivilegsByLoginUser(loginUser);
            if (permissionedPrivileges.contains(checkingFuncationPrivilege)) {
                result = pjp.proceed(args);
            } else {
                throw new InsufficientPriviledgeException("403", "no permission");
            }
        } else {
            throw new InsufficientPriviledgeException("403", "no permission");
        }

        return result;
    } else {
        //            System.out.println(((MethodSignature)pjp.getSignature()).getReturnType().getSimpleName().toString());  
        String redirectStr = "login";
        String returnType = ((MethodSignature) pjp.getSignature()).getReturnType().getSimpleName().toString();
        if (returnType.equals("String")) {
            return redirectStr;
        } else if (returnType.equals("Map")) {
            Map<String, Object> resMap = new HashMap<>();
            resMap.put("resCode", MessageContent.MSG_CODE_SESSIONOUTOFDATE);
            resMap.put("resMsg", MessageContent.MSG_SESSIONOUTOFDATE);
            return resMap;
        } else {
            throw new SessionTimeOutException(MessageContent.MSG_CODE_SESSIONOUTOFDATE,
                    MessageContent.MSG_SESSIONOUTOFDATE);
        }
    }
}

From source file:com.stee.asm.aop.LoggerAdvice.java

License:Open Source License

@Around("servicePointCut()")
public Object around(ProceedingJoinPoint pjp) throws Throwable {
    logger.doLog(LoggerLevel.INFO, "Invoke --> Class: " + pjp.getTarget().getClass().getSimpleName()
            + " -- Method: " + pjp.getSignature().getName() + " -- Args: " + Arrays.toString(pjp.getArgs()));
    long timeMills = System.currentTimeMillis();
    Object proceed = pjp.proceed();
    logger.doLog(LoggerLevel.INFO,// w w w.j a v  a  2 s.  c  o  m
            "Finish --> Return: " + proceed + " -- Cost: " + (System.currentTimeMillis() - timeMills));
    return proceed;
}

From source file:com.stratelia.webactiv.util.annotation.AnnotationUtil.java

License:Open Source License

/**
 * Provides a centralized way to extract annotation of a method.
 * @param invocationContext/*from  ww w . ja  v  a  2s  .co m*/
 * @return
 * @throws Exception
 */
private static Method getMethodFromContext(Object invocationContext) throws Exception {
    if (invocationContext instanceof ProceedingJoinPoint) {
        ProceedingJoinPoint context = (ProceedingJoinPoint) invocationContext;
        final String methodName = context.getSignature().getName();
        final MethodSignature methodSignature = (MethodSignature) context.getSignature();
        Method method = methodSignature.getMethod();
        if (method.getDeclaringClass().isInterface()) {
            method = context.getTarget().getClass().getDeclaredMethod(methodName, method.getParameterTypes());
        }
        return method;
    } else if (invocationContext instanceof InvocationContext) {
        return ((InvocationContext) invocationContext).getMethod();
    }
    throw new NotImplementedException();
}

From source file:com.stratio.qa.aspects.RunOnTagAspect.java

License:Apache License

/**
 * Allows conditional scenario execution.
 * If the scenario contains the following tag:
 * <dl>//from  www .jav  a2 s  .co m
 *    <dt>\@runOnEnv(param)</dt>
 *<dd>The scenario will only be executed if the param is defined when test is launched. Configuration map object.
 * More than one param can be passed in the tag. To do so, the params must be comma separated:
 * \@runOnEnv(param): The scenario will only be executed if the param is defined when test is launched.
 * \@runOnEnv(param1,param2,param3): The scenario will only be executed if ALL the params are defined.
 * </dd>
 * </dl>
 * Additionally, if the scenario contains the following tag:
 * <dl>
 *    <dt>\@skipOnEnv(param)</dt>
 *<dd>The scenario will be omitted if the param is defined when test is launched.
 * More than one param can be passed in the tag. To do so, the params must be comma separated.
 * The scenario will omitted if ANY of params are defined. (OR)</dd>
 *
 *<dd>Or in separated lines to force ALL of the params to be defined in order to omit the execution</dd>
 *    <dt>  \@skipOnEnv(param1)
 *          \@skipOnEnv(param2)
 *          \@skipOnEnv(param3)</dt>
 *<dd>The scenario will omitted if ALL of params are defined. (AND)</dd>
 *</dl>
 *
 * @param pjp ProceedingJoinPoint
 * @param comments comments
 * @param tags tags of scenario
 * @param keyword keyword
 * @param name name
 * @param description description
 * @param line line
 * @param id id
 * @throws Throwable exception
 */
@Around(value = "AddRunOnTagPointcutScenario(comments, tags, keyword, name, description, line, id)")
public void aroundAddRunOnTagPointcut(ProceedingJoinPoint pjp, List<Comment> comments, List<Tag> tags,
        String keyword, String name, String description, Integer line, String id) throws Throwable {

    Scenario linescn = (Scenario) pjp.getTarget();
    Boolean exit = tagsIteration(tags, line);

    if (exit) {
        ThreadProperty.set("skippedOnParams" + pjp.getArgs()[3].toString() + linescn.getLine(), "true");
    }
}

From source file:com.stratio.qa.aspects.SeleniumAspect.java

License:Apache License

/**
 * If an exception has thrown by selenium, this methods save a screen
 * capture.//ww w  .j a  va  2  s. c o m
 *
 * @param pjp ProceedingJoinPoint
 * @return Object object
 * @throws Throwable exception
 */
@Around(value = "exceptionCallPointcut()")
public Object aroundExceptionCalls(ProceedingJoinPoint pjp) throws Throwable {
    Object retVal = null;
    try {
        retVal = pjp.proceed();
        return retVal;
    } catch (Throwable ex) {
        WebDriver driver = null;
        if (ex instanceof WebDriverException) {
            logger.info("Got a selenium exception");
            if (!(pjp.getThis() instanceof WebDriver)) {
                throw ex;
            }
            driver = (WebDriver) pjp.getThis();
        } else if ((pjp.getTarget() instanceof SeleniumAssert) && (ex instanceof AssertionError)) {
            logger.info("Got a SeleniumAssert response");
            SeleniumAssert as = (SeleniumAssert) pjp.getTarget();
            Class<?> c = as.getClass().getSuperclass();
            Field actual = c.getDeclaredField("actual");
            actual.setAccessible(true);
            Object realActual = actual.get(as);

            if (realActual instanceof WebDriver) {
                driver = (WebDriver) actual.get(as);
            } else if (realActual instanceof ArrayList) {
                if (((ArrayList) realActual).get(0) instanceof RemoteWebElement) {
                    driver = ((RemoteWebElement) ((ArrayList) realActual).get(0)).getWrappedDriver();
                }
            } else if ((realActual instanceof PreviousWebElements) || (realActual instanceof Boolean)
                    || (realActual instanceof String) || (realActual == null)) {
                driver = ((CommonG) ((SeleniumAssert) pjp.getTarget()).getCommonspec()).getDriver();
            } else if (realActual instanceof RemoteWebElement) {
                driver = ((RemoteWebElement) actual.get(as)).getWrappedDriver();
            }
        }
        if (driver != null) {
            logger.info("Trying to capture screenshots...");
            CommonG common = null;
            if ((pjp.getThis() instanceof ThenGSpec) && (((ThenGSpec) pjp.getThis()).getCommonSpec() != null)) {
                common = ((ThenGSpec) pjp.getThis()).getCommonSpec();
            } else if ((pjp.getTarget() instanceof SeleniumAssert)
                    && ((SeleniumAssert) pjp.getTarget()).getCommonspec() != null) {
                common = ((CommonG) ((SeleniumAssert) pjp.getTarget()).getCommonspec());
            } else {
                logger.info("Got no Selenium driver to capture a screen");
                throw ex;
            }
            common.captureEvidence(driver, "framehtmlSource", "assert");
            common.captureEvidence(driver, "htmlSource", "assert");
            common.captureEvidence(driver, "screenCapture", "assert");
            logger.info("Screenshots are available at target/executions");
        } else {
            logger.info("Got no Selenium driver to capture a screen");
        }
        throw ex;
    }
}

From source file:com.tikal.tallerWeb.servicio.monitor.imp.EditorMonitorImpV3.java

License:Apache License

@Around("modelChange()")
public void updateProperty(ProceedingJoinPoint pjp) throws Throwable {
    if (encendido && activo) {
        Object target = pjp.getTarget();
        Object proxyTarget = AopContext.currentProxy();
        if (!(target instanceof Metadata)) {
            String methodName = pjp.getSignature().getName();
            String propertyName = StringUtils.substringAfter(methodName, "set");
            String primeraLetra = propertyName.charAt(0) + "";
            propertyName = primeraLetra.toLowerCase() + StringUtils.substringAfter(propertyName, primeraLetra);
            processChange(proxyTarget, propertyName, pjp.getArgs()[0]);
        }/*from   w  ww. j av  a2 s .c o  m*/
    }
    pjp.proceed();
}