~ubuntu-branches/ubuntu/saucy/restlet/saucy

« back to all changes in this revision

Viewing changes to org.restlet/src/org/restlet/engine/http/connector/HttpServerHelper.java

  • Committer: Package Import Robot
  • Author(s): James Page
  • Date: 2012-06-11 16:25:45 UTC
  • Revision ID: package-import@ubuntu.com-20120611162545-5w2o0resi5y3pybc
Tags: upstream-2.0.14
ImportĀ upstreamĀ versionĀ 2.0.14

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/**
 
2
 * Copyright 2005-2012 Restlet S.A.S.
 
3
 * 
 
4
 * The contents of this file are subject to the terms of one of the following
 
5
 * open source licenses: Apache 2.0 or LGPL 3.0 or LGPL 2.1 or CDDL 1.0 or EPL
 
6
 * 1.0 (the "Licenses"). You can select the license that you prefer but you may
 
7
 * not use this file except in compliance with one of these Licenses.
 
8
 * 
 
9
 * You can obtain a copy of the Apache 2.0 license at
 
10
 * http://www.opensource.org/licenses/apache-2.0
 
11
 * 
 
12
 * You can obtain a copy of the LGPL 3.0 license at
 
13
 * http://www.opensource.org/licenses/lgpl-3.0
 
14
 * 
 
15
 * You can obtain a copy of the LGPL 2.1 license at
 
16
 * http://www.opensource.org/licenses/lgpl-2.1
 
17
 * 
 
18
 * You can obtain a copy of the CDDL 1.0 license at
 
19
 * http://www.opensource.org/licenses/cddl1
 
20
 * 
 
21
 * You can obtain a copy of the EPL 1.0 license at
 
22
 * http://www.opensource.org/licenses/eclipse-1.0
 
23
 * 
 
24
 * See the Licenses for the specific language governing permissions and
 
25
 * limitations under the Licenses.
 
26
 * 
 
27
 * Alternatively, you can obtain a royalty free commercial license with less
 
28
 * limitations, transferable or non-transferable, directly at
 
29
 * http://www.restlet.com/products/restlet-framework
 
30
 * 
 
31
 * Restlet is a registered trademark of Restlet S.A.S.
 
32
 */
 
33
 
 
34
package org.restlet.engine.http.connector;
 
35
 
 
36
import java.io.IOException;
 
37
import java.net.Socket;
 
38
import java.nio.channels.SocketChannel;
 
39
 
 
40
import org.restlet.Server;
 
41
import org.restlet.data.Protocol;
 
42
 
 
43
/**
 
44
 * HTTP server helper based on NIO blocking sockets.
 
45
 * 
 
46
 * @author Jerome Louvel
 
47
 */
 
48
public class HttpServerHelper extends BaseServerHelper {
 
49
 
 
50
    /**
 
51
     * Constructor.
 
52
     * 
 
53
     * @param server
 
54
     *            The server to help.
 
55
     */
 
56
    public HttpServerHelper(Server server) {
 
57
        super(server);
 
58
        getProtocols().add(Protocol.HTTP);
 
59
    }
 
60
 
 
61
    @Override
 
62
    protected Connection<Server> createConnection(BaseHelper<Server> helper,
 
63
            Socket socket, SocketChannel socketChannel) throws IOException {
 
64
        return new ServerConnection(helper, socket, socketChannel);
 
65
    }
 
66
 
 
67
    @Override
 
68
    public synchronized void start() throws Exception {
 
69
        getLogger().info(
 
70
                "Starting the internal " + getProtocols().get(0).getName()
 
71
                        + " server on port " + getHelped().getPort());
 
72
        super.start();
 
73
    }
 
74
 
 
75
    @Override
 
76
    public synchronized void stop() throws Exception {
 
77
        getLogger().info("Stopping the internal HTTP server");
 
78
        super.stop();
 
79
    }
 
80
 
 
81
}