Java Reference
In-Depth Information
public void showBanner() throws IOException {
InputStream in = banner.getInputStream();
...
}
}
In the bean configuration, you can simply specify the resource path for this Resource property.
Spring will use the preregistered property editor ResourceEditor to convert it into a Resource object
before injecting it into your bean.
<bean id="bannerLoader"
class="com.apress.springenterpriserecipes.shop.BannerLoader"
init-method="showBanner">
<property name="banner">
<value>classpath:com/apress/springenterpriserecipes/shop/banner.txt</value>
</property>
</bean>
1-10. Enabling AspectJ Annotation Support in Spring
Problem
Spring version 2.0 and later support the use of POJO aspects written with AspectJ annotations in its AOP
framework. But first you have to enable AspectJ annotation support in the Spring IoC container.
Solution
To enable AspectJ annotation support in the Spring IoC container, you only have to define an empty
XML element <aop:aspectj-autoproxy> in your bean configuration file. Then Spring will automatically
create proxies for any of your beans that are matched by your AspectJ aspects.
How It Works
Let's consider a calculator interface, whose interface is as follows:
package com.apress.springenterpriserecipes.calculator;
public interface ArithmeticCalculator {
public double add(double a, double b);
public double sub(double a, double b);
public double mul(double a, double b);
public double div(double a, double b);
}
package com.apress.springenterpriserecipes.calculator;
public interface UnitCalculator {
 
Search WWH ::




Custom Search