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.test.web.ejb;
023:
024: import javax.naming.InitialContext;
025: import javax.ejb.CreateException;
026: import javax.ejb.EJBException;
027: import javax.ejb.SessionBean;
028: import javax.ejb.SessionContext;
029:
030: import org.jboss.test.web.interfaces.ReferenceTest;
031: import org.jboss.test.web.interfaces.StatelessSession;
032: import org.jboss.test.web.interfaces.StatelessSessionHome;
033: import org.jboss.test.web.interfaces.ReturnData;
034: import org.jboss.logging.Logger;
035:
036: /** A stateless SessionBean
037:
038: @author Scott.Stark@jboss.org
039: @version $Revision: 57211 $
040: */
041: public class StatelessSessionBean2 implements SessionBean {
042: static Logger log = Logger.getLogger(StatelessSessionBean2.class);
043:
044: private SessionContext sessionContext;
045:
046: public void ejbCreate() throws CreateException {
047: log.debug("ejbCreate() called");
048: }
049:
050: public void ejbActivate() {
051: log.debug("ejbActivate() called");
052: }
053:
054: public void ejbPassivate() {
055: log.debug("ejbPassivate() called");
056: }
057:
058: public void ejbRemove() {
059: log.debug("ejbRemove() called");
060: }
061:
062: public void setSessionContext(SessionContext context) {
063: sessionContext = context;
064: }
065:
066: public String echo(String arg) {
067: log.debug("echo, arg=" + arg);
068: return arg;
069: }
070:
071: public String forward(String echoArg) {
072: log.debug("forward, echoArg=" + echoArg);
073: String echo = null;
074: try {
075: InitialContext ctx = new InitialContext();
076: StatelessSessionHome home = (StatelessSessionHome) ctx
077: .lookup("java:comp/env/ejb/Session");
078: StatelessSession bean = home.create();
079: echo = bean.echo(echoArg);
080: } catch (Exception e) {
081: log.debug("failed", e);
082: e.fillInStackTrace();
083: throw new EJBException(e);
084: }
085: return echo;
086: }
087:
088: public void noop(ReferenceTest test, boolean optimized) {
089: boolean wasSerialized = test.getWasSerialized();
090: log.debug("noop, test.wasSerialized=" + wasSerialized
091: + ", optimized=" + optimized);
092: if (optimized && wasSerialized == true)
093: throw new EJBException(
094: "Optimized call had serialized argument");
095: if (optimized == false && wasSerialized == false)
096: throw new EJBException(
097: "NotOptimized call had non serialized argument");
098: }
099:
100: public ReturnData getData() {
101: ReturnData data = new ReturnData();
102: data.data = "TheReturnData2";
103: return data;
104: }
105:
106: /** A method deployed with no method permissions */
107: public void unchecked() {
108: log.debug("unchecked");
109: }
110:
111: /** A method deployed with method permissions such that only a run-as
112: * assignment will allow access.
113: */
114: public void checkRunAs() {
115: log.debug("checkRunAs");
116: }
117: }
|