Source Code Cross Referenced for ClientInfo.java in  » Groupware » Data-share » org » datashare » 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 
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: ClientInfo.java,v 1.4 2002/02/04 19:34:57 lizellaman Exp $
025:         * $Log: ClientInfo.java,v $
026:         * Revision 1.4  2002/02/04 19:34:57  lizellaman
027:         * correct spelling of privilege
028:         *
029:         * Revision 1.3  2002/01/29 20:50:17  lizellaman
030:         * Added LoggingInterface, modified the PropertiesInterface implementation
031:         *
032:         * Revision 1.2  2002/01/03 03:37:36  lizellaman
033:         * periodic update of changes I have made
034:         *
035:         * Revision 1.1.1.1  2001/10/23 13:37:19  lizellaman
036:         * initial sourceforge release
037:         *
038:         */
039:
040:        package org.datashare;
041:
042:        import org.datashare.objects.DataShareConnectionDescriptor;
043:        import org.datashare.objects.DefaultObjectInfo;
044:        import org.datashare.objects.RegistrationInfo;
045:        import java.util.Date;
046:        import java.net.InetAddress;
047:
048:        /**
049:         * Holds information about a Client.
050:         *
051:         * @date March 01, 2000
052:         * @author Charles Wood
053:         * @version 1.0
054:         */
055:        public class ClientInfo extends DefaultObjectInfo implements 
056:                PersistDataCallbackInterface {
057:            /**
058:             * Client's unique name, used as a key for the client
059:             */
060:            protected String clientKey = null;
061:
062:            /**
063:             * machine Client is located on
064:             */
065:            protected InetAddress hostMachine;
066:
067:            /**
068:             *  this client's commandStatus connection
069:             */
070:            protected DataShareConnectionDescriptor clientCommandStatusConnectionDescriptor = null;
071:
072:            /**
073:             * UserInfo for this client
074:             */
075:            protected UserInfo userInfo = null;
076:
077:            /**
078:             * true if this client has admin privileges
079:             */
080:            protected boolean admin = false;
081:
082:            /**
083:             * indicates if user wants to see all sessions/clients in their tree objects
084:             */
085:            protected boolean seeAllTreeObjects = false;
086:
087:            /**
088:             * indicates how the client code was launched (applet/application/desktop)
089:             */
090:            protected int clientMode;
091:
092:            /**
093:             * indicates if this instance can expect to access beans
094:             */
095:            boolean saveData = false;
096:
097:            /**
098:             * info from the client's RegistrationInfo
099:             */
100:            String userSuppliedInfo = "";
101:
102:            /**
103:             * Class constructor, should not be used because it leaves attributes with null values
104:             * and there are no methods to populate them.
105:             */
106:            private ClientInfo() {
107:                originalType = CLIENTTYPE;
108:            }
109:
110:            /**
111:             * Class constructor
112:             *
113:             */
114:            public ClientInfo(
115:                    DataShareConnectionDescriptor commandStatusConnectionDescriptor,
116:                    UserInfo userInfo, boolean saveData) {
117:                this (); // set create time, set originalType
118:                name = userInfo.getUserName();
119:                clientKey = userInfo.uniqueName;
120:                clientCommandStatusConnectionDescriptor = commandStatusConnectionDescriptor;
121:                this .userInfo = userInfo;
122:                this .admin = userInfo.admin;
123:                this .saveData = saveData;
124:                this .clientMode = userInfo.getClientMode();
125:                this .userSuppliedInfo = userInfo.getOtherInfo();
126:                hostMachine = commandStatusConnectionDescriptor.clientIP;
127:                this .clientClass = userInfo.getClientClass();
128:                toString = clientKey;
129:                if (userInfo != null) {
130:                    try {
131:                        clientRealName = userInfo.firstName + " "
132:                                + userInfo.lastName;
133:                        imageURL = userInfo.imageURL;
134:                    } catch (Exception e) {
135:                        e.printStackTrace();
136:                    }
137:                }
138:            }
139:
140:            /**
141:             *
142:             */
143:            public void updateCommandStatusConnectionDescriptor(
144:                    DataShareConnectionDescriptor newDescriptor) {
145:                clientCommandStatusConnectionDescriptor = newDescriptor;
146:                hostMachine = clientCommandStatusConnectionDescriptor.clientIP;
147:            }
148:
149:            /**
150:             * allows the host machine to be retreived
151:             *
152:             * @return returns information about host machine
153:             */
154:            public InetAddress getHostMachine() {
155:                return hostMachine;
156:            }
157:
158:            /**
159:             * Retrieves a string containing 'Client'.
160:             *
161:             * @return fixed value of 'Client' for all instances
162:             */
163:            public String getType() {
164:                return CLIENTTYPE;
165:            }
166:
167:            /**
168:             * Retrieves a description of this instance.
169:             *
170:             * @return the name of the Client for this instance
171:             */
172:            public String getInfo() {
173:                if (this .infoString == null) {
174:                    // should get in here the first call to getInfo() for each user
175:                    String adminString = "";
176:                    String userInfoString = "";
177:                    String realName = "";
178:                    if (!clientRealName.equals(" ")) // the space between the first and last names
179:                        realName = clientRealName;
180:
181:                    if (admin)
182:                        adminString = "<tr><td>Privileges</td><td>This client has admin privileges</td></tr>";
183:                    if (userInfo != null) {
184:                        try {
185:                            userInfoString = ((!userInfo.primaryEmail
186:                                    .equals("")) ? "<tr><td>Email address</td><td>"
187:                                    + userInfo.primaryEmail + "</td></tr>"
188:                                    : "")
189:                                    + ((!userInfo.primaryPhone.equals("")) ? "<tr><td>Phone</td><td>"
190:                                            + userInfo.primaryPhone
191:                                            + "</td></tr>"
192:                                            : "");
193:                        } catch (Exception e) {
194:                            e.printStackTrace();
195:                        }
196:                    } else {
197:                        if (this .saveData) // if not using beans, don't know about accounts
198:                            userInfoString = "<tr><td colspan=2>This client has no account on this server</td></tr>";
199:                    }
200:
201:                    infoString = "";
202:                    if (realName.trim().length() > 0)
203:                        infoString = "<tr><td>Real name</td><td>" + realName
204:                                + "</td></tr>";
205:
206:                    infoString += userInfoString
207:                            + "<tr><td>User's Name</td><td>"
208:                            + this .name
209:                            + "</td></tr>"
210:                            + "<tr><td>Unique Name</td><td>"
211:                            + this .clientKey
212:                            + "</td></tr>"
213:                            + "<tr><td>Client's IP address</td><td>"
214:                            + hostMachine.getHostAddress()
215:                            + " (server perspective)</td></tr>"
216:                            + "<tr><td>Client's Machine</td><td>"
217:                            + hostMachine.getHostName()
218:                            + " (server perspective)</td></tr>"
219:                            +
220:                            //                "<tr><td>Client class</td><td>" + this.getClientClass() + "</td></tr>" +
221:                            "<tr><td>Connected</td><td>"
222:                            + this .getDate().toString() + "</td></tr>"
223:                            + "<tr><td>Running mode</td><td>"
224:                            + RegistrationInfo.clientModes[clientMode]
225:                            + "</td></tr>" + adminString + userSuppliedInfo;
226:                }
227:                return infoString;
228:            }
229:
230:            /**
231:             * the value to use for the key for this instance in the Hashtable of
232:             * the Server's ClientInfo instances
233:             *
234:             * @return returns the key to use for this instance, String version of URL
235:             *     for ClientInfo
236:             */
237:            public String getKeyValue() {
238:                return clientKey; // this will be unique for the client+VM+server
239:            }
240:
241:            public boolean getSeeAllTreeObjects() {
242:                return this .seeAllTreeObjects;
243:            }
244:
245:            public void setSeeAllTreeObjects(boolean seeAllTreeObjects) {
246:                this .seeAllTreeObjects = seeAllTreeObjects;
247:            }
248:
249:            /**
250:             * Sets the ADSKey String for this instance to the provided parameter value.
251:             * The ADSKey String is the value provided when the EJB was created for this instance.
252:             *
253:             * @param ak the value to save as the ID for this instance
254:             */
255:            public void setDatabaseID(String /* ADSKey */ak) {
256:                SessionUtilities.getLoggingInterface().debugMsg(
257:                        SessionUtilities.getLoggingInterface().DEBUG,
258:                        SessionUtilities.getLoggingInterface().DATABASE,
259:                        "setDatabaseID(): Table Key for " + this .getKeyValue()
260:                                + " has value of " + ak);
261:                databaseID = ak;
262:                waitingForKey = false;
263:                keyHasBeenReturned = true;
264:            }
265:
266:            /**
267:             * Retrieves the ADSKey String for this instance.  Should always be checked for null.
268:             * Also realize that this method may block until the ADSKey value is available.
269:             *
270:             * @return the ADSKey String that was previously set for this instance.
271:             */
272:            public String /* ADSKey */
273:            getDatabaseID() {
274:                String this Key = null;
275:                if (saveData) {
276:                    if (databaseID != null)
277:                        this Key = databaseID;
278:                    else
279:                        this Key = retrieveEJB();
280:                }
281:                return this Key;
282:            }
283:
284:            /**
285:             * returns true if this client has admin privileges, false otherwise
286:             */
287:            public boolean getAdmin() {
288:                return this.admin;
289:            }
290:
291:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.