I have five source files.
[code=java]
public class SpringAOP implements SpringAOPInterf ace
{
public void showMessage()
{
System.out.prin tln("I m learning Spring+AOP, & i really enjoying dis :-)");
}
}
public interface SpringAOPInterf ace
{
public void showMessage();
}
import org.springframe work.aop.*;
import java.lang.refle ct.Method;
public class SpringAOPAdvice implements MethodBeforeAdv ice
{
public void before(Method method,Object args[],Object Target) throws Throwable
{
System.out.prin tln("My logging message is here");
}
}
import org.springframe work.beans.fact ory.*;
import org.springframe work.beans.fact ory.xml.*;
import org.springframe work.context.su pport.*;
import org.springframe work.core.io.*;
public class SpringAOPTest
{
public static void main(String args[])
{
/*BeanFactory b = new XmlBeanFactory( new FileSystemResou rce("c:/SpringAOP.xml") );
((SpringAOP)b.g etBean("testTar get")).showMess age();*/
FileSystemXmlAp plicationContex t c = new FileSystemXmlAp plicationContex t("c:/SpringAOP.xml") ;
((SpringAOP)c.g etBean("testTar get")).showMess age();
System.out.prin tln("Yahoo....D one it............! !!");
}
}
[/code]
[code=xml]
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframe work.org/dtd/spring-beans.dtd">
<beans>
<bean id="testTarget " class="SpringAO P"/>
<bean id="testAdvice " class="SpringAO PAdvice"/>
<!--<bean id="testPointcu tAdvisor" class="org.spri ngframework.aop .support.NameMa tchMethodPointc utAdvisor">
<property name="mappedNam e">
<value>void showMessage()</value>
</property>
<property name="advice">
<ref bean="testAdvic e"/>
</property>
</bean>-->
<bean id="testProxyBe an" class="org.spri ngframework.aop .framework.Prox yFactoryBean">
<property name="intercept orNames">
<list>
<value>testAdvi ce</value>
</list>
</property>
<property name="target">
<ref bean="testTarge t"/>
</property>
</bean>
</beans>
[/code]
Right now my Logging message is not printed :-(
Where I am going wrong.
Please help !
Kind regards,
Dmjpro.
[code=java]
public class SpringAOP implements SpringAOPInterf ace
{
public void showMessage()
{
System.out.prin tln("I m learning Spring+AOP, & i really enjoying dis :-)");
}
}
public interface SpringAOPInterf ace
{
public void showMessage();
}
import org.springframe work.aop.*;
import java.lang.refle ct.Method;
public class SpringAOPAdvice implements MethodBeforeAdv ice
{
public void before(Method method,Object args[],Object Target) throws Throwable
{
System.out.prin tln("My logging message is here");
}
}
import org.springframe work.beans.fact ory.*;
import org.springframe work.beans.fact ory.xml.*;
import org.springframe work.context.su pport.*;
import org.springframe work.core.io.*;
public class SpringAOPTest
{
public static void main(String args[])
{
/*BeanFactory b = new XmlBeanFactory( new FileSystemResou rce("c:/SpringAOP.xml") );
((SpringAOP)b.g etBean("testTar get")).showMess age();*/
FileSystemXmlAp plicationContex t c = new FileSystemXmlAp plicationContex t("c:/SpringAOP.xml") ;
((SpringAOP)c.g etBean("testTar get")).showMess age();
System.out.prin tln("Yahoo....D one it............! !!");
}
}
[/code]
[code=xml]
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframe work.org/dtd/spring-beans.dtd">
<beans>
<bean id="testTarget " class="SpringAO P"/>
<bean id="testAdvice " class="SpringAO PAdvice"/>
<!--<bean id="testPointcu tAdvisor" class="org.spri ngframework.aop .support.NameMa tchMethodPointc utAdvisor">
<property name="mappedNam e">
<value>void showMessage()</value>
</property>
<property name="advice">
<ref bean="testAdvic e"/>
</property>
</bean>-->
<bean id="testProxyBe an" class="org.spri ngframework.aop .framework.Prox yFactoryBean">
<property name="intercept orNames">
<list>
<value>testAdvi ce</value>
</list>
</property>
<property name="target">
<ref bean="testTarge t"/>
</property>
</bean>
</beans>
[/code]
Right now my Logging message is not printed :-(
Where I am going wrong.
Please help !
Kind regards,
Dmjpro.
Comment