1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105
|
// **********************************************************************
//
// Copyright (c) 2003-2009 ZeroC, Inc. All rights reserved.
//
// This copy of Ice is licensed to you under the terms described in the
// ICE_LICENSE file included in this distribution.
//
// **********************************************************************
public class Server
{
static class ServantFactory implements Ice.ObjectFactory
{
public Ice.Object
create(String type)
{
assert(type.equals("::Test::Servant"));
Test._ServantTie tie = new Test._ServantTie();
tie.ice_delegate(new ServantI(tie));
return tie;
}
public void
destroy()
{
}
}
static class FacetFactory implements Ice.ObjectFactory
{
public Ice.Object
create(String type)
{
assert(type.equals("::Test::Facet"));
Test._FacetTie tie = new Test._FacetTie();
tie.ice_delegate(new FacetI(tie));
return tie;
}
public void
destroy()
{
}
}
static int
run(String[] args, Ice.Communicator communicator, String envName)
{
communicator.getProperties().setProperty("Evictor.Endpoints", "default -p 12010");
Ice.ObjectAdapter adapter = communicator.createObjectAdapter("Evictor");
RemoteEvictorFactoryI factory = new RemoteEvictorFactoryI(adapter, envName);
adapter.add(factory, communicator.stringToIdentity("factory"));
Ice.ObjectFactory servantFactory = new ServantFactory();
communicator.addObjectFactory(servantFactory, "::Test::Servant");
Ice.ObjectFactory facetFactory = new FacetFactory();
communicator.addObjectFactory(facetFactory, "::Test::Facet");
adapter.activate();
communicator.waitForShutdown();
return 0;
}
public static void
main(String[] args)
{
int status = 0;
Ice.Communicator communicator = null;
String envName = "db";
try
{
Ice.StringSeqHolder holder = new Ice.StringSeqHolder();
holder.value = args;
communicator = Ice.Util.initialize(holder);
args = holder.value;
status = run(args, communicator, envName);
}
catch(Exception ex)
{
ex.printStackTrace();
status = 1;
}
if(communicator != null)
{
try
{
communicator.destroy();
}
catch(Ice.LocalException ex)
{
ex.printStackTrace();
status = 1;
}
}
System.gc();
System.exit(status);
}
}
|