Source Code Cross Referenced for DefaultObjectInfo.java in  » Groupware » Data-share » org » datashare » objects » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Groupware » Data share » org.datashare.objects 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /* ----- BEGIN LICENSE BLOCK -----
002:         * Version: MPL 1.1
003:         *
004:         * The contents of this file are subject to the Mozilla Public License Version
005:         * 1.1 (the "License"); you may not use this file except in compliance with
006:         * the License. You may obtain a copy of the License at
007:         * http://www.mozilla.org/MPL/
008:         *
009:         * Software distributed under the License is distributed on an "AS IS" basis,
010:         * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
011:         * for the specific language governing rights and limitations under the
012:         * License.
013:         *
014:         * The Original Code is the DataShare server.
015:         *
016:         * The Initial Developer of the Original Code is
017:         * Ball Aerospace & Technologies Corp, Fairborn, Ohio
018:         * Portions created by the Initial Developer are Copyright (C) 2001
019:         * the Initial Developer. All Rights Reserved.
020:         *
021:         * Contributor(s): Charles Wood <cwood@ball.com>
022:         *
023:         * ----- END LICENSE BLOCK ----- */
024:        /* RCS $Id: DefaultObjectInfo.java,v 1.2 2002/01/29 20:57:16 lizellaman Exp $
025:         * $Log: DefaultObjectInfo.java,v $
026:         * Revision 1.2  2002/01/29 20:57:16  lizellaman
027:         * Added LoggingInterface, modified the PropertiesInterface implementation
028:         *
029:         * Revision 1.1.1.1  2001/10/23 13:37:20  lizellaman
030:         * initial sourceforge release
031:         *
032:         */
033:
034:        package org.datashare.objects;
035:
036:        import java.util.Date;
037:        import org.datashare.ChannelInfo;
038:        import org.datashare.ClientInfo;
039:        import org.datashare.SessionInfo;
040:        import org.datashare.ConsumerInfo;
041:        import org.datashare.SessionUtilities;
042:
043:        /**
044:         * this class is used to convert the ClientInfo, ChannelInfo, SessionInfo, and ConsumerInfo
045:         * classes into a class that is serializable, and common for processing on the recieving end.
046:         * Note that DefaultObjectInfo instances are only created on the Server then sent to clients.
047:         *
048:         * @author Charles Wood
049:         * @version 1.0
050:         */
051:        public class DefaultObjectInfo implements  DSObjectInfoInterface,
052:                java.io.Serializable {
053:            /**
054:             * this allows us to serialize this class without 'marshalling' errors.
055:             *
056:             */
057:            static final long serialVersionUID = 9030593813711490593L;
058:
059:            /**
060:             * the name used to refer to this unique instance
061:             *
062:             */
063:            protected String name;
064:
065:            /**
066:             * the Owner name string, used only for Sessions and Channels
067:             *
068:             */
069:            protected String ownerName = "";
070:
071:            /**
072:             * indicates the class of the client for this object
073:             */
074:            protected String clientClass = "";
075:
076:            /**
077:             * this is the string that is displayed in the Jtree for this instance,
078:             * this must be set for every instance.
079:             *
080:             */
081:            protected String toString = "*";
082:
083:            /**
084:             * flag to indicate if this instance is currently active in the JSDT Registry
085:             *
086:             */
087:            protected boolean active = false;
088:
089:            /**
090:             * when this instance was created
091:             *
092:             */
093:            protected Date date;
094:
095:            /**
096:             * the String value to use for this instance in a Hashtable.  Must be unique for the
097:             * context in which it is used:
098:             * i.e. for ChannelInfo the keyValue must be unique in the Session,
099:             * for SessionInfo the keyValue must be unique for all active Sessions,
100:             * for ClientInfo the keyValue must be unique for each Client instance (Java VM) the Client is using,
101:             * for ConsumerInfo the keyValue must match it's corresponding ClientInfo value and must
102:             * be unique within the Channel.
103:             *
104:             */
105:            protected String keyValue;
106:
107:            /**
108:             * the String that should be displayed when the detailed information about this
109:             * instance is desired
110:             *
111:             */
112:            protected String infoString;
113:
114:            /**
115:             * this is used to indicate what type this object should represent.  It is especially
116:             * useful when a SessionInfo has been pared-down to a DefaultObjectInfo so it can
117:             * be serialized.  The fact that a DefaultObjectInfo is now representing what was
118:             * a SessionInfo is maintained in this attribute.  In the example case, this attribute
119:             * would be set to 'sessionType'
120:             *
121:             */
122:            protected String originalType;
123:
124:            /**
125:             * represents the parent instance's keyValue, used only for Channels and Consumers.
126:             * For Channels, the parent is it's Session, for Consumers it is the Channel it is in.
127:             *
128:             */
129:            protected String parentKeyValue;
130:
131:            /**
132:             * represents the grandparent instance's keyValue, used only when this instance
133:             * represents a Consumer.  In that case, the parentKeyValue is set to its Channel
134:             * and the grandparentKeyValue is set to the Session.  This is because the keyValue
135:             * for a Channel is not enough to find the Channel unless you also know the Session.
136:             *
137:             */
138:            protected String grandparentKeyValue;
139:
140:            /**
141:             * contains the database key String for this instance, populated only when the Server is saving
142:             * data for this type.  Note that this value may contain null even if data is saved (if the
143:             * server has problems saving the data, or has not yet determined this key value)
144:             *
145:             */
146:            protected String databaseID;
147:
148:            /**
149:             * Used only if the server is creating/using EJBs, true indicates an EJB create was
150:             * requested and we are waiting for it's key value to be returned, false otherwise.
151:             *
152:             */
153:            protected boolean waitingForKey = true;
154:
155:            /**
156:             * Used only if the server is creating/using EJBs, true indicates that the EJB was
157:             * created and the setDatabaseID method has been called in this instance with the EJB's
158:             * key value.  It is set to false if EJBs are not used and also if EJBs are used,
159:             * but the ADSKey String for the EJB has not yet been returned.
160:             *
161:             */
162:            protected boolean keyHasBeenReturned = false;
163:
164:            /**
165:             * Used to hold the URL for the image of Client/Consumers
166:             */
167:            protected String imageURL = "";
168:
169:            /**
170:             * Used to hold the real name of a user, i.e. 'Chuck Wood', valid only for Client/Consumers
171:             */
172:            protected String clientRealName = "";
173:
174:            /**
175:             * use depends on which object it is being applied to.  Currently used only for Sessions/SessionInfo
176:             */
177:            protected boolean privateOnly = false;
178:
179:            //   /**
180:            //    * this is the self-generated key that will be used by the server to give
181:            //    * Channels a unique key for use with keeping up with the Token for this Channel (if it is used).
182:            //    * -- really should be same as keyValue, but for channels, the keyValue is not unique among all
183:            //    * channels and would take too long to change at this point.
184:            //    */
185:            //   protected String tokenKey = "";
186:
187:            /**
188:             * Empty Class constructor
189:             *
190:             */
191:            protected DefaultObjectInfo() {
192:                name = "no name";
193:                toString = name;
194:                //originalType = DEFAULTOBJECTTYPE;  // should be overwritten later
195:                date = new Date(); //GregorianCalendar().getTime();
196:            }
197:
198:            /**
199:             * Class constructor with name of instance specified.  Used for nodes that are not associated with
200:             * any specific client or session
201:             *
202:             * @param name instance name
203:             */
204:            public DefaultObjectInfo(String name, String type, String infoString) {
205:                this ();
206:                this .name = name;
207:                this .toString = name;
208:                originalType = type;
209:                this .infoString = infoString;
210:            }
211:
212:            /**
213:             * Class constructor with name of instance specified.  Used when the node is associated with a
214:             * client or session.
215:             *
216:             * @param name instance name
217:             */
218:            public DefaultObjectInfo(String name, String type,
219:                    String clientClass, String infoString) {
220:                this (name, type, infoString);
221:                this .clientClass = clientClass;
222:            }
223:
224:            public DefaultObjectInfo(ChannelInfo infoObject) {
225:                this .date = infoObject.getDate();
226:                this .keyValue = infoObject.getKeyValue();
227:                this .name = infoObject.getConnectionDescriptor().name;
228:                this .toString = infoObject.toString();
229:                this .infoString = infoObject.getInfo();
230:                this .originalType = infoObject.CHANNELTYPE;
231:                this .parentKeyValue = infoObject.getParentKeyValue();
232:                this .ownerName = infoObject.getSessionInfo().getOwnerName();
233:                this .databaseID = infoObject.getDatabaseID();
234:                this .active = infoObject.getActive();
235:                this .clientClass = infoObject.getClientClass();
236:                //      this.tokenKey = infoObject.getTokenKey();
237:            }
238:
239:            public DefaultObjectInfo(ClientInfo infoObject) {
240:                this .date = infoObject.getDate();
241:                this .keyValue = infoObject.getKeyValue();
242:                this .name = infoObject.getName();
243:                this .toString = infoObject.toString(); // don't use name for display of Clients
244:                this .infoString = infoObject.getInfo();
245:                this .originalType = infoObject.CLIENTTYPE;
246:                this .imageURL = infoObject.getImageURL();
247:                this .clientRealName = infoObject.getClientRealName();
248:                this .databaseID = infoObject.getDatabaseID();
249:                this .active = infoObject.getActive();
250:                this .clientClass = infoObject.getClientClass();
251:            }
252:
253:            public DefaultObjectInfo(SessionInfo infoObject) {
254:                this .date = infoObject.getDate();
255:                this .keyValue = infoObject.getKeyValue();
256:                this .name = infoObject.toString();
257:                this .toString = infoObject.toString();
258:                this .infoString = infoObject.getInfo();
259:                this .originalType = infoObject.SESSIONTYPE;
260:                this .ownerName = infoObject.getOwnerName();
261:                this .databaseID = infoObject.getDatabaseID();
262:                this .privateOnly = infoObject.getPrivate();
263:                this .active = infoObject.getActive();
264:                this .clientClass = infoObject.getClientClass();
265:            }
266:
267:            public DefaultObjectInfo(ConsumerInfo infoObject) {
268:                this .date = infoObject.getDate();
269:                this .keyValue = infoObject.getKeyValue();
270:                this .name = infoObject.getName();
271:                this .toString = infoObject.toString();
272:                this .infoString = infoObject.getInfo();
273:                this .originalType = infoObject.CONSUMERTYPE;
274:                this .parentKeyValue = infoObject.getParentKeyValue();
275:                this .grandparentKeyValue = infoObject.getGrandParentKeyValue();
276:                this .imageURL = infoObject.getClientInfo().getImageURL();
277:                this .clientRealName = infoObject.getClientRealName();
278:                this .active = infoObject.getActive();
279:                this .clientClass = infoObject.getClientClass();
280:                //      this.databaseID = infoObject.getDatabaseID(); // who cares? and doesn't work well...times out
281:            }
282:
283:            /**
284:             * Retrieves the string to use for the JTree display of this instance
285:             *
286:             * @return the instance's name
287:             */
288:            public String toString() {
289:                return toString;
290:            }
291:
292:            /**
293:             * Retrieves the unique name of this instance.
294:             *
295:             * @return the instance's name
296:             */
297:            public String getName() {
298:                return name;
299:            }
300:
301:            /**
302:             * returns the client's real name, if available, empty string otherwise
303:             */
304:            public String getClientRealName() {
305:                return clientRealName;
306:            }
307:
308:            //   /**
309:            //    * returns the tokenKey value, normally available only for ChannelInfo objects, empty string otherwise
310:            //    */
311:            //   public String
312:            //   getTokenKey()
313:            //      {
314:            //      return tokenKey;
315:            //      }
316:
317:            /**
318:             * Retrieves the ADSKey string for this Instance
319:             *
320:             * @return the instance's databaseID
321:             */
322:            public String getDatabaseID() {
323:                return databaseID;
324:            }
325:
326:            /**
327:             * Waits for the container to return the EJB String ID, or returns null if we have waited long enough
328:             */
329:            public String retrieveEJB() {
330:                String this Key = "";
331:                int count = 0;
332:                Date startTime = new Date();
333:                Date stopTime = null;
334:
335:                SessionUtilities.getLoggingInterface().debugMsg(
336:                        SessionUtilities.getLoggingInterface().DEBUG,
337:                        SessionUtilities.getLoggingInterface().DATABASE,
338:                        "Trying to retrieve a " + this .getType()
339:                                + " ADSKey for " + getKeyValue());
340:                // let's give the Bean a while to get created (if we have to wait)
341:                while (waitingForKey && count < 35) {
342:                    count++;
343:                    try {
344:                        Thread.sleep(1000);
345:                    } catch (InterruptedException ie) {
346:                    }
347:                }
348:                if (keyHasBeenReturned)
349:                    this Key = databaseID;
350:                else {
351:                    stopTime = new Date();
352:                    SessionUtilities.getLoggingInterface().debugMsg(
353:                            SessionUtilities.getLoggingInterface().DEBUG,
354:                            SessionUtilities.getLoggingInterface().DATABASE,
355:                            "getDatabaseID(" + this .getKeyValue()
356:                                    + ") bad state: started EJBCreate at "
357:                                    + SessionUtilities.getTimeString(startTime)
358:                                    + " and gave up at "
359:                                    + SessionUtilities.getTimeString(stopTime));
360:                }
361:                return this Key;
362:            }
363:
364:            /**
365:             * Retrieves the Creator/Owner name for this instance, used only for Sessions and Channels
366:             *
367:             * @return this instance's owner/creator name
368:             */
369:            public String getOwnerName() {
370:                return this .ownerName;
371:            }
372:
373:            /**
374:             * Retrieves a string containing 'DefaultObjectInfo'.
375:             *
376:             * @return fixed value of 'DefaultObjectInfo' for all instances, used when
377:             *     this class is referenced by it's parent class so all subclasses have a
378:             *     common method that can be used to test for the instance type.
379:             */
380:            public String getType() {
381:                return DEFAULTOBJECTTYPE;
382:            }
383:
384:            /**
385:             * Retrieves a string containing the original type of object that is represented by this instance.
386:             *
387:             * @return value of originalType for this instance
388:             */
389:            public String getOriginalType() {
390:                return originalType;
391:            }
392:
393:            /**
394:             * Retrieves an Object reference of this instance, used when this class
395:             * is cast to the parent class for common handling of JSDTObjectInfo objects.
396:             *
397:             * @return the DefaultObjectInfo instance as an Object
398:             */
399:            public Object getObject() {
400:                return this ;
401:            }
402:
403:            /**
404:             * Retrieves the clientClass for this object
405:             */
406:            public String getClientClass() {
407:                return clientClass;
408:            }
409:
410:            /**
411:             * Retrieves a description of this instance.
412:             *
413:             * @return the infoString for this instance which should contain detailed
414:             *     information about this instance; returns the name of this instance if
415:             *     infoString is null
416:             */
417:            public String getInfo() {
418:                if (infoString != null && infoString.length() != 0)
419:                    return infoString;
420:                else
421:                    return "<tr><td>User Name:</td><td>" + name + "</td></tr>";
422:            }
423:
424:            /**
425:             * Sets the value that is used to hold detailed information about this instance.
426:             *
427:             * @param infoString the detailed information about this instance.
428:             */
429:            public void setInfo(String infoString) {
430:                this .infoString = infoString;
431:            }
432:
433:            /**
434:             * Retrieves the active flag
435:             *
436:             * @return true if this instance is currently active in the JSDT Registry
437:             */
438:            public boolean getActive() {
439:                return active;
440:            }
441:
442:            /**
443:             * sets the active flag for this instance to the specified value
444:             *
445:             * @param active value to set active flag to
446:             */
447:            public void setActive(boolean active) {
448:                this .active = active;
449:            }
450:
451:            /**
452:             * Retrieves when this instance was created
453:             *
454:             * @return the time this instance was created (first put into the JSDT
455:             *     Registry)
456:             */
457:            public Date getDate() {
458:                return date;
459:            }
460:
461:            /**
462:             * the value to use for the key for this instance in a Hashtable of
463:             * these instances (care must be taken to ensure keys are unique in the Hashtable):
464:             * the String used in the constructor is used as the key here.
465:             *
466:             * @return the value to use as the key for this instance in a Hashtable
467:             */
468:            public String getKeyValue() {
469:                return keyValue; // must be unique in the Hashtable
470:            }
471:
472:            /**
473:             * the value to use for the key of this instances parent's keyValue.
474:             *
475:             * @return the value to use as the key for this instances parent in a
476:             *     Hashtable
477:             */
478:            public String getParentKeyValue() {
479:                if (parentKeyValue == null)
480:                    return "NULL";
481:                else
482:                    return parentKeyValue; // must be unique in the Hashtable
483:            }
484:
485:            /**
486:             * the value to use for the key of this instances grandparent's keyValue.
487:             *
488:             * @return the value to use as the key for this instances grandparent in a
489:             *     Hashtable
490:             */
491:            public String getGrandParentKeyValue() {
492:                if (grandparentKeyValue == null)
493:                    return "NULL";
494:                else
495:                    return grandparentKeyValue; // must be unique in the Hashtable
496:            }
497:
498:            /**
499:             * Sets the value to use for the key for this instance in a Hashtable of
500:             * these instances (care must be taken to ensure keys are unique in the Hashtable)
501:             *
502:             * @param keyValue value to use as the key in a Hashtable for this instance
503:             */
504:            public void setKeyValue(String keyValue) {
505:                this .keyValue = keyValue; // must be unique in the Hashtable
506:            }
507:
508:            /**
509:             * Used to set the value that represents if the EJB has been created and it's
510:             * corresponding ADSKey String value set into the invoking class via the setEjbId() method.
511:             * This method is used only if EJBs are being used/created.
512:             *
513:             * @param value true if the ADSKey String has been returned, false if we
514:             *     are still waiting
515:             */
516:            public void setKeyHasBeenReturned(boolean value) {
517:                keyHasBeenReturned = value;
518:            }
519:
520:            /**
521:             * Indicates the status of the EJB that was requested to be created: this method
522:             * is called with a true value while we are waiting for the EJB to be created, and
523:             * set to false after the EJB has been created and it's ADSKey String value has been
524:             * returned via the setADSKey method.  Note that to truly determine if the ADSKey
525:             * value has been completed, this method will return a false and the method
526:             * getKeyHasBeenReturned will return true.  This method is used only if EJBs are
527:             * being used/created.
528:             *
529:             * @param value true if the EJB has not been completed, false otherwise.
530:             */
531:            public void setWaitingForKey(boolean value) {
532:                waitingForKey = value;
533:            }
534:
535:            /**
536:             * Sets the ADSKey String for this instance to the provided parameter value.
537:             * The ADSKey String is the value provided when the EJB was created for this instance.
538:             *
539:             * @param ak the value to save as the ID for this instance
540:             */
541:            public void setDatabaseID(String /* ADSKey */ak) {
542:                SessionUtilities.getLoggingInterface().debugMsg(
543:                        SessionUtilities.getLoggingInterface().DEBUG,
544:                        SessionUtilities.getLoggingInterface().DATABASE,
545:                        "setDatabaseID(): EJB Key for " + this .getKeyValue()
546:                                + " has value of " + ak);
547:                databaseID = ak;
548:                waitingForKey = false;
549:                keyHasBeenReturned = true;
550:            }
551:
552:            /**
553:             * returns the URL for the image of a user, probably valid only if this instance refers to a Client/Consumer
554:             */
555:            public String getImageURL() {
556:                return this .imageURL;
557:            }
558:
559:            /**
560:             * returns the value that was set by the original object, use is specific to the
561:             * original type of object this instance was created from
562:             */
563:            public boolean getPrivate() {
564:                return this.privateOnly;
565:            }
566:
567:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.