FileDocCategorySizeDatePackage
RemoteHolder.javaAPI DocExample3161Thu Nov 08 00:22:56 GMT 2001com.ora.rmibook.chapter15.impl

RemoteHolder

public class RemoteHolder extends Object

Fields Summary
private TreeMap
_ourTree
Constructors Summary
public RemoteHolder()

        _ourTree = new TreeMap();
    
Methods Summary
protected synchronized voidbind(java.lang.String name, AttributeSet attributes, java.rmi.Remote server)

        NameAttributeSetPair nameAttributePair = new NameAttributeSetPair (name, attributes);
        Object alreadyBoundObject = _ourTree.get(nameAttributePair);

        if (null != alreadyBoundObject) {
            throw new BindingException("Object already bound to " + name);
        }
        _ourTree.put(nameAttributePair, server);
    
private java.rmi.Remote[]convertCollectionToRemoteArray(java.util.Collection remotes)

        Iterator iterator = remotes.iterator();
        Remote[] returnValue = new Remote[remotes.size()];
        int counter = 0;

        while (iterator.hasNext()) {
            returnValue[counter] = (Remote) iterator.next();;
            counter++;
        }
        return returnValue;
    
protected synchronized java.rmi.Remote[]list()

        return convertCollectionToRemoteArray(_ourTree.values());
    
protected synchronized java.rmi.Remote[]list(AttributeSet attributes)

        return list(null, attributes);
    
protected synchronized java.rmi.Remote[]list(java.lang.String name, AttributeSet attributes)

        NameAttributeSetPair queryObject = new NameAttributeSetPair (name, attributes);
        ArrayList returnValues = new ArrayList();
        Iterator i = _ourTree.keySet().iterator();

        while (i.hasNext()) {
            NameAttributeSetPair next = (NameAttributeSetPair) i.next();

            if (next.matchesQueryObject(queryObject)) {
                returnValues.add(_ourTree.get(next));
            }
        }
        return convertCollectionToRemoteArray(returnValues);
    
protected synchronized java.rmi.Remotelookup(java.lang.String name, AttributeSet attributes)

        NameAttributeSetPair nameAttributePair = new NameAttributeSetPair (name, attributes);

        return (Remote) _ourTree.get(nameAttributePair);
    
protected synchronized voidrebind(java.lang.String name, AttributeSet attributes, java.rmi.Remote server)

        NameAttributeSetPair nameAttributePair = new NameAttributeSetPair (name, attributes);

        _ourTree.remove(nameAttributePair);
        _ourTree.put(nameAttributePair, server);
    
protected synchronized voidunbind(java.lang.String name, AttributeSet attributes)

        NameAttributeSetPair nameAttributePair = new NameAttributeSetPair (name, attributes);

        _ourTree.remove(nameAttributePair);