01: /*
02: ItsNat Java Web Application Framework
03: Copyright (C) 2007 Innowhere Software Services S.L., Spanish Company
04: Author: Jose Maria Arranz Santamaria
05:
06: This program is free software: you can redistribute it and/or modify
07: it under the terms of the GNU Affero General Public License as published by
08: the Free Software Foundation, either version 3 of the License, or
09: (at your option) any later version. See the GNU Affero General Public
10: License for more details. See the copy of the GNU Affero General Public License
11: included in this program. If not, see <http://www.gnu.org/licenses/>.
12: */
13:
14: package org.itsnat.impl.core.client;
15:
16: import java.lang.ref.WeakReference;
17: import org.itsnat.core.CometNotifier;
18: import org.itsnat.core.ItsNatException;
19: import org.itsnat.impl.core.*;
20:
21: /**
22: *
23: * @author jmarranz
24: */
25: public abstract class ClientDocumentInvitedImpl extends
26: ClientDocumentImpl {
27: protected WeakReference itsNatDoc;
28: protected String observedSessionId;
29: protected String docId;
30: protected int syncMode;
31: protected long ajaxTimeout;
32:
33: /**
34: * Creates a new instance of ClientDocumentInvitedImpl
35: */
36: public ClientDocumentInvitedImpl(int syncMode, long ajaxTimeout,
37: ItsNatSessionImpl session, ItsNatDocumentImpl itsNatDoc) {
38: super (session);
39:
40: this .syncMode = syncMode;
41: this .ajaxTimeout = ajaxTimeout;
42: this .itsNatDoc = new WeakReference(itsNatDoc);
43: this .observedSessionId = itsNatDoc.getItsNatSessionImpl()
44: .getId();
45: this .docId = itsNatDoc.getId();
46: }
47:
48: public int getSyncMode() {
49: return syncMode;
50: }
51:
52: public long getAJAXTimeout() {
53: return ajaxTimeout;
54: }
55:
56: public ItsNatDocumentImpl getItsNatDocumentImpl() {
57: ItsNatDocumentImpl doc = (ItsNatDocumentImpl) itsNatDoc.get(); // Si devuelve null es que se ha sido garbage collected
58: if (doc == null)
59: return null;
60: // if (doc.isInvalid())
61: // return null; // No esperamos a que el objeto sea garbage collected, sabemos que ya no es válido (el usuario ha abandonado la página)
62: return doc;
63: }
64:
65: public String getObservedItsNatSessionId() {
66: // Sirve para saber cual era la sesión observada cuando documento cuando se pierde (para info de error)
67: return observedSessionId;
68: }
69:
70: public String getItsNatDocumentId() {
71: // Sirve para saber cual era el documento cuando se pierde (para info de error)
72: return docId;
73: }
74:
75: public void normalEventReceived() {
76: // Por defecto no hacer nada, sólo en caso de Comet
77: }
78:
79: }
|