Example usage for org.aspectj.lang ProceedingJoinPoint getSignature

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

Introduction

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

Prototype

Signature getSignature();

Source Link

Document

getStaticPart().getSignature() returns the same object

Usage

From source file:com.sccl.attech.common.advice.CustomJsonFilterAdvice.java

License:Open Source License

/**
 * Do around.// ww w . j  a v  a 2 s . c om
 * 
 * @param pjp the pjp
 * @return the object
 * @throws Throwable the throwable
 */
@Around("execution(* com.sccl.attech.modules.template.web.*.*(..))")
public Object doAround(ProceedingJoinPoint pjp) throws Throwable {
    MethodSignature msig = (MethodSignature) pjp.getSignature();
    HttpServletResponse response = getResponse(pjp.getArgs());
    CustomJsonFilter annotation = msig.getMethod().getAnnotation(CustomJsonFilter.class);
    CustomJsonFilters annotations = msig.getMethod().getAnnotation(CustomJsonFilters.class);

    if ((annotation == null && annotations == null) || null == response) {
        return pjp.proceed();
    }

    JsonMapper mapper = new JsonMapper();
    if (annotation != null) {
        Class<?> mixin = annotation.mixin();
        Class<?> target = annotation.target();

        if (target != null) {
            mapper.addMixInAnnotations(target, mixin);
        } else {
            mapper.addMixInAnnotations(msig.getMethod().getReturnType(), mixin);
        }
    }

    if (annotations != null) {
        CustomJsonFilter[] filters = annotations.filters();
        for (CustomJsonFilter filter : filters) {
            Class<?> mixin = filter.mixin();
            Class<?> target = filter.target();
            if (target != null) {
                mapper.addMixInAnnotations(target, mixin);
            } else {
                mapper.addMixInAnnotations(msig.getMethod().getReturnType(), mixin);
            }
        }

    }

    try {
        //         response.setCharacterEncoding("UTF-8");
        mapper.writeValue(response.getOutputStream(), pjp.proceed());
        return null;
    } catch (Exception ex) {
        throw new RuntimeException(ex);
    }
    // return null;
}

From source file:com.seleniumtests.core.aspects.LogAction.java

License:Apache License

@Around("execution(public * com.seleniumtests.uipage.PageObject+.* (..)) "
        + "|| execution(public * com.seleniumtests.uipage.htmlelements.HtmlElement+.* (..))")
public Object logDebug(ProceedingJoinPoint joinPoint) throws Throwable {
    if (LogAction.indent.get(Thread.currentThread()) == null) {
        LogAction.indent.put(Thread.currentThread(), 0);
    }// w  ww  .  ja  v a2 s  .  c om

    String currentIndent = StringUtils.repeat(" ", LogAction.indent.get(Thread.currentThread()));
    logger.debug(String.format("%sEntering %s", currentIndent, joinPoint.getSignature()));
    Object reply = null;
    try {
        LogAction.indent.put(Thread.currentThread(), LogAction.indent.get(Thread.currentThread()) + 2);
        reply = joinPoint.proceed(joinPoint.getArgs());
    } catch (Throwable e) {
        logger.debug(String.format("%sError in %s: %s - %s", currentIndent, joinPoint.getSignature(),
                e.getClass().getName(), e.getMessage()));
        throw e;
    } finally {
        LogAction.indent.put(Thread.currentThread(), LogAction.indent.get(Thread.currentThread()) - 2);
        logger.debug(String.format("%sFinishing %s: %s", currentIndent, joinPoint.getSignature(),
                buildReplyValues(reply)));
    }
    return reply;
}

From source file:com.seleniumtests.core.aspects.LogAction.java

License:Apache License

/**
 * Log this method call as a test step//from  w  w  w  .j a va 2s .  c o  m
 * @param joinPoint         the join point
 * @param stepNamePrefix   string to add before step name
 * @param configStep      is this method call a TestNG configuration method (\@BeforeXXX or \@AfterXXX)
 * @return
 * @throws Throwable
 */
private Object logTestStep(ProceedingJoinPoint joinPoint, String stepNamePrefix, boolean configStep)
        throws Throwable {

    // skip test logging when manual steps are active. This avoid having steps logged twice.
    // do not skip configuration step logging so that debugging remains easy
    if ((SeleniumTestsContextManager.getThreadContext().isManualTestSteps() && !configStep)
            // skip internal configuration steps
            || joinPoint.getSignature().getDeclaringTypeName().startsWith("com.seleniumtests.core")) {
        return joinPoint.proceed(joinPoint.getArgs());
    }

    return commonLogTestStep(joinPoint, stepNamePrefix, configStep);
}

From source file:com.seleniumtests.core.aspects.LogAction.java

License:Apache License

/**
 * Log an action inside a TestStep/*from  w  w w . j a  v a  2 s  . c  o  m*/
 * @param joinPoint      the joinPoint
 * @param targetName   target on which action is done (page or element)
 * @return
 * @throws Throwable 
 */
private Object logAction(ProceedingJoinPoint joinPoint, String targetName) throws Throwable {
    List<String> pwdToReplace = new ArrayList<>();
    String actionName = String.format("%s on %s %s", joinPoint.getSignature().getName(), targetName,
            buildArgString(joinPoint, pwdToReplace, new HashMap<>()));
    Object reply = null;
    boolean actionFailed = false;
    TestAction currentAction = new TestAction(actionName, false, pwdToReplace);

    // log action before its started. By default, it's OK. Then result may be overwritten if step fails
    // order of steps is the right one (first called is first displayed)   
    if (TestLogging.getParentTestStep() != null) {
        TestLogging.getParentTestStep().addAction(currentAction);
    }

    try {
        reply = joinPoint.proceed(joinPoint.getArgs());
    } catch (Throwable e) {
        actionFailed = true;
        throw e;
    } finally {
        if (TestLogging.getParentTestStep() != null) {
            currentAction.setFailed(actionFailed);
        }
    }
    return reply;
}

From source file:com.seleniumtests.uipage.aspects.ReplayAction.java

License:Apache License

/**
 * Replay all HtmlElement actions annotated by ReplayOnError.
 * Classes which are not subclass of HtmlElement won't go there 
 * See javadoc of the annotation for details
 * @param joinPoint//from ww  w .j  a  va  2 s  .  c  om
 * @throws Throwable
 */
@Around("execution(public * com.seleniumtests.uipage.htmlelements.HtmlElement+.* (..))"
        + "&& execution(@com.seleniumtests.uipage.ReplayOnError public * * (..)) && @annotation(replay)")
public Object replayHtmlElement(ProceedingJoinPoint joinPoint, ReplayOnError replay) throws Throwable {

    Instant end = systemClock.instant()
            .plusSeconds(SeleniumTestsContextManager.getThreadContext().getReplayTimeout());
    Object reply = null;

    // update driver reference of the element
    // corrects bug of waitElementPresent which threw a SessionNotFoundError because driver reference were not
    // updated before searching element (it used the driver reference of an old test session)
    HtmlElement element = (HtmlElement) joinPoint.getTarget();
    element.setDriver(WebUIDriver.getWebDriver());
    String targetName = joinPoint.getTarget().toString();

    TestAction currentAction = null;
    String methodName = joinPoint.getSignature().getName();
    if (methodName != "getCoordinates") {
        List<String> pwdToReplace = new ArrayList<>();
        String actionName = String.format("%s on %s %s", methodName, targetName,
                LogAction.buildArgString(joinPoint, pwdToReplace, new HashMap<>()));
        currentAction = new TestAction(actionName, false, pwdToReplace);
    }

    // log action before its started. By default, it's OK. Then result may be overwritten if step fails
    // order of steps is the right one (first called is first displayed)
    if (currentAction != null && isHtmlElementDirectlyCalled(Thread.currentThread().getStackTrace())
            && TestLogging.getParentTestStep() != null) {
        TestLogging.getParentTestStep().addAction(currentAction);
    }

    boolean actionFailed = false;
    boolean ignoreFailure = false;

    try {
        while (end.isAfter(systemClock.instant())) {

            // in case we have switched to an iframe for using previous webElement, go to default content
            if (element.getDriver() != null && SeleniumTestsContextManager.isWebTest()) {
                element.getDriver().switchTo().defaultContent(); // TODO: error when clic is done, closing current window
            }

            try {
                reply = joinPoint.proceed(joinPoint.getArgs());
                WaitHelper.waitForMilliSeconds(200);
                break;
            } catch (UnhandledAlertException e) {
                throw e;
            } catch (WebDriverException e) {

                // don't prevent TimeoutException to be thrown when coming from waitForPresent
                // only check that cause is the not found element and not an other error (NoSucheSessionError for example)
                if ((e instanceof TimeoutException
                        && joinPoint.getSignature().getName().equals("waitForPresent")
                        && e.getCause() instanceof NoSuchElementException) // issue #104: do not log error when waitForPresent raises TimeoutException
                        || (e instanceof NoSuchElementException
                                && isFromExpectedConditions(Thread.currentThread().getStackTrace())) // issue #194: return immediately if the action has been performed from ExpectedConditions class
                //   This way, we let the FluentWait process to retry or re-raise the exception
                ) {
                    ignoreFailure = true;
                    throw e;
                }

                if (end.minusMillis(200).isAfter(systemClock.instant())) {
                    WaitHelper.waitForMilliSeconds(replay.replayDelayMs());
                    continue;
                } else {
                    if (e instanceof NoSuchElementException) {
                        throw new NoSuchElementException("Searched element could not be found");
                    } else if (e instanceof UnreachableBrowserException) {
                        throw new WebDriverException("Browser did not reply, it may have frozen");
                    }
                    throw e;
                }
            }

        }
        return reply;
    } catch (Throwable e) {

        if (e instanceof NoSuchElementException && joinPoint.getTarget() instanceof HtmlElement
                && (joinPoint.getSignature().getName().equals("findElements")
                        || joinPoint.getSignature().getName().equals("findHtmlElements"))) {
            return new ArrayList<WebElement>();
        } else {
            actionFailed = true && !ignoreFailure;
            throw e;
        }
    } finally {
        if (currentAction != null && isHtmlElementDirectlyCalled(Thread.currentThread().getStackTrace())
                && TestLogging.getParentTestStep() != null) {
            currentAction.setFailed(actionFailed);
        }
    }
}

From source file:com.seleniumtests.uipage.aspects.ReplayAction.java

License:Apache License

/**
 * Replay all actions annotated by ReplayOnError if the class is not a subclass of 
 * HtmlElement/*from  w ww  .  j ava2 s  .co  m*/
 * @param joinPoint
 * @throws Throwable
 */
@Around("!execution(public * com.seleniumtests.uipage.htmlelements.HtmlElement+.* (..))"
        + "&& execution(@com.seleniumtests.uipage.ReplayOnError public * * (..)) && @annotation(replay)")
public Object replay(ProceedingJoinPoint joinPoint, ReplayOnError replay) throws Throwable {

    int replayDelayMs = replay != null ? replay.replayDelayMs() : 100;

    Instant end = systemClock.instant()
            .plusSeconds(SeleniumTestsContextManager.getThreadContext().getReplayTimeout());
    Object reply = null;

    String targetName = joinPoint.getTarget().toString();
    TestAction currentAction = null;

    if (joinPoint.getTarget() instanceof GenericPictureElement) {
        String methodName = joinPoint.getSignature().getName();
        List<String> pwdToReplace = new ArrayList<>();
        String actionName = String.format("%s on %s %s", methodName, targetName,
                LogAction.buildArgString(joinPoint, pwdToReplace, new HashMap<>()));
        currentAction = new TestAction(actionName, false, pwdToReplace);

        // log action before its started. By default, it's OK. Then result may be overwritten if step fails
        // order of steps is the right one (first called is first displayed)
        if (isHtmlElementDirectlyCalled(Thread.currentThread().getStackTrace())
                && TestLogging.getParentTestStep() != null) {
            TestLogging.getParentTestStep().addAction(currentAction);
        }
    }

    boolean actionFailed = false;

    try {
        while (end.isAfter(systemClock.instant())) {

            try {
                reply = joinPoint.proceed(joinPoint.getArgs());
                WaitHelper.waitForMilliSeconds(200);
                break;
            } catch (Throwable e) {

                // do not replay when error comes from test writing or configuration
                if (e instanceof ScenarioException || e instanceof ConfigurationException
                        || e instanceof DatasetException) {
                    throw e;
                }

                if (end.minusMillis(200).isAfter(systemClock.instant())) {
                    WaitHelper.waitForMilliSeconds(replayDelayMs);
                    continue;
                } else {
                    throw e;
                }
            }
        }
        return reply;
    } catch (Throwable e) {
        actionFailed = true;
        throw e;
    } finally {
        if (currentAction != null && isHtmlElementDirectlyCalled(Thread.currentThread().getStackTrace())
                && TestLogging.getParentTestStep() != null) {
            currentAction.setFailed(actionFailed);

            if (joinPoint.getTarget() instanceof GenericPictureElement) {
                currentAction.setDurationToExclude(
                        ((GenericPictureElement) joinPoint.getTarget()).getActionDuration());
            }
        }
    }
}

From source file:com.si.xe.trader.infra.util.ProfilingAspect.java

License:Apache License

@Around("methodsToBeProfiled()")
public Object profile(ProceedingJoinPoint pjp) throws Throwable {
    StopWatch sw = new StopWatch(getClass().getSimpleName());
    try {// w w w  . j  a  va  2  s. c  om
        sw.start(pjp.getSignature().getName());
        return pjp.proceed();
    } finally {
        sw.stop();
        System.out.println(sw.getLastTaskName() + sw.shortSummary());
    }

}

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

License:Open Source License

/**
 * <pre>/*  w ww  .  j a  va 2  s .  co m*/
 *  ? ?? ?? ? .
 * </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 www . j a  v  a 2s .  c om*/
    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();/*from  w ww . j a v  a2  s  . c  o m*/
    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;
    }
}