ttomcat-1778514358873.zip-extract/apache-tomcat-11.0.18-src/webapps/examples/WEB-INF/classes/async/Async0.java

Path
ttomcat-1778514358873.zip-extract/apache-tomcat-11.0.18-src/webapps/examples/WEB-INF/classes/async/Async0.java
Status
scanned
Type
file
Name
Async0.java
Extension
.java
Programming language
Java
Mime type
text/plain
File type
Perl5 module source, ASCII text, with CRLF line terminators
Tag

      
    
Rootfs path

      
    
Size
2932 (2.9 KB)
MD5
93251b4a11c03c0495125f335732636f
SHA1
d8acc104789c9674230d539c7288806eaf194b2c
SHA256
06eb9d8a8d128ce4ddc44124a257fea78f946b826200948a1fee4660f13accfb
SHA512

      
    
SHA1_git
c08144e97ddfb73761f59cabf6e139de50270cb0
Is binary

      
    
Is text
True
Is archive

      
    
Is media

      
    
Is legal

      
    
Is manifest

      
    
Is readme

      
    
Is top level

      
    
Is key file

      
    
Async0.java | 2.9 KB |

/* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package async; import java.io.IOException; import java.text.SimpleDateFormat; import java.util.Date; import jakarta.servlet.AsyncContext; import jakarta.servlet.ServletException; import jakarta.servlet.http.HttpServlet; import jakarta.servlet.http.HttpServletRequest; import jakarta.servlet.http.HttpServletResponse; import org.apache.juli.logging.Log; import org.apache.juli.logging.LogFactory; public class Async0 extends HttpServlet { private static final long serialVersionUID = 1L; private static final Log log = LogFactory.getLog(Async0.class); @Override protected void service(final HttpServletRequest req, final HttpServletResponse resp) throws ServletException, IOException { if (Boolean.TRUE.equals(req.getAttribute("dispatch"))) { log.info("Received dispatch, completing on the worker thread."); log.info("After complete called started:"+req.isAsyncStarted()); Date date = new Date(System.currentTimeMillis()); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss Z"); resp.getWriter().write("Async dispatch worked: " + sdf.format(date) + " "); } else { resp.setContentType("text/plain"); final AsyncContext actx = req.startAsync(); actx.setTimeout(Long.MAX_VALUE); Runnable run = new Runnable() { @Override public void run() { try { req.setAttribute("dispatch", Boolean.TRUE); Thread.currentThread().setName("Async0-Thread"); log.info("Putting AsyncThread to sleep"); Thread.sleep(2*1000); log.info("Dispatching"); actx.dispatch(); }catch (InterruptedException | IllegalStateException x) { log.error("Async1",x); } } }; Thread t = new Thread(run); t.start(); } } }
Detected license expression
apache-2.0
Detected license expression (SPDX)
Apache-2.0
Percentage of license text
38.02
Copyrights

      
    
Holders

      
    
Authors

      
    
License detections License expression License expression SPDX
apache_2_0-4bde3f57-78aa-4201-96bf-531cba09e7de apache-2.0 Apache-2.0
URL Start line End line
http://www.apache.org/licenses/LICENSE-2.0 9 9