Default Auto proxy defaultadvisorautoproxycreator in ssm-spring-14:spring

Source: Internet
Author: User

------------I do not have him, but the hand is ripe, humble and foolish, and eager to be hungry-------------

Default Auto Proxy Defaultadvisorautoproxycreator

There is nothing to talk about, put the original code

Isomeservice Interface:

Package cn.dawn.day17atuo01; /*  */Publicinterface  isomeservice    {publicvoid Insert ();      Public void Delete ();      Public void Select ();      Public void update ();}

The Someserviceimpl class inherits the above interface:

Package cn.dawn.day17atuo01;/** * Created by Dawn on 2018/3/8.*/ Public classSomeserviceimpl implements isomeservice{ Public voidInsert () {System. out. println ("Insert OK"); }     Public voidDelete () {System. out. println ("Delete OK"); }     Public void Select() {System. out. println ("Select OK"); }     Public voidUpdate () {System. out. println ("Update OK"); }}

Loggerbefore class, made a pre-enhancement

 package cn.dawn.day17atuo01;import org.springframework.aop.MethodBeforeAdvice; Import Java.lang.reflect.Method;  /*  * * Created by Dawn on 2018/3/5.  */ /*   pre-enhancement  */ public  class   Loggerbefore implements Methodbeforeadvice {  Public  void   before (method, object[] objects, Object o) throws Throwable {System.  out . println ( "  logging   "    

In the XML configuration file

<?xml version="1.0"encoding="UTF-8"? ><beans xmlns="Http://www.springframework.org/schema/beans"Xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"XMLNS:AOP="HTTP://WWW.SPRINGFRAMEWORK.ORG/SCHEMA/AOP"xmlns:p="http://www.springframework.org/schema/p"xmlns:context="Http://www.springframework.org/schema/context"xsi:schemalocation="Http://www.springframework.org/schema/beanshttp//www.springframework.org/schema/beans/spring-beans.xsdhttp//WWW.SPRINGFRAMEWORK.ORG/SCHEMA/AOPhttp//www.springframework.org/schema/aop/spring-aop.xsdHttp://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd"><!--objects to enhance--<bean id="Service" class="Cn.dawn.day17atuo01.SomeServiceImpl"></bean> <!--enhanced Content-<bean id="Myadvice" class="Cn.dawn.day17atuo01.LoggerBefore"></bean> <!--Advisor--<bean id="Myadvisor" class="Org.springframework.aop.support.RegexpMethodPointcutAdvisor"> <property name="Advice" ref="Myadvice"></property> <!--<property name="Mappednames"Value="do*"></property>--> <!--<property name="pattern"Value=". *do.*"></property>--> <property name="Patterns"Value=". *select.*"></property> </bean> <!--default Auto-proxy-<beanclass="Org.springframework.aop.framework.autoproxy.DefaultAdvisorAutoProxyCreator"></bean></beans>

Must have consultant, no no no, the default automatic proxy does not have to implement parameters, he automatically matches

Single test method:

Package Cn.dawn.day17auto01;import Cn.dawn.day17atuo01.isomeservice;import org.junit.test;import Org.springframework.context.applicationcontext;import Org.springframework.context.support.ClassPathXmlApplicationContext;/** * Created by Dawn on 2018/3/3.*/ Public classtest20180312 {@Test/*Default Auto Proxy*/     Public voidt01 () {ApplicationContext context=NewClasspathxmlapplicationcontext ("Applicationcontext-day17auto01.xml"); Isomeservice Service= (Isomeservice) Context.getbean ("Service"); Service.Select(); }}

Default Auto proxy defaultadvisorautoproxycreator in ssm-spring-14:spring

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.