~ubuntu-branches/ubuntu/quantal/zeroc-ice/quantal

« back to all changes in this revision

Viewing changes to java/demo/book/simple_filesystem/Server.java

  • Committer: Bazaar Package Importer
  • Author(s): Cleto Martin Angelina
  • Date: 2011-04-25 18:44:24 UTC
  • mfrom: (6.1.14 sid)
  • Revision ID: james.westby@ubuntu.com-20110425184424-sep9i9euu434vq4c
Tags: 3.4.1-7
* Bug fix: "libdb5.1-java.jar was renamed to db.jar", thanks to Ondřej
  Surý (Closes: #623555).
* Bug fix: "causes noise in php5", thanks to Jayen Ashar (Closes:
  #623533).

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
// **********************************************************************
2
2
//
3
 
// Copyright (c) 2003-2009 ZeroC, Inc. All rights reserved.
 
3
// Copyright (c) 2003-2010 ZeroC, Inc. All rights reserved.
4
4
//
5
5
// This copy of Ice is licensed to you under the terms described in the
6
6
// ICE_LICENSE file included in this distribution.
9
9
 
10
10
import Filesystem.*;
11
11
 
12
 
public class Server extends Ice.Application {
 
12
public class Server extends Ice.Application
 
13
{
13
14
    public int
14
15
    run(String[] args)
15
16
    {
 
17
        //
16
18
        // Terminate cleanly on receipt of a signal
17
19
        //
18
20
        shutdownOnInterrupt();
19
21
 
 
22
        //
20
23
        // Create an object adapter.
21
24
        //
22
 
        Ice.ObjectAdapter adapter = communicator().createObjectAdapterWithEndpoints(
23
 
                                        "SimpleFilesystem", "default -p 10000");
 
25
        Ice.ObjectAdapter adapter =
 
26
            communicator().createObjectAdapterWithEndpoints("SimpleFilesystem", "default -h 127.0.0.1 -p 10000");
24
27
 
 
28
        //
25
29
        // Create the root directory (with name "/" and no parent)
26
30
        //
27
31
        DirectoryI root = new DirectoryI(communicator(), "/", null);
28
32
        root.activate(adapter);
29
33
 
 
34
        //
30
35
        // Create a file called "README" in the root directory
31
36
        //
32
37
        FileI file = new FileI(communicator(), "README", root);
33
38
        String[] text;
34
39
        text = new String[]{ "This file system contains a collection of poetry." };
35
 
        try {
 
40
        try
 
41
        {
36
42
            file.write(text, null);
37
 
        } catch (GenericError e) {
 
43
        }
 
44
        catch(GenericError e)
 
45
        {
38
46
            System.err.println(e.reason);
39
47
        }
40
48
        file.activate(adapter);
41
49
 
 
50
        //
42
51
        // Create a directory called "Coleridge" in the root directory
43
52
        //
44
53
        DirectoryI coleridge = new DirectoryI(communicator(), "Coleridge", root);
45
54
        coleridge.activate(adapter);
46
55
 
 
56
        //
47
57
        // Create a file called "Kubla_Khan" in the Coleridge directory
48
58
        //
49
59
        file = new FileI(communicator(), "Kubla_Khan", coleridge);
52
62
                             "Where Alph, the sacred river, ran",
53
63
                             "Through caverns measureless to man",
54
64
                             "Down to a sunless sea." };
55
 
        try {
 
65
        try
 
66
        {
56
67
            file.write(text, null);
57
 
        } catch (GenericError e) {
 
68
        }
 
69
        catch(GenericError e)
 
70
        {
58
71
            System.err.println(e.reason);
59
72
        }
60
73
        file.activate(adapter);
61
74
 
 
75
        //
62
76
        // All objects are created, allow client requests now
63
77
        //
64
78
        adapter.activate();
65
79
 
 
80
        //
66
81
        // Wait until we are done
67
82
        //
68
83
        communicator().waitForShutdown();
69
84
 
70
 
        if (interrupted())
 
85
        if(interrupted())
 
86
        {
71
87
            System.err.println(appName() + ": terminating");
 
88
        }
72
89
 
73
90
        return 0;
74
91
    }