java - Aspects are not executed -


i'm trying test simple aspect. app compiles , runs fine, not aspect executed. or @ least, not output aspect should produce. (my aim write exception logger ex occures in app. first test aspect should run...)

maybe has more experience in aspects see's i'm doing wrong?

package business; public interface customer {     void addcustomer(); }  import org.springframework.stereotype.component; @component public class customerimpl implements customer {      public void addcustomer() {         system.out.println("addcustomer() running ");     } }    @requestscoped @named //this backing bean jsf page public class service {       @inject      customer cust;      add() {         system.out.println("service running ");         cust.addcustomer();     } }   @aspect public class aspectcomp {     @before("within(business..*)")     public void out() {      system.out.println("system out works!!");  } } 

spring:

<beans     xmlns="http://www.springframework.org/schema/beans"     xmlns:xsi="http://www.w3.org/2001/xmlschema-instance"     xmlns:beans="http://www.springframework.org/schema/beans"     xmlns:aop="http://www.springframework.org/schema/aop"     xsi:schemalocation="     http://www.springframework.org/schema/beans     http://www.springframework.org/schema/beans/spring-beans-3.0.xsd     http://www.springframework.org/schema/aop     http://www.springframework.org/schema/aop/spring-aop-3.0.xsd     ">      <context:annotation-config />     <context:component-scan base-package="business" />      <aop:aspectj-autoproxy /> </beans> 

output:

service running  addcustomer() running  

the aspect statement missing.

you creating component constructor, , not getting spring container! that's problem, or must use aspectj's load-time weaver.

just inject component (customerimpl) in service , use injected instance.


Comments

Popular posts from this blog

delphi - How to convert bitmaps to video? -

jasper reports - Fixed header in Excel using JasperReports -

python - ('The SQL contains 0 parameter markers, but 50 parameters were supplied', 'HY000') or TypeError: 'tuple' object is not callable -