1 /*
2 * Licensed to the Apache Software Foundation (ASF) under one
3 * or more contributor license agreements. See the NOTICE file
4 * distributed with this work for additional information
5 * regarding copyright ownership. The ASF licenses this file
6 * to you under the Apache License, Version 2.0 (the
7 * "License"); you may not use this file except in compliance
8 * with the License. You may obtain a copy of the License at
9 *
10 * http://www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing,
13 * software distributed under the License is distributed on an
14 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 * KIND, either express or implied. See the License for the
16 * specific language governing permissions and limitations
17 * under the License.
18 */
19 package org.apache.myfaces.orchestra.conversation;
20
21 import org.aopalliance.aop.Advice;
22 import org.springframework.aop.Pointcut;
23 import org.springframework.aop.PointcutAdvisor;
24
25 /**
26 * A Spring object that defines what Advice objects should be applied to which beans.
27 * <p>
28 * Various standard Spring BeanPostProcessor classes look for registered beans of type
29 * Advisor, test whether they apply to the bean being created and if so then add the
30 * advice to a proxy for that bean (creating the proxy if necessary).
31 * <p>
32 * Various sub-interfaces can be implemented by an Advisor class in order to filter
33 * which classes or methods it applies to. In Spring2.5, a class that simply implements
34 * Advisor gets applied to every method of every class. But in Spring2.0, it will get
35 * silently ignored - either PointcutAdvisor ot IntroductionAdvisor must be implemented.
36 * <p>
37 * This mock implementation is happy to apply the MockAdvice advice to any class
38 * that is offered to it by a BeanPostProcessor.
39 */
40 public class MockAdvisor implements PointcutAdvisor
41 {
42 MockAdvice advice = new MockAdvice();
43 public Advice getAdvice()
44 {
45 return advice;
46 }
47
48 public boolean isPerInstance()
49 {
50 return false;
51 }
52
53 public Pointcut getPointcut()
54 {
55 // return a pointcut that matches all methods
56 return Pointcut.TRUE;
57 }
58
59 public void setMessage(String msg)
60 {
61 advice.setMessage(msg);
62 }
63 }