Source Code Cross Referenced for DefaultServletContainerAdapter.java in  » Library » Apache-beehive-1.0.2-src » org » apache » beehive » netui » pageflow » 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 
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;
020:
021:        import org.apache.beehive.netui.core.factory.Factory;
022:        import org.apache.beehive.netui.core.factory.FactoryConfig;
023:        import org.apache.beehive.netui.pageflow.adapter.AdapterContext;
024:        import org.apache.beehive.netui.pageflow.internal.PageFlowBeanContext;
025:        import org.apache.beehive.netui.util.logging.Logger;
026:
027:        import javax.security.auth.login.LoginException;
028:        import javax.servlet.ServletContext;
029:        import javax.servlet.http.HttpServletRequest;
030:        import javax.servlet.http.HttpServletResponse;
031:
032:        /**
033:         * Default implementation of a Servlet container adapter.
034:         */
035:        public abstract class DefaultServletContainerAdapter implements 
036:                ServletContainerAdapter {
037:            private static boolean _productionMode = true;
038:
039:            private ServletContext _servletContext;
040:            private PageFlowEventReporter _eventReporter;
041:
042:            static {
043:                String productionModeFlag = System
044:                        .getProperty("beehive.productionmode");
045:
046:                if (productionModeFlag != null) {
047:                    _productionMode = Boolean.valueOf(productionModeFlag)
048:                            .booleanValue();
049:                } else {
050:                    //
051:                    // This is our default definition of "production mode": when asserts are disabled (the following statement
052:                    // sets _productionMode to false when asserts are enabled).
053:                    //
054:                    assert (_productionMode = false) || true;
055:                }
056:            }
057:
058:            protected DefaultServletContainerAdapter() {
059:            }
060:
061:            /**
062:             * Tell whether the system is in production mode.
063:             * 
064:             * @return <code>true</code> if the system property "beehive.productionmode" is set to "true", or if asserts are
065:             *         disabled for this class in the case where the system property has no value; <code>false</code>  if the
066:             *         system property is set to "false", or if asserts are enabled for this class in the case where the
067:             *         system property has no value.
068:             */
069:            public boolean isInProductionMode() {
070:                return _productionMode;
071:            }
072:
073:            /**
074:             * Tell whether a web application resource requires a secure transport protocol.  This default implementation
075:             * simply returns {@link SecurityProtocol#UNSPECIFIED} for all paths.
076:             * 
077:             * @param path a webapp-relative path for a resource.
078:             * @param request the current HttpServletRequest.
079:             * @return {@link SecurityProtocol#UNSPECIFIED}.
080:             */
081:            public SecurityProtocol getSecurityProtocol(String path,
082:                    HttpServletRequest request) {
083:                // TODO: implement this based on parsing of web.xml
084:                return SecurityProtocol.UNSPECIFIED;
085:            }
086:
087:            /**
088:             * Cause the server to do a security check for the given path.  This default implementation does nothing.
089:             * @return <code>false</code>
090:             */
091:            public boolean doSecurityRedirect(String path,
092:                    HttpServletRequest request, HttpServletResponse response) {
093:                return false;
094:            }
095:
096:            /**
097:             * Get the port on which the server is listening for unsecure connections.  This default implementation always
098:             * returns <code>-1</code>.
099:             * @param request the current HttpServletRequest.
100:             * @return <code>-1</code>.
101:             */
102:            public int getListenPort(HttpServletRequest request) {
103:                // TODO: have a configuration in beehive-netui-config.xml to specify this; an alternative to having to have an adapter.
104:                return -1;
105:            }
106:
107:            /**
108:             * Get the port on which the server is listening for secure connections.  This default implementation always
109:             * returns <code>-1</code>.
110:             * @param request the current HttpServletRequest.
111:             * @return <code>-1</code>.
112:             */
113:            public int getSecureListenPort(HttpServletRequest request) {
114:                // TODO: have a configuration in beehive-netui-config.xml to specify this; an alternative to having to have an adapter.
115:                return -1;
116:            }
117:
118:            /**
119:             * Log in the user, using "weak" username/password authentication.  This default implementation always throws
120:             * {@link UnsupportedOperationException}.
121:             * 
122:             * @throws UnsupportedOperationException in all cases.
123:             */
124:            public void login(String username, String password,
125:                    HttpServletRequest request, HttpServletResponse response)
126:                    throws LoginException {
127:                throw new UnsupportedOperationException(
128:                        "login is not supported by "
129:                                + DefaultServletContainerAdapter.class
130:                                        .getName());
131:            }
132:
133:            /**
134:             * Log out the user.  This default implementation always throws {@link UnsupportedOperationException}.
135:             * 
136:             * @throws UnsupportedOperationException in all cases.
137:             */
138:            public void logout(boolean invalidateSessions,
139:                    HttpServletRequest request, HttpServletResponse response) {
140:                throw new UnsupportedOperationException(
141:                        "logout is not supported by "
142:                                + DefaultServletContainerAdapter.class
143:                                        .getName());
144:            }
145:
146:            /**
147:             * Return the webapp context path for the given request.  This can differ from HttpServletRequest.getContextPath()
148:             * only in that it will return a valid value even if the request is for the default webapp.  This default 
149:             * implementation always returns the value of <code>getContextPath()</code> on the request.
150:             * 
151:             * @param request the current HttpServletRequest.
152:             * @return the value of <code>getContextPath()</code> on the current request.
153:             */
154:            public String getFullContextPath(HttpServletRequest request) {
155:                return request.getContextPath();
156:            }
157:
158:            /**
159:             * Ensure that the given session attribute is replicated in a cluster for session failover.
160:             * This method does not need to be implemented for servers that do not support clustering and
161:             * session failover.  The default implementation does nothing.
162:             * 
163:             * @param attrName the name of the session attribute for which failover should be ensured.
164:             * @param attrVal the value of the given session attribute.
165:             * @param request the current HttpServletRequest.
166:             */
167:            public void ensureFailover(String attrName, Object attrVal,
168:                    HttpServletRequest request) {
169:            }
170:
171:            /**
172:             * Called at the beginning of each processed request.  This default implementation does nothing.
173:             * 
174:             * @param request the current HttpServletRequest.
175:             * @param response the current HttpServletResponse.
176:             */
177:            public void beginRequest(HttpServletRequest request,
178:                    HttpServletResponse response) {
179:            }
180:
181:            /**
182:             * Called at the end of each processed request.  This default implementation does nothing.
183:             * 
184:             * @param request the current HttpServletRequest.
185:             * @param response the current HttpServletResponse.
186:             */
187:            public void endRequest(HttpServletRequest request,
188:                    HttpServletResponse response) {
189:            }
190:
191:            /**
192:             * Get a context object to support Beehive Controls.  This default implementation returns an instance of
193:             * {@link PageFlowBeanContext}.
194:             * 
195:             * @param request the current HttpServletRequest.
196:             * @param response the current HttpServletResponse.
197:             * @return a new ControlBeanContext.
198:             */
199:            public Object createControlBeanContext(HttpServletRequest request,
200:                    HttpServletResponse response) {
201:                return new PageFlowBeanContext();
202:            }
203:
204:            /**
205:             * Get the current ServletContext.
206:             * @return the current ServletContext.
207:             */
208:            protected ServletContext getServletContext() {
209:                return _servletContext;
210:            }
211:
212:            /**
213:             * Set the AdapterContext.
214:             * @param context the AdapterContext to set.
215:             */
216:            public void setContext(AdapterContext context) {
217:                Object servletContext = context.getExternalContext();
218:                assert servletContext instanceof  ServletContext : servletContext;
219:                _servletContext = (ServletContext) servletContext;
220:                _eventReporter = createEventReporter();
221:            }
222:
223:            /**
224:             * Get the name of the platform, which may be used to find platform-specific configuration files.  This default
225:             * implementation returns "generic".
226:             * 
227:             * @return the name of the platform ("generic" in this default implementation).
228:             */
229:            public String getPlatformName() {
230:                return "generic";
231:            }
232:
233:            /**
234:             * Get an event reporter, which will be notified of events like "page flow created", "action raised", etc.
235:             * This default implementation returns an instance of {@link DefaultPageFlowEventReporter}.
236:             * 
237:             * @return a {@link PageFlowEventReporter}.
238:             */
239:            public PageFlowEventReporter getEventReporter() {
240:                return _eventReporter;
241:            }
242:
243:            protected PageFlowEventReporter createEventReporter() {
244:                return new DefaultPageFlowEventReporter(_servletContext);
245:            }
246:
247:            /**
248:             * Generic method to get a Factory class that may be container dependent.
249:             *
250:             * <p>
251:             * This method is called to get the following Factory implementations:
252:             * </p>
253:             * <ul>
254:             *   <li>{@link org.apache.beehive.netui.core.urltemplates.URLTemplatesFactory}</li>
255:             * </ul>
256:             *
257:             * @param factoryType the class type that the factory should extend or implement
258:             * @param id can be used for the case where there is more than one possible Factory
259:             *           that extends or implaments the class type.
260:             * @param config a configuration object passed to a {@link Factory}
261:             * @return a Factory class that extends or implemtents the given class type.
262:             */
263:            public Factory getFactory(Class factoryType, String id,
264:                    FactoryConfig config) {
265:                return null;
266:            }
267:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.