001
014
015 package com.liferay.portal.kernel.poller.comet;
016
017
021 public abstract class BaseCometHandler implements CometHandler {
022
023 @Override
024 public abstract CometHandler clone();
025
026 public void destroy() throws CometException {
027 _cometState = CometState.STATE_CLOSED;
028
029 try {
030 doDestroy();
031 }
032 catch (CometException ce) {
033 throw ce;
034 }
035 catch (Exception e) {
036 throw new CometException(e);
037 }
038 }
039
040 public CometSession getCometSession() {
041 return _cometSession;
042 }
043
044 public CometState getCometState() {
045 return _cometState;
046 }
047
048 public void init(CometSession cometSession) throws CometException {
049 _cometSession = cometSession;
050 _cometState = CometState.STATE_READY;
051
052 try {
053 doInit(cometSession);
054 }
055 catch (CometException ce) {
056 throw ce;
057 }
058 catch (Exception e) {
059 throw new CometException(e);
060 }
061 }
062
063 public void receiveData(char[] data) throws CometException {
064 receiveData(new String(data));
065 }
066
067 protected void doDestroy() throws Exception {
068 }
069
070 protected void doInit(CometSession cometSession) throws Exception {
071 }
072
073 private CometSession _cometSession;
074 private CometState _cometState = CometState.STATE_OPEN;
075
076 }