Announcement Announcement Module
Collapse
No announcement yet.
setup spring-config-xml Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • setup spring-config-xml

    Hi everybody,

    I'm trying to setup an exception handling using spring aop.
    In fact I found an introduction (http://www.javabeat.net/tips/86-how-...pring-aop.html)
    but I'm having a few problems to configure my spring-config.xml.

    F.ex. I defined a bean in my applicationContext for a service:
    Code:
    <bean id="myService" class="package.MyService"></bean>
    In this bean I throw a Exception which I want to catch in my own ExceptionHandler.

    So how do I have to configure the spring-config.xml?
    My approach:
    Code:
    ?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE beans PUBLIC
        "-//SPRING//DTD BEAN//EN"
        "http://www.springframework.org/dtd/spring-beans.dtd">
    
    <beans>
    
        <!-- Bean configuration -->
        <bean id="businesslogicbean" class="org.springframework.aop.framework.ProxyFactoryBean">
            <property name="proxyInterfaces">
                <value>????</value>
            </property>
            <property name="target">
                <ref local="beanTarget" />
            </property>
            <property name="interceptorNames">
                <list>
                    <value>theTracingThrowsAdvisor</value>
                </list>
            </property>
        </bean>
    
        <!-- Bean Classes -->
        <bean id="beanTarget" class="package.MyService" />
    
        <!-- Advisor pointcut definition for before advice -->
        <bean id="theTracingThrowsAdvisor"
            class="org.springframework.aop.support.RegexpMethodPointcutAdvisor">
            <property name="advice">
                <ref local="theTracingThrowsAdvice" />
            </property>
            <property name="pattern">
                <value>.*</value>
            </property>
        </bean>
    
        <!-- Advice classes -->
        <bean id="theTracingThrowsAdvice"
            class="package.ExceptionHandler" />
    
    </beans>
    This doesn't work.
    I even don't know how to handle the proxyInterface? Do I have to have one??

    Thanks in advance!

  • #2
    Spring reference clearly defines what 'proxyInterfaces' property stands for - 7.5.3. JDK- and CGLIB-based proxies.

    Also I'd recommend you to use Spring2 aop - 6. Aspect Oriented Programming with Spring. It's more convenient and provides transparent aspectj integration in the case of @AspectJ configuration style usage.

    Comment

    Working...
    X