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

  • trial aop code not working

    Hi,
    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

    <code>
    <bean id="logInterceptor" class="org.springframework.aop.support.NameMatchMe thodPointcutAdvisor">
    <property name="mappedName">
    <value>deleteScope</value>
    </property>
    <property name="advice">
    <ref bean="logAdvice"/>
    </property>
    </bean>

    <!--this is the advice -->
    <bean id="logAdvice" class="com.hmco.college.finder.webapp.admin.Finder Welcome"/>

    <bean id="log" class="org.springframework.aop.framework.ProxyFact oryBean">
    <property name="proxyInterfaces">
    <value>com.hmco.college.finder.common.dao.springHi story.HistoryDAO</value>
    </property>
    <property name="interceptorNames">
    <list>
    <value>logInterceptor</value>
    </list>
    </property>
    <property name="target">
    <ref bean="scopingMgr"></ref>
    </property>
    </bean>


    <bean id="scopingMgr" class="org.springframework.transaction.interceptor .TransactionProxyFactoryBean">
    <property name="transactionManager" ref="transactionManager"/>
    <property name="target" ref="scopingTarget"/>
    <property name="transactionAttributes">
    <props>
    <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>-->
    </props>
    </property>
    </bean>


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

    <bean id="scopingTarget" scope="prototype" class="com.hmco.college.finder.common.dao.springHi story.HistoryDAOImpl">
    <property name="sessionFactory" ref="sessionFactory"/>

    </bean>


    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
    {
    getHibernateTemplate().delete(scope);
    getHibernateTemplate().flush();
    }

    </code>

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

    -Manoj
    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?

    Comment

    Working...
    X