Announcement Announcement Module
No announcement yet.
trial aop code not working Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • trial aop code not working

    I am trying to understand the aop concept by writing a simple application. The intent is that a simple message will be printed when the control enters a particular method. I am trying the MethodBeforeAdvice, AfterReturningAdvice, ThrowsAdvice interfaces. I am pasting the appropriate code snippets

    <bean id="logInterceptor" class=" thodPointcutAdvisor">
    <property name="mappedName">
    <property name="advice">
    <ref bean="logAdvice"/>

    <!--this is the advice -->
    <bean id="logAdvice" class=" Welcome"/>

    <bean id="log" class="org.springframework.aop.framework.ProxyFact oryBean">
    <property name="proxyInterfaces">
    <value> story.HistoryDAO</value>
    <property name="interceptorNames">
    <property name="target">
    <ref bean="scopingMgr"></ref>

    <bean id="scopingMgr" class="org.springframework.transaction.interceptor .TransactionProxyFactoryBean">
    <property name="transactionManager" ref="transactionManager"/>
    <property name="target" ref="scopingTarget"/>
    <property name="transactionAttributes">
    <prop key="get*">PROPAGATION_REQUIRED,readOnly</prop>
    <!--<prop key="find*">PROPAGATION_REQUIRED,readOnly</prop>-->
    <!--<prop key="load*">PROPAGATION_REQUIRED,readOnly</prop>-->
    <!--<prop key="store*">PROPAGATION_REQUIRED</prop>-->

    <bean id="transactionManager" class="org.springframework.orm.hibernate3.Hibernat eTransactionManager">
    <property name="sessionFactory">
    <ref bean="sessionFactory"/>

    <bean id="scopingTarget" scope="prototype" class=" story.HistoryDAOImpl">
    <property name="sessionFactory" ref="sessionFactory"/>


    public class FinderWelcome implements MethodBeforeAdvice, AfterReturningAdvice, ThrowsAdvice

    public FinderWelcome()
    System.out.println("come in the constructor of FinderWelcome");

    public void before(Method method, Object[] objects, Object object) throws Throwable
    // Scoping s = (Scoping)objects[0];
    System.out.println("Come aspect to delete id ");

    public void afterReturning(Object arg0, Method arg1, Object[] arg2, Object arg3) throws Throwable
    System.out.println("come in the after returning of finderwelcome");

    public void afterThrowing(Method m, Object[] args, Object target, Throwable ex)
    System.out.println("come in the afterThrowing of finderwelcome");

    method in HistoryDAOImpl

    public void deleteScope(Scoping scope) throws DataAccessException


    The problem is that none of the messages in the before or afterReturning are printed.

    Last edited by manojkar; Oct 10th, 2007, 09:23 AM. Reason: wrapped the code in <code/>

  • #2
    Please re-edit your post with code tags

    Can you re-edit your posting and wrap code with code tags?