KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > ccm > demo3 > 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): Christophe Demarey.
24
25 ====================================================================*/

26
27 package org.objectweb.ccm.demo3.cif;
28
29 import org.objectweb.ccm.demo3.*;
30
31 /**
32  * This is the implementation of the OMG IDL3 demo3::Server component type.
33  *
34  * This class inherits from the skeleton
35  * generated by the OpenCCM's CIF to Java mapping generator.
36  *
37  * @author <a HREF="mailto:Philippe.Merle@lifl.fr">Philippe Merle</A>
38  * <a HREF="mailto:Mathieu.Vadet@lifl.fr">Mathieu Vadet</A>
39  * <a HREF="mailto:Christophe.Demarey@lifl.fr">Christophe Demarey</A>
40  */

41
42 public class ServerImpl
43      extends org.objectweb.ccm.demo3.ServerSessionComposition.ComponentImpl
44 {
45     // ==================================================================
46
//
47
// Internal state.
48
//
49
// ==================================================================
50

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

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

78     // ==================================================================
79
//
80
// Public methods.
81
//
82
// ==================================================================
83

84     // ==================================================================
85
//
86
// Methods for OMG IDL Components::EnterpriseComponent
87
//
88
// ==================================================================
89

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

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

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

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

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

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

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

171     public String JavaDoc
172     name()
173     {
174         return name_;
175     }
176
177     // ==================================================================
178
//
179
// Methods for OMG IDL demo3::CCM_Service
180
//
181
// ==================================================================
182

183     /**
184      * The display operation of the demo3::Service interface.
185      *
186      * @param text The text to display.
187      */

188     public void
189     display(String JavaDoc text)
190     {
191         // Puts the text into the text area.
192
textArea_.append(text + "\n");
193
194         // Pushes an event to all connected consumers.
195
get_context().push_to_consumers( new TextEventImpl(text) );
196     }
197 }
198
199
200
201
202
203
204
205
Popular Tags