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


001:        /* Copyright 2005 Sun Microsystems, Inc. All
002:         * rights reserved. Use of this product is subject
003:         * to license terms. Federal Acquisitions:
004:         * Commercial Software -- Government Users
005:         * Subject to Standard License Terms and
006:         * Conditions.
007:         *
008:         * Sun, Sun Microsystems, the Sun logo, and Sun ONE
009:         * are trademarks or registered trademarks of Sun Microsystems,
010:         * Inc. in the United States and other countries.
011:         */
012:        package com.sun.portal.taglibs.i18n;
013:
014:        import java.util.logging.Level;
015:        import java.util.logging.Logger;
016:        import java.util.Locale;
017:        import java.util.ResourceBundle;
018:        import java.util.Properties;
019:        import java.io.IOException;
020:
021:        import javax.servlet.jsp.*;
022:        import javax.servlet.jsp.PageContext;
023:        import javax.servlet.jsp.tagext.*;
024:
025:        import com.sun.portal.log.common.PortalLogger;
026:        import com.sun.portal.providers.context.ProviderContext;
027:        import com.sun.portal.providers.context.ProviderContextException;
028:        import com.sun.portal.desktop.taglib.providerContext.BaseProviderContextTagSupport;
029:        import com.sun.portal.desktop.context.ProviderClassLoader;
030:        import com.sun.portal.desktop.context.DesktopContext;
031:        import com.sun.portal.desktop.context.DesktopContextThreadLocalizer;
032:
033:        /**
034:         * MessageCatalog - Loads a resource bundle for a given locale
035:         *
036:         * @author Shanmugam Senthil
037:         * @author Robert O'Brien
038:         * @version 1.0
039:         */
040:        public class MessageCatalogTag extends BaseProviderContextTagSupport {
041:
042:            public MessageCatalogTag() {
043:                super ();
044:            }
045:
046:            /**
047:             * Make the message catalog available
048:             *
049:             * @return EVAL_BODY_INCLUDE
050:             * @exception JspException
051:             */
052:            public int doStartTag() throws JspException {
053:                if (baseName != null) {
054:                    catalog = (ResourceBundle) pageContext
055:                            .findAttribute(baseName);
056:                    if (catalog != null) {
057:                        return EVAL_BODY_INCLUDE;
058:                    }
059:                } else {
060:                    logger.log(Level.WARNING, "PSTL_CSPTI0002");
061:                    throw new JspException(
062:                            "In setBundle Tag 'baseName' attribute is missing");
063:                }
064:
065:                catalog = getRB();
066:                String id = getVar();
067:                if (id != null) {
068:                    pageContext.setAttribute(id, catalog);
069:                }
070:                return EVAL_BODY_INCLUDE;
071:            }
072:
073:            public void setBaseName(String baseName) {
074:                this .baseName = baseName;
075:            }
076:
077:            public String getBaseName() {
078:                return baseName;
079:            }
080:
081:            public void setVar(String var) {
082:                this .var = var;
083:            }
084:
085:            public String getVar() {
086:                return var;
087:            }
088:
089:            /**
090:             * Get the ResourceBundle
091:             *
092:             * @return
093:             */
094:            private ResourceBundle getRB() {
095:                ResourceBundle catlg = null;
096:                ProviderContext pc = null;
097:
098:                try {
099:                    if (getCurrentObjType() != UNDEFINED) {
100:                        pc = getCurrentProviderContext();
101:                    }
102:
103:                    if ((pc != null) && providerClassDir == null) {
104:                        DesktopContext dc = DesktopContextThreadLocalizer.get();
105:                        providerClassDir = dc.getProviderClassBaseDir();
106:                        logger.log(Level.FINEST, "PSTL_CSPTI0011",
107:                                providerClassDir);
108:                    }
109:                } catch (com.sun.portal.desktop.taglib.DesktopTaglibException e) {
110:                    logger.log(Level.INFO, "PSTL_CSPTI0007", e);
111:                    pc = null;
112:                } catch (Exception e) {
113:                    logger.log(Level.INFO, "PSTL_CSPTI0007", e);
114:                    pc = null;
115:                }
116:                Locale loc = getLocale(pc);
117:                if ((pc != null) && (providerClassDir != null)) {
118:                    catlg = ResourceBundle.getBundle(baseName, loc,
119:                            ProviderClassLoader.getInstance(providerClassDir));
120:                } else {
121:                    catlg = ResourceBundle.getBundle(baseName, loc);
122:                }
123:                return catlg;
124:            }
125:
126:            /**
127:             * Get the user's locale 
128:             *
129:             * @return
130:             */
131:            private Locale getLocale(ProviderContext pc) {
132:                Locale loc = null;
133:
134:                if (pc != null) {
135:                    loc = pc.getLocale();
136:                    logger.log(Level.FINE, "PSTL_CSPTI0008", loc);
137:                } else {
138:                    logger.log(Level.FINE, "Getting the locale");
139:                    /* Get Locale form HTTPServletRequest */
140:                    loc = pageContext.getRequest().getLocale();
141:                    logger.log(Level.FINE, "PSTL_CSPTI0008", loc);
142:                }
143:
144:                if (loc == null) {
145:                    loc = Locale.getDefault();
146:                    logger.log(Level.WARNING, "PSTL_CSPTI0009", loc);
147:                }
148:                return loc;
149:
150:            }
151:
152:            /**
153:             * Cleanup
154:             */
155:            public void release() {
156:                super .release();
157:                baseName = null;
158:                catalog = null;
159:                var = null;
160:            }
161:
162:            public ResourceBundle getResourceBundle() {
163:                return catalog;
164:            }
165:
166:            private String baseName;
167:            private ResourceBundle catalog;
168:            private String var;
169:            private static String providerClassDir = null;
170:
171:            private static Logger logger = PortalLogger
172:                    .getLogger(MessageCatalogTag.class);
173:
174:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.