KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > catalina > connector > CometEventImpl


1 /*
2  * Licensed to the Apache Software Foundation (ASF) under one or more
3  * contributor license agreements. See the NOTICE file distributed with
4  * this work for additional information regarding copyright ownership.
5  * The ASF licenses this file to You under the Apache License, Version 2.0
6  * (the "License"); you may not use this file except in compliance with
7  * the License. You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */

17
18
19 package org.apache.catalina.connector;
20
21 import java.io.IOException JavaDoc;
22
23 import javax.servlet.ServletException JavaDoc;
24 import javax.servlet.http.HttpServletRequest JavaDoc;
25 import javax.servlet.http.HttpServletResponse JavaDoc;
26
27 import org.apache.catalina.CometEvent;
28
29 public class CometEventImpl implements CometEvent {
30
31
32     public CometEventImpl(Request request, Response response) {
33         this.request = request;
34         this.response = response;
35     }
36
37
38     // ----------------------------------------------------- Instance Variables
39

40     
41     /**
42      * Associated request.
43      */

44     protected Request request = null;
45
46
47     /**
48      * Associated response.
49      */

50     protected Response response = null;
51
52     
53     /**
54      * Event type.
55      */

56     protected EventType eventType = EventType.BEGIN;
57     
58
59     /**
60      * Event sub type.
61      */

62     protected EventSubType eventSubType = null;
63     
64
65     // --------------------------------------------------------- Public Methods
66

67     /**
68      * Clear the event.
69      */

70     public void clear() {
71         request = null;
72         response = null;
73     }
74
75     public void setEventType(EventType eventType) {
76         this.eventType = eventType;
77     }
78     
79     public void setEventSubType(EventSubType eventSubType) {
80         this.eventSubType = eventSubType;
81     }
82     
83     public void close() throws IOException JavaDoc {
84         request.setComet(false);
85         response.finishResponse();
86     }
87
88     public EventSubType getEventSubType() {
89         return eventSubType;
90     }
91
92     public EventType getEventType() {
93         return eventType;
94     }
95
96     public HttpServletRequest JavaDoc getHttpServletRequest() {
97         return request.getRequest();
98     }
99
100     public HttpServletResponse JavaDoc getHttpServletResponse() {
101         return response.getResponse();
102     }
103
104     public void setTimeout(int timeout) throws IOException JavaDoc, ServletException JavaDoc,
105             UnsupportedOperationException JavaDoc {
106         if (request.getAttribute("org.apache.tomcat.comet.timeout.support") == Boolean.TRUE) {
107             request.setAttribute("org.apache.tomcat.comet.timeout", new Integer JavaDoc(timeout));
108         } else {
109             throw new UnsupportedOperationException JavaDoc();
110         }
111     }
112
113 }
114
Popular Tags