spring-aop

Spring AOP advice not getting excuted

☆樱花仙子☆ 提交于 2019-12-24 06:37:44
问题 I am new to Spring AOP and facing some issues in its implementation. I am trying to implement logging as advice. But advice is not getting executed. Following is the files I am using. LoggingAspect.java package com.demo.conference.aspects; @Aspect @Component public class LoggingAspect { @Pointcut("execution(* com.demo.conference.daoImpl.ConferenceDAOImpl.*(..))") public void point(){} @Pointcut("execution(public * *(..))") //this should work for the public pointcut private void

Spring AOP ignores some methods of Hessian Service

江枫思渺然 提交于 2019-12-24 03:29:23
问题 I have an Aspect with the following pointcut definition @Pointcut("execution(public de.company.project..* *(..))") and a spring configuration containing the following <aop:aspectj-autoproxy /> <bean id="myaspect" class="de.company.project.impl.MyAspect" /> <bean id="someService" class="de.company.project.impl.SomeService" /> <bean name="/SomeService" class="org.springframework.remoting.caucho.HessianServiceExporter"> <property name="service" ref="someService" /> <property name=

Spring AOP Logging Interceptor and JAXB issue

落爺英雄遲暮 提交于 2019-12-24 00:54:19
问题 I am trying to implement logging aspect into my application. This is the first time I am attempting AOP, so please let me know if I am missing something obvious. In order to achieve weaving external jars, I am trying to implement load time weaver. I did specify the load-time-weaver in my application context and mentioned TomcatInstrumentableClassLoader in my context.xml file along with the aop.xml. My application is a Spring MVC REST application and utilizes JAXB content negotiation as well.

Aspect advising other aspects

被刻印的时光 ゝ 提交于 2019-12-24 00:24:58
问题 I am currently developing two Spring applications that makes use of Spring-AOP. I have an aspect that allows simple performance logging which is defined as such: @Aspect final class PerformanceAdvice { private Logger logger = LoggerFactory.getLogger("perfLogger"); public Object log(final ProceedingJoinPoint call) throws Throwable { logger.info("Logging statistics."); } } This advice can then be created through Spring AOP configuration with the following XML: <bean id="performanceAdvice" class

Enabling AOP breaks my dependency injection for a factory bean that takes a string

非 Y 不嫁゛ 提交于 2019-12-23 20:21:15
问题 Enabling AOP breaks my dependency injection for a factory bean that takes a string. Here's the fragment from the context file: <aop:aspectj-autoproxy/> <bean id="foo" class="FooFactory" p:url-ref="url"/> <bean id="url" class="java.lang.String"> <constructor-arg value="#{ 'localhost:50131'}"/> </bean> Here's the factory bean. public class FooFactory extends AbstractFactoryBean<Foo> { private String url; public void setUrl(final String url) { this.url = url; } @Override public Class<?>

Can't create aspect in Spring Boot

我是研究僧i 提交于 2019-12-23 19:48:30
问题 I just want to achieve one simple thing - to create logging aspect, which should hook on every method to be able print arguments. The aspect looks like as following: @Aspect @Component @Slf4j public class MyLogger { public MyLogger () {} @AfterReturning("execution(* my.package..*.*(..))") public void logMethodAccessAfter(JoinPoint joinPoint) { System.out.println("***** Completed: " + joinPoint.getSignature().getName() + " *****"); } @Before("execution(* my.package..*.*(..))") public void

Failed to load Spring ApplicationContext

我的梦境 提交于 2019-12-23 18:04:27
问题 I'm writing unit tests for a spring application which is sort of complex. I want to load spring context in order to use defined beans. My context.xml is located at: src/main/resources/context.xml After maven build, the context.xml appears at: target/classes/context.xml In the pom.xml, I have: (As suggested by this post) <resources> <resource> <filtering>true</filtering> <directory>src/test/resources</directory> <includes> <include>**/*.properties</include> </includes> <excludes> <exclude>**/

Aspect not executed in Spring

非 Y 不嫁゛ 提交于 2019-12-23 17:15:44
问题 I'm coding a website that will be almost fully protected by login (I'm using Spring Security for it). There are certain pages that are not protected, though (home page, login page, registration page, forgotten password page, ...) and what I'm trying to achieve is: If the user is not logged in when accessing these non-secured pages, show them normally If the user is already logged in, redirect to the home page (or to the page specified in the redirectTo annotation element) Of course I want to

Spring AOP :- Getting parameterNames as null in the joinPoint

巧了我就是萌 提交于 2019-12-23 13:25:14
问题 LoggingAspect.java @Around("allGenericAppServiceImplMethods()") public Object LoggingAdvice(ProceedingJoinPoint joinPoint)throws Throwable{ MethodSignature signature = (MethodSignature)joinPoint.getSignature(); String[] parameterNames = signature.getParameterNames(); Object[] arguments = joinPoint.getArgs(); I am getting parameterNames as null.How do I get the parameterNames? 回答1: I just checked in plain AspectJ and I never get parameter names as null with AspectJ 1.8.6. Maybe you use an

Spring AOP Pointcut with method name starting with get

若如初见. 提交于 2019-12-23 12:59:41
问题 I'm trying to implement a Pointcut for spring AOP. All the methods which are like getXXXX should be logged. I tried the following but either they throw exception or does not trigger: 1st try @Pointcut("within(net.services.*.get*)") private void clServiceLayer() {} @Pointcut("within(net.services.*.get*(..))") private void clServiceLayer() {} Need help with the proper expression for point cut. 回答1: within limits matching to join points within certain types. Instead you should use execution