spring-aop

How to execute custom sql code in every transaction managed by spring DataSourceTransactionManager?

我的梦境 提交于 2019-12-12 18:12:12
问题 Consider situation in which we have tons of java DAO classes managed by Spring. Every method defined in those beans executes SQL code in Spring's Datasource transaction, defined by annotation on a method. Now we have a requirement to run some custom code just before target execution of mentioned methods, this code MUST be executed in the same transaction as defined by annotation on target method. Update based on R4J comment: My proxy for DAO calls which should call procedure PR_Adm_Set_Usr in

Spring batch with scoped beans and AllowBeanDefinitionOverriding=false

China☆狼群 提交于 2019-12-12 16:30:36
问题 I want to use scoped spring batch beans <bean id="processor" class="com.example.Processor" p:type="#{jobParameters['type']}" scope="step"/> and AllowBeanDefinitionOverriding = false GenericXmlApplicationContext context = new GenericXmlApplicationContext(); context.setAllowBeanDefinitionOverriding(false); context.load("myResource.xml", "otherResource.xml"); context.refresh(); How to avoid BeanDefinitionStoreException with Spring version 4.2.4.RELEASE Exception in thread "main" org

Error in instantiating bean in Spring 3.1

孤者浪人 提交于 2019-12-12 15:23:23
问题 I have the following classes: public abstract class AbstractBusinessModule { } public class MS3BusinessModule extends AbstractBusinessModule { public MS3BusinessModule(SomeOtherClass value) { } } And the following bean declarations: <bean id="ms3BusinessModule" class="com.hba.MS3BusinessModule" > <constructor-arg index="0"> <ref bean="someOtherBeanID"/> </constructor-arg> <aop:scoped-proxy /> </bean> Upon startup of my application I get the following error: Exception in thread "main" org

Spring AOP slow startup time

☆樱花仙子☆ 提交于 2019-12-12 10:43:48
问题 We're using Spring (3.0.5) AOP with @AspectJ style annotations and <aop:aspectj-autoproxy/> . We use it for transactions, auditing, profiling etc. It works fine except that the startup time of the application is continuously growing as more code is being added. I have done some profiling and found that most of the time is spent during Spring container initialization, more specifically org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(String, ObjectFactory) -

Custom Spring AOP Around + @Transactional

白昼怎懂夜的黑 提交于 2019-12-12 08:29:45
问题 I have a custom Around implemented to match on a custom Annotation. I want the custom around to execute WITHIN the outer @Transactional. Unfortunately, this doesn't appear to work. (The AOP is working. I see stacktraces that show it). The stack traces show my AOP executing before (a logger), the MyBatis Session starting a transaction, MyBatis closing the Transactions, Spring closing the transaction and then my AOP completing. I thought having my AOP implement Ordered would help. I set the

AspectJ expression gives formal unbound in pointcut error

断了今生、忘了曾经 提交于 2019-12-12 08:22:49
问题 I have within aspectJ the expression: @Pointcut("within(com.param.cpms.dao.impl.ProjectMetaDaoImpl)") public void daoExceptionHandle() { } At Spring 3.0 startup, I am getting the following error : nested exception is java.lang.IllegalArgumentException: error at ::0 formal unbound in pointcut 回答1: Probably the problem is not in your pointcut, but in an advice using that pointcut and using a parameter which does not exist in the pointcut. Just remove the parameter from the advice (well, or add

how to set many targets to ProxyFactoryBean?

£可爱£侵袭症+ 提交于 2019-12-12 04:48:36
问题 I am working with Spring 4 AOP and right now, i have my ProxyFactoryBean configured like this: @Bean @Primary public ProxyFactoryBean proxyFactoryBean() { ProxyFactoryBean proxyFactoryBean = new ProxyFactoryBean(); proxyFactoryBean.setTarget(new ClientService()); proxyFactoryBean.addAdvice(new LoggingAdvice()); proxyFactoryBean.addAdvice(new DebugInterceptor()); return proxyFactoryBean; } This works, but the target is just the ClientService object. Is it possible to set many targets and not

Easymock3 Spring4.0.0.RELEASE cglib compatibility

僤鯓⒐⒋嵵緔 提交于 2019-12-12 04:39:09
问题 I followed the advice given here to try some unit tests with spring aop enabled methods. However, I suspect that the repackaged cglib classes under spring-core and the cglib-nodep-2.2.jar conflict with each other, causing my class being proxied to be loaded by the classloader twice. This results in the following error: Caused by: java.lang.LinkageError: loader (instance of sun/misc/Launcher$AppClassLoader): attempted duplicate class definition for name: Tools: easmock-3.0 (with cglib-nodep-2

Spring AOP @AfterThrowing Advice not being executed

ぃ、小莉子 提交于 2019-12-12 04:35:20
问题 The @AfterThrowing advice I have defined is not getting executed. Could some one take a look and please help me out? Below is the code I am using. Pom.xml <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>Test</groupId> <artifactId>Test</artifactId> <version>0.0.1-SNAPSHOT</version> <name

Converting Code based style to Annotation Based style AOP using Spring or AspectJ

匆匆过客 提交于 2019-12-12 04:05:17
问题 I have the following code based style aspect which looks for a field level annotation in the code and calls a method with that field as argument. This is how it looks.. public aspect EncryptFieldAspect { pointcut encryptStringMethod(Object o, String inString): call(@Encrypt * *(String)) && target(o) && args(inString) && !within(EncryptFieldAspect); void around(Object o, String inString) : encryptStringMethod(o, inString) { proceed(o, FakeEncrypt.Encrypt(inString)); return; } } The above