001    /**
002     * Copyright (c) 2000-2013 Liferay, Inc. All rights reserved.
003     *
004     * This library is free software; you can redistribute it and/or modify it under
005     * the terms of the GNU Lesser General Public License as published by the Free
006     * Software Foundation; either version 2.1 of the License, or (at your option)
007     * any later version.
008     *
009     * This library is distributed in the hope that it will be useful, but WITHOUT
010     * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
011     * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
012     * details.
013     */
014    
015    package com.liferay.portal.kernel.nio.intraband;
016    
017    import java.util.Queue;
018    
019    /**
020     * @author Shuyang Zhou
021     */
022    public class ChannelContext {
023    
024            public ChannelContext(Queue<Datagram> sendingQueue) {
025                    _sendingQueue = sendingQueue;
026            }
027    
028            public Datagram getReadingDatagram() {
029                    return _readingDatagram;
030            }
031    
032            public RegistrationReference getRegistrationReference() {
033                    return _registrationReference;
034            }
035    
036            public Queue<Datagram> getSendingQueue() {
037                    return _sendingQueue;
038            }
039    
040            public Datagram getWritingDatagram() {
041                    return _writingDatagram;
042            }
043    
044            public void setReadingDatagram(Datagram readingDatagram) {
045                    _readingDatagram = readingDatagram;
046            }
047    
048            public void setRegistrationReference(
049                    RegistrationReference registrationReference) {
050    
051                    _registrationReference = registrationReference;
052            }
053    
054            public void setWritingDatagram(Datagram writingDatagram) {
055                    _writingDatagram = writingDatagram;
056            }
057    
058            // All nonfinal fields are not thread safe. They depend on external logic to
059            // do thread safe publication and must be accessed solely by polling threads
060            // to remain thread safety.
061    
062            private Datagram _readingDatagram;
063            private RegistrationReference _registrationReference;
064            private final Queue<Datagram> _sendingQueue;
065            private Datagram _writingDatagram;
066    
067    }