Source Code Cross Referenced for PresenceObserverHelper.java in  » ERP-CRM-Financial » sakai » org » sakaiproject » chat2 » tool » 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 » ERP CRM Financial » sakai » org.sakaiproject.chat2.tool 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /**********************************************************************************
002:         * $URL: https://source.sakaiproject.org/svn/presence/trunk/presence-util/util/src/java/org/sakaiproject/util/PresenceObservingCourier.java $
003:         * $Id: PresenceObservingCourier.java 8204 2006-04-24 19:35:57Z ggolden@umich.edu $
004:         ***********************************************************************************
005:         *
006:         * Copyright (c) 2003, 2004, 2005, 2006 The Sakai Foundation.
007:         * 
008:         * Licensed under the Educational Community License, Version 1.0 (the "License"); 
009:         * you may not use this file except in compliance with the License. 
010:         * You may obtain a copy of the License at
011:         * 
012:         *      http://www.opensource.org/licenses/ecl1.php
013:         * 
014:         * Unless required by applicable law or agreed to in writing, software 
015:         * distributed under the License is distributed on an "AS IS" BASIS, 
016:         * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
017:         * See the License for the specific language governing permissions and 
018:         * limitations under the License.
019:         *
020:         **********************************************************************************/package org.sakaiproject.chat2.tool;
021:
022:        import org.sakaiproject.chat2.model.PresenceObserver;
023:
024:        import java.util.List;
025:        import java.util.Observable;
026:        import java.util.Observer;
027:
028:        import org.sakaiproject.event.api.Event;
029:        import org.sakaiproject.event.api.EventTrackingService;
030:        import org.sakaiproject.presence.cover.PresenceService;
031:
032:        /**
033:         * <p>
034:         * PresenceObservingCourier is an EventObservingCourier which watches for only presence service events at a particular location, and delivers a direct refresh delivery.
035:         * </p>
036:         */
037:        public class PresenceObserverHelper implements  Observer {
038:            /** Constructor discovered injected EventTrackingService. */
039:            protected EventTrackingService m_eventTrackingService = null;
040:
041:            private String m_resourcePattern;
042:            private String location;
043:
044:            private PresenceObserver presenceObserver;
045:
046:            /**
047:             * This variant, watches presense changes at 
048:             * the specified location, and sends the notifications to 
049:             * that same location.  The elementID is null so the main window is refreshed when the notification 
050:             * is received.
051:             * 
052:             * @param location
053:             *        The location under observation *and* the location for the delivery of the events.
054:             */
055:            public PresenceObserverHelper(PresenceObserver presenceObserver,
056:                    String location) {
057:                this .presenceObserver = presenceObserver;
058:                this .location = location;
059:                m_resourcePattern = PresenceService.presenceReference(location);
060:
061:                // "inject" a eventTrackingService
062:                m_eventTrackingService = org.sakaiproject.event.cover.EventTrackingService
063:                        .getInstance();
064:
065:                // register to listen to events
066:                m_eventTrackingService.addObserver(this );
067:                // %%% add the pattern to have it filtered there?
068:            }
069:
070:            protected void finalize() {
071:                // stop observing the presence location
072:                m_eventTrackingService.deleteObserver(this );
073:            }
074:
075:            public void endObservation() {
076:                // stop observing the presence location
077:                m_eventTrackingService.deleteObserver(this );
078:            }
079:
080:            public void updatePresence() {
081:                PresenceService.setPresence(location);
082:            }
083:
084:            public void removePresence() {
085:                PresenceService.removePresence(location);
086:            }
087:
088:            public List getPresentUsers() {
089:                return PresenceService.getPresentUsers(location);
090:            }
091:
092:            public String getLocation() {
093:                return location;
094:            }
095:
096:            /**
097:             * Check to see if we want to process or ignore this update.
098:             * 
099:             * @param arg
100:             *        The arg from the update.
101:             * @return true to continue, false to quit.
102:             */
103:            public boolean check(Object arg) {
104:                // arg is Event
105:                if (!(arg instanceof  Event))
106:                    return false;
107:                Event event = (Event) arg;
108:                String key = event.getResource();
109:
110:                // reject non presence events
111:                String function = event.getEvent();
112:                if (!(function.equals(PresenceService.EVENT_PRESENCE) || function
113:                        .equals(PresenceService.EVENT_ABSENCE)))
114:                    return false;
115:
116:                // look for matches to the pattern
117:                if (m_resourcePattern != null) {
118:                    if (!key.equals(m_resourcePattern))
119:                        return false;
120:                }
121:
122:                return true;
123:            }
124:
125:            /**
126:             * This method is called whenever the observed object is changed. An application calls an <tt>Observable</tt> object's <code>notifyObservers</code> method to have all the object's observers notified of the change. default implementation is to
127:             * cause the courier service to deliver to the interface controlled by my controller. Extensions can override.
128:             * 
129:             * @param o
130:             *        the observable object.
131:             * @param arg
132:             *        an argument passed to the <code>notifyObservers</code> method.
133:             */
134:            public void update(Observable o, Object arg) {
135:                if (!check(arg))
136:                    return;
137:
138:                Event event = (Event) arg;
139:
140:                if (event.getEvent().equals(PresenceService.EVENT_PRESENCE))
141:                    presenceObserver.userJoined(location, "");
142:                else
143:                    presenceObserver.userLeft(location, "");
144:
145:            }
146:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.