1 /* 2 Copyright (c) 2003, Laurent Caillette. 3 All rights reserved. 4 5 Redistribution and use in source and binary forms, with or without modifica- 6 tion, are permitted provided that the following conditions are met: 7 8 1. Redistributions of source code must retain the above copyright notice, 9 this list of conditions and the following disclaimer. 10 11 2. Redistributions in binary form must reproduce the above copyright notice, 12 this list of conditions and the following disclaimer in the documentation 13 and/or other materials provided with the distribution. 14 15 3. The end-user documentation included with the redistribution, if any, must 16 include the following acknowledgment: "This product includes software 17 written by Laurent Caillette." 18 Alternately, this acknowledgment may appear in the software itself, if 19 and wherever such third-party acknowledgments normally appear. 20 21 4. The name "Laurent Caillette" must not be used to endorse or 22 promote products derived from this software without 23 prior written permission. For written permission, please contact 24 laurent.caillette@laposte.net 25 26 5. Products derived from this software may not be called 27 "Laurent Caillette", nor may "Laurent Caillette" appear 28 in their name, without prior written permission of the 29 author. 30 31 THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, 32 INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND 33 FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 34 AUTHOR (LAURENT CAILLETTE) BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 35 SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED 36 TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, 37 OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 38 THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 39 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 40 THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 41 */ 42 package tweed.system.interceptor; 43 import tweed.system.interceptor.InterceptionHandler; 44 import tweed.system.interceptor.MethodDescriptor; 45 46 /*** 47 * Hard-coded version of an intercepted <code>MyBean</code> class, 48 * useful for tests and bytecode reverse-engineering. 49 * 50 * @author Laurent Caillette 51 * @version $Id$ 52 */ 53 public class MyBeanInterceptor extends MyBean { 54 55 private final MyBean subject ; 56 private final InterceptionHandler interceptor ; 57 58 public MyBeanInterceptor( 59 MyBean subject, 60 InterceptionHandler interceptor 61 ) { 62 this.subject = subject ; 63 this.interceptor = interceptor ; 64 } 65 66 public final MethodDescriptor[] methodDescriptors = 67 new MethodDescriptor[ 10 ] ; 68 69 public Object getMyObject() { 70 interceptor.handleMethod( subject, methodDescriptors[ 0 ] ) ; 71 return super.getMyObject() ; 72 } 73 74 public void setMyObject( Object myObject ) { 75 super.setMyObject( myObject ) ; 76 } 77 78 public int getMyIntProperty() { 79 interceptor.handleMethod( subject, methodDescriptors[ 2 ] ) ; 80 return subject.getMyIntProperty() ; 81 } 82 83 public void setMyIntProperty( int value ) { 84 subject.setMyIntProperty( value ) ; 85 } 86 87 public String getMyStringProperty() { 88 interceptor.handleMethod( subject, methodDescriptors[ 4 ] ) ; 89 return subject.getMyStringProperty() ; 90 } 91 92 public void setMyStringProperty( String value ) { 93 subject.setMyStringProperty( value ) ; 94 } 95 96 public boolean isMyBooleanProperty() { 97 interceptor.handleMethod( subject, methodDescriptors[ 6 ] ) ; 98 return subject.isMyBooleanProperty() ; 99 } 100 101 public void setMyBooleanProperty( boolean value ) { 102 subject.setMyBooleanProperty( value ) ; 103 } 104 105 public int intInt( int amount ) { 106 return subject.intInt( amount ) ; 107 } 108 109 public void voidVoid() { 110 subject.voidVoid() ; 111 } 112 113 public double doubleIntDouble( int param1, double param2 ) { 114 return subject.doubleIntDouble( param1, param2 ) ; 115 } 116 117 }

This page was automatically generated by Maven