01: /**
02: * EasyBeans
03: * Copyright (C) 2006 Bull S.A.S.
04: * Contact: easybeans@ow2.org
05: *
06: * This library is free software; you can redistribute it and/or
07: * modify it under the terms of the GNU Lesser General Public
08: * License as published by the Free Software Foundation; either
09: * 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: EJB2And3Bean.java 1970 2007-10-16 11:49:25Z benoitf $
23: * --------------------------------------------------------------------------
24: */package org.ow2.easybeans.examples.migrationejb21;
25:
26: import javax.ejb.CreateException;
27: import javax.ejb.EJB;
28: import javax.ejb.LocalHome;
29: import javax.ejb.Remote;
30: import javax.ejb.RemoteHome;
31: import javax.ejb.Stateless;
32:
33: /**
34: * Simple stateless bean with EJB 2.1 view.
35: * @author Florent Benoit
36: */
37: @Stateless
38: @RemoteHome(EJB2RemoteHome.class)
39: @LocalHome(EJB2LocalHome.class)
40: @Remote(EJB3RemoteBusinessInterface.class)
41: public class EJB2And3Bean implements EJB3RemoteBusinessInterface {
42:
43: /**
44: * Link to itself (EJB 2.x) Remote view.
45: */
46: @EJB
47: private EJB2RemoteHome ejb2RemoteView = null;
48:
49: /**
50: * Link to itself (EJB 2.x) Local view.
51: */
52: @EJB
53: private EJB2LocalHome ejb2LocalView = null;
54:
55: /**
56: * Hello world (of the EJB3 business interface).
57: */
58: public void hello() {
59: System.out.println("Hello world EJB 3.0 !");
60: }
61:
62: /**
63: * Hello World (of EJB 2.1 Remote interface).
64: */
65: public void hello21Remote() {
66: System.out.println("Hello world EJB 2.1 Remote View !");
67: System.out.println("Link to itself remote = " + ejb2RemoteView);
68: System.out.println("Link to itself local view = "
69: + ejb2LocalView);
70: System.out.println("Calling itself on the local view...");
71: try {
72: ejb2LocalView.create().hello21Local();
73: } catch (CreateException e) {
74: System.err.println("Cannot create local bean");
75: e.printStackTrace();
76: }
77: }
78:
79: /**
80: * Hello World (of EJB 2.1 Local interface).
81: */
82: public void hello21Local() {
83: System.out.println("Hello world EJB 2.1 Local View !");
84: }
85:
86: }
|