Example usage for org.aspectj.lang ProceedingJoinPoint getArgs

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

Introduction

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

Prototype

Object[] getArgs();

Source Link

Usage

From source file:com.polydeucesys.kaos.example.aspect.StringSharerAspects.java

License:Apache License

@Around("readLinePointcut(msg)")
public Object modifyMessage(ProceedingJoinPoint pjp, String msg) throws Throwable {
    Strategy<String> strategy = ConfigurationFactory.getInstance().getConfiguration()
            .strategyForName("msg-aspect");
    if (!isReadStarted) {
        strategy.start();/* w  ww .  ja va 2s  .  c  o m*/
        isReadStarted = true;
    }
    for (Behaviour before : strategy.beforeBehaviours()) {
        before.execute();
    }
    String work = msg;
    Object[] args = pjp.getArgs();
    for (Modifier<String> m : strategy.modifiers()) {
        work = m.modify(work);
    }
    args[0] = work;
    Object res = pjp.proceed(args);
    for (Behaviour after : strategy.afterBehaviours()) {
        after.execute();
    }
    return res;
}

From source file:com.qbao.cat.plugin.DefaultPluginTemplate.java

License:Apache License

public Object proxyCollector(ProceedingJoinPoint pjp) throws Throwable {
    Transaction transaction = proxyBeginLog(pjp);
    Object obj = null;//  w w w  .j  a  v a 2  s.co m
    try {
        obj = pjp.proceed();
        proxySuccess(transaction);
        return obj;
    } catch (Throwable e) {
        exception(transaction, e);
        throw e;
    } finally {
        proxyEndLog(transaction, obj, pjp.getArgs());
    }
}

From source file:com.qcadoo.mes.states.aop.StateChangePhaseAspect.java

License:Open Source License

@Around("(execution(@com.qcadoo.mes.states.annotation.StateChangePhase * *.*(..)) "
        + "|| execution(public void com.qcadoo.mes.states.service.StateChangeService.changeState(..)) "
        + "|| execution(public void com.qcadoo.mes.states.service.StateChangeService.changeStatePhase(..))) "
        + "&& args(stateChangeContext,..) && within(com.qcadoo.mes.states.service.StateChangeService+)")
public Object omitExecutionIfStateChangeEntityHasErrors(final ProceedingJoinPoint pjp,
        final StateChangeContext stateChangeContext) throws Throwable {
    stateChangeContext.save();//  www.  j  a va2 s  .  c  om
    Object result = null;
    if (StateChangePhaseUtil.canRun(stateChangeContext)) {
        result = pjp.proceed(pjp.getArgs());
    } else {
        if (LOGGER.isDebugEnabled()) {
            LOGGER.debug(String.format(CANCELING_MSG_TMPL, stateChangeContext));
        }
        stateChangeContext.setStatus(StateChangeStatus.FAILURE);
        if (!stateChangeContext.save()) {
            if (LOGGER.isErrorEnabled()) {
                LOGGER.error(String.format(CANNOT_SAVE_STATE_CHANGE_ENTITY, stateChangeContext));
            }
        }
    }
    return result;
}

From source file:com.qmetry.qaf.automation.step.JavaStepReporter.java

License:Open Source License

@Around("execution(@QAFTestStep * *.*(..))")
public Object javaTestStep(ProceedingJoinPoint jp, JoinPoint.StaticPart thisJoinPointStaticPart)
        throws Throwable {
    JavaStep testStep = null;// w w  w.  ja va2  s .c om
    Signature sig = null;

    try {
        sig = thisJoinPointStaticPart.getSignature();
        if ((sig instanceof MethodSignature)
                && TestBaseProvider.instance().get().getContext().getBoolean(JavaStep.ATTACH_LISTENER, true)) {
            // this must be a call or execution join point
            Method method = ((MethodSignature) sig).getMethod();

            testStep = new MockJavaStep(method, jp);
            if (null != jp.getArgs()) {
                testStep.setActualArgs(jp.getArgs());
            }
        }
    } catch (Exception e) {
        // ignore it...
    }

    if (ConfigurationManager.getBundle().getBoolean("method.recording.mode", false)) {
        ConfigurationManager.getBundle().setProperty("method.param.names",
                ((MethodSignature) sig).getParameterNames());
        return null;
    } else {
        // unblock for sub-steps
        TestBaseProvider.instance().get().getContext().setProperty(JavaStep.ATTACH_LISTENER, true);
        if (null != testStep) {
            try {
                return testStep.execute();
            } catch (JPThrowable e) {
                throw e.getCause();
            }
        } else {

            // this call is from text client (bdd/kwd/excel)
            testStep = (JavaStep) TestBaseProvider.instance().get().getContext()
                    .getProperty("current.teststep");
            testStep.setFileName(jp.getSourceLocation().getFileName());
            testStep.setLineNumber(jp.getSourceLocation().getLine());
            testStep.signature = jp.getSignature().toLongString();

            return jp.proceed();

        }

    }

}

From source file:com.qpark.eip.core.spring.statistics.FlowExecutionLog.java

License:Open Source License

/**
 * Aspect around the execution of the invokeFlow method of all
 * {@link com.qpark.eip.inf.Flow} implementations.
 *
 * @param joinPoint/*  w  ww  .  j  a  va2 s . c  o  m*/
 *            The {@link ProceedingJoinPoint}.
 * @return the result of the flow.
 * @throws Throwable
 */
@Around(value = "execution(* com.qpark.eip.inf.Flow+.invokeFlow(..)) || execution(public * com.qpark.eip.inf.FlowGateway+.*(..))")
public Object invokeFlowAspect(final ProceedingJoinPoint joinPoint) throws Throwable {
    long start = System.currentTimeMillis();
    String interfaceName = this.getInterfaceName(joinPoint);
    String methodName = this.getMethodName(joinPoint);
    String userName = "";
    if (joinPoint.getArgs().length > 0 && joinPoint.getArgs()[0] != null) {
        userName = this.messageContentProvider.getUserName(joinPoint.getArgs()[0]);
    }
    this.logger.debug("+{}.{}({})", interfaceName, methodName, userName);
    Object result = null;
    try {
        result = joinPoint.proceed();
    } catch (Throwable t) {
        this.logger.debug(" {}.{}({}) failed with {}: {}", interfaceName, methodName, userName,
                t.getClass().getSimpleName(), t.getMessage());
        throw t;
    } finally {
        this.logger.debug("-{}.{}({}) {}", interfaceName, methodName, userName,
                DateUtil.getDuration(start, System.currentTimeMillis()));
    }
    return result;
}

From source file:com.rover12421.shaka.apktool.AspjectJ.apktool_cli.MultiLanguageAj.java

License:Apache License

@Around("call(* java.lang.String.format(..))" + "&& args(format, args)"
        + "&& !within(com.rover12421.shaka.apktool.AspjectJ.apktool_cli.MultiLanguageAj)")
public String around_String_format(ProceedingJoinPoint joinPoint, String format, Object... args)
        throws Throwable {
    return covertLocaleInfo((String) joinPoint.proceed(joinPoint.getArgs()));
}

From source file:com.rover12421.shaka.apktool.lib.AndrolibAj.java

License:Apache License

@Around("execution(* brut.androlib.Androlib.decodeSourcesRaw(..))" + "&& args(apkFile, outDir, filename)")
public void decodeSourcesRaw(ProceedingJoinPoint joinPoint, ExtFile apkFile, File outDir, String filename)
        throws Throwable {
    /**// ww  w . j  ava2 s  .  co  m
     * ??dex,?classes.dex?copy,unkownfiles???
     */
    if (filename.equals("classes.dex")) {
        joinPoint.proceed(joinPoint.getArgs());
    }
}

From source file:com.rover12421.shaka.apktool.lib.AndrolibAj.java

License:Apache License

@Around("execution(* brut.androlib.Androlib.readMetaFile(..))")
public MetaInfo readMetaFile(ProceedingJoinPoint joinPoint) throws Throwable {
    metaInfo = (MetaInfo) joinPoint.proceed(joinPoint.getArgs());
    return metaInfo;
}

From source file:com.rover12421.shaka.apktool.lib.AndrolibResourcesAj.java

License:Apache License

/**
 * png?//from   w  w w.  ja va  2s.  c  om
 * brut.androlib.res.AndrolibResources
 * public void aaptPackage(File apkFile, File manifest, File resDir, File rawDir, File assetDir, File[] include)
 */
@Around("execution(* brut.androlib.res.AndrolibResources.aaptPackage(..))"
        + "&& args(apkFile, manifest, resDir, rawDir, assetDir, include)")
public void aaptPackage_around(ProceedingJoinPoint joinPoint, File apkFile, File manifest, File resDir,
        File rawDir, File assetDir, File[] include) throws Throwable {

    AndrolibResources thiz = (AndrolibResources) joinPoint.getThis();
    doNotCompress_in_aapt_fix(thiz);

    /**
     * ?10,?
     */
    int max = 10;
    PrintStream olderr = System.err;
    String lastErrInfo = null;
    while (max-- > 0) {

        try (ByteArrayOutputStream baos = new ByteArrayOutputStream(); PrintStream ps = new PrintStream(baos)) {
            System.setErr(ps);
            try {
                joinPoint.proceed(joinPoint.getArgs());
                System.setErr(olderr);
                /**
                 * ????
                 */
                fuckNotDefinedRes_clearAddRes(apkFile);
                break;
            } catch (Throwable e) {
                System.setErr(olderr);

                String errStr = new String(baos.toByteArray());

                /**
                 * ?,?,
                 */
                if (errStr.equals(lastErrInfo)) {
                    throw new ShakaException(errStr, e);
                }
                lastErrInfo = errStr;

                boolean bContinue = false;
                if (manifest != null) {
                    String rootDir = manifest.getParentFile().getAbsolutePath();

                    if (checkPng(errStr, rootDir)) {
                        bContinue = true;
                    }

                    if (horizontalScrollView_check(errStr)) {
                        bContinue = true;
                    }

                    if (!bContinue) {
                        //????,????
                        bContinue = fuckNotDefinedRes(errStr, rootDir);
                    }
                }

                if (!bContinue) {
                    throw new ShakaException(errStr, e);
                }
            } finally {
                System.setErr(olderr);
            }
        }
    }

}

From source file:com.rover12421.shaka.apktool.lib.ARSCDecoderAj.java

License:Apache License

@Around("execution(* brut.androlib.res.decoder.ARSCDecoder.addMissingResSpecs())")
public void addMissingResSpecs(ProceedingJoinPoint joinPoint) throws Throwable {
    if (!ShakaDecodeOption.getInstance().isFuckUnkownId()) {
        joinPoint.proceed(joinPoint.getArgs());
    }/*  www.j a  v  a2 s.com*/
}