KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > demo > ejb > client > ReverseBean


1 /*
2  * Jeenius - a J2EE Framework
3  * Copyright (C) 2002 The Mentum Group
4  *
5  * This library is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Lesser General Public
7  * License as published by the Free Software Foundation; either
8  * version 2.1 of the License, or (at your option) any later version.
9  *
10  * This library is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  * Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public
16  * License along with this library; if not, write to the Free Software
17  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18  */

19 package demo.ejb.client;
20
21 import javax.rmi.*;
22 import com.mentumgroup.jeenius.webclient.*;
23 import demo.ejb.interfaces.*;
24
25 public class ReverseBean extends EjbClient implements ActionBean
26 {
27   private String JavaDoc textToReverse;
28   private String JavaDoc reversedText;
29
30   /** This method is called to initialise the bean. See the Jeenius Tags design
31    * doc for information on what type of beans should implement what type of
32    * logic in this method.
33    */

34   public void initialise() throws ActionBeanException
35   {
36     // do nothing
37
}
38
39   /** This method is called to execute the bean. See the Jeenius Tags design
40    * doc for information on what type of beans should implemnt what type of
41    * logic in this method.
42    */

43   public void execute() throws ActionBeanException
44   {
45     if (textToReverse == null || textToReverse.trim().length() < 1)
46     {
47       throw new ValidationException("Please enter some text to reverse.");
48     }
49
50     try
51     {
52       Object JavaDoc homeRef = getContext().lookup("demo.Reverser");
53
54       ReverserHome home = (ReverserHome)PortableRemoteObject.narrow(homeRef,ReverserHome.class);
55
56       Reverser reverser = home.create();
57
58       reversedText = reverser.reverse(textToReverse);
59
60       reverser.remove();
61     }
62     catch(Exception JavaDoc e)
63     {
64       throw new FatalException("Unable to reverse string. Error was: " + e.getMessage() );
65     }
66   }
67
68
69   /** Setter for property textToReverse.
70    * @param textToReverse New value of property textToReverse.
71    */

72   public void setTextToReverse(java.lang.String JavaDoc textToReverse)
73   {
74     this.textToReverse = textToReverse;
75   }
76
77   /** Getter for property reversedText.
78    * @return Value of property reversedText.
79    */

80   public java.lang.String JavaDoc getReversedText()
81   {
82     return reversedText;
83   }
84
85   /** Getter for property textToReverse.
86    * @return Value of property textToReverse.
87    */

88   public java.lang.String JavaDoc getTextToReverse()
89   {
90     return textToReverse;
91   }
92
93 }
94
95
96
Popular Tags