- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我有一个带有 @Around
注释的简单方面(见下文)。当应用程序不使用响应式范例时,此方面有效。但是当应用程序返回 Mono 或 Flux 时就无法正常工作。
我需要获取从方法返回的对象来生成 JSON 对象以用作日志、生成事件等。
这是我在非响应式(Reactive)类中工作的代码:
@Around("@annotation(simpleEvent)")
public Object logExecutionTime(ProceedingJoinPoint joinPoint, SimpleEvent simpleEvent) throws Throwable {
final long start = System.currentTimeMillis();
Object proceed = null;
try {
proceed = joinPoint.proceed();
// here in the real life the object that transformed in json to do others actions
System.out.println(proceed);
final long executionTime = System.currentTimeMillis() - start;
System.out.println(joinPoint.getSignature() + " executed in " + executionTime + "ms");
return proceed;
} catch (Exception e) {
e.printStackTrace();
}
return proceed;
}
当是Mono或Flux时,如何获取joinPoint.proceed()
返回的对象?
提前致谢。
最佳答案
你可以这样做,当继续返回一个 Mono 时也是如此
@Around("somePointCut()")
public Object aspectForSomething(ProceedingJoinPoint point) throws Throwable {
Flux flux = (Flux) point.proceed();
return flux
.doOnNext(obj -> {
log.error("just take a look: " + obj);
})
.map(obj -> {
if (obj instanceof SomeBo) {
SomeBo bo = (SomeBo) obj;
bo.setName("do some modification");
return bo;
} else {
return obj;
}
});
}
关于java - 如何使用 Spring AOP 和 WebFlux 获取从 joinPoint.proceed() 返回的对象,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53137150/
举个例子:Permutation Game (interviewstreet.com)。我想知道我该如何处理这些问题。 P.S.:请不要发布完整的算法(因为那样会破坏乐趣),只是一些提示。 最佳答案
这是我第一次接触 AOP。我有一个带有一个方面的 spring-boot 应用程序,一个记录器。搜索我得出的结论是 @Around 方法在方法之前和之后执行(我只在一种方法中调用它),这是对的吗? 在
javax.interceptor.InitationContext 的proceed() 方法是否抛出除目标方法或干预代码之外的任何异常?调用目标异常怎么样?一般来说,文档在这一点上似乎不完整。 [
我正在尝试了解当在 WebviewClient 的 onReceivedSslError 函数中调用 SslErrorHandler.proceed()(来自类 https://developer.a
这是 JSFiddle:http://jsfiddle.net/dAQrE/ 在 javascript 部分的顶部,您将看到假定在动画之后向下滚动到 #proceed div 的代码: line 1,
我有以下几个方面: aspect NullifyNoResultException { Object around(..) : execution(public Object com.exam
我有一个带有 UITableView 的应用程序。应用程序与服务器通信。 问题如下: 客户端 1 删除了 TableView 的一个单元格。数据更新被传输到服务器,服务器将数据更新发送到客户端 2。同
我刚开始使用laravel。我正在关注这个 Laravel 指南。我的环境是一个运行 php 5.6 的 aws 服务器,我已经安装了 composer。 https://laravel.com/do
当未登录(匿名)的用户点击继续结帐时,我希望他们被带到登录页面。然后,在他们登录或注册后,他们应该返回到结帐页面。 我正在使用单页结帐,其中有一个您未登录的登录部分,但当权者不希望这样。 最初,我开始
我正在尝试使用 Highcharts Javascript 图表引擎绘制一些图表,我已经全部设置好,它在我的本地开发环境中工作正常,但是当我将它部署到 Gitlab 并访问它时,它会给我以下信息错误:
当我尝试运行我的应用程序时出现此错误: 我检查过,没有理由认为它找不到 libnlopt-0.dll。这里是(注意GlassModelCalcualator是使用libnlopt-0.dll的DLL)
我有一个 UIViewController,其中包含一个 UITableView 和一个 UIRefreshControl 作为此 TableView 的 subview 。当 TableView 中
我刚开始学习 MYSQLI 准备语句技术,遇到了非常烦人的问题。我的代码在 bind_result() 处停止。我就是不明白哪里出了问题,所以请大家帮帮我。 这是我的 config.php: con
我是新手,没有开发 Android(Ubuntu 14.04、Android Studio 1.4)的经验。我只是想解决多个错误以构建我的代码,当我这样做时,我会弹出一个提示 Gradle is ru
假设您有三个建议:around、before 和 after。 1) 在 around 建议中调用 proceed 时是否会调用 before/after,还是将它们称为 before/after a
我正在尝试使用 azure 站点恢复保管库来保护我的 Hyper V 虚拟机,我使用以下链接: https://azure.microsoft.com/en-in/documentation/arti
我正在尝试设置Shake用于构建 Web 应用程序。在构建过程结束时,我想重命名生成的 .js和.css根据内容哈希文件(用于缓存清除目的)。 这当然意味着我不知道这些文件的最终名称,类似于 app-
就我而言,我有主项目和测试项目。我在测试项目中得到了正确的结果,其中我只有一个安装程序类并将所有内容注册在一处。在我的主要项目中,我有几个安装程序(一个用于服务,一个用于拦截器,一个用于公共(publ
我在使用 iOS Combine 框架时遇到了一些心理障碍。 我正在将一些代码从“手动”从远程 API 获取转换为使用组合。基本上,API 是 SQL 和 REST(实际上是 Salesforce,但
我有以下建议代码: @Around("annotatedMethod()") public Object aroundGetPanel(ProceedingJoinPoint join
我是一名优秀的程序员,十分优秀!