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.poller.comet;
016    
017    /**
018     * @author Edward Han
019     * @author Brian Wing Shun Chan
020     */
021    public abstract class BaseCometSession implements CometSession {
022    
023            @Override
024            public void close() throws CometException {
025                    try {
026                            doClose();
027    
028                            _cometResponse.close();
029                    }
030                    catch (CometException ce) {
031                            throw ce;
032                    }
033                    catch (Exception e) {
034                            throw new CometException(e);
035                    }
036            }
037    
038            @Override
039            public CometRequest getCometRequest() {
040                    return _cometRequest;
041            }
042    
043            @Override
044            public CometResponse getCometResponse() {
045                    return _cometResponse;
046            }
047    
048            @Override
049            public String getSessionId() {
050                    return _sessionId;
051            }
052    
053            @Override
054            public void setCometRequest(CometRequest cometRequest) {
055                    _cometRequest = cometRequest;
056            }
057    
058            @Override
059            public void setCometResponse(CometResponse cometResponse) {
060                    _cometResponse = cometResponse;
061            }
062    
063            @Override
064            public void setSessionId(String sessionId) {
065                    _sessionId = sessionId;
066            }
067    
068            protected abstract void doClose() throws Exception;
069    
070            private CometRequest _cometRequest;
071            private CometResponse _cometResponse;
072            private String _sessionId;
073    
074    }