KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > ccm > demo1 > monolithic > 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_______________________________.
24
25 ====================================================================*/

26
27 package org.objectweb.ccm.demo1.monolithic;
28
29 import org.objectweb.ccm.demo1.*;
30
31 /**
32  * This is the implementation of the OMG IDL3 demo1::Server component type.
33  *
34  * This class inherits from the local CCM_Server interface
35  * generated by the OpenCCM's IDL3 to IDL2 mapping generator.
36  *
37  * The provided for_clients facet is directly implemented by the
38  * component class by implementing the demo1::Display interface.
39  *
40  * @author <a HREF="mailto:Philippe.Merle@lifl.fr">Philippe Merle</A>
41  * <a HREF="mailto:Mathieu.Vadet@lifl.fr">Mathieu Vadet</A>
42  */

43
44 public class ServerImpl
45      extends org.omg.CORBA.LocalObject JavaDoc
46   implements CCM_Server,
47              CCM_Display,
48              org.omg.Components.SessionComponent
49 {
50     // ==================================================================
51
//
52
// Internal state.
53
//
54
// ==================================================================
55

56     /** The name of the component. */
57     private String JavaDoc name_;
58
59     /** To refer to the GUI frame. */
60     private javax.swing.JFrame JavaDoc frame_;
61
62     /** To refer to the GUI output area. */
63     private javax.swing.JTextArea JavaDoc textArea_;
64
65     /** To refer to the component context. */
66     private CCM_Server_Context the_context_;
67
68     // ==================================================================
69
//
70
// Constructor.
71
//
72
// ==================================================================
73

74     /** The default constructor. */
75     public
76     ServerImpl()
77     {
78     }
79
80     // ==================================================================
81
//
82
// Internal methods.
83
//
84
// ==================================================================
85

86     // ==================================================================
87
//
88
// Public methods.
89
//
90
// ==================================================================
91

92     // ==================================================================
93
//
94
// Methods for OMG IDL Components::EnterpriseComponent
95
//
96
// ==================================================================
97

98     /**
99      * Complete the component configuration.
100      *
101      * @exception org.omg.Components.InvalidConfiguration
102      * Thrown if the configuration is invalid.
103      */

104     public void
105     configuration_complete ()
106     throws org.omg.Components.InvalidConfiguration
107     {
108         // Checks if the configuration is not completed.
109
if(name_ == null)
110             throw new org.omg.Components.InvalidConfiguration();
111
112         // Instantiating the GUI.
113

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

140     /**
141      * Set the session component context.
142      *
143      * @param context The session component context.
144      *
145      * @throw org.omg.Components.CCMException For any problems.
146      */

147     public void
148     set_session_context(org.omg.Components.SessionContext context)
149     throws org.omg.Components.CCMException
150     {
151         the_context_ = (CCM_Server_Context)context;
152     }
153
154     /**
155      * Container callback to signal that the component is activated.
156      *
157      * @throw org.omg.Components.CCMException For any problems.
158      */

159     public void
160     ccm_activate()
161     throws org.omg.Components.CCMException
162     {
163         // Nothing to do currently.
164
}
165
166     /**
167      * Container callback to signal that the component is activated.
168      *
169      * @throw org.omg.Components.CCMException For any problems.
170      */

171     public void
172     ccm_passivate()
173     throws org.omg.Components.CCMException
174     {
175         // Nothing to do currently.
176
}
177
178     /**
179      * Container callback to signal that the component is removed.
180      *
181      * @throw org.omg.Components.CCMException For any problems.
182      */

183     public void
184     ccm_remove()
185     throws org.omg.Components.CCMException
186     {
187         // Release the associated frame.
188
frame_.dispose();
189     frame_ = null;
190     }
191
192     // ==================================================================
193
//
194
// Methods for OMG IDL demo1::CCM_Display
195
//
196
// ==================================================================
197

198     /**
199      * The print operation of the demo1::Display interface.
200      *
201      * @param text The message to output.
202      */

203     public void
204     print(String JavaDoc text)
205     {
206         // Puts the text into the text area.
207
textArea_.append(text + "\n");
208     }
209
210     // ==================================================================
211
//
212
// Methods for OMG IDL demo1::CCM_Server
213
//
214
// ==================================================================
215

216     /**
217      * Provide the executor for the for_clients facet.
218      *
219      * @return An executor implemening CCM_Display.
220      */

221     public CCM_Display
222     get_for_clients()
223     {
224         return this;
225     }
226
227     /**
228      * The mutator method for the attribute name.
229      *
230      * @param n The name.
231      */

232     public void
233     the_name(String JavaDoc n)
234     {
235         name_ = n;
236
237         if (frame_ != null)
238             frame_.setTitle(name_ + "'s Server GUI");
239     }
240
241     /**
242      * The accessor method for the attribute name.
243      *
244      * @return The name.
245      */

246     public String JavaDoc
247     the_name()
248     {
249         return name_;
250     }
251 }
252
253
254
Popular Tags