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

« back to all changes in this revision

Viewing changes to cs/test/Ice/invoke/Server.cs

  • 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
// **********************************************************************
 
2
//
 
3
// Copyright (c) 2003-2010 ZeroC, Inc. All rights reserved.
 
4
//
 
5
// This copy of Ice is licensed to you under the terms described in the
 
6
// ICE_LICENSE file included in this distribution.
 
7
//
 
8
// **********************************************************************
 
9
 
 
10
using System;
 
11
using System.Diagnostics;
 
12
using System.Reflection;
 
13
 
 
14
[assembly: CLSCompliant(true)]
 
15
 
 
16
[assembly: AssemblyTitle("IceTest")]
 
17
[assembly: AssemblyDescription("Ice test")]
 
18
[assembly: AssemblyCompany("ZeroC, Inc.")]
 
19
 
 
20
public class ServantLocatorI : Ice.ServantLocator
 
21
{
 
22
    public ServantLocatorI(bool async)
 
23
    {
 
24
        if(async)
 
25
        {
 
26
            _blobject = new BlobjectAsyncI();
 
27
        }
 
28
        else
 
29
        {
 
30
            _blobject = new BlobjectI();
 
31
        }
 
32
    }
 
33
 
 
34
    public Ice.Object
 
35
    locate(Ice.Current current, out System.Object cookie)
 
36
    {
 
37
        cookie = null;
 
38
        return _blobject;
 
39
    }
 
40
 
 
41
    public void
 
42
    finished(Ice.Current current, Ice.Object servant, System.Object cookie)
 
43
    {
 
44
    }
 
45
 
 
46
    public void
 
47
    deactivate(string category)
 
48
    {
 
49
    }
 
50
 
 
51
    private Ice.Object _blobject;
 
52
}
 
53
 
 
54
public class Server
 
55
{
 
56
    public static int run(string[] args, Ice.Communicator communicator)
 
57
    {
 
58
        bool async = false;
 
59
        for(int i = 0; i < args.Length; ++i)
 
60
        {
 
61
            if(args[i].Equals("--async"))
 
62
            {
 
63
               async = true;
 
64
            }
 
65
        }
 
66
 
 
67
        communicator.getProperties().setProperty("TestAdapter.Endpoints", "default -p 12010:udp");
 
68
        Ice.ObjectAdapter adapter = communicator.createObjectAdapter("TestAdapter");
 
69
        adapter.addServantLocator(new ServantLocatorI(async), "");
 
70
        adapter.activate();
 
71
 
 
72
        communicator.waitForShutdown();
 
73
        return 0;
 
74
    }
 
75
 
 
76
    public static void Main(string[] args)
 
77
    {
 
78
        int status = 0;
 
79
        Ice.Communicator communicator = null;
 
80
 
 
81
        Debug.Listeners.Add(new ConsoleTraceListener());
 
82
 
 
83
        try
 
84
        {
 
85
            Ice.InitializationData initData = new Ice.InitializationData();
 
86
            initData.properties = Ice.Util.createProperties(ref args);
 
87
            communicator = Ice.Util.initialize(ref args, initData);
 
88
            status = run(args, communicator);
 
89
        }
 
90
        catch(System.Exception ex)
 
91
        {
 
92
            Console.Error.WriteLine(ex);
 
93
            status = 1;
 
94
        }
 
95
 
 
96
        if(communicator != null)
 
97
        {
 
98
            try
 
99
            {
 
100
                communicator.destroy();
 
101
            }
 
102
            catch(Ice.LocalException ex)
 
103
            {
 
104
                Console.Error.WriteLine(ex);
 
105
                status = 1;
 
106
            }
 
107
        }
 
108
 
 
109
        if(status != 0)
 
110
        {
 
111
            System.Environment.Exit(status);
 
112
        }
 
113
    }
 
114
 
 
115
}