本文整理汇总了Java中org.apache.catalina.comet.CometEvent类的典型用法代码示例。如果您正苦于以下问题:Java CometEvent类的具体用法?Java CometEvent怎么用?Java CometEvent使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
CometEvent类属于org.apache.catalina.comet包,在下文中一共展示了CometEvent类的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: sessionDestroyed
import org.apache.catalina.comet.CometEvent; //导入依赖的package包/类
@Override
public void sessionDestroyed(HttpSessionEvent se) {
// Close all Comet connections associated with this session
Request[] reqs = (Request[])
se.getSession().getAttribute(cometRequestsAttribute);
if (reqs != null) {
for (int i = 0; i < reqs.length; i++) {
Request req = reqs[i];
try {
CometEventImpl event = req.getEvent();
event.setEventType(CometEvent.EventType.END);
event.setEventSubType(CometEvent.EventSubType.SESSION_END);
((CometProcessor)
req.getWrapper().getServlet()).event(event);
event.close();
} catch (Exception e) {
req.getWrapper().getParent().getLogger().warn(sm.getString(
"cometConnectionManagerValve.listenerEvent"), e);
}
}
}
}
开发者ID:liaokailin,项目名称:tomcat7,代码行数:23,代码来源:CometConnectionManagerValve.java
示例2: sessionDestroyed
import org.apache.catalina.comet.CometEvent; //导入依赖的package包/类
@Override
public void sessionDestroyed(HttpSessionEvent se) {
// Close all Comet connections associated with this session
Request[] reqs = (Request[]) se.getSession().getAttribute(cometRequestsAttribute);
if (reqs != null) {
for (int i = 0; i < reqs.length; i++) {
Request req = reqs[i];
try {
CometEventImpl event = req.getEvent();
event.setEventType(CometEvent.EventType.END);
event.setEventSubType(CometEvent.EventSubType.SESSION_END);
((CometProcessor) req.getWrapper().getServlet()).event(event);
event.close();
} catch (Exception e) {
req.getWrapper().getParent().getLogger()
.warn(sm.getString("cometConnectionManagerValve.listenerEvent"), e);
}
}
}
}
开发者ID:how2j,项目名称:lazycat,代码行数:21,代码来源:CometConnectionManagerValve.java
示例3: begin
import org.apache.catalina.comet.CometEvent; //导入依赖的package包/类
protected void begin(@SuppressWarnings("unused") CometEvent event,
HttpServletRequest request, HttpServletResponse response)
throws IOException {
log("Begin for session: " + request.getSession(true).getId());
response.setContentType("text/html; charset=" + CHARSET);
PrintWriter writer = response.getWriter();
writer.println("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\" \"http://www.w3.org/TR/html4/loose.dtd\">");
writer.println("<html><head><title>JSP Chat</title></head><body bgcolor=\"#FFFFFF\">");
writer.println("<div>Welcome to the chat. <a href='chat'>Click here to reload this window</a></div>");
writer.flush();
synchronized(connections) {
connections.add(response);
}
messageSender.send("Tomcat", request.getSession(true).getAttribute("nickname") + " joined the chat.");
}
开发者ID:sunmingshuai,项目名称:apache-tomcat-7.0.73-with-comment,代码行数:20,代码来源:ChatServlet.java
示例4: read
import org.apache.catalina.comet.CometEvent; //导入依赖的package包/类
protected void read(CometEvent event, HttpServletRequest request, HttpServletResponse response)
throws IOException {
InputStream is = request.getInputStream();
byte[] buf = new byte[512];
while (is.available() > 0) {
log("Available: " + is.available());
int n = is.read(buf);
if (n > 0) {
log("Read " + n + " bytes: " + new String(buf, 0, n)
+ " for session: " + request.getSession(true).getId());
} else if (n < 0) {
log("End of file: " + n);
end(event, request, response);
return;
}
}
}
开发者ID:sunmingshuai,项目名称:apache-tomcat-7.0.73-with-comment,代码行数:18,代码来源:ChatServlet.java
示例5: read
import org.apache.catalina.comet.CometEvent; //导入依赖的package包/类
protected void read(CometEvent event, HttpServletRequest request, HttpServletResponse response)
throws IOException {
InputStream is = request.getInputStream();
byte[] buf = new byte[512];
while (is.available() > 0) {
log("Available: " + is.available());
int n = is.read(buf);
if (n > 0) {
log("Read " + n + " bytes: " + new String(buf, 0, n)
+ " for session: " + request.getSession(true).getId());
} else if (n < 0) {
log("End of file: " + n);
end(event, request, response);
return;
}
}
}
开发者ID:WhiteBearSolutions,项目名称:WBSAirback,代码行数:18,代码来源:ChatServlet.java
示例6: processCometEvent
import org.apache.catalina.comet.CometEvent; //导入依赖的package包/类
/**
* Perform the filtering that has been configured for this Filter, matching
* against the specified request property.
*
* @param property The property to check against the allow/deny rules
* @param event The comet event to be filtered
* @param chain The comet filter chain
* @exception IOException if an input/output error occurs
* @exception ServletException if a servlet error occurs
*/
protected void processCometEvent(String property, CometEvent event,
CometFilterChain chain) throws IOException, ServletException {
HttpServletResponse response = event.getHttpServletResponse();
if (isAllowed(property)) {
chain.doFilterEvent(event);
} else {
response.sendError(denyStatus);
event.close();
}
}
开发者ID:liaokailin,项目名称:tomcat7,代码行数:22,代码来源:RequestFilter.java
示例7: doFilterEvent
import org.apache.catalina.comet.CometEvent; //导入依赖的package包/类
@Override
public void doFilterEvent(CometEvent event, CometFilterChain chain)
throws IOException, ServletException {
if (event.getEventType() == CometEvent.EventType.BEGIN
&& !isGoodRequest(event.getHttpServletRequest())) {
event.getHttpServletResponse().sendError(
HttpServletResponse.SC_BAD_REQUEST);
event.close();
return;
}
chain.doFilterEvent(event);
}
开发者ID:liaokailin,项目名称:tomcat7,代码行数:13,代码来源:FailedRequestFilter.java
示例8: doFilterEvent
import org.apache.catalina.comet.CometEvent; //导入依赖的package包/类
/**
* Process the event, using the security manager if the option is enabled.
*
* @param event the event to process
*
* @exception IOException if an input/output error occurs
* @exception ServletException if a servlet exception occurs
*/
@Override
public void doFilterEvent(CometEvent event)
throws IOException, ServletException {
if( Globals.IS_SECURITY_ENABLED ) {
final CometEvent ev = event;
try {
java.security.AccessController.doPrivileged(
new java.security.PrivilegedExceptionAction<Void>() {
@Override
public Void run()
throws ServletException, IOException {
internalDoFilterEvent(ev);
return null;
}
}
);
} catch( PrivilegedActionException pe) {
Exception e = pe.getException();
if (e instanceof ServletException)
throw (ServletException) e;
else if (e instanceof IOException)
throw (IOException) e;
else if (e instanceof RuntimeException)
throw (RuntimeException) e;
else
throw new ServletException(e.getMessage(), e);
}
} else {
internalDoFilterEvent(event);
}
}
开发者ID:liaokailin,项目名称:tomcat7,代码行数:41,代码来源:ApplicationFilterChain.java
示例9: end
import org.apache.catalina.comet.CometEvent; //导入依赖的package包/类
protected void end(CometEvent event, HttpServletRequest request, HttpServletResponse response)
throws IOException {
log("End for session: " + request.getSession(true).getId());
synchronized(connections) {
connections.remove(response);
}
PrintWriter writer = response.getWriter();
writer.println("</body></html>");
event.close();
}
开发者ID:sunmingshuai,项目名称:apache-tomcat-7.0.73-with-comment,代码行数:13,代码来源:ChatServlet.java
示例10: error
import org.apache.catalina.comet.CometEvent; //导入依赖的package包/类
protected void error(CometEvent event, HttpServletRequest request, HttpServletResponse response)
throws IOException {
log("Error for session: " + request.getSession(true).getId());
synchronized(connections) {
connections.remove(response);
}
event.close();
}
开发者ID:sunmingshuai,项目名称:apache-tomcat-7.0.73-with-comment,代码行数:9,代码来源:ChatServlet.java
示例11: doFilterEvent
import org.apache.catalina.comet.CometEvent; //导入依赖的package包/类
@Override
public void doFilterEvent(CometEvent event, CometFilterChain chain) throws IOException, ServletException {
if (event.getEventType() == CometEvent.EventType.BEGIN && !isGoodRequest(event.getHttpServletRequest())) {
event.getHttpServletResponse().sendError(HttpServletResponse.SC_BAD_REQUEST);
event.close();
return;
}
chain.doFilterEvent(event);
}
开发者ID:how2j,项目名称:lazycat,代码行数:10,代码来源:FailedRequestFilter.java
示例12: doFilterEvent
import org.apache.catalina.comet.CometEvent; //导入依赖的package包/类
/**
* Process the event, using the security manager if the option is enabled.
*
* @param event
* the event to process
*
* @exception IOException
* if an input/output error occurs
* @exception ServletException
* if a servlet exception occurs
*/
@Override
public void doFilterEvent(CometEvent event) throws IOException, ServletException {
if (Globals.IS_SECURITY_ENABLED) {
final CometEvent ev = event;
try {
java.security.AccessController.doPrivileged(new java.security.PrivilegedExceptionAction<Void>() {
@Override
public Void run() throws ServletException, IOException {
internalDoFilterEvent(ev);
return null;
}
});
} catch (PrivilegedActionException pe) {
Exception e = pe.getException();
if (e instanceof ServletException)
throw (ServletException) e;
else if (e instanceof IOException)
throw (IOException) e;
else if (e instanceof RuntimeException)
throw (RuntimeException) e;
else
throw new ServletException(e.getMessage(), e);
}
} else {
internalDoFilterEvent(event);
}
}
开发者ID:how2j,项目名称:lazycat,代码行数:40,代码来源:ApplicationFilterChain.java
注:本文中的org.apache.catalina.comet.CometEvent类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论