Source Code Cross Referenced for ChannelInfo.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: ChannelInfo.java,v 1.3 2002/02/20 14:10:09 lizellaman Exp $
025:         * $Log: ChannelInfo.java,v $
026:         * Revision 1.3  2002/02/20 14:10:09  lizellaman
027:         * changes to improve history retrieval
028:         *
029:         * Revision 1.2  2002/01/29 20:50:17  lizellaman
030:         * Added LoggingInterface, modified the PropertiesInterface implementation
031:         *
032:         * Revision 1.1.1.1  2001/10/23 13:37:19  lizellaman
033:         * initial sourceforge release
034:         *
035:         */
036:
037:        package org.datashare;
038:
039:        import java.util.Date;
040:        import java.util.Hashtable;
041:        import org.datashare.objects.ChannelDescription;
042:        import org.datashare.objects.DefaultObjectInfo;
043:        import org.datashare.objects.DataShareConnectionDescriptor;
044:
045:        /**
046:         * Holds information about a Channel.  The keyValue for ChannelInfo is the
047:         * Channel's name.
048:         * Note that this class is not serializable.
049:         *
050:         * @date March 01, 2001
051:         * @author Charles Wood
052:         * @version 2.0
053:         */
054:        public class ChannelInfo extends DefaultObjectInfo implements 
055:                PersistDataCallbackInterface, java.io.Serializable {
056:            /**
057:             * this allows us to serialize this class without 'marshalling' errors.
058:             *
059:             */
060:            static final long serialVersionUID = 9030593814524545453L;
061:
062:            /**
063:             *
064:             */
065:            transient private DataReceiverAdapter dataReceiverAdapter = null;
066:
067:            /**
068:             *
069:             */
070:            private DataShareConnectionDescriptor connectionDescriptor = null;
071:
072:            /**
073:             * reference to the parent Session, may be null
074:             *
075:             */
076:            transient private SessionInfo parentSession = null; // must be set if this instance retrieved from persistence
077:
078:            /**
079:             * contains all Consumer/Clients for this Channel
080:             *
081:             */
082:            transient private Hashtable consumerTable = new Hashtable(); // ConsumerInfo objects, index by keyValue
083:
084:            /**
085:             * indicates if EJBs should be attempted for this channel, should not be true if server not creating beans
086:             *
087:             */
088:            private boolean saveData = true;
089:
090:            /**
091:             * empty class constuctor
092:             *
093:             */
094:            private ChannelInfo() {
095:                originalType = CHANNELTYPE;
096:            }
097:
098:            /**
099:             * class constructor, not for general use
100:             *
101:             * @param name
102:             */
103:            private ChannelInfo(String name) {
104:                this ();
105:                this .name = name;
106:                keyValue = name;
107:                toString = name;
108:            }
109:
110:            /**
111:             * Class constructor
112:             */
113:            public ChannelInfo(
114:                    DataShareConnectionDescriptor connectionDescriptor,
115:                    DataReceiverAdapter dataReceiverAdapter,
116:                    SessionInfo parentSession, boolean tryToSaveData) {
117:                this (connectionDescriptor.name);
118:                this .connectionDescriptor = connectionDescriptor;
119:                this .parentSession = parentSession;
120:                this .parentKeyValue = parentSession.getKeyValue();
121:                this .dataReceiverAdapter = dataReceiverAdapter;
122:                this .ownerName = parentSession.getOwnerName();
123:                if (connectionDescriptor.channelDescription.allowPersistSelection)
124:                    this .saveData = connectionDescriptor.channelDescription.persist
125:                            && tryToSaveData;
126:                else
127:                    this .saveData = false;
128:                this .clientClass = parentSession.getClientClass();
129:            }
130:
131:            /**
132:             * Retrieves the Channel descriptor (so an instance of a DataShareConnection can be created),
133:             * can return a null.
134:             */
135:            public DataShareConnectionDescriptor getConnectionDescriptor() {
136:                return connectionDescriptor;
137:            }
138:
139:            /**
140:             * Retrieves the DataReceiverAdapter for this Channel
141:             */
142:            public DataReceiverAdapter getDataReceiverAdapter() {
143:                return dataReceiverAdapter;
144:            }
145:
146:            /**
147:             * Retrieves the Channel's parent Session, may be null depending on which
148:             * constructor was used to create this instance.
149:             *
150:             * @return a reference to this Channel's parent Session (may be null)
151:             */
152:            public SessionInfo getSessionInfo() {
153:                return parentSession;
154:            }
155:
156:            /**
157:             * Sets the Channel's parent Session, only used when this ChannelInfo instance
158:             * is retrieved from persistence because normally the sessionInfo would have been
159:             * set by the constructor
160:             *
161:             * @param sessionInfo reference to this Channel's parent Session
162:             */
163:            public void setSessionInfo(SessionInfo sessionInfo) {
164:                parentSession = sessionInfo;
165:            }
166:
167:            /**
168:             * Retrieves an Object reference of this instance, used when this class
169:             * is cast to the parent class for common handling of DSObjectInfo objects. May return
170:             * null if constructor that does not have Channel as parameter was used to construct this
171:             * instance.
172:             *
173:             * @return the Channel instance as an Object (may be null)
174:             */
175:            public Object getObject() {
176:                return connectionDescriptor;
177:            }
178:
179:            /**
180:             * Retrieves a string containing 'Channel'.
181:             *
182:             * @return fixed value of 'Channel' for all instances, used when this class
183:             *      is referenced by it's parent class so all subclasses have a common
184:             *     method that can be used to test for the instance type.
185:             */
186:            public String getType() {
187:                return CHANNELTYPE;
188:            }
189:
190:            /**
191:             * Shuts down all the sockets associate with this Channel
192:             */
193:            public void shutDown() {
194:                this .dataReceiverAdapter.removeAllConsumerConnections();
195:                this .dataReceiverAdapter.getSocketServer().close();
196:                this .setActive(false);
197:            }
198:
199:            /**
200:             * Determines what type of HC function this Channel should be used for.  The
201:             * correct answers are one of the 'supported' HC Functions
202:             *
203:             * @return the HC Function that would normally use a Channel by this name
204:             */
205:            public String getFunction() {
206:                return name;
207:            }
208:
209:            /**
210:             * Retrieves a description of this instance.
211:             *
212:             * @return information about this instance
213:             */
214:            public String getInfo() {
215:                String filename = "";
216:                if (this .connectionDescriptor.channelDescription.channelJarFileName
217:                        .equals(""))
218:                    filename = "";
219:                else
220:                    filename = "<tr><td>Jar Filename</td><td>"
221:                            + this .connectionDescriptor.channelDescription.channelJarFileName
222:                            + "</td></tr>";
223:
224:                return "<tr><td>Function Name</td><td>"
225:                        + this .name
226:                        + "</td></tr>"
227:                        + "<tr><td>Description</td><td>"
228:                        + this .connectionDescriptor.channelDescription.channelDescription
229:                        + "</td></tr>"
230:                        + filename
231:                        + "<tr><td>Socket type</td><td>"
232:                        + ChannelDescription.validTypes[this .connectionDescriptor.type]
233:                        + "</td></tr>"
234:                        + "<tr><td>Server port</td><td>"
235:                        + this .connectionDescriptor.serverPort
236:                        + "</td></tr>"
237:                        + "<tr><td>Data persistance</td><td>"
238:                        + (this .getSaveDataForThisChannel() ? "Data is "
239:                                : "Data is not ")
240:                        + "being saved</td></tr>"
241:                        + "<tr><td>Allowed to record history</td><td>"
242:                        + (this .connectionDescriptor.channelDescription.allowPersistSelection ? "Yes"
243:                                : "No") + "</td></tr>"
244:                        + "<tr><td>Creation date</td><td>"
245:                        + this .getDate().toString() + "</td></tr>";
246:            }
247:
248:            /**
249:             * adds a Client/Consumer to this Channel
250:             *
251:             * @param consumer the consumer to add
252:             */
253:            public void addConsumerClient(ConsumerInfo consumer) {
254:                SessionUtilities.getLoggingInterface().debugMsg(
255:                        SessionUtilities.getLoggingInterface().DEBUG,
256:                        SessionUtilities.getLoggingInterface().CLIENT,
257:                        "channelInfo.addConsumerClient ("
258:                                + consumer.getKeyValue() + ") to Session "
259:                                + this .parentSession.getName() + ", Channel "
260:                                + this .toString() + " table of Consumers");
261:
262:                // if this object was retrieved from persistenceInterface, the table will be null the first time...
263:                if (consumerTable == null)
264:                    consumerTable = new Hashtable();
265:
266:                consumerTable.put(consumer.getKeyValue(), consumer);
267:            }
268:
269:            /**
270:             * removes a Client/Consumer from this Channel
271:             *
272:             * @param consumer the consumer to remove
273:             */
274:            public void removeConsumerClient(ConsumerInfo consumer) {
275:                // make sure connections are gone/closed
276:                this .dataReceiverAdapter.removeConsumerConnection(consumer
277:                        .getKeyValue());
278:
279:                SessionUtilities.getLoggingInterface().debugMsg(
280:                        SessionUtilities.getLoggingInterface().DEBUG,
281:                        SessionUtilities.getLoggingInterface().CLIENT,
282:                        "Removing consumer (" + consumer.getKeyValue()
283:                                + ") from Session "
284:                                + this .parentSession.getName() + ", Channel "
285:                                + this .toString()
286:                                + " ChannelInfo table of consumers");
287:                consumerTable.remove(consumer.getKeyValue());
288:            }
289:
290:            /**
291:             * checks to see if a Consumer is already in this Channel
292:             */
293:            public boolean checkForConsumer(ConsumerInfo consumer) {
294:                boolean retValue = false;
295:                if (consumerTable.contains(consumer.getKeyValue()))
296:                    retValue = true;
297:                return retValue;
298:            }
299:
300:            /**
301:             * returns the Hashtable of Consumers for this Channel
302:             *
303:             * @return the list of consumers, keyed by name
304:             */
305:            public Hashtable getConsumerTable() {
306:                return consumerTable;
307:            }
308:
309:            /**
310:             * sets the indicator for whether or not EJBs should be used for this Channel's Data.
311:             * Default value is true.
312:             *
313:             * @param useBeans true if beans are to be used, false otherwise
314:             */
315:            public void setSaveDataForThisChannel(boolean saveData) {
316:                this .saveData = saveData;
317:            }
318:
319:            /**
320:             * returns an indicator for whether or not EJBs are saved for this Channel's data
321:             *
322:             * @return returns true if beans are in use for this channel
323:             */
324:            public boolean getSaveDataForThisChannel() {
325:                return saveData;
326:            }
327:
328:            /**
329:             * Sets the ADSKey String for this instance to the provided parameter value.
330:             * The ADSKey String is the value provided when the EJB was created for this instance.
331:             *
332:             * @param ak the value to save as the ID for this instance
333:             */
334:            public void setDatabaseID(String /* ADSKey */ak) {
335:                SessionUtilities.getLoggingInterface().debugMsg(
336:                        SessionUtilities.getLoggingInterface().DEBUG,
337:                        SessionUtilities.getLoggingInterface().DATABASE,
338:                        "setDatabaseID(): EJB Key for " + this .getKeyValue()
339:                                + " has value of " + ak);
340:                databaseID = ak;
341:                waitingForKey = false;
342:                keyHasBeenReturned = true;
343:            }
344:
345:            /**
346:             * Retrieves the ADSKey String for this instance.  Should always be checked for null.
347:             * Also realize that this method may block until the ADSKey value is available.
348:             *
349:             * @return the ADSKey String that was previously set for this instance.
350:             */
351:            public String /* ADSKey */
352:            getDatabaseID() {
353:                String thisKey = null;
354:                if (this.saveData)
355:                    if (this.databaseID != null)
356:                        thisKey = databaseID;
357:                    else
358:                        thisKey = retrieveEJB();
359:                return thisKey;
360:            }
361:
362:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.