Source Code Cross Referenced for Component.java in  » Web-Services » restlet-1.0.8 » org » restlet » 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 » org.restlet 
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 org.restlet;
020:
021:        import java.util.ArrayList;
022:        import java.util.List;
023:
024:        import org.restlet.data.Request;
025:        import org.restlet.data.Response;
026:        import org.restlet.service.LogService;
027:        import org.restlet.service.StatusService;
028:        import org.restlet.util.ClientList;
029:        import org.restlet.util.Engine;
030:        import org.restlet.util.Helper;
031:        import org.restlet.util.ServerList;
032:
033:        /**
034:         * Restlet managing a set of Connectors, VirtualHosts and Applications.
035:         * Applications are expected to be directly attached to VirtualHosts. Components
036:         * also expose several services: access logging and status setting. <br>
037:         * <br>
038:         * From an architectural point of view, here is the REST definition: "A
039:         * component is an abstract unit of software instructions and internal state
040:         * that provides a transformation of data via its interface." Roy T. Fielding<br>
041:         * <br>
042:         * 
043:         * @see <a
044:         *      href="http://roy.gbiv.com/pubs/dissertation/software_arch.htm#sec_1_2_1">Source
045:         *      dissertation</a>
046:         * @author Jerome Louvel (contact@noelios.com)
047:         */
048:        public class Component extends Restlet {
049:            /** The modifiable list of client connectors. */
050:            private ClientList clients;
051:
052:            /** The modifiable list of server connectors. */
053:            private ServerList servers;
054:
055:            /** The modifiable list of virtual hosts. */
056:            private List<VirtualHost> hosts;
057:
058:            /** The default host. */
059:            private VirtualHost defaultHost;
060:
061:            /** The helper provided by the implementation. */
062:            private Helper helper;
063:
064:            /** The log service. */
065:            private LogService logService;
066:
067:            /** The status service. */
068:            private StatusService statusService;
069:
070:            /**
071:             * Constructor.
072:             */
073:            public Component() {
074:                super (null);
075:
076:                if (Engine.getInstance() != null) {
077:                    this .helper = Engine.getInstance().createHelper(this );
078:                    if (this .helper != null) {
079:                        setContext(this .helper.createContext(getClass()
080:                                .getCanonicalName()));
081:                        this .hosts = null;
082:                        this .defaultHost = new VirtualHost(getContext());
083:                        this .logService = null;
084:                        this .statusService = null;
085:                    }
086:                }
087:            }
088:
089:            /**
090:             * Returns the modifiable list of client connectors.
091:             * 
092:             * @return The modifiable list of client connectors.
093:             */
094:            public ClientList getClients() {
095:                if (this .clients == null)
096:                    this .clients = new ClientList(getContext());
097:                return this .clients;
098:            }
099:
100:            /**
101:             * Returns the modifiable list of server connectors.
102:             * 
103:             * @return The modifiable list of server connectors.
104:             */
105:            public ServerList getServers() {
106:                if (this .servers == null)
107:                    this .servers = new ServerList(getContext(), this );
108:                return this .servers;
109:            }
110:
111:            /**
112:             * Starts the component and all its connectors.
113:             */
114:            @Override
115:            public void start() throws Exception {
116:                if (isStopped()) {
117:                    if (this .clients != null) {
118:                        for (Client client : this .clients) {
119:                            client.start();
120:                        }
121:                    }
122:
123:                    if (this .servers != null) {
124:                        for (Server server : this .servers) {
125:                            server.start();
126:                        }
127:                    }
128:
129:                    if (getHelper() != null)
130:                        getHelper().start();
131:
132:                    super .start();
133:                }
134:            }
135:
136:            /**
137:             * Stops the component and all its connectors.
138:             */
139:            @Override
140:            public void stop() throws Exception {
141:                if (getHelper() != null)
142:                    getHelper().stop();
143:
144:                if (this .clients != null) {
145:                    for (Client client : this .clients) {
146:                        client.stop();
147:                    }
148:                }
149:
150:                if (this .servers != null) {
151:                    for (Server server : this .servers) {
152:                        server.stop();
153:                    }
154:                }
155:
156:                super .stop();
157:            }
158:
159:            /**
160:             * Returns the default virtual host.
161:             * 
162:             * @return The default virtual host.
163:             */
164:            public VirtualHost getDefaultHost() {
165:                return this .defaultHost;
166:            }
167:
168:            /**
169:             * Returns the helper provided by the implementation.
170:             * 
171:             * @return The helper provided by the implementation.
172:             */
173:            private Helper getHelper() {
174:                return this .helper;
175:            }
176:
177:            /**
178:             * Returns the modifiable list of host routers.
179:             * 
180:             * @return The modifiable list of host routers.
181:             */
182:            public List<VirtualHost> getHosts() {
183:                if (this .hosts == null)
184:                    this .hosts = new ArrayList<VirtualHost>();
185:                return this .hosts;
186:            }
187:
188:            /**
189:             * Returns the global log service. On the first call, if no log service was
190:             * defined via the {@link #setLogService(LogService)} method, then a default
191:             * logger service is created. This default service is enabled by default and
192:             * has a logger name composed of the canonical name of the current
193:             * component's class or subclass, appended with the instance hash code
194:             * between parenthesis (eg. "com.mycompany.MyComponent(1439)").
195:             * 
196:             * @return The global log service.
197:             */
198:            public LogService getLogService() {
199:                if (this .logService == null) {
200:                    this .logService = new LogService(true);
201:                    this .logService.setLoggerName(getClass().getCanonicalName()
202:                            + " (" + hashCode() + ")");
203:                }
204:
205:                return this .logService;
206:            }
207:
208:            /**
209:             * Returns the status service. This service is enabled by default.
210:             * 
211:             * @return The status service.
212:             */
213:            public StatusService getStatusService() {
214:                if (this .statusService == null)
215:                    this .statusService = new StatusService(true);
216:                return this .statusService;
217:            }
218:
219:            /**
220:             * Handles a call.
221:             * 
222:             * @param request
223:             *            The request to handle.
224:             * @param response
225:             *            The response to update.
226:             */
227:            public void handle(Request request, Response response) {
228:                init(request, response);
229:                if (getHelper() != null)
230:                    getHelper().handle(request, response);
231:            }
232:
233:            /**
234:             * Sets the global log service.
235:             * 
236:             * @param logService
237:             *            The global log service.
238:             */
239:            public void setLogService(LogService logService) {
240:                this .logService = logService;
241:            }
242:
243:            /**
244:             * Sets the status service.
245:             * 
246:             * @param statusService
247:             *            The status service.
248:             */
249:            public void setStatusService(StatusService statusService) {
250:                this.statusService = statusService;
251:            }
252:
253:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.