Whiteship's Note

'<aop:pointcut>'에 해당되는 글 1건

  1. 2007.04.05 Schema 기반 Spring AOP 희한한 것

Schema 기반 Spring AOP 희한한 것

Spring/Chapter 6 : 2007.04.05 08:47


    <aop:config>
        <aop:aspect id="cinema" ref="aspect">
            <aop:pointcut id="sellTicket" expression="execution(* sell*(..))" />
            <aop:before method="welcome" pointcut-ref="sellTicket" />
            <aop:before method="welcome" pointcut="execution(* sell*(..))"/>
        </aop:aspect>
    </aop:config>

이렇게 포인트컷 하나, 어드바이스 다수 일 경우에는 실행이 되는데요.
    <aop:config>
        <aop:aspect id="cinema" ref="aspect">
            <aop:pointcut id="sellTicket" expression="execution(* sell*(..))" />
            <aop:before method="welcome" pointcut-ref="sellTicket" />

            <aop:pointcut id="sellTicket2" expression="execution(* sell*(..))" />
            <aop:before method="welcome" pointcut-ref="sellTicket2" />
        </aop:aspect>
    </aop:config>

이렇게 포인트컷이 둘 이상일 경우에는 에러가 발생합니다.
org.springframework.beans.factory.BeanDefinitionStoreException: Line 42 in XML document from class path resource [aop/newStyle/schemaConfiguration.xml] is invalid; nested exception is org.xml.sax.SAXParseException: cvc-complex-type.2.4.a: Invalid content was found starting with element 'aop:pointcut'. One of '{"http://www.springframework.org/schema/aop":before, "http://www.springframework.org/schema/aop":after, "http://www.springframework.org/schema/aop":after-returning, "http://www.springframework.org/schema/aop":after-throwing, "http://www.springframework.org/schema/aop":around}' is expected.

흠...in-line 포인트컷은 되는데 왜 그냥 포인트컷은 하나밖에 못쓸까요. 희한하군요.
top