blob: 070dd7987cbda190688d967ffb8d12f3846525da (
plain)
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
|
// **********************************************************************
//
// Copyright (c) 2003-2017 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 <objc/Ice.h>
#import <location/ServerLocator.h>
@implementation ServerLocatorRegistry
-(id) init
{
self = [super init];
if(!self)
{
return nil;
}
adapters_ = [[NSMutableDictionary alloc] init];
objects_ = [[NSMutableDictionary alloc] init];
return self;
}
#if defined(__clang__) && !__has_feature(objc_arc)
-(void) dealloc
{
[adapters_ release];
[objects_ release];
[super dealloc];
}
#endif
-(void) setAdapterDirectProxy:(NSMutableString *)adapter proxy:(id<ICEObjectPrx>)proxy current:(ICECurrent *)current
{
if(proxy == nil)
{
[adapters_ removeObjectForKey:adapter];
}
else
{
[adapters_ setObject:proxy forKey:adapter];
}
}
-(void) setReplicatedAdapterDirectProxy:(NSMutableString *)adapterId
replicaGroupId:(NSMutableString *)replicaGroupId
p:(id<ICEObjectPrx>)p
current:(ICECurrent *)current
{
if(p == nil)
{
[adapters_ removeObjectForKey:adapterId];
[adapters_ removeObjectForKey:replicaGroupId];
}
else
{
[adapters_ setObject:p forKey:adapterId];
[adapters_ setObject:p forKey:replicaGroupId];
}
}
-(void) setServerProcessProxy:(NSMutableString *)id_ proxy:(id<ICEProcessPrx>)proxy current:(ICECurrent *)current
{
}
-(void) addObject:(id<ICEObjectPrx>)object current:(ICECurrent*)current
{
[self addObject:object];
}
-(id<ICEObjectPrx>) getAdapter:(NSString*)adapterId
{
id<ICEObjectPrx> proxy = [adapters_ objectForKey:adapterId];
if(proxy == nil)
{
@throw [ICEAdapterNotFoundException adapterNotFoundException];
}
return proxy;
}
-(id<ICEObjectPrx>) getObject:(ICEIdentity*)ident
{
id<ICEObjectPrx> proxy = [objects_ objectForKey:ident];
if(proxy == nil)
{
@throw [ICEObjectNotFoundException objectNotFoundException];
}
return proxy;
}
-(void) addObject:(id<ICEObjectPrx>)object
{
[objects_ setObject:object forKey:[object ice_getIdentity]];
}
@end
@implementation ServerLocator
-(id) init:(ServerLocatorRegistry*)registry proxy:(id<ICELocatorRegistryPrx>)registryPrx
{
self = [super init];
if(!self)
{
return nil;
}
registry_ = registry;
registryPrx_ = registryPrx;
requestCount_ = 0;
return self;
}
-(id<ICEObjectPrx>) findObjectById:(ICEIdentity *)id_ current:(ICECurrent *)current
{
++requestCount_;
return [registry_ getObject:id_];
}
-(id<ICEObjectPrx>) findAdapterById:(NSMutableString *)id_ current:(ICECurrent *)current
{
++requestCount_;
if([id_ isEqualToString:@"TestAdapter10"] || [id_ isEqualToString:@"TestAdapter10-2"])
{
NSAssert([current.encoding isEqual:ICEEncoding_1_0], @"unexpected encoding");
return [registry_ getAdapter:@"TestAdapter"];
}
return [registry_ getAdapter:id_];
}
-(id<ICELocatorRegistryPrx>) getRegistry:(ICECurrent *)current
{
return registryPrx_;
}
-(int) getRequestCount:(ICECurrent*)current
{
return requestCount_;
}
@end
|