001: /*
002: ItsNat Java Web Application Framework
003: Copyright (C) 2007 Innowhere Software Services S.L., Spanish Company
004: Author: Jose Maria Arranz Santamaria
005:
006: This program is free software: you can redistribute it and/or modify
007: it under the terms of the GNU Affero General Public License as published by
008: the Free Software Foundation, either version 3 of the License, or
009: (at your option) any later version. See the GNU Affero General Public
010: License for more details. See the copy of the GNU Affero General Public License
011: included in this program. If not, see <http://www.gnu.org/licenses/>.
012: */
013:
014: package org.itsnat.core.event;
015:
016: /**
017: * This event object is sent to registered {@link RemoteControlEventListener} objects
018: * to notify the several phases of a remote control process using a timer or comet
019: * to notify the client any document change.
020: *
021: * @author Jose Maria Arranz Santamaria
022: */
023: public interface RemoteControlEvent extends ItsNatEvent {
024: /**
025: * Constant used to inform that an event is a new request to
026: * remote control a document.
027: *
028: * @see #getPhase()
029: */
030: public static final int REQUEST = 1;
031:
032: /**
033: * Constant used to inform that a remote control client document is being loaded.
034: *
035: * @see #getPhase()
036: */
037: public static final int LOAD = 2;
038:
039: /**
040: * Constant used to inform that an event has been received to refresh (update)
041: * the client with any document change.
042: *
043: * @see #getPhase()
044: */
045: public static final int REFRESH = 3;
046:
047: /**
048: * Constant used to inform that a remote control client document is being unloaded.
049: *
050: * @see #getPhase()
051: */
052: public static final int UNLOAD = 4;
053:
054: /**
055: * Constant used to inform that the remote controled document has been unloaded (is invalid).
056: *
057: * @see #getPhase()
058: */
059: public static final int OBSERVED_INVALID = 5;
060:
061: /**
062: * Returns the life cycle phase/notification type of this event.
063: *
064: * @return the phase or notification type.
065: * @see #REQUEST
066: * @see #LOAD
067: * @see #REFRESH
068: * @see #UNLOAD
069: * @see #OBSERVED_INVALID
070: */
071: public int getPhase();
072:
073: /**
074: * Returns true if this event request is accepted.
075: *
076: * <p>If this event is a new remote control
077: * request ({@link #REQUEST} phase) by default returns false
078: * otherwise returns true.</p>
079: *
080: * @return true if this request is accepted.
081: * @see #setAccepted(boolean)
082: */
083: public boolean isAccepted();
084:
085: /**
086: * Used to accept or deny a remote control request.
087: *
088: * <p>This method must be called with a true value to accept a new remote control request
089: * ({@link #REQUEST} phase), because by default ItsNat does not accept new remote control requests.
090: * </p>
091: *
092: * <p>If called with false informs ItsNat to deny a new remote control request or to end
093: * an already running remote control process.</p>
094: *
095: * @param accepted if set to false rejects or ends a new or existing remote control process.
096: */
097: public void setAccepted(boolean accepted);
098:
099: /**
100: * Returns the timeout of asynchronous AJAX events used for remote control. If this event is a {@link RemoteControlEvent#REQUEST}
101: * returned value may be used to validate the request.
102: *
103: * <p>Returned value is proposed initially by the client but can not change
104: * during the remote control life cycle.</p>
105: *
106: * @return the timeout of asynchronous AJAX events. If negative no timeout is defined.
107: * @see #setAccepted(boolean)
108: */
109: public long getAJAXTimeout();
110: }
|