Source Code Cross Referenced for EProxy.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.File;
004:        import java.io.FileWriter;
005:        import java.io.IOException;
006:        import java.net.ServerSocket;
007:        import java.net.SocketException;
008:        import java.util.logging.Level;
009:        import java.util.logging.Logger;
010:        import java.util.List;
011:        import java.util.Iterator;
012:
013:        import com.sun.portal.log.common.PortalLogger;
014:        import com.sun.portal.rproxy.configservlet.client.GatewayProfile;
015:        import com.sun.portal.rproxy.configservlet.client.PlatformProfile;
016:        import com.sun.portal.rproxy.monitoring.MonitoringSubsystem;
017:        import com.sun.portal.rproxy.rewriter.SRAPRewriterModule;
018:        import com.sun.portal.rproxy.server.GatewayContext;
019:        import com.sun.portal.rproxy.server.GatewayContextFactory;
020:        import com.sun.portal.util.GWDebug;
021:        import com.sun.portal.util.GWLocale;
022:        import com.sun.portal.util.GWLogManager;
023:        import com.sun.portal.util.GWNSSInit;
024:        import com.sun.portal.util.GWThreadPool;
025:        import com.sun.portal.util.NetletLogMgr;
026:        import com.sun.portal.util.ServiceIdentifier;
027:        import com.sun.portal.util.SystemProperties;
028:
029:        public class EProxy {
030:
031:            public static boolean isNetletEnabled = true;
032:
033:            public static boolean isProxyletEnabled = false;
034:
035:            public static Logger logger = null;
036:
037:            private static void init() throws SocketException {
038:                System.setProperty("com.sun.portal.sra.component.type",
039:                        "gateway");
040:                if (logger == null) {
041:                    // The following will replace the %sraComponentType key in the log file with the key
042:                    // Gateway and generate the log file name . See the platform.conf file for the entire
043:                    // key   
044:                    logger = PortalLogger.getLogger(EProxy.class);
045:                }
046:                GWDebug.createDefault("srapGateway");
047:                if (!GWNSSInit.initialize()) {
048:                    System.exit(1);
049:                }
050:                ServiceIdentifier.createDefault("srapGateway");
051:                try {
052:                    String profileName = System.getProperty(
053:                            "gateway.profilename", "default");
054:                    GatewayProfile.init("this-should-be-sid", profileName);
055:                    PlatformProfile.init("this-should-be-sid");
056:                    SRAPRewriterModule.initIDSAME();
057:                } catch (Exception e) {
058:
059:                    // logger.log(Level.SEVERE, "Unable to initialize
060:                    // GatewayProfile/PlatformProfile", e);
061:                    logger.log(Level.SEVERE, "PSSRNTLT_CSPNEPROX010");
062:                    System.exit(1);
063:                }
064:                // GatewayContextFactory.init(GatewayContextFactory.FILE_INSTANCE);
065:                GatewayContextFactory
066:                        .init(GatewayContextFactory.DSAME_INSTANCE);
067:
068:                GWLogManager.initialise();
069:                if (GWLogManager.loggingEnabled) {
070:                    // Guess this is ok since this is in static block
071:                    // Log file name should not contain '-' as per iDSAME Log api
072:                    StringBuffer logsb = new StringBuffer();
073:                    logsb.append("srapGateway_").append(
074:                            SystemProperties.get("gateway.host").replace('-',
075:                                    '_')).append('_').append(
076:                            System
077:                                    .getProperty("gateway.profilename",
078:                                            "default").replace('-', '_'));
079:                    GWLogManager.createDefault(logsb.toString());
080:                }
081:
082:                if (NetletLogMgr.loggingEnabled) {
083:                    StringBuffer logsb = new StringBuffer();
084:                    logsb.append("srapNetlet_").append(
085:                            SystemProperties.get("gateway.host").replace('-',
086:                                    '_')).append('_').append(
087:                            System
088:                                    .getProperty("gateway.profilename",
089:                                            "default").replace('-', '_'));
090:                    NetletLogMgr.createDefault(logsb.toString());
091:                }
092:
093:                GWLocale.createDefault();
094:
095:                GWThreadPool.init();
096:            }
097:
098:            // Lihue PRD : 4.5
099:            static final String watchdogInfoFileBase = "/var/opt/SUNWportal/.gw.";
100:
101:            // EOC :: Lihue PRD : 4.5
102:
103:            public static void main(String argv[]) {
104:
105:                try {
106:                    init();
107:                    if (GWLogManager.loggingEnabled) {
108:                        GWLogManager.write("EProxy", GWLocale
109:                                .getPFString("StartEProxy"));
110:                    }
111:                } catch (SocketException e) {
112:                    e.printStackTrace();
113:                }
114:
115:                if (GWLogManager.loggingEnabled) {
116:                    GWLogManager.write("EProxy", GWLocale
117:                            .getPFString("StartEProxy"));
118:                }
119:
120:                GatewayContext gatewayContext = GatewayContextFactory
121:                        .getGatewayContext();
122:                boolean httpEnabled = gatewayContext.isHttpEnabled();
123:                boolean httpsEnabled = gatewayContext.isHttpsEnabled();
124:
125:                if (!(httpEnabled || httpsEnabled)) {
126:                    // Neither of them is enabled...
127:                    return;
128:                }
129:
130:                int httpPort = gatewayContext.getHttpPort();
131:                int httpsPort = gatewayContext.getHttpsPort();
132:
133:                writePortInfoForWatchdog(httpEnabled, httpPort, httpsEnabled,
134:                        httpsPort);
135:
136:                isNetletEnabled = gatewayContext.isEProxyEnabled();
137:
138:                isProxyletEnabled = gatewayContext.isPProxyEnabled();
139:
140:                //
141:                // Start gateway in two modes ( non-ssl as well as SSL mode ) if
142:                // proxylet is enabled.
143:                //
144:                if (isProxyletEnabled) {
145:                    // logger.info("Proxylet Enabled");
146:                    logger.info("PSSRNTLT_CSPNEPROX011");
147:                    //
148:                    // Find out an unused port on the local machine.
149:                    //
150:                    int internalPort = 0;
151:                    try {
152:                        ServerSocket s = new ServerSocket(0);
153:                        internalPort = s.getLocalPort();
154:                        s.close();
155:                        s = null;
156:
157:                    } catch (Exception ignore) {
158:                    }
159:
160:                    // logger.info("Free port on localhost " + internalPort);
161:                    Object[] params2 = { "" + internalPort };
162:                    logger.log(Level.INFO, "PSSRNTLT_CSPNEPROX012", params2);
163:
164:                    // Start SSL server on any free port . This port information is
165:                    // local to the server
166:                    // and is not published
167:                    startRProxy(httpEnabled, httpPort, httpsEnabled,
168:                            internalPort);
169:
170:                    // Start non-ssl server on the acutal SSL port. Request that arrive
171:                    // on this port will
172:                    // be forwarded to the SSL server running on the internal port
173:                    startPProxy(httpsEnabled, httpsPort, internalPort);
174:                } else
175:                    startRProxy(httpEnabled, httpPort, httpsEnabled, httpsPort);
176:
177:                MonitoringSubsystem.getInstance();
178:            }
179:
180:            private static void startPProxy_HTTP(boolean httpEnabled,
181:                    int httpPort, int internalPort) {
182:
183:                if (httpEnabled) {
184:                    PProxyConnection.startHttps(httpPort, internalPort);
185:                    // logger.info("PProxy HTTP is being initialised at port:" +
186:                    // httpPort); }
187:                    Object[] params3 = { httpPort + "" };
188:                    logger.log(Level.INFO, "PSSRNTLT_CSPNEPROX013", params3);
189:
190:                }
191:            }
192:
193:            private static void startPProxy(boolean httpsEnabled,
194:                    int httpsPort, int internalPort) {
195:
196:                if (httpsEnabled) {
197:                    PProxyConnection.startHttps(httpsPort, internalPort);
198:                    // logger.info("PProxy Https is being initialised at port:" +
199:                    // httpsPort);
200:                    Object[] params4 = { "" + httpsPort };
201:                    logger.log(Level.INFO, "PSSRNTLT_CSPNEPROX014", params4);
202:                }
203:
204:            }
205:
206:            private static void startRProxy(boolean httpEnabled, int httpPort,
207:                    boolean httpsEnabled, int httpsPort) {
208:
209:                int numberOfGatewayInstances = (httpEnabled && httpsEnabled) ? 2
210:                        : 1;
211:                GW.setNumberOfInstances(numberOfGatewayInstances);
212:
213:                if (httpEnabled) {
214:                    RProxyConnection.startHttp(httpPort);
215:                    // logger.info("Http is being initialised at port:" + httpPort);
216:                    Object[] params5 = { httpPort + "" };
217:                    logger.log(Level.INFO, "PSSRNTLT_CSPNEPROX015", params5);
218:                }
219:
220:                if (httpsEnabled) {
221:                    RProxyConnection.startHttps(httpsPort);
222:                    // logger.info("Https is being initialised at port:" + httpsPort);
223:                    Object[] params6 = { httpsPort + "" };
224:                    logger.log(Level.INFO, "PSSRNTLT_CSPNEPROX016", params6);
225:                }
226:
227:            }
228:
229:            private static void writePortInfoForWatchdog(boolean httpEnabled,
230:                    int httpPort, boolean httpsEnabled, int httpsPort) {
231:                File watchdogInfoFile = new File(watchdogInfoFileBase
232:                        + System.getProperty("conf.suffix"));
233:                if (watchdogInfoFile.exists()) {
234:                    watchdogInfoFile.delete();
235:                }
236:
237:                // Write port Information for watchdog process.
238:                try {
239:                    FileWriter fw = new FileWriter(watchdogInfoFile);
240:
241:                    if (httpEnabled) {
242:                        fw.write(httpPort + "\n");
243:                    }
244:
245:                    if (httpsEnabled) {
246:                        fw.write(httpsPort + "\n");
247:                    }
248:
249:                    fw.flush();
250:                    fw.close();
251:                } catch (IOException ex) {
252:                    // logger.severe("Unable to enter information for watchdog
253:                    // information");
254:                    logger.severe("PSSRNTLT_CSPNEPROX017");
255:                }
256:            }
257:
258:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.