public interface BusinessObject {
public void doSomething();
public void doAnotherThing();
}
import mons
import mons
public void doSomething();
public void doAnotherThing();
}
import mons
import mons
public class BusinessObjectImpl implements BusinessObject {
private String words;
public void setWords(String words){
this
}
public void doSomething() {
Log log = LogFactory
(words);
}
public void doAnotherThing() {
Log log = LogFactory
(
}
}public class BusinessObjectImpl implements BusinessObject {
private String words;
public void setWords(String words){
this
}
public void doSomething() {
Log log = LogFactory
(words);
}
public void doAnotherThing() {
Log log = LogFactory
(
}
}
import org
import orgre
public class Main {
public static void main(String[] args){
XmlBeanFactory xbf = new XmlBeanFactory(new ClassPathResource(
BusinessObject bo = (BusinessObject)xbf
bo
bo
}
}import org
import orgre
public class Main {
public static void main(String[] args){
XmlBeanFactory xbf = new XmlBeanFactory(new ClassPathResource(
BusinessObject bo = (BusinessObject)xbf
bo
bo
}
}
import org
import org
import mons
import mons
public class MyInterceptor implements MethodInterceptor {
private String before
public void setAfter(String after) {
this
}
public void setBefore(String before) {
this
}
public Object invoke(MethodInvocation invocation) throws Throwable {
Log log = LogFactory
(before);
Object rval = invocation
(after);
return rval;
}
}import org
import org
import mons
import mons
public class MyInterceptor implements MethodInterceptor {
private String before
public void setAfter(String after) {
this
}
public void setBefore(String before) {
this
}
public Object invoke(MethodInvocation invocation) throws Throwable {
Log log = LogFactory
(before);
Object rval = invocation
(after);
return rval;
}
}
<?xml version=
<!DOCTYPE beans PUBLIC
<beans>
<bean id=
<property name=
<value>正在執行業務方法</value>
</property>
</bean>
<bean id=
<property name=
<value>執行業務方法前</value>
</property>
<property name=
<value>執行業務方法後</value>
</property>
</bean>
<bean id=
<property name=
<list>
<value>BusinessObject
</list>
</property>
</bean>
<bean id=
<property name=
<property name=
</bean>
<bean id=
<property name=
<ref local=
</property>
<property name=
<value>BusinessObject</value>
</property>
<property name=
<list>
<value>myInterceptor</value>
<value>myAdvisor</value>
</list>
</property>
</bean>
</beans><?xml version=
<!DOCTYPE beans PUBLIC
<beans>
<bean id=
<property name=
<value>正在執行業務方法</value>
</property>
</bean>
<bean id=
<property name=
<value>執行業務方法前</value>
</property>
<property name=
<value>執行業務方法後</value>
</property>
</bean>
<bean id=
<property name=
<list>
<value>BusinessObject
</list>
</property>
</bean>
<bean id=
<property name=
<property name=
</bean>
<bean id=
<property name=
<ref local=
</property>
<property name=
<value>BusinessObject</value>
</property>
<property name=
<list>
<value>myInterceptor</value>
<value>myAdvisor</value>
</list>
</property>
</bean>
</beans>
From:http://tw.wingwit.com/Article/program/Java/ky/201311/28815.html