KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > ccm > chat > 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): Areski Flissi.
23 Contributor(s):
24
25 ====================================================================*/

26
27 package org.objectweb.ccm.chat.cif;
28
29 //import org.objectweb.ccm.chat.*;
30

31 /**
32  * This is the implementation of the OMG IDL3 chat::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:Areski.Flissi@lifl.fr">Areski Flissi</A>
38  */

39
40 public class ServerImpl
41      extends org.objectweb.ccm.chat.ServerSessionComposition.ComponentImpl
42 {
43     // ==================================================================
44
//
45
// Internal state.
46
//
47
// ==================================================================
48

49     /** The name of the component. */
50     private String JavaDoc name_;
51
52     /** To refer to the GUI frame. */
53     private java.awt.Frame JavaDoc frame_;
54     /** To refer to the GUI user output area. */
55     private java.awt.TextArea JavaDoc textArea_;
56
57     // ==================================================================
58
//
59
// Constructor.
60
//
61
// ==================================================================
62

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

75     // ==================================================================
76
//
77
// Public methods.
78
//
79
// ==================================================================
80

81     // ==================================================================
82
//
83
// Methods for OMG IDL Components::EnterpriseComponent
84
//
85
// ==================================================================
86

87     /**
88      * Complete the component configuration.
89      *
90      * @exception org.omg.Components.InvalidConfiguration
91      * Thrown if the configuration is invalid.
92      */

93     public void
94     configuration_complete()
95     throws org.omg.Components.InvalidConfiguration
96     {
97         // Checks if the configuration is not completed.
98
if(name_ == null)
99             throw new org.omg.Components.InvalidConfiguration();
100
101         System.out.println("================================");
102         System.out.println("Welcome to OpenCCM's Chat server");
103         System.out.println("================================");
104     }
105
106     // ==================================================================
107
//
108
// Methods for the OMG IDL org.omg.Components.SessionComponent
109
//
110
// ==================================================================
111

112     /**
113      * Container callback to signal that the component is removed.
114      *
115      * @throw org.omg.Components.CCMException For any problems.
116      */

117     public void
118     ccm_remove()
119     throws org.omg.Components.CCMException
120     {
121         // Release the associated frame.
122
//frame_.dispose();
123
frame_ = null;
124     }
125
126     // ==================================================================
127
//
128
// Methods for OMG IDL chat::CCM_NamedComponent_Executor
129
//
130
// ==================================================================
131

132     /**
133      * The mutator method for the attribute name.
134      *
135      * @param n The name.
136      */

137     public void
138     name(String JavaDoc n)
139     {
140         name_ = n;
141
142         if (frame_ != null)
143             frame_.setTitle(name_ + "'s Server GUI");
144     }
145     /**
146      * The accessor method for the attribute name.
147      *
148      * @return The name.
149      */

150     public String JavaDoc
151     name()
152     {
153         return name_;
154     }
155
156     // ==================================================================
157
//
158
// Methods for OMG IDL chat::CCM_Service
159
//
160
// ==================================================================
161

162     /**
163      * The display operation of the chat::Service interface.
164      *
165      * @param text The text to display.
166      */

167     public void
168     display(String JavaDoc text)
169     {
170         // Puts the text into the text area.
171
//textArea_.append(text + "\n");
172
System.out.println(text);
173         // Pushes an event to all connected consumers.
174
get_context().push_to_consumers( new TextEventImpl(text) );
175     }
176 }
177
178
Popular Tags