Source Code Cross Referenced for SimpleServerHelper.java in  » Web-Services » restlet-1.0.8 » com » noelios » restlet » ext » simple » 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 » Web Services » restlet 1.0.8 » com.noelios.restlet.ext.simple 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Copyright 2005-2007 Noelios Consulting.
003:         * 
004:         * The contents of this file are subject to the terms of the Common Development
005:         * and Distribution License (the "License"). You may not use this file except in
006:         * compliance with the License.
007:         * 
008:         * You can obtain a copy of the license at
009:         * http://www.opensource.org/licenses/cddl1.txt See the License for the specific
010:         * language governing permissions and limitations under the License.
011:         * 
012:         * When distributing Covered Code, include this CDDL HEADER in each file and
013:         * include the License file at http://www.opensource.org/licenses/cddl1.txt If
014:         * applicable, add the following below this CDDL HEADER, with the fields
015:         * enclosed by brackets "[]" replaced with your own identifying information:
016:         * Portions Copyright [yyyy] [name of copyright owner]
017:         */
018:
019:        package com.noelios.restlet.ext.simple;
020:
021:        import java.net.ServerSocket;
022:
023:        import org.restlet.Server;
024:
025:        import simple.http.PipelineHandler;
026:        import simple.http.connect.Connection;
027:
028:        import com.noelios.restlet.http.HttpServerHelper;
029:
030:        /**
031:         * Abstract Simple Web server connector. Here is the list of parameters that are
032:         * supported: <table>
033:         * <tr>
034:         * <th>Parameter name</th>
035:         * <th>Value type</th>
036:         * <th>Default value</th>
037:         * <th>Description</th>
038:         * </tr>
039:         * <tr>
040:         * <td>defaultThreads</td>
041:         * <td>int</td>
042:         * <td>20</td>
043:         * <td>Default number of polling threads for a handler object.</td>
044:         * </tr>
045:         * <tr>
046:         * <td>maxWaitTimeMs</td>
047:         * <td>int</td>
048:         * <td>200</td>
049:         * <td>Maximum waiting time between polls of the input.</td>
050:         * </tr>
051:         * <tr>
052:         * <td>converter</td>
053:         * <td>String</td>
054:         * <td>com.noelios.restlet.http.HttpServerConverter</td>
055:         * <td>Class name of the converter of low-level HTTP calls into high level
056:         * requests and responses.</td>
057:         * </tr>
058:         * <tr>
059:         * <td>useForwardedForHeader</td>
060:         * <td>boolean</td>
061:         * <td>false</td>
062:         * <td>Lookup the "X-Forwarded-For" header supported by popular proxies and
063:         * caches and uses it to populate the Request.getClientAddresses() method
064:         * result. This information is only safe for intermediary components within your
065:         * local network. Other addresses could easily be changed by setting a fake
066:         * header and should not be trusted for serious security checks.</td>
067:         * </tr>
068:         * </table>
069:         * 
070:         * @author Lars Heuer (heuer[at]semagia.com) <a
071:         *         href="http://semagia.com/">Semagia</a>
072:         * @author Jerome Louvel (contact@noelios.com) <a
073:         *         href="http://www.noelios.com">Noelios Consulting</a>
074:         */
075:        public abstract class SimpleServerHelper extends HttpServerHelper {
076:            /**
077:             * Indicates if this service is acting in HTTP or HTTPS mode.
078:             */
079:            private boolean confidential;
080:
081:            /**
082:             * Server socket this server is listening to.
083:             */
084:            private ServerSocket socket;
085:
086:            /**
087:             * Simple pipeline handler.
088:             */
089:            private PipelineHandler handler;
090:
091:            /**
092:             * Simple connection.
093:             */
094:            private Connection connection;
095:
096:            /**
097:             * Constructor.
098:             * 
099:             * @param server
100:             *            The server to help.
101:             */
102:            public SimpleServerHelper(Server server) {
103:                super (server);
104:            }
105:
106:            /** Stops the Restlet. */
107:            public void stop() throws Exception {
108:                getSocket().close();
109:                setSocket(null);
110:                this .setHandler(null);
111:                this .setConnection(null);
112:
113:                // For further information on how to shutdown a Simple
114:                // server, see
115:                // http://sourceforge.net/mailarchive/forum.php?thread_id=10138257&forum_id=38791
116:                // There seems to be place for improvement in this method.
117:            }
118:
119:            /**
120:             * Returns the default number of polling threads for a handler object.
121:             * 
122:             * @return The default number of polling threads for a handler object.
123:             */
124:            public int getDefaultThreads() {
125:                return Integer.parseInt(getParameters().getFirstValue(
126:                        "defaultThreads", "20"));
127:            }
128:
129:            /**
130:             * Returns the maximum waiting time between polls of the input.
131:             * 
132:             * @return The maximum waiting time between polls of the input.
133:             */
134:            public int getMaxWaitTimeMs() {
135:                return Integer.parseInt(getParameters().getFirstValue(
136:                        "maxWaitTimeMs", "200"));
137:            }
138:
139:            /**
140:             * Sets the server socket this server is listening to.
141:             * 
142:             * @param socket
143:             *            The server socket this server is listening to.
144:             */
145:            protected void setSocket(ServerSocket socket) {
146:                this .socket = socket;
147:            }
148:
149:            /**
150:             * Returns the server socket this server is listening to.
151:             * 
152:             * @return The server socket this server is listening to.
153:             */
154:            protected ServerSocket getSocket() {
155:                return socket;
156:            }
157:
158:            /**
159:             * Sets the Simple pipeline handler.
160:             * 
161:             * @param handler
162:             *            The Simple pipeline handler.
163:             */
164:            protected void setHandler(PipelineHandler handler) {
165:                this .handler = handler;
166:            }
167:
168:            /**
169:             * Returns the Simple pipeline handler.
170:             * 
171:             * @return The Simple pipeline handler.
172:             */
173:            protected PipelineHandler getHandler() {
174:                return handler;
175:            }
176:
177:            /**
178:             * Sets the Simple connection.
179:             * 
180:             * @param connection
181:             *            The Simple connection.
182:             */
183:            protected void setConnection(Connection connection) {
184:                this .connection = connection;
185:            }
186:
187:            /**
188:             * Returns the Simple connection.
189:             * 
190:             * @return The Simple connection.
191:             */
192:            protected Connection getConnection() {
193:                return connection;
194:            }
195:
196:            /**
197:             * Indicates if this service is acting in HTTP or HTTPS mode.
198:             * 
199:             * @param confidential
200:             *            True if this service is acting in HTTP or HTTPS mode.
201:             */
202:            protected void setConfidential(boolean confidential) {
203:                this .confidential = confidential;
204:            }
205:
206:            /**
207:             * Indicates if this service is acting in HTTP or HTTPS mode.
208:             * 
209:             * @return True if this service is acting in HTTP or HTTPS mode.
210:             */
211:            protected boolean isConfidential() {
212:                return confidential;
213:            }
214:
215:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.