spring-aop

Spring AOP - Point Cut not getting called

↘锁芯ラ 提交于 2019-12-11 16:53:18
问题 I have a SpringBoot Application. I have defined an Annotation say "Track", and I have annotated few methods in different packages which I want aop to consider. The annotation has been defined as below : @Retention(RetentionPolicy.RUNTIME) @Target(ElementType.METHOD) public @interface Track { } I have not missed the @EnableAspectJAutoProxy in the @Configuration class of my package. I have a Pointcut and an Advice defined in the Aspect like below : @Aspect @Component public class MyAspect {

ClassNotFoundException org.springframework.aop.framework.AopConfigException

折月煮酒 提交于 2019-12-11 16:23:32
问题 I have an application which we're trying to get to run on WebLogic 12.2.1.3 but even though we have the correct spring-aop-3.0.5.RELEASE.jar in the application's web-inf\lib directory we still get a org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'peServicesFactory' defined in BeanDefinition defined in ServletContext resource [/WEB-INF/taskServlet-servlet.xml]: Initialization of bean failed; nested exception is org.springframework.aop.framework

A Java config analog of XML configuration not working

北城余情 提交于 2019-12-11 15:27:50
问题 TL/DR: The problem boils down to creating a custom Spring scope, injecting a prototype -like scoped bean into a singleton with proxyMode = ScopedProxyMode.TARGET_CLASS but still getting a singleton in the Java config version of the configuration (whereas it works fine with XML). UPDATE: Problem solved, see answer. I'm using jBehave to write BDD test scenarios for our Spring application. We recently thought that we need independence in executing test scenarios (meaning that test context has to

Pointcut expression 'if()' contains unsupported pointcut primitive 'if'

可紊 提交于 2019-12-11 15:27:49
问题 I am using AspectJ in my Spring boot project for AOP. I have declared a if() point cut: public class myPointCuts { // a global boolean variable, value can be updated at runtime. public static boolean IS_RESULT_FINE; @Pointcut("if()") public static boolean isResultFine() { return IS_RESULT_FINE; } } At compile time, I get error: Initialization of bean failed; nested exception is org.aspectj.weaver.tools.UnsupportedPointcutPrimitiveException: Pointcut expression 'if()' contains unsupported

Spring Aop Error Can not build thisJoinPoint lazily for this advice

≡放荡痞女 提交于 2019-12-11 15:14:11
问题 Pointcut declaration: @Pointcut(value="com.someapp.someservice.someOperation() && args(t,req)",argNames="t,req") private void logOperationArg(final String t,final String req) { } Advice Declaration not compiling: @Before(value="logOperationArg(t,req)") public void logBeforeOperationAdvice(JoinPoint jp, final String t, final String req){ ... } When compiling Aspect with Aspectj-maven-plugin (1.5 version), have error "can not build thisJoinPoint lazily for this advice since it has no suitable

Spring AOP Not working properly

[亡魂溺海] 提交于 2019-12-11 15:03:24
问题 I'm trying to handle exceptions with AOP approach in my Spring/Swing Application and I couldn't make it work. Main Class: public class MainFrame extends JFrame { private JPanel mainPanel; public static void main(String[] args) { EventQueue.invokeLater(new Runnable() { public void run() { try { MainFrame frame = new MainFrame(); frame.setVisible(true); } catch (Exception e) { e.printStackTrace(); } } }); } public MainFrame() { initializeMainPanel(); } private void initializeMainPanel() {

Spring AOP Capturing of logs inside a method

牧云@^-^@ 提交于 2019-12-11 14:05:39
问题 I'm newbie to Spring AOP. I do understand the concept behind it and i also do understand the concept of @Before or @After etc usage. What i am so confused is still the usage of Spring AOP. Think of the below method of a class. public void test(int x) { : x++; logger.info("This is a test" + x); : try { : } catch (Exception e) { throw new ... } : } The old way of capturing the log is as shown above. Here's my questions: If i were to implement the above method using Spring AOP, this logger will

Logger clean up Using Spring AOP

喜夏-厌秋 提交于 2019-12-11 14:04:03
问题 We're trying to introduce generic logger in our application using Spring AOP for log statements which are under catch block. Before AOP try { \\Business Logic } catch(Exception e){ \\some recovery mechanism that won't be generic across different layers log.error();//These statements needs to be moved to generic logger } After going through Spring Docs,I have found this can be done using AfterThrowing advice. After throwing advice is Advice to be executed if a method exits by throwing an

Spring AOP Advice for Hibernate managed POJO

爷,独闯天下 提交于 2019-12-11 12:14:30
问题 I have a parent-child relationship, such as Order to Order Item, which I have represented in the domain model like this: public class Order { private int id; private Set<OrderItem> orderItems = new HashSet<OrderItem>(); public int getId() { return id; } public void add(OrderItem orderItem) { orderItems.add(orderItem); } } public class OrderItem { private int id; public int getId() { return id; } } I am persisting these entities with Hibernate, using a mapping like this: <class name="Order"

Pointcut expression 'abc(inString)' contains unsupported pointcut primitive 'call'

独自空忆成欢 提交于 2019-12-11 12:14:24
问题 I am new to spring-aop concepts. I am getting this error during compilation. org.aspectj.weaver.tools.UnsupportedPointcutPrimitiveException: Pointcut expression 'abc(inString)' contains unsupported pointcut primitive 'call' My aspect is, @Aspect @Component public class BeforeAdvice { @Pointcut(value="call(@com.app.test.EncryptDemo * *(String)) && args(inString) && !within(com.app.test.BeforeAdvice)",argNames="inString") public void abc(String inString) {}; @Around(value = "abc(inString)"