KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > ist > coach > coachEmfServicesComponents > BasicLogProviderComposition > BasicLogProviderImpl


1 /*====================================================================
2
3 This file was produced by the OpenCCM CIF_JIMPL generator.
4
5 OpenCCM: The Open CORBA Component Model Platform
6 Copyright (C) 2000-2003 INRIA - USTL - LIFL - GOAL
7 Contact: openccm@objectweb.org
8
9 This library is free software; you can redistribute it and/or
10 modify it under the terms of the GNU Lesser General Public
11 License as published by the Free Software Foundation; either
12 version 2.1 of the License, or any later version.
13
14 This library is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 Lesser General Public License for more details.
18
19 You should have received a copy of the GNU Lesser General Public
20 License along with this library; if not, write to the Free Software
21 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
22 USA
23
24 Initial developer(s): Christophe Demarey.
25 Contributor(s): ______________________________________.
26
27 ====================================================================*/

28
29 package ist.coach.coachEmfServicesComponents.BasicLogProviderComposition;
30
31 import java.sql.*;
32 /**
33  * This is the CIDL-based implementation of the
34  * OMG IDL3 IDL:coach.ist/coachEmfServicesComponents/BasicLogProvider:1.0 component type.
35  *
36  * @author OpenCCM CIF_Jimpl Compiler.
37  */

38 public class BasicLogProviderImpl
39      extends ist.coach.coachEmfServicesComponents.BasicLogProviderComposition.BasicLogProvider_impl
40 {
41     // ==================================================================
42
//
43
// Internal states.
44
//
45
// ==================================================================
46
private int recordsReadRange_;
47     private int logId_;
48     private int logMaxSize_;
49     private String JavaDoc databaseConnection_;
50     private String JavaDoc databaseTable_;
51     private String JavaDoc databaseDriver_;
52     private short logFullAction_;
53     private String JavaDoc databaseUserData_ = "?user=test1&password=test1";
54     private String JavaDoc display_name_;
55
56     // ==================================================================
57
//
58
// Constructors.
59
//
60
// ==================================================================
61

62     public BasicLogProviderImpl()
63     {
64     }
65
66     public BasicLogProviderImpl(int logId)
67     {
68       if (logId > 0)
69           logId_ = logId;
70     }
71     // ==================================================================
72
//
73
// Methods for the OMG IDL Components::EnterpriseComponent local interface.
74
//
75
// ==================================================================
76
//
77
// IDL:omg.org/Components/EnterpriseComponent/configuration_complete:1.0
78
//
79
/**
80      ** Completes the component configuration.
81      **
82      ** @throws org.omg.Components.InvalidConfiguration
83      ** Thrown if the configuration is invalid.
84      **/

85     public void
86     configuration_complete()
87     throws org.omg.Components.InvalidConfiguration
88     {
89
90         //
91
// DONE : implement !!!
92
//
93

94           org.omg.CORBA.ORB JavaDoc orb =
95                 org.objectweb.ccm.CORBA.TheORB.getORB();
96
97           if (logId() == 0)
98             throw new org.omg.Components.InvalidConfiguration();
99
100           String JavaDoc logIDstr = Integer.toString(logId());
101           logIDstr = databaseTable() + logIDstr;
102
103             // Crete a new table named by 'logIDstr' in the given database. The
104
// structure of the schema is based on the 'LogRecord'(defined in
105
// Log.idl. In summary it contains:
106
// - logRecordId : Unique number assigned to the record by the Log,
107
// - timeStamp : Timestamp indicating the time an event is logged,
108
// - attrList : User defined name/value pairs,
109
// - logData : data details received by the log as an event.
110
// Connect to JDBC driver
111
try {
112             Class.forName(databaseDriver()).newInstance();
113         }
114         catch (Exception JavaDoc ex) {
115             System.err.println("** BasicLogImpl: <EXCEPTION> While connecting to jdbc driver");
116             System.err.println(ex.getMessage());
117
118         }
119
120         Connection dbConnection = null;
121         try {
122                 dbConnection = DriverManager.getConnection(databaseConnection());
123                 Statement dbStatement = dbConnection.createStatement();
124                 String JavaDoc sqlStr = "CREATE TABLE " + logIDstr +
125                             "(logRecordId BIGINT PRIMARY KEY, " +
126                             "timeStamp VARCHAR(30), " +
127                             "logDataType TINYINT, " +
128                             "logData BLOB)";
129
130                 boolean logCreatedInDb = dbStatement.execute(sqlStr);
131           }
132           catch (SQLException ex) {
133               System.err.println(logIDstr + " Table propably already exists in the database...");
134               //System.err.println("*** BasicLogFactoryImpl : SQLException: " + ex.getMessage());
135
//System.err.println("*** BasicLogFactoryImpl : SQLState: " + ex.getSQLState());
136
//System.err.println("*** BasicLogFactoryImpl : VendorError: " + ex.getErrorCode());
137
}
138       System.err.println("LogProvider " + display_name() + " configuration completed...");
139     }
140
141     //
142
// IDL:omg.org/Components/SessionComponent/ccm_remove:1.0
143
//
144
/**
145      *
146      * Called by the container when the component will be removed.
147      *
148      * @throws org.omg.Components.CCMException
149      * Thrown if a system level error occured.
150      */

151     public void
152     ccm_remove()
153     throws org.omg.Components.CCMException
154     {
155     /************************
156         String logIDstr = Integer.toString(logId());
157         logIDstr = databaseTable() + logIDstr;
158         Connection dbConnection = null;
159         try {
160                 dbConnection = DriverManager.getConnection(databaseConnection());
161                 Statement dbStatement = dbConnection.createStatement();
162                 String sqlStr = "DROP TABLE " + logIDstr;
163
164                 boolean logCreatedInDb = dbStatement.execute(sqlStr);
165           }
166           catch (SQLException ex) {
167               System.err.println(logIDstr + " Table can not be deleted by the database...");
168               System.err.println("*** BasicLogFactoryImpl : SQLException: " + ex.getMessage());
169               System.err.println("*** BasicLogFactoryImpl : SQLState: " + ex.getSQLState());
170               System.err.println("*** BasicLogFactoryImpl : VendorError: " + ex.getErrorCode());
171           }
172      ********************/

173     }
174     // ==================================================================
175
//
176
// Methods.
177
//
178
// ==================================================================
179
/**
180      * Implementation of the ::coachEmfServicesComponents::CCM_BasicLogProvider_Executor::recordsReadRange attribute as accessor operation.
181      */

182     public int
183     recordsReadRange()
184     {
185         //
186
// DONE : Implement
187
//
188
return recordsReadRange_;
189     }
190     /**
191      * Implementation of the ::coachEmfServicesComponents::CCM_BasicLogProvider_Executor::recordsReadRange attribute as mutator operation.
192      */

193     public void
194     recordsReadRange(int val)
195     {
196         //
197
// DONE : Implement
198
//
199
if (val > 0)
200             recordsReadRange_ = val;
201         //System.err.println("BasicLogProviderImpl>recordsReadRange set to " + val);
202
}
203
204      /**
205      * Implementation of the ::coachEmfServicesComponents::CCM_BasicLogProvider_Executor::logFullAction attribute as accessor operation.
206      */

207     public short
208     logFullAction()
209     {
210         //
211
// DONE : Implement
212
//
213
return logFullAction_;
214     }
215     /**
216      * Implementation of the ::coachEmfServicesComponents::CCM_BasicLogProvider_Executor::logFullAction attribute as mutator operation.
217      */

218     public void
219     logFullAction(short val)
220     {
221         //
222
// DONE : Implement
223
//
224
if (val > 0)
225             logFullAction_ = val;
226         //System.err.println("BasicLogProviderImpl>logFullAction set to " + val);
227
}
228     /**
229      * Implementation of the ::coachEmfServicesComponents::CCM_BasicLogProvider_Executor::logMaxSize attribute as accessor operation.
230      */

231     public int
232     logMaxSize()
233     {
234         //
235
// DONE : Implement
236
//
237
return logMaxSize_;
238     }
239     /**
240      * Implementation of the ::coachEmfServicesComponents::CCM_BasicLogProvider_Executor::recordsReadRange attribute as mutator operation.
241      */

242     public void
243     logMaxSize(int val)
244     {
245         //
246
// DONE : Implement
247
//
248
if (val > 0)
249             logMaxSize_ = val;
250         //System.err.println("BasicLogProviderImpl>logMaxSize set to " + val);
251
}
252
253     public void logId(int val) {
254         if (val > 0)
255           logId_ = val;
256
257         //System.err.println("BasicLogProviderImpl>logId set to " + logId_);
258

259
260
261     }
262
263     public int logId() {
264       return logId_;
265     }
266     /**
267      * Implementation of the ::coachEmfServicesComponents::CCM_BasicLogProvider_Executor::databaseConnection attribute as mutator operation.
268      */

269     public void
270     databaseConnection(String JavaDoc val)
271     {
272         //
273
// DONE : Implement
274
//
275
if (val != null && val.length() > 0)
276             databaseConnection_ = val + databaseUserData_;
277         //System.err.println("BasicLogProviderImpl>databaseConnection set to " + databaseConnection_);
278
}
279      /**
280      * Implementation of the ::coachEmfServicesComponents::CCM_BasicLogProvider_Executor::databaseConnection attribute as accessor operation.
281      */

282     public String JavaDoc
283     databaseConnection()
284     {
285         //
286
// DONE : Implement
287
//
288
return databaseConnection_;
289     }
290
291    /**
292      * Implementation of the ::coachEmfServicesComponents::CCM_BasicLogProvider_Executor::databaseDriver attribute as mutator operation.
293      */

294     public void
295     databaseDriver(String JavaDoc val)
296     {
297         //
298
// DONE : Implement
299
//
300
if (val != null && val.length() > 0)
301             databaseDriver_ = val;
302         //System.err.println("BasicLogProviderImpl>databaseDriver set to " + val);
303
}
304      /**
305      * Implementation of the ::coachEmfServicesComponents::CCM_BasicLogProvider_Executor::databaseDriver attribute as accessor operation.
306      */

307     public String JavaDoc
308     databaseDriver()
309     {
310         //
311
// DONE : Implement
312
//
313
return databaseDriver_;
314     }
315
316       /**
317      * Implementation of the ::coachEmfServicesComponents::CCM_BasicLogProvider_Executor::databaseTable attribute as mutator operation.
318      */

319     public void
320     databaseTable(String JavaDoc val)
321     {
322         //
323
// DONE : Implement
324
//
325
if (val != null && val.length() > 0)
326             databaseTable_ = val;
327         //System.err.println("BasicLogProviderImpl>databaseTable set to " + val);
328
}
329      /**
330      * Implementation of the ::coachEmfServicesComponents::CCM_BasicLogProvider_Executor::databaseTable attribute as accessor operation.
331      */

332     public String JavaDoc
333     databaseTable()
334     {
335         //
336
// DONE : Implement
337
//
338
return databaseTable_;
339     }
340     /**
341      * Implementation of the ::coachEmfServicesComponents::CCM_BasicLogProvider_Executor::display_name attribute as accessor operation.
342      */

343     public void
344     display_name(String JavaDoc val)
345     {
346         //
347
// DONE : Implement
348
//
349
if (val != null && val.length() > 0)
350             display_name_ = val;
351
352     }
353
354     public String JavaDoc
355     display_name()
356     {
357         //
358
// DONE : Implement
359
//
360
return display_name_;
361     }
362 }
363
Popular Tags