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


001:        /*
002:         * SRAPSocket.java
003:         *
004:         * Created on November 12, 2002, 5:12 PM
005:         */
006:
007:        package com.sun.portal.util;
008:
009:        import java.io.BufferedInputStream;
010:        import java.io.BufferedOutputStream;
011:        import java.io.IOException;
012:        import java.io.InputStream;
013:        import java.io.OutputStream;
014:        import java.net.InetAddress;
015:        import java.net.Socket;
016:        import java.net.SocketAddress;
017:        import java.net.SocketException;
018:        import java.net.SocketImplFactory;
019:        import java.util.logging.Logger;
020:
021:        import com.sun.portal.log.common.PortalLogger;
022:        import com.sun.portal.rproxy.monitoring.MonitoringSubsystem;
023:
024:        /**
025:         * 
026:         * @author Mridul
027:         */
028:        public class SRAPSocket extends Socket {
029:
030:            private Socket sock = null;
031:
032:            private BufferedInputStream in = null;
033:
034:            private BufferedOutputStream out = null;
035:
036:            private boolean isHTTPS;
037:
038:            // static Logger logger = Logger.getLogger("com.sun.portal.sra.rproxy");
039:            private static Logger logger = PortalLogger
040:                    .getLogger(SRAPSocket.class);
041:
042:            public SRAPSocket(Socket sock) throws IOException {
043:                this .sock = sock;
044:                isHTTPS = (sock instanceof  org.mozilla.jss.ssl.SSLSocket);
045:
046:                if (isHTTPS) {
047:                    MonitoringSubsystem
048:                            .handleEvent(SRAEvent.SSL_SOCKET_CREATED);
049:                } else {
050:                    MonitoringSubsystem
051:                            .handleEvent(SRAEvent.PLAIN_SOCKET_CREATED);
052:                }
053:            }
054:
055:            public InputStream getInputStream() throws IOException {
056:                if (in == null) {
057:                    in = new BufferedInputStream(sock.getInputStream());
058:                }
059:                return in;
060:            }
061:
062:            public void close() throws IOException {
063:                if (_open) {// sock.isClosed() does not give the actual state. probably a bug with JSS. So this new flag is added
064:                    if (isHTTPS) {
065:                        MonitoringSubsystem
066:                                .handleEvent(SRAEvent.SSL_SOCKET_DESTROYED);
067:                    } else {
068:                        MonitoringSubsystem
069:                                .handleEvent(SRAEvent.PLAIN_SOCKET_DESTROYED);
070:                    }
071:                }
072:                /*
073:                 * // This should not cause gateway to throw up - but is the proper way
074:                 * to // exit - but JSS/NSS throws up with a JVM crash if we do this !! //
075:                 * That product sure is buggy !! if (out != null){ try{ out.flush();
076:                 * }catch(IOException ex){} }
077:                 */
078:                sock.close();
079:            }
080:
081:            public InetAddress getInetAddress() {
082:                return sock.getInetAddress();
083:            }
084:
085:            public boolean getKeepAlive() throws SocketException {
086:                return sock.getKeepAlive();
087:            }
088:
089:            public InetAddress getLocalAddress() {
090:                return sock.getLocalAddress();
091:            }
092:
093:            public int getLocalPort() {
094:                return sock.getLocalPort();
095:            }
096:
097:            public OutputStream getOutputStream() throws IOException {
098:                if (out == null) {
099:                    out = new BufferedOutputStream(sock.getOutputStream());
100:                }
101:                return out;
102:            }
103:
104:            public int getPort() {
105:                return sock.getPort();
106:            }
107:
108:            public int getReceiveBufferSize() throws SocketException {
109:                return sock.getReceiveBufferSize();
110:            }
111:
112:            public int getSendBufferSize() throws SocketException {
113:                return sock.getSendBufferSize();
114:            }
115:
116:            public int getSoLinger() throws SocketException {
117:                return sock.getSoLinger();
118:            }
119:
120:            public int getSoTimeout() throws SocketException {
121:                return sock.getSoTimeout();
122:            }
123:
124:            public boolean getTcpNoDelay() throws SocketException {
125:                return sock.getTcpNoDelay();
126:            }
127:
128:            public void setKeepAlive(boolean on) throws SocketException {
129:                sock.setKeepAlive(on);
130:            }
131:
132:            public void setReceiveBufferSize(int size) throws SocketException {
133:                sock.setReceiveBufferSize(size);
134:            }
135:
136:            public void setSendBufferSize(int size) throws SocketException {
137:                sock.setSendBufferSize(size);
138:            }
139:
140:            public static void setSocketImplFactory(SocketImplFactory fac)
141:                    throws UnsupportedOperationException {
142:                // logger.info("setSocketImplFactory(SocketImplFactory fac) called in
143:                // SRAPSocket");
144:                logger.info("PSSR_CSPU091");
145:                throw new UnsupportedOperationException("Not supported");
146:            }
147:
148:            public void setSoLinger(boolean on, int linger)
149:                    throws SocketException {
150:                sock.setSoLinger(on, linger);
151:            }
152:
153:            public void setSoTimeout(int timeout) throws SocketException {
154:
155:                sock.setSoTimeout(timeout);
156:            }
157:
158:            public void setTcpNoDelay(boolean on) throws SocketException {
159:                sock.setTcpNoDelay(on);
160:            }
161:
162:            public void shutdownInput() throws IOException {
163:                // Is this required ??
164:                // Mridul
165:                in.skip(in.available());
166:                sock.shutdownInput();
167:            }
168:
169:            public void shutdownOutput() throws IOException {
170:                out.flush();
171:                sock.shutdownOutput();
172:            }
173:
174:            public String toString() {
175:                try {
176:                    return sock.toString();
177:                } catch (Exception ex) {
178:                    return null;
179:                }
180:            }
181:
182:            public boolean isSSLSocket() {
183:                return isHTTPS;
184:            }
185:
186:            public Socket getActualSocket() {
187:                return sock;
188:            }
189:
190:            private boolean _open = true;
191:
192:            public SocketAddress getRemoteSocketAddress() {
193:                return sock.getRemoteSocketAddress();
194:            }
195:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.