apache-flex 使用筛选器记录来自flex / BlazeDS客户端所有请求

knpiaxh1  于 2022-11-01  发布在  Apache
关注(0)|答案(1)|浏览(193)

我有一个Spring BlazeDS集成应用程序。我想记录所有的请求。
我计划使用过滤器。在我的过滤器当我检查请求参数。它不包含任何与客户端请求有关的东西。如果我改变我的过滤器的顺序(我有spring安全),那么它打印一些与spring安全有关的东西。
我无法记录用户请求。
任何帮助都是感激不尽的。

cyvaqqii

cyvaqqii1#

我已经通过使用AOP(AspectJ)将logger语句注入到通信端点方法中实现了相同的功能。--希望这也是您的一种替代方法。

/**Logger advice and pointcuts for flex remoting stuff based on aspect J*/
public aspect AspectJInvocationLoggerAspect {

    /**The name of the used logger. */
    public final static String LOGGER_NAME = "myPackage.FLEX_INVOCATION_LOGGER";

    /**Logger used to log messages. */
    private static final Logger LOGGER = Logger.getLogger(LOGGER_NAME);

    AspectJInvocationLoggerAspect() {
    }

    /**
     * Pointcut for all flex remoting methods.
     * 
     * Flex remoting methods are determined by two constraints:
     * <ul>
     *   <li>they are public</li>
     *   <li>the are located in a class of name Remoting* within (implement an interface)
     *   {@link com.example.remote} package</li>
     *   <li>they are located within a class with an {@link RemotingDestination} annotation</li>
     * </ul>
     */
    pointcut remotingServiceFunction()
        : (execution(public * com.example.remote.*.*Remote*.*(..)))  
        && (within(@RemotingDestination *));

    before() : remotingServiceFunction() {
        if (LOGGER.isDebugEnabled()) {
            Signature sig = thisJoinPointStaticPart.getSignature();
            Object[] args = thisJoinPoint.getArgs();

            String location = sig.getDeclaringTypeName() + '.' + sig.getName() + ", args=" + Arrays.toString(args);            
            LOGGER.debug(location + " - begin");
        }
    }

    /**Log flex invocation result at TRACE level. */
    after() returning (Object result): remotingServiceFunction() {

        if (LOGGER.isTraceEnabled()) {
            Signature sig = thisJoinPointStaticPart.getSignature();            

            String location = sig.getDeclaringTypeName() + '.' + sig.getName();
            LOGGER.trace(location + " - end = " + result);            
        }
    }
}

相关问题