Source Code Cross Referenced for RWGroupJSSProxy.java in  » Portal » Open-Portal » com » sun » portal » rproxy » connectionhandler » 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 » Portal » Open Portal » com.sun.portal.rproxy.connectionhandler 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package com.sun.portal.rproxy.connectionhandler;
002:
003:        import java.net.*;
004:        import java.lang.*;
005:        import java.io.*;
006:        import java.util.logging.Logger;
007:        import java.util.logging.Level;
008:
009:        import com.sun.portal.netlet.econnection.*;
010:        import com.sun.portal.netlet.eproxy.*;
011:        import com.sun.portal.util.*;
012:        import com.sun.portal.rproxy.monitoring.MonitoringSubsystem;
013:        import com.sun.portal.util.SRAEvent;
014:
015:        public class RWGroupJSSProxy extends ReaderWriterLock {
016:            private Socket fromClient;
017:            private Socket toServer;
018:
019:            private ReaderWriterClear src_to_dst;
020:            private ReaderWriterClear dst_to_src;
021:            private boolean src_to_dst_clean = false;
022:            private boolean dst_to_src_clean = false;
023:            private long startTime;
024:            private static Logger logger = null;
025:
026:            public RWGroupJSSProxy(Socket fromSocket, Socket toSocket) {
027:                logger = Logger.getLogger("com.sun.portal.sra.rproxy");
028:                startTime = System.currentTimeMillis();
029:                fromClient = fromSocket;
030:                toServer = toSocket;
031:                try {
032:                    src_to_dst = new ReaderWriterClear(this , fromClient
033:                            .getInputStream(), toServer.getOutputStream());
034:                    dst_to_src = new ReaderWriterClear(this , toServer
035:                            .getInputStream(), fromClient.getOutputStream());
036:                } catch (Exception ex) {
037:                    /*
038:                    System.out.println("Unable to create ReaderWriter threads.");
039:                    ex.printStackTrace();
040:                     */
041:                    logger.log(Level.SEVERE,
042:                            "Unable to create ReaderWriter threads.", ex);
043:                }
044:                try {
045:                    GWThreadPool.run(src_to_dst);
046:                    GWThreadPool.run(dst_to_src);
047:                } catch (InterruptedException e) {
048:                    logger.log(Level.SEVERE,
049:                            "Could not start ReaderWriterClear tasks", e);
050:                }
051:            }
052:
053:            public synchronized void notifyFinished(ReaderWriter obj) {
054:                if (obj == src_to_dst) {
055:                    if (dst_to_src.isAlive()) {
056:                        dst_to_src.stop();
057:                    }
058:                } else if (obj == dst_to_src) {
059:                    if (src_to_dst.isAlive()) {
060:                        src_to_dst.stop();
061:                    }
062:                }
063:                cleanup();
064:                if (obj == src_to_dst) {
065:                    src_to_dst_clean = true;
066:                } else if (obj == dst_to_src) {
067:                    dst_to_src_clean = true;
068:                }
069:            }
070:
071:            public void cleanup() {
072:                if (fromClient != null) {
073:                    try {
074:                        fromClient.close();
075:                        if (fromClient instanceof  org.mozilla.jss.ssl.SSLSocket) {
076:                            MonitoringSubsystem
077:                                    .handleEvent(SRAEvent.SSL_SOCKET_DESTROYED);
078:                        } else {
079:                            MonitoringSubsystem
080:                                    .handleEvent(SRAEvent.PLAIN_SOCKET_DESTROYED);
081:                        }
082:                    } catch (Exception e) {
083:                    } finally {
084:                        fromClient = null;
085:                    }
086:                }
087:                if (toServer != null) {
088:                    try {
089:                        toServer.close();
090:                        if (toServer instanceof  org.mozilla.jss.ssl.SSLSocket) {
091:                            MonitoringSubsystem
092:                                    .handleEvent(SRAEvent.SSL_SOCKET_DESTROYED);
093:                        } else {
094:                            MonitoringSubsystem
095:                                    .handleEvent(SRAEvent.PLAIN_SOCKET_DESTROYED);
096:                        }
097:                    } catch (Exception e) {
098:                    } finally {
099:                        toServer = null;
100:                    }
101:                }
102:            }
103:
104:            public boolean isDone() {
105:                if (dst_to_src_clean && src_to_dst_clean) {
106:                    dst_to_src = null;
107:                    src_to_dst = null;
108:                }
109:                return (dst_to_src_clean && src_to_dst_clean);
110:            }
111:
112:            /*
113:             * Added by Rajesh T for RFE 4492648.
114:             * @ returns the latest of the two access time of the 2
115:             * ReaderWriter's associated in this Group in milliseconds
116:             * @see com.sun.portal.netlet.eproxy.NetletGroup.
117:             */
118:
119:            public long getLastActivityTime() {
120:
121:                if (src_to_dst.getLastActivityTime() > dst_to_src
122:                        .getLastActivityTime())
123:                    return src_to_dst.getLastActivityTime();
124:                else
125:                    return dst_to_src.getLastActivityTime();
126:
127:            }
128:
129:            /*
130:             * Added for RFE 4492648
131:             * @ see com.sun.portal.econnection.ReaderWriterLock
132:             */
133:
134:            public synchronized void stopAll() {
135:
136:                if (dst_to_src != null) {
137:                    dst_to_src.stop();
138:                }
139:                if (src_to_dst != null) {
140:                    src_to_dst.stop();
141:                }
142:                cleanup();
143:
144:            }
145:
146:            /*
147:             * Added for Netlet PRD 1.8.1 for Lihue
148:             * dummy implementation
149:             */
150:
151:            public int getAppletSrcPort() {
152:                return 0;
153:            }
154:
155:            public long getStartTime() {
156:                return startTime;
157:            }
158:
159:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.