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

ContextImpl

public class ContextImpl extends UnicastRemoteObject implements Context

Fields Summary
private RemoteHolder
_remoteHolder
private ContextHolder
_contextHolder
private ContextHolder
_subContextHolder
Constructors Summary
public ContextImpl(int portNumber)

        _remoteHolder = new RemoteHolder();
        _contextHolder = new ContextHolder();
    
        super (portNumber);
    
public ContextImpl()

        super ();
    
Methods Summary
public voidbind(Path path, java.lang.String name, AttributeSet attributes, java.rmi.Remote server)

        checkNameForBindingOperation(name);
        if ((null == path) || (path.isEmpty())) {
            _remoteHolder.bind(name, attributes, server);
        } else {
            String firstPathComponent = path.getFirstComponent();
            Context subContext = _contextHolder.lookup(firstPathComponent);

            if (null == subContext) {
                throw new InvalidPathException("The specified path in the naming hierarchy does not exist. In particular "
                        + firstPathComponent + " is not a valid context name.");
            }
            subContext.bind(path.getSubPath(), name, attributes, server);
        }
    
public voidbindSubContext(Path path, java.lang.String name, Context context)

        checkNameForBindingOperation(name);
        if ((null == path) || (path.isEmpty())) {
            _contextHolder.bind(name, context);
            return;
        }
        String firstPathComponent = path.getFirstComponent();
        Context subContext = _contextHolder.lookup(firstPathComponent);

        if (null == subContext) {
            throw new InvalidPathException("The specified path in the naming hierarchy does not exist. In particular "
                    + name + " is not a valid context name.");
        }
        subContext.bindSubContext(path.getSubPath(), name, context);
        return;
    
private voidcheckNameForBindingOperation(java.lang.String name)

        if ((null == name) || (name.equals(""))) {
            throw new InvalidNameException("Name cannot be null");
        }
    
public ContextcreateSubContext(Path path, java.lang.String name)

        checkNameForBindingOperation(name);
        Context newSubContext = new ContextImpl();

        bindSubContext(path, name, newSubContext);
        return newSubContext;
    
public java.rmi.Remote[]list(Path path, java.lang.String name, AttributeSet attributes)

        if ((null == path) || (path.isEmpty())) {
            return _remoteHolder.list(name, attributes);
        }
        String firstPathComponent = path.getFirstComponent();
        Context subContext = _contextHolder.lookup(firstPathComponent);

        if (null == subContext) {
            throw new InvalidPathException("The specified path in the naming hierarchy does not exist. In particular "
                    + name + " is not a valid context name.");
        }
        return subContext.list(path.getSubPath(), name, attributes);
    
public java.rmi.Remote[]list()

        return _remoteHolder.list();
    
public java.rmi.Remote[]list(AttributeSet attributes)

        return _remoteHolder.list(attributes);
    
public java.rmi.Remote[]list(java.lang.String name, AttributeSet attributes)

        return _remoteHolder.list(name, attributes);
    
public ContextListlistSubContexts()

        return _contextHolder.list();
    
public ContextListlistSubContexts(Path path)

        if ((null == path) || (path.isEmpty())) {
            return _contextHolder.list();
        }
        String name = path.getFirstComponent();
        Context subContext = _contextHolder.lookup(name);

        if (null == subContext) {
            throw new InvalidPathException("The specified path in the naming hierarchy does not exist. In particular "
                    + name + " is not a valid context name.");
        }
        return subContext.listSubContexts(path.getSubPath());
    
public java.rmi.Remotelookup(Path path, java.lang.String name, AttributeSet attributes)

        if ((null == path) || (path.isEmpty())) {
            return _remoteHolder.lookup(name, attributes);
        }
        String firstPathComponent = path.getFirstComponent();
        Context subContext = _contextHolder.lookup(firstPathComponent);

        if (null == subContext) {
            throw new InvalidPathException("The specified path in the naming hierarchy does not exist. In particular "
                    + name + " is not a valid context name.");
        }
        return subContext.lookup(path.getSubPath(), name, attributes);
    
public ContextlookupSubContext(Path path, java.lang.String name)

        if ((null == path) || (path.isEmpty())) {
            return _contextHolder.lookup(name);
        }
        String firstPathComponent = path.getFirstComponent();
        Context subContext = _contextHolder.lookup(firstPathComponent);

        return subContext.lookupSubContext(path.getSubPath(), name);
    
public voidrebind(Path path, java.lang.String name, AttributeSet attributes, java.rmi.Remote server)

        checkNameForBindingOperation(name);
        if ((null == path) || (path.isEmpty())) {
            _remoteHolder.rebind(name, attributes, server);
        } else {
            String firstPathComponent = path.getFirstComponent();
            Context subContext = _contextHolder.lookup(firstPathComponent);

            if (null == subContext) {
                throw new InvalidPathException("The specified path in the naming hierarchy does not exist. In particular "
                        + firstPathComponent + " is not a valid context name.");
            }
            subContext.rebind(path.getSubPath(), name, attributes, server);
        }
    
public voidrebindSubContext(Path path, java.lang.String name, Context context)

        checkNameForBindingOperation(name);
        if ((null == path) || (path.isEmpty())) {
            _contextHolder.rebind(name, context);
            return;
        }
        String firstPathComponent = path.getFirstComponent();
        Context subContext = _contextHolder.lookup(firstPathComponent);

        if (null == subContext) {
            throw new InvalidPathException("The specified path in the naming hierarchy does not exist. In particular "
                    + name + " is not a valid context name.");
        }
        subContext.rebindSubContext(path.getSubPath(), name, context);
        return;
    
public voidunbind(Path path, java.lang.String name, AttributeSet attributes)

        checkNameForBindingOperation(name);
        if ((null == path) || (path.isEmpty())) {
            _remoteHolder.unbind(name, attributes);
        } else {
            String firstPathComponent = path.getFirstComponent();
            Context subContext = _contextHolder.lookup(firstPathComponent);

            if (null == subContext) {
                throw new InvalidPathException("The specified path in the naming hierarchy does not exist. In particular "
                        + firstPathComponent + " is not a valid context name.");
            }
            subContext.unbind(path.getSubPath(), name, attributes);
        }
    
public voidunbindSubContext(Path path, java.lang.String name)

        checkNameForBindingOperation(name);
        if ((null == path) || (path.isEmpty())) {
            _contextHolder.unbind(name);
            return;
        }
        String firstPathComponent = path.getFirstComponent();
        Context subContext = _contextHolder.lookup(firstPathComponent);

        if (null == subContext) {
            throw new InvalidPathException("The specified path in the naming hierarchy does not exist. In particular "
                    + name + " is not a valid context name.");
        }
        subContext.unbindSubContext(path.getSubPath(), name);
        return;