KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > ccm > demo1 > cif > ServerImpl


1 /*====================================================================
2
3 OpenCCM: The Open CORBA Component Model Platform
4 Copyright (C) 2000-2002 USTL - LIFL - GOAL
5 Contact: openccm-team@objectweb.org
6
7 This library is free software; you can redistribute it and/or
8 modify it under the terms of the GNU Lesser General Public
9 License as published by the Free Software Foundation; either
10 version 2.1 of the License, or any later version.
11
12 This library 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 library; if not, write to the Free Software
19 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
20 USA
21
22 Initial developer(s): Philippe Merle, Mathieu Vadet.
23 Contributor(s): Romain Rouvoy, Christophe Demarey.
24
25 ====================================================================*/

26
27 package org.objectweb.ccm.demo1.cif;
28
29 /**
30  * This is the implementation of the OMG IDL3 demo1::Server component type.
31  *
32  * This class inherits from the CIF generated skeleton class defined
33  * as ServerSessionComposition::ComponentImpl.
34  *
35  * The provided for_clients facet is directly implemented by the
36  * component class by implementing the demo1::Display interface.
37  *
38  * @author <a HREF="mailto:Philippe.Merle@lifl.fr">Philippe Merle</A>
39  * <a HREF="mailto:Mathieu.Vadet@lifl.fr">Mathieu Vadet</A>
40  * <a HREF="mailto:Romain.Rouvoy@lifl.fr">Romain Rouvoy</A>
41  * <a HREF="mailto:Christophe.Demarey@lifl.fr">Christophe Demarey</A>
42  */

43
44 public class ServerImpl
45      extends org.objectweb.ccm.demo1.ServerSessionComposition.ComponentImpl
46 {
47     // ==================================================================
48
//
49
// Internal state.
50
//
51
// ==================================================================
52

53     /** The name of the component. */
54     private String JavaDoc name_;
55
56     /** To refer to the GUI frame. */
57     private javax.swing.JFrame JavaDoc frame_;
58
59     /** To refer to the GUI output area. */
60     private javax.swing.JTextArea JavaDoc textArea_;
61
62     // ==================================================================
63
//
64
// Constructor.
65
//
66
// ==================================================================
67

68     /** The default constructor. */
69     public
70     ServerImpl()
71     {
72     }
73
74     // ==================================================================
75
//
76
// Internal methods.
77
//
78
// ==================================================================
79

80     // ==================================================================
81
//
82
// Public methods.
83
//
84
// ==================================================================
85

86     // ==================================================================
87
//
88
// Methods for OMG IDL Components::EnterpriseComponent
89
//
90
// ==================================================================
91

92     /**
93      * Complete the component configuration.
94      *
95      * @exception org.omg.Components.InvalidConfiguration
96      * Thrown if the configuration is invalid.
97      */

98     public void
99     configuration_complete ()
100     throws org.omg.Components.InvalidConfiguration
101     {
102         // Checks if the configuration is not completed.
103
if(name_ == null)
104             throw new org.omg.Components.InvalidConfiguration();
105
106         // Instantiating the GUI.
107

108         // Creates a Swing Frame.
109
frame_ = new javax.swing.JFrame JavaDoc(name_ + "'s Server GUI");
110         // Sets its size.
111
frame_.setSize(400, 300);
112
113         // Creates a text area for displaying inputs.
114
textArea_ = new javax.swing.JTextArea JavaDoc(40, 20);
115         textArea_.setEditable(false);
116
117         // Constructs and shows the GUI.
118
javax.swing.JPanel JavaDoc panel = new javax.swing.JPanel JavaDoc(
119                                        new java.awt.BorderLayout JavaDoc()
120                                    );
121         frame_.getContentPane().add(panel);
122         panel.add(new javax.swing.JScrollPane JavaDoc(textArea_),
123                   java.awt.BorderLayout.CENTER);
124         frame_.pack();
125         frame_.show();
126     }
127
128     // ==================================================================
129
//
130
// Methods for the OMG IDL org.omg.Components.SessionComponent
131
//
132
// ==================================================================
133

134     /**
135      * Container callback to signal that the component is removed.
136      *
137      * @throw org.omg.Components.CCMException For any problems.
138      */

139     public void
140     ccm_remove()
141     throws org.omg.Components.CCMException
142     {
143         // Release the associated frame.
144
frame_.dispose();
145         frame_ = null;
146     }
147
148     // ==================================================================
149
//
150
// Methods for OMG IDL demo1::CCM_Server_Executor
151
//
152
// ==================================================================
153

154     /**
155      * The mutator method for the attribute name.
156      *
157      * @param n The name.
158      */

159     public void
160     the_name(String JavaDoc n)
161     {
162         name_ = n;
163
164         if (frame_ != null)
165             frame_.setTitle(name_ + "'s Server GUI");
166     }
167
168     /**
169      * The accessor method for the attribute name.
170      *
171      * @return The name.
172      */

173     public String JavaDoc
174     the_name()
175     {
176         return name_;
177     }
178
179     // ==================================================================
180
//
181
// Methods for OMG IDL demo1::CCM_Display
182
//
183
// ==================================================================
184

185     /**
186      * The print operation of the demo1::Display interface.
187      *
188      * @param text The message to output.
189      */

190     public void
191     print(String JavaDoc text)
192     {
193         // Puts the text into the text area.
194
textArea_.append(text + "\n");
195     }
196 }
197
Popular Tags