com.sun.jini.jeri.internal.mux
Class MuxServer

java.lang.Object
  extended by com.sun.jini.jeri.internal.mux.Mux
      extended by com.sun.jini.jeri.internal.mux.MuxServer
Direct Known Subclasses:
ServerConnectionManager.InboundMux

public class MuxServer
extends Mux

A MuxServer controls the server side of a multiplexed connection.

Author:
Sun Microsystems, Inc.

Field Summary
private static Logger logger
          mux logger
private  RequestDispatcher requestDispatcher
          the request dispatcher to dispatch incoming requests to
private  SecurityContext securityContext
          the security context to dispatch incoming requests in
private static int serverInitialInboundRation
          initial inbound ration as server, default is 32768
private static Executor userThreadPool
          pool of threads for executing tasks with user code: used for dispatching incoming requests to request dispatchers
 
Fields inherited from class com.sun.jini.jeri.internal.mux.Mux
Abort, Abort_partial, Acknowledgment, busySessions, CLIENT, ClientConnectionHeader_negotiate, Close, Data, Data_ackRequired, Data_close, Data_eof, Data_open, Error, IncrementRation, IncrementRation_shift, initialInboundRation, initialOutboundRation, MAX_REQUESTS, MAX_SESSION_ID, maxFragmentSize, muxDown, muxDownCause, muxDownMessage, muxLock, NoOperation, Ping, PingAck, role, SERVER, serverConnectionReady, sessions, Shutdown
 
Constructor Summary
MuxServer(OutputStream out, InputStream in, RequestDispatcher requestDispatcher)
          Initiates the server side of a multiplexed connection over the given input/output stream pair.
MuxServer(SocketChannel channel, RequestDispatcher requestDispatcher)
           
 
Method Summary
protected  InvocationConstraints checkConstraints(InvocationConstraints constraints)
          Checks that the specified requirements are either fully or partially satisfied by the constraints actually in force for this connection, and returns any constraints that must be fully or partially implemented by higher layers in order to fully satisfy all of the specified requirements.
protected  void checkPermissions()
          Verifies that the calling context has all of the security permissions necessary to receive a request on this connection.
private  void dispatchNewRequest(int sessionID)
           
(package private)  void handleOpen(int sessionID)
          Handles message to open a new session over this connection.
protected  void populateContext(Collection context)
          Populates the context collection with information representing this connection (such as the client host).
 void shutdown(String message)
          Shuts down this multiplexed connection.
 boolean shutdownGracefully()
          Shuts down this multiplexed connection only if there are no requests in progress (i.e. requests that have been dispatched to the request dispatcher but that have not been aborted or had their response fully written to the client).
 
Methods inherited from class com.sun.jini.jeri.internal.mux.Mux
addSession, asyncSendAbort, asyncSendAcknowledgment, asyncSendClientConnectionHeader, asyncSendClose, asyncSendData, asyncSendError, asyncSendIncrementRation, asyncSendNoOperation, asyncSendPing, asyncSendPingAck, asyncSendServerConnectionHeader, asyncSendShutdown, directBuffersUseful, futureSendData, futureSendError, handleDown, processIncomingData, removeSession, setDown, setStartTimeout, start
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

serverInitialInboundRation

private static final int serverInitialInboundRation
initial inbound ration as server, default is 32768


userThreadPool

private static final Executor userThreadPool
pool of threads for executing tasks with user code: used for dispatching incoming requests to request dispatchers


logger

private static final Logger logger
mux logger


requestDispatcher

private final RequestDispatcher requestDispatcher
the request dispatcher to dispatch incoming requests to


securityContext

private final SecurityContext securityContext
the security context to dispatch incoming requests in

Constructor Detail

MuxServer

public MuxServer(OutputStream out,
                 InputStream in,
                 RequestDispatcher requestDispatcher)
          throws IOException
Initiates the server side of a multiplexed connection over the given input/output stream pair.

Parameters:
out - the output stream of the underlying connection
in - the input stream of the underlying connection
requestDispatcher - the request dispatcher to dispatch incoming requests received on this multiplexed connection to
Throws:
IOException

MuxServer

public MuxServer(SocketChannel channel,
                 RequestDispatcher requestDispatcher)
          throws IOException
Throws:
IOException
Method Detail

shutdown

public void shutdown(String message)
Shuts down this multiplexed connection. Requests in progress will throw IOException for future I/O operations. On the client side, requests that were in progress will appear to have been aborted with unknown partial execution status.

Parameters:
message - reason for shutdown to be included in IOExceptions thrown from future I/O operations

shutdownGracefully

public boolean shutdownGracefully()
Shuts down this multiplexed connection only if there are no requests in progress (i.e. requests that have been dispatched to the request dispatcher but that have not been aborted or had their response fully written to the client).

Returns:
true if the connection was shut down (because there were no requests in progress), and false otherwise

checkPermissions

protected void checkPermissions()
Verifies that the calling context has all of the security permissions necessary to receive a request on this connection. This method should be overridden by subclasses to implement the desired behavior of the checkPermissions method for InboundRequest instances generated for this connection.


checkConstraints

protected InvocationConstraints checkConstraints(InvocationConstraints constraints)
                                          throws UnsupportedConstraintException
Checks that the specified requirements are either fully or partially satisfied by the constraints actually in force for this connection, and returns any constraints that must be fully or partially implemented by higher layers in order to fully satisfy all of the specified requirements. This method should be overridden by subclasses to implement the desired behavior of the checkConstraints method for InboundRequest instances generated for this connection.

Throws:
UnsupportedConstraintException

populateContext

protected void populateContext(Collection context)
Populates the context collection with information representing this connection (such as the client host). This method should be overridden by subclasses to implement the desired behavior of the populateContext method for InboundRequest instances generated for this connection.


handleOpen

void handleOpen(int sessionID)
          throws ProtocolException
Handles message to open a new session over this connection. This method must NOT be invoked while synchronized on muxLock.

Overrides:
handleOpen in class Mux
Throws:
ProtocolException

dispatchNewRequest

private void dispatchNewRequest(int sessionID)
                         throws ProtocolException
Throws:
ProtocolException


Copyright 2007-2010, multiple authors.
Licensed under the Apache License, Version 2.0, see the NOTICE file for attributions.