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 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146
|
// **********************************************************************
//
// 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.
//
// **********************************************************************
import Test.*;
import Ice.*;
public final class ServantLocatorI implements Ice.ServantLocator
{
public
ServantLocatorI(String category)
{
_category = category;
_deactivated = false;
}
protected synchronized void
finalize()
throws Throwable
{
test(_deactivated);
}
private static void
test(boolean b)
{
if(!b)
{
throw new RuntimeException();
}
}
public Ice.Object
locate(Ice.Current current, Ice.LocalObjectHolder cookie) throws Ice.UserException
{
synchronized(this)
{
test(!_deactivated);
}
test(current.id.category.equals(_category) || _category.length() == 0);
if(current.id.name.equals("unknown"))
{
return null;
}
test(current.id.name.equals("locate") || current.id.name.equals("finished"));
if(current.id.name.equals("locate"))
{
exception(current);
}
cookie.value = new CookieI();
return new TestI();
}
public void
finished(Ice.Current current, Ice.Object servant, java.lang.Object cookie) throws Ice.UserException
{
synchronized(this)
{
test(!_deactivated);
}
test(current.id.category.equals(_category) || _category.length() == 0);
test(current.id.name.equals("locate") || current.id.name.equals("finished"));
if(current.id.name.equals("finished"))
{
exception(current);
}
Cookie co = (Cookie)cookie;
test(co.message().equals("blahblah"));
}
public synchronized void
deactivate(String category)
{
synchronized(this)
{
test(!_deactivated);
_deactivated = true;
}
}
private void
exception(Ice.Current current) throws Ice.UserException
{
if(current.operation.equals("ice_ids"))
{
throw new Test.TestIntfUserException();
}
else if(current.operation.equals("requestFailedException"))
{
throw new ObjectNotExistException();
}
else if(current.operation.equals("unknownUserException"))
{
throw new UnknownUserException("reason");
}
else if(current.operation.equals("unknownLocalException"))
{
throw new UnknownLocalException("reason");
}
else if(current.operation.equals("unknownException"))
{
throw new UnknownException("reason");
}
//
// User exceptions are checked exceptions in Java, so it's not
// possible to throw it from the servant locator.
//
// else if(current.operation.equals("userException"))
// {
// throw new TestIntfUserException();
// }
else if(current.operation.equals("localException"))
{
throw new SocketException(0);
}
else if(current.operation.equals("javaException"))
{
throw new java.lang.RuntimeException("message");
}
else if(current.operation.equals("impossibleException"))
{
throw new TestIntfUserException(); // Yes, it really is meant to be TestIntfUserException.
}
else if(current.operation.equals("intfUserException"))
{
throw new TestImpossibleException(); // Yes, it really is meant to be TestImpossibleException.
}
}
private boolean _deactivated;
private final String _category;
}
|