KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jboss > test > isolation > ejb > a > SessionAEJB


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.isolation.ejb.a;
23
24 import javax.ejb.CreateException JavaDoc;
25 import javax.ejb.EJBException JavaDoc;
26 import javax.ejb.SessionBean JavaDoc;
27 import javax.ejb.SessionContext JavaDoc;
28 import javax.naming.InitialContext JavaDoc;
29
30 import org.jboss.logging.Logger;
31 import org.jboss.test.isolation.interfaces.IsolationDTO;
32 import org.jboss.test.isolation.interfaces.b.SessionB;
33 import org.jboss.test.isolation.interfaces.b.SessionBHome;
34 import org.jboss.test.util.Debug;
35
36 /**
37  * A SessionA.
38  *
39  * @author <a HREF="adrian@jboss.com">Adrian Brock</a>
40  * @version $Revision: 37406 $
41  */

42 public class SessionAEJB implements SessionBean JavaDoc
43 {
44    private static final Logger log = Logger.getLogger(SessionAEJB.class);
45    
46    public void invokeSessionB()
47    {
48       try
49       {
50          InitialContext JavaDoc ctx = new InitialContext JavaDoc();
51          Object JavaDoc o = ctx.lookup("java:comp/env/ejb/SessionB");
52
53          StringBuffer JavaDoc buffer = new StringBuffer JavaDoc("SessionBHome lookup");
54          Debug.displayClassInfo(o.getClass(), buffer);
55          log.info(buffer.toString());
56          buffer = new StringBuffer JavaDoc("My SessionBHome");
57          Debug.displayClassInfo(SessionBHome.class, buffer);
58          log.info(buffer.toString());
59          
60          SessionBHome home = (SessionBHome) o;
61          SessionB session = home.create();
62          
63          IsolationDTO dto = new IsolationDTO();
64          dto.payload = "hello";
65          
66          IsolationDTO result = session.sayHello(dto);
67          if (dto == result)
68             throw new EJBException JavaDoc("Expected pass by value");
69          if ("goodbye".equals(result.payload) == false)
70             throw new EJBException JavaDoc("Did not get expected 'goodbye'");
71       }
72       catch (Exception JavaDoc e)
73       {
74          throw new EJBException JavaDoc(e);
75       }
76    }
77    
78    public void ejbCreate() throws CreateException JavaDoc
79    {
80    }
81    
82    public void ejbActivate()
83    {
84    }
85
86    public void ejbPassivate()
87    {
88    }
89    
90    public void ejbRemove()
91    {
92    }
93    
94    public void setSessionContext(SessionContext JavaDoc ctx)
95    {
96    }
97 }
98
Popular Tags