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

« back to all changes in this revision

Viewing changes to org.restlet.example/src/org/restlet/example/book/restlet/ch02/sect4/sub1/MailServerApplication.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.example.book.restlet.ch02.sect4.sub1;
 
35
 
 
36
import org.restlet.Application;
 
37
import org.restlet.Restlet;
 
38
import org.restlet.Server;
 
39
import org.restlet.data.Protocol;
 
40
 
 
41
/**
 
42
 * Setting basic application properties
 
43
 */
 
44
public class MailServerApplication extends Application {
 
45
 
 
46
    /**
 
47
     * Launches the application with an HTTP server.
 
48
     * 
 
49
     * @param args
 
50
     *            The arguments.
 
51
     * @throws Exception
 
52
     */
 
53
    public static void main(String[] args) throws Exception {
 
54
        Server mailServer = new Server(Protocol.HTTP, 8111);
 
55
        mailServer.setNext(new MailServerApplication());
 
56
        mailServer.start();
 
57
    }
 
58
 
 
59
    /**
 
60
     * Constructor.
 
61
     */
 
62
    public MailServerApplication() {
 
63
        setName("RESTful Mail Server");
 
64
        setDescription("Example for 'Restlet in Action' book");
 
65
        setOwner("Restlet S.A.S.");
 
66
        setAuthor("The Restlet Team");
 
67
    }
 
68
 
 
69
    /**
 
70
     * Creates a root Restlet to trace requests.
 
71
     */
 
72
    @Override
 
73
    public Restlet createInboundRoot() {
 
74
        Blocker blocker = new Blocker(getContext());
 
75
        blocker.getBlockedAddresses().add("127.0.0.1");
 
76
        blocker.setNext(new Tracer(getContext()));
 
77
        return blocker;
 
78
    }
 
79
 
 
80
}