是否可以在Java SE环境中使用javax.interceptor? [英] Is it possible to use javax.interceptor in a Java SE environment?

查看:121
本文介绍了是否可以在Java SE环境中使用javax.interceptor?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要使用AOP来解决特定问题,但它是一个小型的独立Java程序(没有Java EE容器)。

I need to use AOP to solve a particular issue, but it is a small standalone Java program (no Java EE container).

我可以使用 javax.interceptor 功能,还是必须下载一些第三方AOP实现?如果可能的话,我宁愿使用Java SE SDK附带的东西。

Can I use javax.interceptor functionality, or do I have to download some 3rd-party AOP implementation? I'd rather use what comes with the Java SE SDK if at all possible.

推荐答案

如果你没有使用容器任何种类,那么你的应用程序就不会有Java EE拦截器API的实现。

If you are not using a container of any sort then there will not be an implementation of the Java EE interceptor API available to your application.

你应该使用类似于AspectJ的AOP解决方案,是一个在线的大量教程和示例。但是,我会小心翼翼地尝试遵循最新版本和最佳实践的示例,因为那里有很多旧东西。

You should instead look to use an AOP solution like AspectJ, for which there is a large amount of tutorials and examples online. However, I would be careful to try to stick to examples that follow the newest versions and best practices since there is a lot of old stuff out there.

如果你已经使用Spring框架然后Spring AOP可以满足您的要求。这将更容易集成到您的应用程序中,虽然它没有为您提供AspectJ的所有功能。

If you are already using the Spring framework then Spring AOP may meet your requirements. This will be significantly easier to integrate into your application, although it does not give you all of the features of AspectJ.

这篇关于是否可以在Java SE环境中使用javax.interceptor?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆