FileDocCategorySizeDatePackage
TCPConnectionImpl.javaAPI DocExample6282Tue May 29 16:57:10 BST 2007com.sun.xml.ws.transport.tcp.server

TCPConnectionImpl

public class TCPConnectionImpl extends Object implements com.sun.xml.ws.api.server.WebServiceContextDelegate
author
Alexey Stashok

Fields Summary
private final com.sun.xml.ws.transport.tcp.util.ChannelContext
channelContext
private final com.sun.xml.ws.transport.tcp.io.Connection
connection
private String
contentType
private int
replyStatus
private InputStream
inputStream
private OutputStream
outputStream
private boolean
isHeaderSerialized
Constructors Summary
public TCPConnectionImpl(com.sun.xml.ws.transport.tcp.util.ChannelContext channelContext)

        this.channelContext = channelContext;
        this.connection = channelContext.getConnection();
    
Methods Summary
public voidclose()

    
public voidflush()

        if (outputStream == null) {
            setMessageHeaders();
            outputStream = connection.openOutputStream();
        }
        
        connection.flush();
    
public com.sun.xml.ws.transport.tcp.util.ChannelContextgetChannelContext()

        return channelContext;
    
public java.lang.StringgetContentType()

        return contentType;
    
public java.lang.StringgetEPRAddress(com.sun.xml.ws.api.message.Packet request, com.sun.xml.ws.api.server.WSEndpoint endpoint)

        return channelContext.getTargetWSURI().toString();
    
private intgetMessageId()

        if (getStatus() == TCPConstants.ONE_WAY) {
            return FrameType.NULL;
        } else if (getStatus() != TCPConstants.OK) {
            return FrameType.ERROR;
        }
        
        return FrameType.MESSAGE;
    
public intgetStatus()

        return replyStatus;
    
public java.security.PrincipalgetUserPrincipal(com.sun.xml.ws.api.message.Packet request)

        return null;
    
public java.lang.StringgetWSDLAddress(com.sun.xml.ws.api.message.Packet request, com.sun.xml.ws.api.server.WSEndpoint endpoint)

        return null;
    
public booleanisUserInRole(com.sun.xml.ws.api.message.Packet request, java.lang.String role)

        return false;
    
public java.io.InputStreamopenInput()

        inputStream = connection.openInputStream();
        contentType = channelContext.getContentType();
        return inputStream;
    
public java.io.OutputStreamopenOutput()

        try {
            setMessageHeaders();
        } catch (IOException ex) {
        }
        
        outputStream = connection.openOutputStream();
        return outputStream;
    
public voidsendErrorMessage(com.sun.xml.ws.transport.tcp.util.WSTCPError message)

        setStatus(TCPConstants.ERROR);
        OutputStream output = openOutput();
        String description = message.getDescription();
        DataInOutUtils.writeInts4(output, message.getCode(), message.getSubCode(), description.length());
        output.write(description.getBytes(TCPConstants.UTF8));
        flush();
    
public voidsetContentType(java.lang.String contentType)

        this.contentType = contentType;
    
private voidsetMessageHeaders()

        if (!isHeaderSerialized) {
            isHeaderSerialized = true;
            
            final int messageId = getMessageId();
            connection.setMessageId(messageId);
            if (FrameType.isFrameContainsParams(messageId)) {
                channelContext.setContentType(contentType);
            }
        }
    
public voidsetStatus(int statusCode)

        replyStatus = statusCode;