Source Code Cross Referenced for ApplicationLoginHostChooser.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:         * ApplicationLoginHostChooser.java
003:         *
004:         * Created on August 29, 2003, 11:29 PM
005:         */
006:
007:        package com.sun.portal.util;
008:
009:        import java.net.MalformedURLException;
010:        import java.net.URL;
011:        import java.util.logging.Level;
012:        import java.util.logging.Logger;
013:
014:        import com.sun.portal.log.common.PortalLogger;
015:        import com.sun.portal.rproxy.configservlet.client.PlatformProfile;
016:
017:        /**
018:         * 
019:         * @author Mridul Muralidharan
020:         * @version
021:         */
022:        public class ApplicationLoginHostChooser extends
023:                HostAvailabilityListener {
024:
025:            private URL currentHostInUse = null;
026:
027:            private boolean isInitialised = false;
028:
029:            private static final String bootupISUrl;
030:
031:            // private static Logger logger =
032:            // Logger.getLogger("com.sun.portal.sra.rproxy");
033:            private static Logger logger = PortalLogger
034:                    .getLogger(ApplicationLoginHostChooser.class);
035:
036:            static {
037:                String url = null;
038:                String protocol = com.iplanet.am.util.SystemProperties
039:                        .get("com.iplanet.am.server.protocol");
040:                String host = com.iplanet.am.util.SystemProperties
041:                        .get("com.iplanet.am.server.host");
042:                String port = com.iplanet.am.util.SystemProperties
043:                        .get("com.iplanet.am.server.port");
044:
045:                try {
046:                    URL _url = new URL(protocol, host, Integer.parseInt(port),
047:                            "/");
048:                    url = _url.toString();
049:                } catch (MalformedURLException mfEx) {
050:                    // logger.log(Level.SEVERE, "Unable to create IS server url from
051:                    // AMConfig.properties", mfEx);
052:                    logger.log(Level.SEVERE, "PSSR_CSPU017", mfEx);
053:                    // logger.severe("protocol : " + protocol + " host : " + host + "
054:                    // port : " + port);
055:                    Object[] params = { protocol, host, port };
056:                    logger.log(Level.SEVERE, "PSSR_CSPU018", params);
057:
058:                } catch (NumberFormatException nfEx) {
059:                    // logger.log(Level.SEVERE, "Unable to create IS server url from
060:                    // AMConfig.properties", nfEx);
061:                    logger.log(Level.SEVERE, "PSSR_CSPU019", nfEx);
062:                    // logger.severe("protocol : " + protocol + " host : " + host + "
063:                    // port : " + port);
064:                    Object[] params = { protocol, host, port };
065:                    logger.log(Level.SEVERE, "PSSR_CSPU020", params);
066:                }
067:                bootupISUrl = url;
068:            }
069:
070:            private static ApplicationLoginHostChooser instance = new ApplicationLoginHostChooser();
071:
072:            private ApplicationLoginHostChooser() {
073:                isInitialised = false;
074:                addHostAvailabilityListener(this );
075:            }
076:
077:            private synchronized void setCurrentHostInUse(URL url) {
078:                currentHostInUse = url;
079:            }
080:
081:            /*
082:             * ApplicationLogin is required to handle the case when ServersList is not
083:             * initialised - this happens when the first request is going to be made to
084:             * fetch the gateway profile. At this time , we dont have a list of servers
085:             * to choose from , but will have to rely on the server , port and protocol
086:             * for IS server that is specified in AMConfig.properties
087:             */
088:            public static synchronized URL getAlivePlatFormServerURL() {
089:                String url = null;
090:                String igString = com.sun.portal.util.SystemProperties
091:                        .get("gateway.ignoreServerList");
092:
093:                if (igString != null && igString.equalsIgnoreCase("true")) {
094:                    GWDebug.debug
095:                            .message("ApplicationLoginHostChooser::getAlivePlatFormServerURL: "
096:                                    + "ignoring ServerList, using "
097:                                    + bootupISUrl);
098:                    url = bootupISUrl;
099:
100:                } else {
101:                    if (PlatformProfile.isInitialised()) {
102:                        url = ServersList.getInstance().getServeraLive();
103:                    } else {
104:                        url = bootupISUrl;
105:                    }
106:                }
107:                URL retUrl = null;
108:                if (url != null) {
109:                    try {
110:                        retUrl = new URL(url);
111:                        instance.setCurrentHostInUse(retUrl);
112:                    } catch (MalformedURLException mfEx) {
113:                        retUrl = null;
114:                    }
115:                }
116:                return retUrl;
117:            }
118:
119:            public void hostAvailabilityChanged(HostAvailabilityEvent hae) {
120:                boolean needRecreate = false;
121:
122:                // logger.info("Host avaliability changed : " + hae.getHostStatus() + "
123:                // for " + hae.getHost());
124:                Object[] params = { new Integer(hae.getHostStatus()),
125:                        hae.getHost() };
126:                logger.log(Level.INFO, "PSSR_CSPU021", params);
127:                // System.out.println("Host avaliability changed : " +
128:                // hae.getHostStatus() + " for " + hae.getHost());
129:                if (!isInitialised || currentHostInUse == null) {
130:                    needRecreate = true;
131:                }
132:                if (hae.getHostType() == hae.IS_HOST) {
133:                    if (hae.getHostStatus() == HostAvailabilityEvent.HOST_UNAVAILABLE) {
134:                        try {
135:                            URL tmpURL = new URL(hae.getHost());
136:                            if (tmpURL.getHost().equalsIgnoreCase(
137:                                    currentHostInUse.getHost())
138:                                    && tmpURL.getPort() == currentHostInUse
139:                                            .getPort()) {
140:                                needRecreate = true;
141:                            }
142:                        } catch (Exception ex) {
143:                            needRecreate = true;
144:                        }
145:                    }
146:                }
147:
148:                // logger.info("Host avaliability changed -> Host : " + hae.getHost() +
149:                // " needRecreate app session : " + needRecreate);
150:                Object[] params1 = { hae.getHost(), new Boolean(needRecreate) };
151:                logger.log(Level.INFO, "PSSR_CSPU022", params1);
152:                if (needRecreate) {
153:                    recreateLoginSession();
154:                }
155:            }
156:
157:            private void recreateLoginSession() {
158:                GWLogManager.createNewAppSession();
159:            }
160:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.