FileDocCategorySizeDatePackage
LockingFactory_Impl.javaAPI DocExample2045Thu Nov 08 00:23:10 GMT 2001com.ora.rmibook.chapter17.better.factory

LockingFactory_Impl

public abstract class LockingFactory_Impl extends UnicastRemoteObject implements LockingFactory

Fields Summary
private HashMap
_lockedServerNames
Constructors Summary
public LockingFactory_Impl()

        _lockedServerNames = new HashMap();
    
Methods Summary
protected abstract java.rmi.Remote_getServer(java.lang.String serverName)

private synchronized voidcheckLock(java.lang.String serverName)

        if (null != _lockedServerNames.get(serverName)) {
            throw new LockedServerException(serverName);
        }
        return;
    
public synchronized java.rmi.RemotegetServer(java.lang.String serverName)

        Remote returnValue = _getServer(serverName);

        _lockedServerNames.put(serverName, serverName);
        return returnValue;
    
public synchronized java.rmi.Remote[]getServers(java.lang.String[] serverNames)

        Remote[] returnValue = new Remote[serverNames.length];
        int counter;

        for (counter = 0; counter < serverNames.length; counter++) {
            try {
                checkLock(serverNames[counter]);
                Remote nextServer = getServer(serverNames[counter]);

                returnValue[counter] = nextServer;
            } catch (LockedServerException serverLocked) {
                int returnCounter;

                for (returnCounter = 0; returnCounter < counter; returnCounter++) {
                    serverNoLongerActive(serverNames[returnCounter]);
                }
                throw serverLocked;
            }
        }
        return returnValue;
    
public synchronized voidserverNoLongerActive(java.lang.String serverName)

        _lockedServerNames.remove(serverName);