001: /*
002: * JBoss, Home of Professional Open Source.
003: * Copyright 2006, Red Hat Middleware LLC, and individual contributors
004: * as indicated by the @author tags. See the copyright.txt file in the
005: * distribution for a full listing of individual contributors.
006: *
007: * This is free software; you can redistribute it and/or modify it
008: * under the terms of the GNU Lesser General Public License as
009: * published by the Free Software Foundation; either version 2.1 of
010: * the License, or (at your option) any later version.
011: *
012: * This software is distributed in the hope that it will be useful,
013: * but WITHOUT ANY WARRANTY; without even the implied warranty of
014: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
015: * Lesser General Public License for more details.
016: *
017: * You should have received a copy of the GNU Lesser General Public
018: * License along with this software; if not, write to the Free
019: * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
020: * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
021: */
022: package org.jboss.ejb3.test.interceptors2;
023:
024: import javax.ejb.EJB;
025: import javax.annotation.PostConstruct;
026: import javax.interceptor.AroundInvoke;
027: import javax.interceptor.ExcludeDefaultInterceptors;
028: import javax.interceptor.InvocationContext;
029: import javax.ejb.PostActivate;
030: import javax.annotation.PreDestroy;
031: import javax.ejb.PrePassivate;
032: import javax.ejb.Remove;
033: import javax.ejb.Stateful;
034:
035: import org.jboss.annotation.ejb.cache.simple.CacheConfig;
036:
037: /**
038: *
039: * @author <a href="kabir.khan@jboss.com">Kabir Khan</a>
040: * @version $Revision: 60233 $
041: */
042: @Stateful
043: @CacheConfig(maxSize=1)
044: public class InheritingSFSB extends InheritingBaseMiddle implements
045: InheritingSFSBRemote {
046: @EJB
047: StatusRemote status;
048:
049: public void method() {
050: System.out.println("method");
051: }
052:
053: @ExcludeDefaultInterceptors
054: public void methodNoDefault() {
055: System.out.println("methodNoDefault");
056: }
057:
058: @Remove
059: public void kill() {
060: System.out.println("kill");
061: }
062:
063: @AroundInvoke
064: public Object intercept(InvocationContext ctx) throws Exception {
065: status.addInterception(new Interception(this , "intercept"));
066: return ctx.proceed();
067: }
068:
069: @PostConstruct
070: void postConstruct() {
071: status.addLifecycle(PostConstruct.class, new Interception(this ,
072: "postConstruct"));
073: }
074:
075: @PostActivate
076: void postActivate() {
077: status.addLifecycle(PostActivate.class, new Interception(this ,
078: "postActivate"));
079: }
080:
081: @PrePassivate()
082: void prePassivate() {
083: status.addLifecycle(PrePassivate.class, new Interception(this ,
084: "prePassivate"));
085: }
086:
087: @PreDestroy()
088: void preDestroy() {
089: status.addLifecycle(PreDestroy.class, new Interception(this ,
090: "preDestroy"));
091: }
092:
093: public Object intercept2(InvocationContext ctx) throws Exception {
094: throw new RuntimeException("Should not be called");
095: }
096:
097: void postConstruct2() {
098: throw new RuntimeException("Should not be called");
099: }
100:
101: void postActivate2() {
102: throw new RuntimeException("Should not be called");
103: }
104:
105: void prePassivate2() {
106: throw new RuntimeException("Should not be called");
107: }
108:
109: void preDestroy2() {
110: throw new RuntimeException("Should not be called");
111: }
112:
113: }
|