java - no aspect invoked after method call -
i've got bean plaindatasource (in external library) extends beannameaware. in method setbeanname logs message
adding bean {} container i decided write aspect couple of actions related setting environment of applicationcontext happens after setbeanname method.
@component @aspect public class datasourceinitializeraspect { @autowired private applicationcontext applicationcontext; @after("execution (* com.path.to.package.plaindatasource.setbeanname(..))") public void initializeenvironment() { logger.info("!!!!!!!!!!!!! invoking aspect !!!!!!!!!!!!!!!!!"); custompropertiesconfigurerext propertiesconfigurer = applicationcontext.getbean(cutsompropertiesconfigurerext.class); boolean localconfig = boolean.parseboolean(propertiesconfigurer.resolveproperty("localconfig")); configurableenvironment env = (configurableenvironment) applicationcontext.getenvironment(); if (localconfig) { env.setactiveprofiles("local"); } else { env.setactiveprofiles("server"); } } } to context.xml added
<aop:aspectj-autoproxy/> with corresponding namespaces
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-4.0.xsd before
<context:annotation-config/> but when start application message
"adding bean datasource container" but don't invoking aspect message assume no aspect being invoked. what's problem?
Comments
Post a Comment