Source Code Cross Referenced for RequestRemoteControlLoadDocImpl.java in  » Ajax » ItsNat » org » itsnat » impl » core » request » 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 » Ajax » ItsNat » org.itsnat.impl.core.request 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:          ItsNat Java Web Application Framework
003:          Copyright (C) 2007 Innowhere Software Services S.L., Spanish Company
004:          Author: Jose Maria Arranz Santamaria
005:
006:          This program is free software: you can redistribute it and/or modify
007:          it under the terms of the GNU Affero General Public License as published by
008:          the Free Software Foundation, either version 3 of the License, or
009:          (at your option) any later version. See the GNU Affero General Public 
010:          License for more details. See the copy of the GNU Affero General Public License
011:          included in this program. If not, see <http://www.gnu.org/licenses/>.
012:         */
013:
014:        package org.itsnat.impl.core.request;
015:
016:        import org.itsnat.core.ItsNatException;
017:        import org.itsnat.core.event.RemoteControlEvent;
018:        import org.itsnat.impl.core.*;
019:        import org.itsnat.impl.core.client.ClientDocumentInvitedRemoteCtrlCometImpl;
020:        import org.itsnat.impl.core.client.ClientDocumentInvitedRemoteCtrlImpl;
021:        import org.itsnat.impl.core.client.ClientDocumentInvitedRemoteCtrlTimerImpl;
022:        import org.itsnat.impl.core.event.client2serv.RemoteControlCometTaskEventImpl;
023:        import org.itsnat.impl.core.event.client2serv.RemoteControlEventImpl;
024:        import org.itsnat.impl.core.event.client2serv.RemoteControlTimerEventImpl;
025:        import org.itsnat.impl.core.response.ResponseRemoteControlLoadDocImpl;
026:
027:        /**
028:         *
029:         * @author jmarranz
030:         */
031:        public class RequestRemoteControlLoadDocImpl extends
032:                RequestRemoteControlImpl {
033:
034:            /**
035:             * Creates a new instance of RequestRemoteControlLoadDocImpl
036:             */
037:            public RequestRemoteControlLoadDocImpl(
038:                    ItsNatServletRequestImpl itsNatRequest) {
039:                super (itsNatRequest);
040:            }
041:
042:            public void process() {
043:                // La sesión que se monitoriza no tiene porqué ser la misma del monitorizador
044:                String sessionId = getParameter("itsnat_session_id"); // Debe existir (sino da error)        
045:                ItsNatServletContextImpl context = itsNatRequest
046:                        .getItsNatServletContext();
047:                ItsNatSessionImpl remSession = context
048:                        .findItsNatSessionById(sessionId);
049:                if (remSession == null)
050:                    throw new ItsNatException("Remote session with id "
051:                            + sessionId + " does not exist");
052:
053:                ItsNatSessionImpl session = itsNatRequest
054:                        .getItsNatSessionImpl();
055:                if (!remSession.isUserAgentCompatible(session.getUserAgent()))
056:                    throw new ItsNatException(
057:                            "User agent is not compatible with the remote user agent: "
058:                                    + remSession.getUserAgent());
059:
060:                // El documento a monitorizar está registrado en la sesión remota:
061:                String docId = getParameter("itsnat_doc_id"); // Debe existir (sino da error)               
062:                ItsNatDocumentImpl itsNatDoc = remSession
063:                        .getItsNatDocumentImplById(docId);
064:                if (itsNatDoc == null)
065:                    throw new ItsNatException(
066:                            "Observed session/document with id "
067:                                    + remSession.getId() + "/" + docId
068:                                    + " does not exist");
069:
070:                synchronized (itsNatDoc) // Sólo un hilo puede acceder al mismo documento
071:                {
072:                    itsNatRequest.setItsNatDocument(itsNatDoc);
073:
074:                    try {
075:                        // Evaluamos si está autorizado para controlar remótamente
076:                        int syncMode;
077:                        String syncModeStr = getParameter("itsnat_syncmode",
078:                                false); // Opcional     
079:                        if (syncModeStr != null)
080:                            syncMode = Integer.parseInt(syncModeStr);
081:                        else
082:                            syncMode = itsNatDoc.getDefaultSyncMode();
083:
084:                        long ajaxTimeout;
085:                        String ajaxTimeoutStr = getParameter(
086:                                "itsnat_ajaxtimeout", false); // Opcional     
087:                        if (ajaxTimeoutStr != null)
088:                            ajaxTimeout = Long.parseLong(ajaxTimeoutStr);
089:                        else
090:                            ajaxTimeout = itsNatDoc.getAJAXTimeout();
091:
092:                        RemoteControlEventImpl requestEvent = null;
093:
094:                        // Phase RemoteControlEvent.REQUEST;
095:                        String refreshMethod = getParameter("itsnat_refresh_method");
096:                        if (refreshMethod.equals("timer")) {
097:                            int interval = Integer
098:                                    .parseInt(getParameter("itsnat_refresh_interval"));
099:
100:                            requestEvent = new RemoteControlTimerEventImpl(
101:                                    interval, syncMode, ajaxTimeout,
102:                                    itsNatRequest);
103:                        } else if (refreshMethod.equals("comet")) {
104:                            requestEvent = new RemoteControlCometTaskEventImpl(
105:                                    syncMode, ajaxTimeout, itsNatRequest);
106:                        } else
107:                            throw new ItsNatException(
108:                                    "Unrecognized refresh method: \""
109:                                            + refreshMethod + "\"");
110:
111:                        itsNatDoc.dispatchRemoteControlListeners(requestEvent);
112:                        if (!requestEvent.isAccepted())
113:                            throw new ItsNatException(
114:                                    "Request to remote control the document/page \""
115:                                            + itsNatDoc
116:                                                    .getDocumentTemplateImpl()
117:                                                    .getName()
118:                                            + "\" is not accepted");
119:
120:                        int phase = RemoteControlEvent.LOAD;
121:
122:                        ClientDocumentInvitedRemoteCtrlImpl observer = null;
123:                        if (requestEvent instanceof  RemoteControlTimerEventImpl) {
124:                            RemoteControlTimerEventImpl requestTimerEvent = (RemoteControlTimerEventImpl) requestEvent;
125:                            observer = new ClientDocumentInvitedRemoteCtrlTimerImpl(
126:                                    requestTimerEvent.getRefreshInterval(),
127:                                    phase, requestEvent.getSyncMode(),
128:                                    requestEvent.getAJAXTimeout(), session,
129:                                    itsNatDoc);
130:                        } else if (requestEvent instanceof  RemoteControlCometTaskEventImpl) {
131:                            observer = new ClientDocumentInvitedRemoteCtrlCometImpl(
132:                                    phase, requestEvent.getSyncMode(),
133:                                    requestEvent.getAJAXTimeout(), session,
134:                                    itsNatDoc);
135:                        }
136:
137:                        itsNatRequest.setClientDocument(observer);
138:                        session.addClientDocumentInvitedRemoteCtrl(observer); // Sujeta el objeto
139:                        itsNatDoc.addClientDocumentInvitedRemoteCtrl(observer); // permite que se notifiquen los cambios
140:
141:                        ResponseRemoteControlLoadDocImpl response = new ResponseRemoteControlLoadDocImpl(
142:                                requestEvent, itsNatRequest
143:                                        .getItsNatServletResponseImpl());
144:                        try {
145:                            response.process();
146:
147:                            if (observer.getPhase() == RemoteControlEvent.LOAD)
148:                                observer.setPhase(RemoteControlEvent.REFRESH);
149:                        } catch (Exception ex) {
150:                            session
151:                                    .removeClientDocumentInvitedRemoteCtrl(observer);
152:                            itsNatDoc
153:                                    .removeClientDocumentInvitedRemoteCtrl(observer); // El documento no lo retiene pero así se quita explícitamente
154:
155:                            throw new ItsNatException(ex);
156:                        }
157:                    } finally {
158:                        itsNatRequest.unsetItsNatDocument();
159:                        itsNatRequest.setClientDocument(null);
160:                    }
161:                }
162:            }
163:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.