001: /* ====================================================================
002: The Jicarilla Software License
003:
004: Copyright (c) 2003 Leo Simons.
005: All rights reserved.
006:
007: Permission is hereby granted, free of charge, to any person obtaining
008: a copy of this software and associated documentation files (the
009: "Software"), to deal in the Software without restriction, including
010: without limitation the rights to use, copy, modify, merge, publish,
011: distribute, sublicense, and/or sell copies of the Software, and to
012: permit persons to whom the Software is furnished to do so, subject to
013: the following conditions:
014:
015: The above copyright notice and this permission notice shall be
016: included in all copies or substantial portions of the Software.
017:
018: THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
019: EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
020: MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
021: IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
022: CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
023: TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
024: SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
025: ==================================================================== */
026: package org.jicarilla.net;
027:
028: import org.jicarilla.lang.Recyclable;
029:
030: import java.nio.channels.SocketChannel;
031: import java.util.HashMap;
032: import java.util.Map;
033:
034: /**
035: * Represents a request/response pair.
036: *
037: * @author <a href="lsimons at jicarilla dot org">Leo Simons</a>
038: * @version $Id: Event.java,v 1.4 2004/03/23 13:37:48 lsimons Exp $
039: */
040: public class Event implements Recyclable {
041: // ----------------------------------------------------------------------
042: // Properties
043: // ----------------------------------------------------------------------
044: protected SocketChannel m_channel;
045: protected Map m_context;
046: protected Object m_request;
047: protected Object m_response;
048:
049: // ----------------------------------------------------------------------
050: // Constructors
051: // ----------------------------------------------------------------------
052: public Event() {
053: this (null);
054: }
055:
056: public Event(final SocketChannel channel) {
057: this (channel, new HashMap());
058: }
059:
060: public Event(final SocketChannel channel, final Map context) {
061: setContext(context);
062: setChannel(channel);
063: }
064:
065: // ----------------------------------------------------------------------
066: // Getters/Setters
067: // ----------------------------------------------------------------------
068: public SocketChannel getChannel() {
069: return m_channel;
070: }
071:
072: public void setChannel(final SocketChannel channel) {
073: m_channel = channel;
074: }
075:
076: public Object getRequest() {
077: return m_request;
078: }
079:
080: public void setRequest(final Object request) {
081: m_request = request;
082: }
083:
084: public Object getResponse() {
085: return m_response;
086: }
087:
088: public void setResponse(final Object response) {
089: m_response = response;
090: }
091:
092: public Map getContext() {
093: return m_context;
094: }
095:
096: public void setContext(final Map context) {
097: m_context = context;
098: }
099:
100: // ----------------------------------------------------------------------
101: // Work Interface: Recyclable
102: // ----------------------------------------------------------------------
103: public void recycle() {
104: m_channel = null;
105: m_context = new HashMap();
106: m_request = null;
107: m_response = null;
108: }
109: }
|