1 /** 2 * EasyBeans 3 * Copyright (C) 2006 Bull S.A.S. 4 * Contact: easybeans@objectweb.org 5 * 6 * This library is free software; you can redistribute it and/or 7 * modify it under the terms of the GNU Lesser General Public 8 * License as published by the Free Software Foundation; either 9 * version 2.1 of the License, or any later version. 10 * 11 * This library is distributed in the hope that it will be useful, 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 * Lesser General Public License for more details. 15 * 16 * You should have received a copy of the GNU Lesser General Public 17 * License along with this library; if not, write to the Free Software 18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 19 * USA 20 * 21 * -------------------------------------------------------------------------- 22 * $Id: SLSBInvocationContext01.java 880 2006-07-17 11:51:17Z studzine $ 23 * -------------------------------------------------------------------------- 24 */ 25 package org.objectweb.easybeans.tests.common.ejbs.stateless.containermanaged.invocationcontext; 26 27 import javax.ejb.Remote; 28 import javax.ejb.Stateless; 29 import javax.interceptor.AroundInvoke; 30 import javax.interceptor.ExcludeClassInterceptors; 31 import javax.interceptor.InvocationContext; 32 33 import org.objectweb.easybeans.tests.common.ejbs.base.invocationcontext.ItfInvocation00; 34 35 /** 36 * This bean is used to manipulate the invocation context object. 37 * @author Eduardo Studzinski E. de Castro 38 * @author Gisele Pinheiro Souza 39 */ 40 @Stateless 41 @Remote 42 public class SLSBInvocationContext01 implements ItfInvocation00 { 43 44 /** 45 * Information from interceptor. 46 */ 47 private Integer interceptorInfo = null; 48 49 /** 50 * Verifies if the Interceptor.getTarget() returns an object with the same 51 * hashcode of the bean instance. 52 */ 53 public void check() { 54 if (interceptorInfo.intValue() != this.hashCode()) { 55 throw new IllegalStateException("The referenced bean is not equal as the invocation context reference."); 56 } 57 } 58 59 /** 60 * Allows the interceptor to store an information in the bean. 61 * @param o information 62 */ 63 @ExcludeClassInterceptors 64 public void setInterceptorInfo(final Object o) { 65 interceptorInfo = (Integer) o; 66 } 67 68 /** 69 * Interceptor that checks the invocation context object, it's compares the 70 * bean descriptor. <li>The first parameter of the intercepted method must 71 * be a BeanDescriptor.</li> 72 * @param ic contains attributes of invocation 73 * @return method's invocation result 74 * @throws Exception if invocation fails 75 */ 76 @SuppressWarnings("unused") 77 @AroundInvoke 78 private Object checkDescriptor(final InvocationContext ic) throws Exception { 79 interceptorInfo = new Integer(ic.getTarget().hashCode()); 80 return ic.proceed(); 81 } 82 83 } 84