spring-aop

Spring MVC Application - How do I set a session scoped bean value

点点圈 提交于 2019-12-01 06:34:48
问题 In my application I need to gather information on one screen and then display it on the next. I have selected to store this information in a bean with a scope set as session ( it will be used in several other screens after the initial data gathering screen) The Manager is configured as follows: <bean name="/springapp.htm" class="foo.bar.controller.springcontroller"> <property name="sessionBeanManager" ref="sessionBeanManager" /> </bean> The bean is configured as follows : <bean id=

Spring @Transactional is applied both as a dynamic Jdk proxy and an aspectj aspect

青春壹個敷衍的年華 提交于 2019-12-01 06:06:22
I am in the process of adding Spring declarative transactions via the @Transactional annotation to an existing Java project. When I ran into a problem (unrelated to this question), I turned on full debug logging. Curiously, I noticed the following: 17:47:27,834 DEBUG HibernateTransactionManager:437 - Found thread-bound Session [org.hibernate.impl.SessionImpl@10ed8a8e] for Hibernate transaction 17:47:27,845 DEBUG HibernateTransactionManager:470 - Participating in existing transaction 17:47:27,865 DEBUG AnnotationTransactionAttributeSource:106 - Adding transactional method 'updateUserProfile'

Intercepting method with Spring AOP using only annotations

随声附和 提交于 2019-12-01 06:05:10
问题 In my Spring context file I have something like this: <bean id="userCheck" class="a.b.c.UserExistsCheck"/> <aop:config> <aop:aspect ref="userCheck"> <aop:pointcut id="checkUser" expression="execution(* a.b.c.d.*.*(..)) && args(a.b.c.d.RequestObject)"/> <aop:around pointcut-ref="checkUser" method="checkUser"/> </aop:aspect> </aop:config> a.b.c.UserExistsCheck looks like this: @Aspect public class UserExistsCheck { @Autowired private UserInformation userInformation; public Object checkUser

how to setup load-time weaving with Spring and Tomcat WITHOUT using the -javaagent on the command line

依然范特西╮ 提交于 2019-12-01 04:27:07
I am using Spring 3.2.9, Tomcat 6.0.44 I am trying to configure my application's Spring instrumentation provider (e.g. spring-instrumentation.jar) for load-time weaving, when it is deployed on Tomcat. I have a requirement to NOT use: "-javaagent:/path/path/spring-instrument.jar" on the command line to do the configuration. I've read that I can configure the Spring instrumentation by modifying the <Context> element of my application's Tomcat configuration (in either Tomcat's server.xml or my web app's context.xml). Adding the appropriate <Context> element to the server.xml results in my

Using Spring AOP on App Engine causes StackOverflowError

爱⌒轻易说出口 提交于 2019-12-01 03:42:25
We have an app running on App Engine and using Spring framework. Recently we have added some new features that are based on AOP. We decided to use @AspectJ style hence we added <aop:aspectj-autoproxy> into our XML based configuration and implemented respective aspects. Everything is working OK on development server, however, when deployed to the cloud environment we get java.lang.StackOverflowError every time the app is being initialized. The bean that cannot be created and causes the error is configuration class annotated with @Configuration annotation. It seems that basically any

Spring @Transactional is applied both as a dynamic Jdk proxy and an aspectj aspect

萝らか妹 提交于 2019-12-01 03:06:12
问题 I am in the process of adding Spring declarative transactions via the @Transactional annotation to an existing Java project. When I ran into a problem (unrelated to this question), I turned on full debug logging. Curiously, I noticed the following: 17:47:27,834 DEBUG HibernateTransactionManager:437 - Found thread-bound Session [org.hibernate.impl.SessionImpl@10ed8a8e] for Hibernate transaction 17:47:27,845 DEBUG HibernateTransactionManager:470 - Participating in existing transaction 17:47:27

how to setup load-time weaving with Spring and Tomcat WITHOUT using the -javaagent on the command line

徘徊边缘 提交于 2019-12-01 02:35:06
问题 I am using Spring 3.2.9, Tomcat 6.0.44 I am trying to configure my application's Spring instrumentation provider (e.g. spring-instrumentation.jar) for load-time weaving, when it is deployed on Tomcat. I have a requirement to NOT use: "-javaagent:/path/path/spring-instrument.jar" on the command line to do the configuration. I've read that I can configure the Spring instrumentation by modifying the <Context> element of my application's Tomcat configuration (in either Tomcat's server.xml or my

Configuring Hibernate session with Spring AOP

不羁岁月 提交于 2019-12-01 00:25:50
问题 I have a Spring Framework 4 application that uses Hibernate 4.3.8 as the JPA provider. I want to use Hibernate filters, and therefore I need to enable them. I want to do this globally in the application, which I am trying to do with Spring AOP. The idea is that I can write an aspect that enables filters every time a session is created/fetched, like in this and this question. I have added the spring-aop and aspectjweaver dependencies to my project (using Maven). I have added the following

Compile/load time weaving with spring

自作多情 提交于 2019-11-30 21:54:13
The docs explain that, the LTW has to enabled either through the use of <context:load-time-weaver/> xml instruction or the use of @EnableLoadTimeWeaving annotation. However, I have done neither, but I still see that aspects are woven correctly in my projects! In this case, I don't think they are woven at compile-time (but are they?), so it's surely got to be load-time-weaving? Even if that's the case, how does it automatically choose to weave aspects in during load-time? Shouldn't the aspects remain unwoven if they are not turned on using one of the ways mentioned above as the docs say? I've

Set an AspectJ advise for static method

懵懂的女人 提交于 2019-11-30 19:50:41
I have written simple Aspect with primitive Pointcut and Advise method: @Aspect public class MyAspect { @Pointcut("execution(static * com.mtag.util.SomeUtil.someMethod(..))") public void someMethodInvoke() { } @AfterReturning(value = "someMethodInvoke())", returning = "comparisonResult") public void decrementProductCount(List<String> comparisonResult) { //some actions } } I have following Spring annotation-based application config: @Configuration @EnableAspectJAutoProxy public class AppConfig { //... } And utility class in com.mtag.util package: public class SomeUtil { static List<String>