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


001:        package com.sun.portal.netlet.eproxy;
002:
003:        import java.io.IOException;
004:        import java.net.ServerSocket;
005:        import java.net.Socket;
006:        import java.net.SocketException;
007:        import java.util.logging.Level;
008:        import java.util.logging.Logger;
009:
010:        import com.sun.portal.log.common.PortalLogger;
011:        import com.sun.portal.util.GWLocale;
012:        import com.sun.portal.util.GWLogManager;
013:        import com.sun.portal.util.SRAPSocket;
014:        import com.sun.portal.util.SRAEvent;
015:        import com.sun.portal.rproxy.monitoring.MonitoringSubsystem;
016:
017:        abstract public class ProxyConnection {
018:
019:            // The "dummyLockString" is used to synchronize calls to GW.run_GW() and
020:            // GW.unrun_GW()
021:            private static String dummyLockString = "DummyLockString";
022:
023:            private String threadName = null;
024:
025:            private ServerSocket serverSocket = null;
026:
027:            private String connectionInfoKey = null;
028:
029:            private static Logger logger = PortalLogger
030:                    .getLogger(ProxyConnection.class);
031:
032:            public ProxyConnection(String threadName, String connectionInfoKey) {
033:                this .threadName = threadName;
034:                this .connectionInfoKey = connectionInfoKey;
035:            }
036:
037:            public void start() throws SocketException {
038:
039:                Thread.currentThread().setName(threadName);
040:                serverSocket = makeServerSocket();
041:                Socket inconnection;
042:
043:                Integer logid = new Integer(0);
044:                GW.run_GW();
045:
046:                while (serverSocket != null) {
047:                    inconnection = null;
048:                    try {
049:
050:                        try {
051:                            inconnection = serverSocket.accept();
052:                            incrementSocketCount();
053:                        } catch (SocketException se) {
054:                            continue; // Famous Fix
055:                        } catch (IOException e) {
056:                            // logger.log(Level.SEVERE, threadName + " cannot accept new
057:                            // connection on " + serverSocket, e);
058:                            Object[] params0 = {
059:                                    " cannot accept new connection on ",
060:                                    serverSocket, e };
061:                            logger.log(Level.SEVERE, "PSSRNTLT_CSPNEPROX051",
062:                                    params0);
063:
064:                            closeServerSocket();
065:                            // hack, if io error, retry?
066:                            resetServerSocket();
067:                            continue;
068:                        }
069:
070:                        if (GWLogManager.loggingEnabled) {
071:                            logid = new Integer(GWLogManager.getLogId());
072:                            // System.out.println("Before write ... " + inconnection);
073:                            // System.out.println("threadName ... " + threadName);
074:                            // System.out.println("connectionInfoKey ... " +
075:                            // connectionInfoKey);
076:
077:                            try {
078:                                GWLogManager
079:                                        .write(
080:                                                threadName,
081:                                                GWLocale
082:                                                        .getPFString(
083:                                                                connectionInfoKey,
084:                                                                new Object[] {
085:                                                                        logid,
086:                                                                        inconnection
087:                                                                                .getInetAddress()
088:                                                                                .toString(),
089:                                                                        new Integer(
090:                                                                                inconnection
091:                                                                                        .getPort()) }));
092:                            } catch (Exception ex) {
093:                                // ex.printStackTrace();
094:                            }
095:                        }
096:
097:                        try {
098:                            inconnection.setTcpNoDelay(true);
099:                        } catch (SocketException e) {
100:                            // logger.log(Level.SEVERE, threadName + " cannot set
101:                            // TcpNoDelay on " + inconnection, e);
102:                            Object[] params1 = { " cannot set TcpNoDelay on ",
103:                                    inconnection, e };
104:                            logger.log(Level.SEVERE, "PSSRNTLT_CSPNEPROX052",
105:                                    params1);
106:
107:                            closeSocket(inconnection);
108:                            inconnection = null;
109:                            continue;
110:                        }
111:
112:                        process(new SRAPSocket(inconnection), logid);
113:
114:                    } catch (Throwable t) {
115:                        // logger.log(Level.SEVERE, threadName + ": Uncaught
116:                        // exception:", t);
117:                        Object[] params2 = { ": Uncaught exception:", t };
118:                        logger.log(Level.SEVERE, "PSSRNTLT_CSPNEPROX053",
119:                                params2);
120:                    }
121:                }
122:                stop();
123:            }
124:
125:            private void resetServerSocket() throws SocketException {
126:
127:                try {
128:                    Thread.sleep(5);
129:                } catch (InterruptedException ee) {
130:                }
131:
132:                // now, reopen the connection and listen for requests...
133:                synchronized (dummyLockString) {
134:                    GW.unrun_GW();
135:                    GW.setNumberOfInstances(1);
136:                    serverSocket = makeServerSocket();
137:                    GW.run_GW();
138:                }
139:            }
140:
141:            protected void closeSocket(Socket socket) {
142:
143:                try {
144:                    socket.close();
145:                    boolean isHTTPS = serverSocket instanceof  org.mozilla.jss.ssl.SSLServerSocket;
146:                    if (isHTTPS) {
147:                        MonitoringSubsystem
148:                                .handleEvent(SRAEvent.SSL_SOCKET_DESTROYED);
149:                    } else {
150:                        MonitoringSubsystem
151:                                .handleEvent(SRAEvent.PLAIN_SOCKET_DESTROYED);
152:                    }
153:
154:                } catch (IOException ee) {
155:                    // logger.log(Level.SEVERE, threadName + ": IO Exception while
156:                    // closing server socket:", ee);
157:                    Object[] params3 = {
158:                            ": IO Exception while closing server socket:", ee };
159:                    logger.log(Level.SEVERE, "PSSRNTLT_CSPNEPROX054", params3);
160:                } finally {
161:                    socket = null;
162:                }
163:            }
164:
165:            private void closeServerSocket() {
166:
167:                /**
168:                 * Bug 4710658
169:                 */
170:                if (serverSocket != null) {
171:                    try {
172:                        serverSocket.close();
173:                    } catch (IOException ee) {
174:                        // logger.log(Level.SEVERE, threadName + " cannot close server
175:                        // socket", ee);
176:                        Object[] params4 = { " cannot close server socket", ee };
177:                        logger.log(Level.SEVERE, "PSSRNTLT_CSPNEPROX055",
178:                                params4);
179:                    } finally {
180:                        MonitoringSubsystem
181:                                .handleEvent(SRAEvent.SERVER_SOCKET_DESTROYED);
182:                        serverSocket = null;
183:                    }
184:                }
185:                // End of code change for Bug 4710658
186:
187:            }
188:
189:            private void incrementSocketCount() {
190:                boolean isHTTPS = serverSocket instanceof  org.mozilla.jss.ssl.SSLServerSocket;
191:
192:                if (isHTTPS) {
193:                    MonitoringSubsystem
194:                            .handleEvent(SRAEvent.SSL_SOCKET_CREATED);
195:                } else {
196:                    MonitoringSubsystem
197:                            .handleEvent(SRAEvent.PLAIN_SOCKET_CREATED);
198:                }
199:            }
200:
201:            private void stop() {
202:                // logger.severe("FATAL ERROR: " + threadName + " exited");
203:                Object[] params5 = { threadName, " exited" };
204:                logger.log(Level.SEVERE, "PSSRNTLT_CSPNEPROX056", params5);
205:            }
206:
207:            abstract protected ServerSocket makeServerSocket()
208:                    throws SocketException;
209:
210:            abstract protected void process(Socket connection, Integer logId);
211:
212:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.