All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.zeroc.IceInternal.RouterManager Maven / Gradle / Ivy

Go to download

Ice is a comprehensive RPC framework that helps you build distributed applications with minimal effort using familiar object-oriented idioms

There is a newer version: 3.7.10
Show newest version
//
// Copyright (c) ZeroC, Inc. All rights reserved.
//

package com.zeroc.IceInternal;

public final class RouterManager
{
    RouterManager()
    {
    }

    synchronized void
    destroy()
    {
        for(RouterInfo info : _table.values())
        {
            info.destroy();
        }
        _table.clear();
    }

    //
    // Returns router info for a given router. Automatically creates
    // the router info if it doesn't exist yet.
    //
    public RouterInfo
    get(com.zeroc.Ice.RouterPrx rtr)
    {
        if(rtr == null)
        {
            return null;
        }

        //
        // The router cannot be routed.
        //
        com.zeroc.Ice.RouterPrx router = com.zeroc.Ice.RouterPrx.uncheckedCast(rtr.ice_router(null));

        synchronized(this)
        {
            RouterInfo info = _table.get(router);
            if(info == null)
            {
                info = new RouterInfo(router);
                _table.put(router, info);
            }

            return info;
        }
    }

    public RouterInfo
    erase(com.zeroc.Ice.RouterPrx rtr)
    {
        RouterInfo info = null;
        if(rtr != null)
        {
            // The router cannot be routed.
            com.zeroc.Ice.RouterPrx router = com.zeroc.Ice.RouterPrx.uncheckedCast(rtr.ice_router(null));

            synchronized(this)
            {
                info = _table.remove(router);
            }
        }
        return info;
    }

    private java.util.HashMap _table =
        new java.util.HashMap();
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy