Question

We have two modules in our project app-ui and app-services. app-ui is a portlet project follows spring based implementation and app-services has restful and soap services follows Java EE 6 based implementation. We want to enable security, logging and exception handling aspects through out the modules.

We face the following problems:

  1. Spring aop works well only in app-ui. In app-services side we tried using Load-Time Weaving and spring-bridging but did not succeed, it works successfully only if beans.xml(Java EE 6) is not present in the project.
  2. We tried Java EE global interceptors (placing in ejb-jar.xml), which works only for EJBs. Hence it wont work in app-ui.

Is there a way to develop aspects common to app-ui and app-services?

Was it helpful?

Solution

Using AspectJ directly and not the spring specific support for it it should work OK, this allows to develop aspects that work both in Spring and Java EE.

There are three ways to weave the AspectJ aspects into the code:

  • compile time weaving, meaning we need to have the code

  • byte code weaving can be used for third party jars for which no code is available

  • load time weaving (not the spring specific support) can be used to weave the aspects at class loading time, this can be more invasive as it requires a JVM wide agent, and access to the server startup script.

The spring support for LTW allows to use LTW in a more convenient way but it only works for spring applications, unlike the LTW general mechanism above.

So if using LTW directly is too cumbersome, byte code weaving and compile time weaving are still valid options, although with impact on the build process.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top