17 |
|
|
18 |
|
|
19 |
|
|
20 |
@EJB(beanInterface=AsyncEjb.class,name="ejb/SimpleBeanJNDI") |
//@EJB(beanInterface=AsyncEjb.class,name="ejb/SimpleBeanJNDI") |
21 |
@WebServlet(name = "AsyncEjbServlet", urlPatterns = { "/AsyncEjbServlet" }) |
@WebServlet(name = "AsyncEjbServlet", urlPatterns = { "/AsyncEjbServlet" }) |
22 |
public class AsyncEjbServlet extends HttpServlet { |
public class AsyncEjbServlet extends HttpServlet { |
23 |
private static final long serialVersionUID = 1L; |
private static final long serialVersionUID = 1L; |
24 |
|
|
25 |
private EJBContainer container; |
//private EJBContainer container; |
26 |
private Context namingContext; |
//private Context namingContext; |
27 |
|
|
28 |
|
@EJB |
29 |
private AsyncEjb asyncBean; |
private AsyncEjb asyncBean; |
30 |
|
|
31 |
|
|
40 |
public void init() throws ServletException { |
public void init() throws ServletException { |
41 |
super.init(); |
super.init(); |
42 |
|
|
43 |
|
/* |
44 |
try { |
try { |
45 |
InitialContext ctx = new InitialContext(); |
InitialContext ctx = new InitialContext(); |
46 |
|
|
47 |
asyncBean = (AsyncEjb) ctx.lookup("ejb/SimpleBeanJNDI"); |
asyncBean = (AsyncEjb) ctx.lookup("ejb/SimpleBeanJNDI"); |
48 |
//asyncBean = (AsyncEjb) namingContext.lookup("java:global/Test3/AsyncBean"); |
asyncBean = (AsyncEjb) namingContext.lookup("java:global/Test3/AsyncBean"); |
49 |
} catch (NamingException ne) { |
} catch (NamingException ne) { |
50 |
throw new ServletException(ne); |
throw new ServletException(ne); |
51 |
} |
}*/ |
52 |
} |
} |
53 |
|
|
54 |
|
|
55 |
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { |
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { |
56 |
|
asyncBean.doWork(); |
57 |
response.getWriter().print("Started"); |
response.getWriter().print("Started"); |
58 |
} |
} |
59 |
} |
} |