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

IceInternal.ObjectFactoryManager 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) 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.
//
// **********************************************************************

package IceInternal;

public final class ObjectFactoryManager
{
    public synchronized void
    add(Ice.ObjectFactory factory, String id)
    {
        Object o = _factoryMap.get(id);
        if(o != null)
        {
            Ice.AlreadyRegisteredException ex = new Ice.AlreadyRegisteredException();
            ex.id = id;
            ex.kindOfObject = "object factory";
            throw ex;
        }
        _factoryMap.put(id, factory);
    }

    public void
    remove(String id)
    {
        Ice.ObjectFactory factory = null;

        synchronized(this)
        {
            factory = _factoryMap.get(id);
            if(factory == null)
            {
                Ice.NotRegisteredException ex = new Ice.NotRegisteredException();
                ex.id = id;
                ex.kindOfObject = "object factory";
                throw ex;
            }
            _factoryMap.remove(id);
        }

        factory.destroy();
    }

    public synchronized Ice.ObjectFactory
    find(String id)
    {
        return _factoryMap.get(id);
    }

    //
    // Only for use by Instance
    //
    ObjectFactoryManager()
    {
    }

    void
    destroy()
    {
        java.util.Map oldMap = null;
        synchronized(this)
        {
            oldMap = _factoryMap;
            _factoryMap = new java.util.HashMap();
        }

        for(Ice.ObjectFactory factory : oldMap.values())
        {
            factory.destroy();
        }
    }

    private java.util.Map _factoryMap = new java.util.HashMap();
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy