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

« back to all changes in this revision

Viewing changes to java/src/IceInternal/RoutableReference.java

  • 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
1
// **********************************************************************
2
2
//
3
 
// Copyright (c) 2003-2009 ZeroC, Inc. All rights reserved.
 
3
// Copyright (c) 2003-2010 ZeroC, Inc. All rights reserved.
4
4
//
5
5
// This copy of Ice is licensed to you under the terms described in the
6
6
// ICE_LICENSE file included in this distribution.
65
65
        return _locatorCacheTimeout;
66
66
    }
67
67
 
 
68
    public final String
 
69
    getConnectionId()
 
70
    {
 
71
        return _connectionId;
 
72
    }
 
73
 
68
74
    public Reference
69
75
    changeCompress(boolean newCompress)
70
76
    {
259
265
        if(_endpoints.length > 0)
260
266
        {
261
267
            assert(_adapterId.length() == 0);
262
 
            for(int i = 0; i < _endpoints.length; i++)
 
268
            for(EndpointI endpoint : _endpoints)
263
269
            {
264
 
                _endpoints[i].streamWrite(s);
 
270
                endpoint.streamWrite(s);
265
271
            }
266
272
        }
267
273
        else
284
290
        s.append(super.toString());
285
291
        if(_endpoints.length > 0)
286
292
        {
287
 
            for(int i = 0; i < _endpoints.length; i++)
 
293
            for(EndpointI endpoint : _endpoints)
288
294
            {
289
 
                String endp = _endpoints[i].toString();
 
295
                String endp = endpoint.toString();
290
296
                if(endp != null && endp.length() > 0)
291
297
                {
292
298
                    s.append(':');
304
310
            // the adapter id string in quotes.
305
311
            //
306
312
            String a = IceUtilInternal.StringUtil.escapeString(_adapterId, null);
307
 
            if(IceUtilInternal.StringUtil.findFirstOf(a, " \t\n\r") != -1)
 
313
            if(IceUtilInternal.StringUtil.findFirstOf(a, " :@") != -1)
308
314
            {
309
315
                s.append('"');
310
316
                s.append(a);
318
324
        return s.toString();
319
325
    }
320
326
 
 
327
    public java.util.Map<String, String> toProperty(String prefix)
 
328
    {
 
329
        java.util.Map<String, String> properties = new java.util.HashMap<String, String>();
 
330
 
 
331
        properties.put(prefix, toString());
 
332
        properties.put(prefix + ".CollocationOptimized", _collocationOptimized ? "1" : "0");
 
333
        properties.put(prefix + ".ConnectionCached", _cacheConnection ? "1" : "0");
 
334
        properties.put(prefix + ".PreferSecure", _preferSecure ? "1" : "0");
 
335
        properties.put(prefix + ".EndpointSelection", 
 
336
                       _endpointSelection == Ice.EndpointSelectionType.Random ? "Random" : "Ordered");
 
337
 
 
338
        StringBuffer s = new StringBuffer();
 
339
        s.append(_locatorCacheTimeout);
 
340
        properties.put(prefix + ".LocatorCacheTimeout", s.toString());
 
341
 
 
342
        if(_routerInfo != null)
 
343
        {
 
344
            Ice.ObjectPrxHelperBase h = (Ice.ObjectPrxHelperBase)_routerInfo.getRouter();
 
345
            java.util.Map<String, String> routerProperties = h.__reference().toProperty(prefix + ".Router");
 
346
            for(java.util.Map.Entry<String, String> p : routerProperties.entrySet())
 
347
            {
 
348
                properties.put(p.getKey(), p.getValue());
 
349
            }
 
350
        }
 
351
 
 
352
        if(_locatorInfo != null)
 
353
        {
 
354
            Ice.ObjectPrxHelperBase h = (Ice.ObjectPrxHelperBase)_locatorInfo.getLocator();
 
355
            java.util.Map<String, String> locatorProperties = h.__reference().toProperty(prefix + ".Locator");
 
356
            for(java.util.Map.Entry<String, String> p : locatorProperties.entrySet())
 
357
            {
 
358
                properties.put(p.getKey(), p.getValue());
 
359
            }
 
360
        }
 
361
 
 
362
        return properties;
 
363
    }
 
364
 
321
365
    public synchronized int
322
366
    hashCode()
323
367
    {
584
628
    RoutableReference(Instance instance,
585
629
                      Ice.Communicator communicator,
586
630
                      Ice.Identity identity,
587
 
                      java.util.Map<String, String> context,
588
631
                      String facet,
589
632
                      int mode,
590
633
                      boolean secure,
598
641
                      Ice.EndpointSelectionType endpointSelection,
599
642
                      int locatorCacheTimeout)
600
643
    {
601
 
        super(instance, communicator, identity, context, facet, mode, secure);
 
644
        super(instance, communicator, identity, facet, mode, secure);
602
645
        _endpoints = endpoints;
603
646
        _adapterId = adapterId;
604
647
        _locatorInfo = locatorInfo;
648
691
        java.util.List<EndpointI> endpoints = new java.util.ArrayList<EndpointI>();
649
692
 
650
693
        //
651
 
        // Filter out unknown endpoints.
 
694
        // Filter out opaque endpoints.
652
695
        //
653
 
        for(int i = 0; i < allEndpoints.length; i++)
 
696
        for(EndpointI endpoint : allEndpoints)
654
697
        {
655
 
            if(!allEndpoints[i].unknown())
 
698
            if(!(endpoint instanceof IceInternal.OpaqueEndpointI))
656
699
            {
657
 
                endpoints.add(allEndpoints[i]);
 
700
                endpoints.add(endpoint);
658
701
            }
659
702
        }
660
703
        
704
747
        //
705
748
        // Sort the endpoints according to the endpoint selection type.
706
749
        //
707
 
        switch(getEndpointSelection().value())
 
750
        switch(getEndpointSelection())
708
751
        {
709
 
            case Ice.EndpointSelectionType._Random:
 
752
            case Random:
710
753
            {
711
754
                java.util.Collections.shuffle(endpoints);
712
755
                break;
713
756
            }
714
 
            case Ice.EndpointSelectionType._Ordered:
 
757
            case Ordered:
715
758
            {
716
759
                // Nothing to do.
717
760
                break;