ICE 3.4.2
[php5-ice-freebsdport.git] / java / src / IceInternal / FixedReference.java
blob68a15f50cbff22f765c0759978c4600f7f6b12be
1 // **********************************************************************
2 //
3 // Copyright (c) 2003-2011 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 // **********************************************************************
10 package IceInternal;
12 public class FixedReference extends Reference
14 public
15 FixedReference(Instance instance,
16 Ice.Communicator communicator,
17 Ice.Identity identity,
18 String facet,
19 int mode,
20 boolean secure,
21 Ice.ConnectionI connection)
23 super(instance, communicator, identity, facet, mode, secure);
24 _fixedConnection = connection;
27 public EndpointI[]
28 getEndpoints()
30 return _emptyEndpoints;
33 public String
34 getAdapterId()
36 return "";
39 public LocatorInfo
40 getLocatorInfo()
42 return null;
45 public RouterInfo
46 getRouterInfo()
48 return null;
51 public boolean
52 getCollocationOptimized()
54 return false;
57 public final boolean
58 getCacheConnection()
60 return false;
63 public boolean
64 getPreferSecure()
66 return false;
69 public final Ice.EndpointSelectionType
70 getEndpointSelection()
72 return Ice.EndpointSelectionType.Random;
75 public int
76 getLocatorCacheTimeout()
78 return 0;
81 public String
82 getConnectionId()
84 return "";
87 public Reference
88 changeEndpoints(EndpointI[] newEndpoints)
90 throw new Ice.FixedProxyException();
93 public Reference
94 changeAdapterId(String newAdapterId)
96 throw new Ice.FixedProxyException();
99 public Reference
100 changeLocator(Ice.LocatorPrx newLocator)
102 throw new Ice.FixedProxyException();
105 public Reference
106 changeRouter(Ice.RouterPrx newRouter)
108 throw new Ice.FixedProxyException();
111 public Reference
112 changeCollocationOptimized(boolean newCollocationOptimized)
114 throw new Ice.FixedProxyException();
117 public final Reference
118 changeCacheConnection(boolean newCache)
120 throw new Ice.FixedProxyException();
123 public Reference
124 changePreferSecure(boolean prefSec)
126 throw new Ice.FixedProxyException();
129 public final Reference
130 changeEndpointSelection(Ice.EndpointSelectionType newType)
132 throw new Ice.FixedProxyException();
135 public Reference
136 changeLocatorCacheTimeout(int newTimeout)
138 throw new Ice.FixedProxyException();
141 public Reference
142 changeTimeout(int newTimeout)
144 throw new Ice.FixedProxyException();
147 public Reference
148 changeConnectionId(String connectionId)
150 throw new Ice.FixedProxyException();
153 public boolean
154 isIndirect()
156 return false;
159 public boolean
160 isWellKnown()
162 return false;
165 public void
166 streamWrite(BasicStream s)
167 throws Ice.MarshalException
169 throw new Ice.FixedProxyException();
172 public String
173 toString()
174 throws Ice.MarshalException
176 throw new Ice.FixedProxyException();
179 public java.util.Map<String, String>
180 toProperty(String prefix)
182 throw new Ice.FixedProxyException();
185 public Ice.ConnectionI
186 getConnection(Ice.BooleanHolder compress)
188 switch(getMode())
190 case Reference.ModeTwoway:
191 case Reference.ModeOneway:
192 case Reference.ModeBatchOneway:
194 if(_fixedConnection.endpoint().datagram())
196 throw new Ice.NoEndpointException("");
198 break;
201 case Reference.ModeDatagram:
202 case Reference.ModeBatchDatagram:
204 if(!_fixedConnection.endpoint().datagram())
206 throw new Ice.NoEndpointException("");
208 break;
213 // If a secure connection is requested or secure overrides is set,
214 // check if the connection is secure.
216 boolean secure;
217 DefaultsAndOverrides defaultsAndOverrides = getInstance().defaultsAndOverrides();
218 if(defaultsAndOverrides.overrideSecure)
220 secure = defaultsAndOverrides.overrideSecureValue;
222 else
224 secure = getSecure();
226 if(secure && !_fixedConnection.endpoint().secure())
228 throw new Ice.NoEndpointException("");
231 _fixedConnection.throwException(); // Throw in case our connection is already destroyed.
233 if(defaultsAndOverrides.overrideCompress)
235 compress.value = defaultsAndOverrides.overrideCompressValue;
237 else if(_overrideCompress)
239 compress.value = _compress;
241 else
243 compress.value = _fixedConnection.endpoint().compress();
245 return _fixedConnection;
248 public void
249 getConnection(GetConnectionCallback callback)
253 Ice.BooleanHolder compress = new Ice.BooleanHolder();
254 Ice.ConnectionI connection = getConnection(compress);
255 callback.setConnection(connection, compress.value);
257 catch(Ice.LocalException ex)
259 callback.setException(ex);
263 public boolean
264 equals(java.lang.Object obj)
266 if(this == obj)
268 return true;
270 if(!(obj instanceof FixedReference))
272 return false;
274 FixedReference rhs = (FixedReference)obj;
275 if(!super.equals(rhs))
277 return false;
279 return _fixedConnection.equals(rhs._fixedConnection);
282 public int
283 hashCode()
285 return super.hashCode();
288 private Ice.ConnectionI _fixedConnection;
289 private static EndpointI[] _emptyEndpoints = new EndpointI[0];