Announcement Announcement Module
No announcement yet.
How configure aop:pointcut, aop:advisor, tx:advice into JavaConfig... Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • How configure aop:pointcut, aop:advisor, tx:advice into JavaConfig...

    Hello Guys

    I have the follow two classes

    public class SpringFrameworkTransactionConfiguration {
    	private SessionFactory sessionFactory;
    	public void setSessionFactory(SessionFactory sessionFactory) {
    		this.sessionFactory = sessionFactory;
    	public PlatformTransactionManager transactionManager(){
    		HibernateTransactionManager transactionManager = new HibernateTransactionManager();
    		return transactionManager;

    public class SpringFrameworkTransactionServiceRepositoryConfiguration {
    According with the @EnableTransactionManagement API it says..

    In both of the scenarios above, @EnableTransactionManagement and <tx:annotation-driven/> are responsible for registering the necessary Spring components that power annotation-driven transaction management, such as the TransactionInterceptor and the proxy- or AspectJ-based advice that weave the interceptor into the call stack when JdbcFooRepository's @Transacational methods are invoked.
    Therefore @EnableTransactionManagement is the same than <tx:annotation-driven/>

    Now my file spring-framework-transaction-service-repository-configuration.xml has the follow

    	<aop:pointcut id="service"
    		            expression="execution(* com.manuel.jordan.service.impl.sinannotations.*ServiceImpl.*(..) )" />
    	<aop:pointcut id="repository"
    		            expression="execution(* com.manuel.jordan.repository.hibernate.sinannotations.*Repository.*(..) )" />
    	<aop:advisor pointcut-ref="service" advice-ref="txAdvice"/>
    	<aop:advisor pointcut-ref="repository" advice-ref="txAdvice"/>
    <tx:advice id="txAdvice" transaction-manager="transactionManager">
    		<tx:method name="*"/>
    BTW: <tx:annotation-driven/> is declared in other file together with the transactionManager defined on XML, both with the purpose to be used only with Spring for XML or Annotation approaches...Such file never is loaded or referenced with JavaConfig, it is isolated for this approach.

    And The Java classes are free of any this

    public class ArticuloServiceImpl implements ArticuloService{
    	private static final Logger logger = LoggerFactory.getLogger(ArticuloServiceImpl.class);
    	private ArticuloRepository articuloRepository;
    	public ArticuloServiceImpl(ArticuloRepository articuloRepository){
    		this.articuloRepository = articuloRepository;
    The Bean is created with JavaConfig

    public class SpringFrameworkServiceConfiguration {
    	public ArticuloService articuloService(ArticuloRepository articuloRepository){
    		ArticuloService articuloService = new ArticuloServiceImpl(articuloRepository);
    		return articuloService;
    How I can configure aop : point cut, aop:advisor, tx:advice into JavaConfig... to avoid in a 100% XML?

    I know I can mix XML with JavaConfig and annotations... but in the case I have the explicit situation to use Java in a 100% without XML and annotations...How I can do this?

    Thank You.