Announcement Announcement Module
Collapse
No announcement yet.
cflow in XML definition Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • cflow in XML definition

    Hi,

    first of all, I'm pretty new to Spring AOP, so sorry for asking stupid questions.

    I'd like to define, in a springconfig.xml file, a cflow pointcut. As far as I have seen so far, beans created through the ProxyFactoryBean are bound to interceptors via the "interceptorNames" property.

    The interceptors, in the examples I've seen, implement the PointcutAdvisor interface.

    Now, there is a ControlFlowPointcut, but no corresponding advisor.

    How do I, in the XML file, describe the binding to a cflow pointcut? What concrete advisor beans do I have to use?

    Thanks in advance,

    Michael

  • #2
    Hopefully this example will help:
    Code:
    	<bean id="myPointcut" class="org.springframework.aop.support.ControlFlowPointcut">
            <constructor-arg index="0" >
                <value>forum9652.cflow.Outer</value>
            </constructor-arg> 
    	</bean>
    
        <bean id="cFlowAdvisor" class="org.springframework.aop.support.DefaultPointcutAdvisor">
            <property name="pointcut">
                <ref local="myPointcut"/>
            </property>
            <property name="advice">
                <ref local="advice"/>
            </property>
        </bean>

    If Outer defines:
    Code:
        public String doSomethingOne&#40;int i&#41; &#123;
            return proxiedObject.doSomething1&#40;i&#41;;
        &#125;
    Then
    Code:
    new Outer&#40;proxiedObject&#41;.doSomethingOne&#40;1&#41;;
    will be advised, but:
    Code:
            TestBean tb = &#40;TestBean&#41; ctx.getBean&#40;"testBean"&#41;;
            String result = tb.doSomething1&#40;10&#41;;
    won't be.

    Comment


    • #3
      Hi,

      thanks. This already improves my understanding, but I was actually up to formulating, in Spring XML configuration, a pointcut like ths one (in AspectJ syntax):

      Code:
      execution&#40;SomeClass.someMethod&#40;&#41;&#41; && cflow&#40;execution&#40;SomeOtherClass.someOtherMethod&#40;&#41;&#41;&#41;
      From what you have posted, it seems that the cflow matches when a method is called from a certain object, not from some other control flow.

      Is that possible in Spring AOP?

      Thanks,

      Michael

      Comment


      • #4
        There is currently no way to specify that a pointcut executes below another pointcut
        See Control flow pointcuts

        Comment


        • #5
          Hi,

          oops. I thought I had read that section. :shock:

          Thanks a lot!

          Michael

          Comment

          Working...
          X