KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jboss > test > web > ejb > StatelessSessionBean2


1 /*
2   * JBoss, Home of Professional Open Source
3   * Copyright 2005, JBoss Inc., and individual contributors as indicated
4   * by the @authors tag. See the copyright.txt in the distribution for a
5   * full listing of individual contributors.
6   *
7   * This is free software; you can redistribute it and/or modify it
8   * under the terms of the GNU Lesser General Public License as
9   * published by the Free Software Foundation; either version 2.1 of
10   * the License, or (at your option) any later version.
11   *
12   * This software is distributed in the hope that it will be useful,
13   * but WITHOUT ANY WARRANTY; without even the implied warranty of
14   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15   * Lesser General Public License for more details.
16   *
17   * You should have received a copy of the GNU Lesser General Public
18   * License along with this software; if not, write to the Free
19   * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
20   * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
21   */

22 package org.jboss.test.web.ejb;
23
24 import javax.naming.InitialContext JavaDoc;
25 import javax.ejb.CreateException JavaDoc;
26 import javax.ejb.EJBException JavaDoc;
27 import javax.ejb.SessionBean JavaDoc;
28 import javax.ejb.SessionContext JavaDoc;
29
30 import org.jboss.test.web.interfaces.ReferenceTest;
31 import org.jboss.test.web.interfaces.StatelessSession;
32 import org.jboss.test.web.interfaces.StatelessSessionHome;
33 import org.jboss.test.web.interfaces.ReturnData;
34 import org.jboss.logging.Logger;
35
36 /** A stateless SessionBean
37
38  @author Scott.Stark@jboss.org
39  @version $Revision: 37406 $
40  */

41 public class StatelessSessionBean2 implements SessionBean JavaDoc
42 {
43    static Logger log = Logger.getLogger(StatelessSessionBean2.class);
44
45    private SessionContext JavaDoc sessionContext;
46
47    public void ejbCreate() throws CreateException JavaDoc
48    {
49       log.debug("ejbCreate() called");
50    }
51
52    public void ejbActivate()
53    {
54       log.debug("ejbActivate() called");
55    }
56
57    public void ejbPassivate()
58    {
59       log.debug("ejbPassivate() called");
60    }
61
62    public void ejbRemove()
63    {
64       log.debug("ejbRemove() called");
65    }
66
67    public void setSessionContext(SessionContext JavaDoc context)
68    {
69       sessionContext = context;
70    }
71
72    public String JavaDoc echo(String JavaDoc arg)
73    {
74       log.debug("echo, arg=" + arg);
75       return arg;
76    }
77
78    public String JavaDoc forward(String JavaDoc echoArg)
79    {
80       log.debug("forward, echoArg=" + echoArg);
81       String JavaDoc echo = null;
82       try
83       {
84          InitialContext JavaDoc ctx = new InitialContext JavaDoc();
85          StatelessSessionHome home = (StatelessSessionHome) ctx.lookup("java:comp/env/ejb/Session");
86          StatelessSession bean = home.create();
87          echo = bean.echo(echoArg);
88       }
89       catch (Exception JavaDoc e)
90       {
91          log.debug("failed", e);
92          e.fillInStackTrace();
93          throw new EJBException JavaDoc(e);
94       }
95       return echo;
96    }
97
98    public void noop(ReferenceTest test, boolean optimized)
99    {
100       boolean wasSerialized = test.getWasSerialized();
101       log.debug("noop, test.wasSerialized=" + wasSerialized + ", optimized=" + optimized);
102       if (optimized && wasSerialized == true)
103          throw new EJBException JavaDoc("Optimized call had serialized argument");
104       if (optimized == false && wasSerialized == false)
105          throw new EJBException JavaDoc("NotOptimized call had non serialized argument");
106    }
107
108    public ReturnData getData()
109    {
110       ReturnData data = new ReturnData();
111       data.data = "TheReturnData2";
112       return data;
113    }
114
115    /** A method deployed with no method permissions */
116    public void unchecked()
117    {
118       log.debug("unchecked");
119    }
120
121    /** A method deployed with method permissions such that only a run-as
122     * assignment will allow access.
123     */

124    public void checkRunAs()
125    {
126       log.debug("checkRunAs");
127    }
128 }
129
Popular Tags