Source Code Cross Referenced for LegacySettings.java in  » Library » Apache-beehive-1.0.2-src » org » apache » beehive » netui » pageflow » internal » 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 » Library » Apache beehive 1.0.2 src » org.apache.beehive.netui.pageflow.internal 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Licensed to the Apache Software Foundation (ASF) under one or more
003:         * contributor license agreements.  See the NOTICE file distributed with
004:         * this work for additional information regarding copyright ownership.
005:         * The ASF licenses this file to You under the Apache License, Version 2.0
006:         * (the "License"); you may not use this file except in compliance with
007:         * the License.  You may obtain a copy of the License at
008:         * 
009:         *     http://www.apache.org/licenses/LICENSE-2.0
010:         * 
011:         * Unless required by applicable law or agreed to in writing, software
012:         * distributed under the License is distributed on an "AS IS" BASIS,
013:         * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014:         * See the License for the specific language governing permissions and
015:         * limitations under the License.
016:         *
017:         * $Header:$
018:         */
019:        package org.apache.beehive.netui.pageflow.internal;
020:
021:        import org.apache.beehive.netui.util.logging.Logger;
022:        import org.apache.beehive.netui.util.config.ConfigUtil;
023:        import org.apache.beehive.netui.util.config.bean.PageFlowConfig;
024:        import org.apache.beehive.netui.pageflow.PageFlowActionServlet;
025:        import org.apache.beehive.netui.pageflow.PageFlowContextListener;
026:        import org.apache.beehive.netui.pageflow.PageFlowConstants;
027:
028:        import javax.servlet.ServletContext;
029:        import java.io.Serializable;
030:
031:        public class LegacySettings implements  Serializable, PageFlowConstants {
032:            private static final Logger _log = Logger
033:                    .getInstance(LegacySettings.class);
034:
035:            private static final String CONTEXT_ATTR = InternalConstants.ATTR_PREFIX
036:                    + "_cache";
037:
038:            public static final int serialVersionUID = 1;
039:
040:            private boolean _secureForwards = false;
041:            private int _forwardOverflowCount;
042:            private int _nestingOverflowCount;
043:
044:            public static LegacySettings get(ServletContext servletContext) {
045:                LegacySettings ls = (LegacySettings) servletContext
046:                        .getAttribute(CONTEXT_ATTR);
047:
048:                if (ls == null) {
049:                    if (_log.isErrorEnabled()) {
050:                        _log
051:                                .error("Page Flow ServletContext cache not initialized; either "
052:                                        + PageFlowActionServlet.class.getName()
053:                                        + " must be the Struts action servlet, or "
054:                                        + PageFlowContextListener.class
055:                                                .getName()
056:                                        + " must be registered as a listener in web.xml.");
057:                    }
058:
059:                    //
060:                    // We can initialize it now, but it's not good because many requests could conceivably be in this
061:                    // code at the same time.
062:                    //
063:                    return init(servletContext);
064:                }
065:
066:                return ls;
067:            }
068:
069:            public static LegacySettings init(ServletContext servletContext) {
070:                LegacySettings cache = new LegacySettings(servletContext);
071:                servletContext.setAttribute(CONTEXT_ATTR, cache);
072:                return cache;
073:            }
074:
075:            private void loadLegacySettings(ServletContext servletContext) {
076:                PageFlowConfig pageflowConfig = ConfigUtil.getConfig()
077:                        .getPageFlowConfig();
078:                assert pageflowConfig != null : "Received an invalid PageFlowConfig object";
079:
080:                Integer forwardOverflowCount = loadLegacyParam(
081:                        FORWARD_OVERFLOW_COUNT_PARAM, servletContext,
082:                        "max-forwards-per-request");
083:                if (forwardOverflowCount != null) {
084:                    _forwardOverflowCount = forwardOverflowCount.intValue();
085:                } else {
086:                    // Why can't we read the default value from the XmlObjext?
087:                    _forwardOverflowCount = pageflowConfig
088:                            .getMaxForwardsPerRequest();
089:                }
090:
091:                Integer nestingOverflowCount = loadLegacyParam(
092:                        NESTING_OVERFLOW_COUNT_PARAM, servletContext,
093:                        "max-nesting-stack-depth");
094:                if (nestingOverflowCount != null) {
095:                    _nestingOverflowCount = nestingOverflowCount.intValue();
096:                } else {
097:                    // Why can't we read the default value from the XmlObjext?
098:                    _nestingOverflowCount = pageflowConfig
099:                            .getMaxNestingStackDepth();
100:                }
101:
102:                String doSecureForwards = servletContext
103:                        .getInitParameter(SECURE_FORWARDS_PARAM);
104:
105:                if (doSecureForwards != null) {
106:                    _log
107:                            .warn("Servlet context-param "
108:                                    + SECURE_FORWARDS_PARAM
109:                                    + " is deprecated; use the ensure-secure-forwards element within pageflow-config in "
110:                                    + InternalConstants.NETUI_CONFIG_PATH);
111:                    _secureForwards = Boolean.valueOf(doSecureForwards)
112:                            .booleanValue();
113:                } else {
114:                    _secureForwards = pageflowConfig.isEnsureSecureForwards();
115:                }
116:
117:            }
118:
119:            private LegacySettings(ServletContext servletContext) {
120:                //
121:                // Try loading some settings (max-forwards-per-requst, max-nesting-stack-depth, ensure-secure-forwards) from
122:                // the deprecated locations first, then fall back to netui-config.xml.
123:                //
124:                loadLegacySettings(servletContext);
125:
126:            }
127:
128:            public boolean shouldDoSecureForwards() {
129:                return _secureForwards;
130:            }
131:
132:            public int getForwardOverflowCount() {
133:                return _forwardOverflowCount;
134:            }
135:
136:            public int getNestingOverflowCount() {
137:                return _nestingOverflowCount;
138:            }
139:
140:            private static Integer loadLegacyParam(String paramName,
141:                    ServletContext servletContext, String configElementName) {
142:                String strVal = servletContext.getInitParameter(paramName);
143:
144:                if (strVal != null) {
145:                    _log.warn("Servlet context-param " + paramName
146:                            + "is deprecated; use the " + configElementName
147:                            + " element within pageflow-config in "
148:                            + InternalConstants.NETUI_CONFIG_PATH);
149:
150:                    try {
151:                        return Integer.valueOf(strVal);
152:                    } catch (NumberFormatException e) {
153:                        _log
154:                                .error("Could not parse integer value from context-param "
155:                                        + paramName + '.');
156:                    }
157:                }
158:
159:                return null;
160:            }
161:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.