4 |
|
|
5 |
import java.io.IOException; |
import java.io.IOException; |
6 |
|
|
7 |
|
import javax.ejb.EJB; |
8 |
import javax.ejb.embeddable.EJBContainer; |
import javax.ejb.embeddable.EJBContainer; |
9 |
import javax.naming.Context; |
import javax.naming.Context; |
10 |
|
import javax.naming.InitialContext; |
11 |
import javax.naming.NamingException; |
import javax.naming.NamingException; |
12 |
import javax.servlet.ServletException; |
import javax.servlet.ServletException; |
13 |
import javax.servlet.annotation.WebServlet; |
import javax.servlet.annotation.WebServlet; |
17 |
|
|
18 |
|
|
19 |
|
|
20 |
|
@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; |
37 |
@Override |
@Override |
38 |
public void init() throws ServletException { |
public void init() throws ServletException { |
39 |
super.init(); |
super.init(); |
40 |
container = EJBContainer.createEJBContainer(); |
|
41 |
namingContext = container.getContext(); |
|
42 |
try { |
try { |
43 |
asyncBean = (AsyncEjb) namingContext.lookup("java:global/testApp/AsyncBean"); |
InitialContext ctx = new InitialContext(); |
44 |
|
|
45 |
|
asyncBean = (AsyncEjb) ctx.lookup("ejb/SimpleBeanJNDI"); |
46 |
|
//asyncBean = (AsyncEjb) namingContext.lookup("java:global/Test3/AsyncBean"); |
47 |
} catch (NamingException ne) { |
} catch (NamingException ne) { |
48 |
throw new ServletException(ne); |
throw new ServletException(ne); |
49 |
} |
} |
51 |
|
|
52 |
|
|
53 |
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { |
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { |
54 |
// TODO Auto-generated method stub |
response.getWriter().print("Started"); |
55 |
} |
} |
56 |
} |
} |