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

BaseContextImpl

public class BaseContextImpl extends ContextImpl implements Context

Fields Summary
public static final int
BOOTSTRAP_PORT_NUMBER
public static final int
DEFAULT_PORT_NUMBER
Constructors Summary
public BaseContextImpl(int port)

        super (port);
    
public BaseContextImpl()

        this (DEFAULT_PORT_NUMBER);
    
Methods Summary
public static ContextgetStubFromServer(java.lang.String serverName)


         
        return getStubFromServer(serverName, BOOTSTRAP_PORT_NUMBER);
    
public static ContextgetStubFromServer(java.lang.String serverName, int portNumber)

        Context returnValue = null;

        try {
            Socket socket = new Socket(serverName, portNumber);
            ObjectInputStream objectInputStream = new ObjectInputStream(socket.getInputStream());

            returnValue = (Context) objectInputStream.readObject();
        } catch (Exception e) {
            System.out.println("Stub note available");
            e.printStackTrace();
        }
        return returnValue;
    
public voidvendStubViaSocket()

        vendStubViaSocket(BOOTSTRAP_PORT_NUMBER);
    
public voidvendStubViaSocket(int portNumber)

        StubSender stubSender = new StubSender(this);
        Thread stubSenderThread = new Thread(stubSender);

        stubSenderThread.setName("Stub sender thread");
        stubSenderThread.start();
        StubSocketListener socketListener = new StubSocketListener(portNumber, stubSender);
        Thread socketListenerThread = new Thread(socketListener);

        socketListenerThread.setName("Socket Listener thread");
        socketListenerThread.start();