FileDocCategorySizeDatePackage
GrizzlyTCPConnector.javaAPI DocExample5615Tue May 29 16:57:08 BST 2007com.sun.xml.ws.transport.tcp.grizzly

GrizzlyTCPConnector

public class GrizzlyTCPConnector extends Object implements com.sun.xml.ws.transport.tcp.server.WSTCPConnector
author
Alexey Stashok

Fields Summary
private com.sun.enterprise.web.connector.grizzly.SelectorThread
selectorThread
private String
host
private int
port
private com.sun.xml.ws.transport.tcp.server.TCPMessageListener
listener
private final Properties
properties
private final boolean
isPortUnificationMode
Constructors Summary
public GrizzlyTCPConnector(String host, int port, com.sun.xml.ws.transport.tcp.server.TCPMessageListener listener)

        this.host = host;
        this.port = port;
        this.listener = listener;
        isPortUnificationMode = false;
        properties = new Properties();
    
public GrizzlyTCPConnector(com.sun.xml.ws.transport.tcp.server.TCPMessageListener listener, Properties properties)

        this.listener = listener;
        isPortUnificationMode = true;
        this.properties = properties;
    
Methods Summary
public voidclose()

        if (selectorThread != null) {
            selectorThread.stopEndpoint();
            IncomeMessageProcessor.releaseListener(selectorThread.getPort());
            selectorThread = null;
        }
    
public intgetFrameSize()

        return selectorThread.getBufferSize();
    
public java.lang.StringgetHost()

        return host;
    
public com.sun.xml.ws.transport.tcp.server.TCPMessageListenergetListener()

        return listener;
    
public intgetPort()

        return port;
    
public voidlisten()

        if (isPortUnificationMode) {
            listenOnUnifiedPort();
        } else {
            listenOnNewPort();
        }
    
public voidlistenOnNewPort()

        try {
            IncomeMessageProcessor.registerListener(port, listener, properties);
            
            selectorThread = new SelectorThread();
            selectorThread.setClassLoader(WSTCPStreamAlgorithm.class.getClassLoader());
            selectorThread.setAlgorithmClassName(WSTCPStreamAlgorithm.class.getName());
            selectorThread.setAddress(InetAddress.getByName(host));
            selectorThread.setPort(port);
            selectorThread.setBufferSize(TCPConstants.DEFAULT_FRAME_SIZE);
            selectorThread.initEndpoint();
            selectorThread.start();
        } catch (IOException e) {
            close();
            throw e;
        } catch (InstantiationException e) {
            close();
            throw new IOException(e.getClass().getName() + ": " + e.getMessage());
        }
    
public voidlistenOnUnifiedPort()

        WSTCPProtocolHandler.setIncomingMessageProcessor(IncomeMessageProcessor.registerListener(0, listener, properties));
    
public voidsetFrameSize(int frameSize)

        selectorThread.setBufferSize(frameSize);
    
public voidsetHost(java.lang.String host)

        this.host = host;
    
public voidsetListener(com.sun.xml.ws.transport.tcp.server.TCPMessageListener listener)

        this.listener = listener;
    
public voidsetPort(int port)

        this.port = port;