01: /*
02: * Copyright 2005-2007 Noelios Consulting.
03: *
04: * The contents of this file are subject to the terms of the Common Development
05: * and Distribution License (the "License"). You may not use this file except in
06: * compliance with the License.
07: *
08: * You can obtain a copy of the license at
09: * http://www.opensource.org/licenses/cddl1.txt See the License for the specific
10: * language governing permissions and limitations under the License.
11: *
12: * When distributing Covered Code, include this CDDL HEADER in each file and
13: * include the License file at http://www.opensource.org/licenses/cddl1.txt If
14: * applicable, add the following below this CDDL HEADER, with the fields
15: * enclosed by brackets "[]" replaced with your own identifying information:
16: * Portions Copyright [yyyy] [name of copyright owner]
17: */
18:
19: package com.noelios.restlet.ext.asyncweb;
20:
21: import org.restlet.Server;
22: import org.restlet.data.Protocol;
23: import org.safehaus.asyncweb.container.ContainerLifecycleException;
24: import org.safehaus.asyncweb.transport.nio.NIOTransport;
25:
26: /**
27: * AsyncWeb HTTP server connector.
28: *
29: * This implementation passes by all of AsyncWeb ServiceContainer,
30: * HttpServiceHandler etc. mechanisms and implements a
31: * {@link com.noelios.restlet.http.HttpServerHelper} and a
32: * {@link org.safehaus.asyncweb.container.ServiceContainer} directly. It takes
33: * care about setting up a
34: * {@link org.safehaus.asyncweb.transport.nio.NIOTransport}.
35: * <p>
36: * Note: This implementation is not usable inside an AsyncWeb standard
37: * environment because it represents a container and not a handler; it takes
38: * full control over the container lifecycle.
39: * </p>
40: *
41: * @author Lars Heuer (heuer[at]semagia.com) <a
42: * href="http://www.semagia.com/">Semagia</a>
43: */
44: public class HttpServerHelper extends AsyncWebServerHelper {
45: /**
46: * Constructor.
47: *
48: * @param server
49: * The server to help.
50: */
51: public HttpServerHelper(Server server) {
52: super (server, false);
53: getProtocols().add(Protocol.HTTP);
54: }
55:
56: /** Starts the Connector. */
57: public void start() throws ContainerLifecycleException {
58: NIOTransport nio = new NIOTransport();
59: nio.setPort(getServer().getPort());
60: nio.setServiceContainer(this);
61: nio.setIoWorkerCount(getIoWorkerCount());
62: setTransport(nio);
63: super.start();
64: }
65:
66: }
|