1 |
/* AsyncEjbServlet + Async Ejb - demonstrates how to use async. execution in java EE6 */ |
2 |
|
3 |
package dk.thoerup.asyncsamples; |
4 |
|
5 |
import java.io.IOException; |
6 |
|
7 |
import javax.ejb.embeddable.EJBContainer; |
8 |
import javax.naming.Context; |
9 |
import javax.naming.NamingException; |
10 |
import javax.servlet.ServletException; |
11 |
import javax.servlet.annotation.WebServlet; |
12 |
import javax.servlet.http.HttpServlet; |
13 |
import javax.servlet.http.HttpServletRequest; |
14 |
import javax.servlet.http.HttpServletResponse; |
15 |
|
16 |
|
17 |
|
18 |
@WebServlet(name = "AsyncEjbServlet", urlPatterns = { "/AsyncEjbServlet" }) |
19 |
public class AsyncEjbServlet extends HttpServlet { |
20 |
private static final long serialVersionUID = 1L; |
21 |
|
22 |
private EJBContainer container; |
23 |
private Context namingContext; |
24 |
private AsyncEjb asyncBean; |
25 |
|
26 |
|
27 |
public AsyncEjbServlet() { |
28 |
|
29 |
} |
30 |
|
31 |
|
32 |
|
33 |
|
34 |
@Override |
35 |
public void init() throws ServletException { |
36 |
super.init(); |
37 |
container = EJBContainer.createEJBContainer(); |
38 |
namingContext = container.getContext(); |
39 |
try { |
40 |
asyncBean = (AsyncEjb) namingContext.lookup("java:global/testApp/AsyncBean"); |
41 |
} catch (NamingException ne) { |
42 |
throw new ServletException(ne); |
43 |
} |
44 |
} |
45 |
|
46 |
|
47 |
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { |
48 |
// TODO Auto-generated method stub |
49 |
} |
50 |
} |