Use code includes and tabs in Regexp Pointcuts documentation
See gh-22171
This commit is contained in:
parent
515295e205
commit
a471aa6a9a
|
@ -128,18 +128,7 @@ the resulting pointcut is effectively the union of the specified patterns.)
|
||||||
|
|
||||||
The following example shows how to use `JdkRegexpMethodPointcut`:
|
The following example shows how to use `JdkRegexpMethodPointcut`:
|
||||||
|
|
||||||
[source,xml,indent=0,subs="verbatim"]
|
include-code::./JdkRegexpConfiguration[tag=snippet,indent=0]
|
||||||
----
|
|
||||||
<bean id="settersAndAbsquatulatePointcut"
|
|
||||||
class="org.springframework.aop.support.JdkRegexpMethodPointcut">
|
|
||||||
<property name="patterns">
|
|
||||||
<list>
|
|
||||||
<value>.*set.*</value>
|
|
||||||
<value>.*absquatulate</value>
|
|
||||||
</list>
|
|
||||||
</property>
|
|
||||||
</bean>
|
|
||||||
----
|
|
||||||
|
|
||||||
Spring provides a convenience class named `RegexpMethodPointcutAdvisor`, which lets us
|
Spring provides a convenience class named `RegexpMethodPointcutAdvisor`, which lets us
|
||||||
also reference an `Advice` (remember that an `Advice` can be an interceptor, before advice,
|
also reference an `Advice` (remember that an `Advice` can be an interceptor, before advice,
|
||||||
|
@ -147,21 +136,7 @@ throws advice, and others). Behind the scenes, Spring uses a `JdkRegexpMethodPoi
|
||||||
Using `RegexpMethodPointcutAdvisor` simplifies wiring, as the one bean encapsulates both
|
Using `RegexpMethodPointcutAdvisor` simplifies wiring, as the one bean encapsulates both
|
||||||
pointcut and advice, as the following example shows:
|
pointcut and advice, as the following example shows:
|
||||||
|
|
||||||
[source,xml,indent=0,subs="verbatim"]
|
include-code::./RegexpConfiguration[tag=snippet,indent=0]
|
||||||
----
|
|
||||||
<bean id="settersAndAbsquatulateAdvisor"
|
|
||||||
class="org.springframework.aop.support.RegexpMethodPointcutAdvisor">
|
|
||||||
<property name="advice">
|
|
||||||
<ref bean="beanNameOfAopAllianceInterceptor"/>
|
|
||||||
</property>
|
|
||||||
<property name="patterns">
|
|
||||||
<list>
|
|
||||||
<value>.*set.*</value>
|
|
||||||
<value>.*absquatulate</value>
|
|
||||||
</list>
|
|
||||||
</property>
|
|
||||||
</bean>
|
|
||||||
----
|
|
||||||
|
|
||||||
You can use `RegexpMethodPointcutAdvisor` with any `Advice` type.
|
You can use `RegexpMethodPointcutAdvisor` with any `Advice` type.
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,34 @@
|
||||||
|
/*
|
||||||
|
* Copyright 2002-2024 the original author or authors.
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* https://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package org.springframework.docs.core.aopapi.aopapipointcutsregex;
|
||||||
|
|
||||||
|
import org.springframework.aop.support.JdkRegexpMethodPointcut;
|
||||||
|
import org.springframework.context.annotation.Bean;
|
||||||
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
|
||||||
|
// tag::snippet[]
|
||||||
|
@Configuration
|
||||||
|
public class JdkRegexpConfiguration {
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
public JdkRegexpMethodPointcut settersAndAbsquatulatePointcut() {
|
||||||
|
JdkRegexpMethodPointcut pointcut = new JdkRegexpMethodPointcut();
|
||||||
|
pointcut.setPatterns(".*set.*", ".*absquatulate");
|
||||||
|
return pointcut;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// end::snippet[]
|
|
@ -0,0 +1,38 @@
|
||||||
|
/*
|
||||||
|
* Copyright 2002-2024 the original author or authors.
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* https://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package org.springframework.docs.core.aopapi.aopapipointcutsregex;
|
||||||
|
|
||||||
|
import org.aopalliance.aop.Advice;
|
||||||
|
|
||||||
|
import org.springframework.aop.support.RegexpMethodPointcutAdvisor;
|
||||||
|
import org.springframework.context.annotation.Bean;
|
||||||
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
|
||||||
|
// tag::snippet[]
|
||||||
|
@Configuration
|
||||||
|
public class RegexpConfiguration {
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
public RegexpMethodPointcutAdvisor settersAndAbsquatulateAdvisor(Advice beanNameOfAopAllianceInterceptor) {
|
||||||
|
RegexpMethodPointcutAdvisor advisor = new RegexpMethodPointcutAdvisor();
|
||||||
|
advisor.setAdvice(beanNameOfAopAllianceInterceptor);
|
||||||
|
advisor.setPatterns(".*set.*", ".*absquatulate");
|
||||||
|
return advisor;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// end::snippet[]
|
||||||
|
|
|
@ -0,0 +1,32 @@
|
||||||
|
/*
|
||||||
|
* Copyright 2002-2024 the original author or authors.
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* https://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package org.springframework.docs.core.aopapi.aopapipointcutsregex
|
||||||
|
|
||||||
|
import org.springframework.aop.support.JdkRegexpMethodPointcut
|
||||||
|
import org.springframework.context.annotation.Bean
|
||||||
|
import org.springframework.context.annotation.Configuration
|
||||||
|
|
||||||
|
// tag::snippet[]
|
||||||
|
@Configuration
|
||||||
|
class JdkRegexpConfiguration {
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
fun settersAndAbsquatulatePointcut() = JdkRegexpMethodPointcut().apply {
|
||||||
|
setPatterns(".*set.*", ".*absquatulate")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// end::snippet[]
|
|
@ -0,0 +1,34 @@
|
||||||
|
/*
|
||||||
|
* Copyright 2002-2024 the original author or authors.
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* https://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package org.springframework.docs.core.aopapi.aopapipointcutsregex
|
||||||
|
|
||||||
|
import org.aopalliance.aop.Advice
|
||||||
|
import org.springframework.aop.support.RegexpMethodPointcutAdvisor
|
||||||
|
import org.springframework.context.annotation.Bean
|
||||||
|
import org.springframework.context.annotation.Configuration
|
||||||
|
|
||||||
|
// tag::snippet[]
|
||||||
|
@Configuration
|
||||||
|
class RegexpConfiguration {
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
fun settersAndAbsquatulateAdvisor(beanNameOfAopAllianceInterceptor: Advice) = RegexpMethodPointcutAdvisor().apply {
|
||||||
|
advice = beanNameOfAopAllianceInterceptor
|
||||||
|
setPatterns(".*set.*", ".*absquatulate")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// end::snippet[]
|
|
@ -0,0 +1,20 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<beans xmlns="http://www.springframework.org/schema/beans"
|
||||||
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xsi:schemaLocation="http://www.springframework.org/schema/beans
|
||||||
|
https://www.springframework.org/schema/beans/spring-beans.xsd">
|
||||||
|
|
||||||
|
<!-- tag::snippet[] -->
|
||||||
|
<bean id="settersAndAbsquatulatePointcut"
|
||||||
|
class="org.springframework.aop.support.JdkRegexpMethodPointcut">
|
||||||
|
<property name="patterns">
|
||||||
|
<list>
|
||||||
|
<value>.*set.*</value>
|
||||||
|
<value>.*absquatulate</value>
|
||||||
|
</list>
|
||||||
|
</property>
|
||||||
|
</bean>
|
||||||
|
<!-- end::snippet[] -->
|
||||||
|
|
||||||
|
</beans>
|
||||||
|
|
|
@ -0,0 +1,22 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<beans xmlns="http://www.springframework.org/schema/beans"
|
||||||
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xsi:schemaLocation="http://www.springframework.org/schema/beans
|
||||||
|
https://www.springframework.org/schema/beans/spring-beans.xsd">
|
||||||
|
|
||||||
|
<!-- tag::snippet[] -->
|
||||||
|
<bean id="settersAndAbsquatulateAdvisor"
|
||||||
|
class="org.springframework.aop.support.RegexpMethodPointcutAdvisor">
|
||||||
|
<property name="advice">
|
||||||
|
<ref bean="beanNameOfAopAllianceInterceptor"/>
|
||||||
|
</property>
|
||||||
|
<property name="patterns">
|
||||||
|
<list>
|
||||||
|
<value>.*set.*</value>
|
||||||
|
<value>.*absquatulate</value>
|
||||||
|
</list>
|
||||||
|
</property>
|
||||||
|
</bean>
|
||||||
|
<!-- end::snippet[] -->
|
||||||
|
|
||||||
|
</beans>
|
Loading…
Reference in New Issue