spring-aop

IBM Websphere: Getting error for Spring AOP

£可爱£侵袭症+ 提交于 2019-11-30 19:49:07
I am getting following error while booting up the server. Application has Spring as well as AspectJ classes in it. Caused by: java.lang.VerifyError: JVMVRFY013 class loading constraint violated; class=org/springframework/aop/aspectj/MethodInvocationProceedingJoinPoint, method=getSourceLocation()Lorg/aspectj/lang/reflect/SourceLocation;, pc=0 at java.lang.J9VMInternals.verifyImpl(Native Method) at java.lang.J9VMInternals.verify(J9VMInternals.java:93) at java.lang.J9VMInternals.initialize(J9VMInternals.java:170) at org.springframework.aop.aspectj.AbstractAspectJAdvice.currentJoinPoint

Can we calculate Spring bean initialization time

喜夏-厌秋 提交于 2019-11-30 19:10:23
问题 I would like to develop a spring AOP feature where we can put a point cut/within during the spring bean initialization so as to calculate some statistics as required for business. I would like to know if its possible using spring AOP module? 回答1: You can measure initialization time using this component: @Component public class MyBeanPostProcessor implements BeanPostProcessor, Ordered { private Map<String, Long> start; private Map<String, Long> end; public MyBeanPostProcessor() { start = new

Spring AOP: exclude avoid final classes and enums from pointcut

Deadly 提交于 2019-11-30 14:42:09
I am using try to implement Logging using Spring AOP. I have defined the @Pointcut("execution(* com.mycom..*(..))") private void framework() {} @Around("framework()") public Object aroundAdviceFramework(ProceedingJoinPoint jp) throws Throwable { if (logger.isDebugEnabled()) logger.debug("DEBUG:: {} {} Enter", jp.getTarget().getClass().getName(), jp.getSignature().getName()); Object returnVal = jp.proceed(jp.getArgs()); if (logger.isDebugEnabled()) logger.debug("DEBUG:: {} {} Out", jp.getTarget().getClass().getName(), jp.getSignature().getName()); logger.info("INFO:: " + jp.getTarget().getClass

Spring Boot, @Autowire into an unmanaged class using @Configurable and load time weaving

巧了我就是萌 提交于 2019-11-30 13:56:23
I have a collection of unmanaged classes that I are instantiated outside of Spring. I've been attempting to use Spring AOP with load time weaving to @Autowire a bean into these classes but have so far not had any luck. I've been testing using Tomcat 8 and Spring Boot 1.2.0. My @Configuration where I attempt to set up class looks like this: @Configuration @PropertySource("classpath:application.properties") @EnableSpringConfigured @EnableLoadTimeWeaving public class Config Inside Config I define the bean I want to @Auotwire into my unmanaged classes: @Bean public StateProvider stateProvider() {

Autowiring Unmanaged Beans Annotated With @Component

有些话、适合烂在心里 提交于 2019-11-30 12:18:42
问题 I want to use @AutoWired to inject a non-managed bean configured with @Component into a managed bean. I'm pretty sure I have the configuration right, but for some reason I keep getting the exception: No unique bean of type [foo.Baz] is defined: Unsatisfied dependency of type [class foo.Baz]: expected at least 1 matching bean Based on the error, I'm guessing it's not able to find the Baz class, but I'm not sure why. It's my understanding that the context:spring-configured element in the XML

Exception handling through spring AOP + Aspectj

◇◆丶佛笑我妖孽 提交于 2019-11-30 09:56:53
In my project I have a domain layer which is basically POJO and a Spring controller / service layer that is sitting on top of the domain layer. I also have an AOP layer which is sitting between the service and domain. My domain layer is throwing business exceptions which are now being handled in the service layer. However I want to change it so that exception thrown from domain layer will be handled in the AOP layer. AOP layer will some kind of error response and send it back to spring controller/ web service layer. I can create a IBizResponse and make two subclasses/interfaces of it perhaps a

Can we enable or disable Aspect based on value of any flag or through configuration file?

不想你离开。 提交于 2019-11-30 08:34:30
问题 I have added following dependency in pom.xml <dependency> <groupId>org.springframework</groupId> <artifactId>spring-aop</artifactId> <version>${spring.version}</version> </dependency> <dependency> <groupId>org.aspectj</groupId> <artifactId>aspectjrt</artifactId> <version>1.8.5</version> </dependency> <dependency> <groupId>org.aspectj</groupId> <artifactId>aspectjweaver</artifactId> <version>1.8.5</version> </dependency> And enable AspectJ in appContext.xml as follows: And define aspect as

Why Spring AOP is not weaving external jars at runtime?

心已入冬 提交于 2019-11-30 05:20:25
I have a java application build upon Spring 3. This project has another jar as a dependency. This dependency contains a @org.aspectj.lang.annotation.Aspect class (lets say, com.aspectprovider.aspects.MyAspect ). There's a @Before advice to weave a method from classes that implements the interface Foo . Something like: @Before("execution(* com.project.Foo.save(..))") The Foo interface can be inside the "project" or in another jar. It doesn't matter for this example. My project contains classes that implements Foo . Those are the classes that I want it to be weaved, of course. My Spring

Spring AOP at Service Layer

回眸只為那壹抹淺笑 提交于 2019-11-30 05:14:08
I need some help with Spring AOP. I've the following code: @Service public class UserSecurityService implements UserDetailsService { @Autowired private UserService userService; .... } @Service public class UserService extends CrudService<User, UserRepository> { public UserService() { super(); } @Autowired public UserService(UserRepository repository) { super(repository); this.repository = repository; } .... } @Repository interface UserRepository extends JpaRepository<User, String> { ... } application-context.xml <import resource="classpath*:spring/application-context-db.xml" /> <import

Set an AspectJ advise for static method

我与影子孤独终老i 提交于 2019-11-30 04:45:26
问题 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