001/*
002 * Copyright 2002-2018 the original author or authors.
003 *
004 * Licensed under the Apache License, Version 2.0 (the "License");
005 * you may not use this file except in compliance with the License.
006 * You may obtain a copy of the License at
007 *
008 *      https://www.apache.org/licenses/LICENSE-2.0
009 *
010 * Unless required by applicable law or agreed to in writing, software
011 * distributed under the License is distributed on an "AS IS" BASIS,
012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013 * See the License for the specific language governing permissions and
014 * limitations under the License.
015 */
016
017package org.springframework.aop.support;
018
019import java.io.Serializable;
020
021import org.aopalliance.aop.Advice;
022
023import org.springframework.aop.Pointcut;
024import org.springframework.aop.PointcutAdvisor;
025import org.springframework.core.Ordered;
026import org.springframework.util.Assert;
027
028/**
029 * Convenient base class for Advisors that are also static pointcuts.
030 * Serializable if Advice and subclass are.
031 *
032 * @author Rod Johnson
033 * @author Juergen Hoeller
034 */
035@SuppressWarnings("serial")
036public abstract class StaticMethodMatcherPointcutAdvisor extends StaticMethodMatcherPointcut
037                implements PointcutAdvisor, Ordered, Serializable {
038
039        private Advice advice;
040
041        private int order = Integer.MAX_VALUE;
042
043
044        /**
045         * Create a new StaticMethodMatcherPointcutAdvisor,
046         * expecting bean-style configuration.
047         * @see #setAdvice
048         */
049        public StaticMethodMatcherPointcutAdvisor() {
050        }
051
052        /**
053         * Create a new StaticMethodMatcherPointcutAdvisor for the given advice.
054         * @param advice the Advice to use
055         */
056        public StaticMethodMatcherPointcutAdvisor(Advice advice) {
057                Assert.notNull(advice, "Advice must not be null");
058                this.advice = advice;
059        }
060
061
062        public void setOrder(int order) {
063                this.order = order;
064        }
065
066        @Override
067        public int getOrder() {
068                return this.order;
069        }
070
071        public void setAdvice(Advice advice) {
072                this.advice = advice;
073        }
074
075        @Override
076        public Advice getAdvice() {
077                return this.advice;
078        }
079
080        @Override
081        public boolean isPerInstance() {
082                return true;
083        }
084
085        @Override
086        public Pointcut getPointcut() {
087                return this;
088        }
089
090}