| 1 |
// |
| 2 |
// ======================================================================== |
| 3 |
// Copyright (c) 1995-2022 Mort Bay Consulting Pty Ltd and others. |
| 4 |
// ------------------------------------------------------------------------ |
| 5 |
// All rights reserved. This program and the accompanying materials |
| 6 |
// are made available under the terms of the Eclipse Public License v1.0 |
| 7 |
// and Apache License v2.0 which accompanies this distribution. |
| 8 |
// |
| 9 |
// The Eclipse Public License is available at |
| 10 |
// http://www.eclipse.org/legal/epl-v10.html |
| 11 |
// |
| 12 |
// The Apache License v2.0 is available at |
| 13 |
// http://www.opensource.org/licenses/apache2.0.php |
| 14 |
// |
| 15 |
// You may elect to redistribute this code under either of these licenses. |
| 16 |
// ======================================================================== |
| 17 |
// |
| 18 |
|
| 19 |
package org.eclipse.jetty.test; |
| 20 |
|
| 21 |
import java.io.IOException; |
| 22 |
import java.io.PrintWriter; |
| 23 |
import java.util.Set; |
| 24 |
import javax.enterprise.inject.Any; |
| 25 |
import javax.enterprise.inject.spi.Bean; |
| 26 |
import javax.enterprise.inject.spi.BeanManager; |
| 27 |
import javax.enterprise.inject.spi.InjectionPoint; |
| 28 |
import javax.enterprise.util.AnnotationLiteral; |
| 29 |
import javax.inject.Inject; |
| 30 |
import javax.servlet.annotation.WebServlet; |
| 31 |
import javax.servlet.http.HttpServlet; |
| 32 |
import javax.servlet.http.HttpServletRequest; |
| 33 |
import javax.servlet.http.HttpServletResponse; |
| 34 |
|
| 35 |
@WebServlet("/info") |
| 36 |
public class InfoServlet extends HttpServlet |
| 37 |
{ |
| 38 |
@Inject |
| 39 |
BeanManager beanManager; |
| 40 |
|
| 41 |
@Override |
| 42 |
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws IOException |
| 43 |
{ |
| 44 |
resp.setContentType("text/plain"); |
| 45 |
resp.setCharacterEncoding("utf-8"); |
| 46 |
|
| 47 |
PrintWriter out = resp.getWriter(); |
| 48 |
out.println("Bean Manager: " + beanManager); |
| 49 |
Set<Bean<?>> beans = beanManager.getBeans(Object.class, new AnnotationLiteral<Any>() {}); |
| 50 |
for (Bean<?> bean : beans) |
| 51 |
{ |
| 52 |
out.printf("%16s => %s%n", bean.getName(), bean); |
| 53 |
for (InjectionPoint ij : bean.getInjectionPoints()) |
| 54 |
{ |
| 55 |
out.printf("%16s -> %s%n", "", ij); |
| 56 |
} |
| 57 |
} |
| 58 |
} |
| 59 |
} |