Search in sources :

Example 1 with Any

use of jakarta.enterprise.inject.Any in project security by jakartaee.

the class BasicServlet2 method doGet.

@Override
public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
    System.out.println("Inside  BasicServlet ....." + "<BR>");
    response.getWriter().write("This is a servlet \n");
    try {
        BeanManager bm = CDI.current().getBeanManager();
        Set<Bean<?>> beans = bm.getBeans(HttpAuthenticationMechanism.class, new AnnotationLiteral<Any>() {
        });
        for (Bean<?> bean : beans) {
            response.getWriter().println("Class: " + bean.getBeanClass().getName());
            response.getWriter().println("Qualifier: " + split(bean.getQualifiers()));
            response.getWriter().println("Scope: " + bean.getScope().getSimpleName());
            response.getWriter().println("Have qualifier @Default: " + haveQualifierDefault(bean.getQualifiers()));
            response.getWriter().println("Have scope @ApplicationScoped: " + (bean.getScope() == ApplicationScoped.class));
        }
    } catch (Exception e) {
        throw new ServletException(e);
    }
}
Also used : ServletException(jakarta.servlet.ServletException) ApplicationScoped(jakarta.enterprise.context.ApplicationScoped) BeanManager(jakarta.enterprise.inject.spi.BeanManager) Any(jakarta.enterprise.inject.Any) IOException(java.io.IOException) ServletException(jakarta.servlet.ServletException) Bean(jakarta.enterprise.inject.spi.Bean)

Example 2 with Any

use of jakarta.enterprise.inject.Any in project security by jakartaee.

the class FormServlet2 method doGet.

@Override
public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
    System.out.println("Inside  FormServlet ....." + "<BR>");
    response.getWriter().write("This is a servlet \n");
    try {
        BeanManager bm = CDI.current().getBeanManager();
        Set<Bean<?>> beans = bm.getBeans(HttpAuthenticationMechanism.class, new AnnotationLiteral<Any>() {
        });
        for (Bean<?> bean : beans) {
            response.getWriter().println("Class: " + bean.getBeanClass().getName());
            response.getWriter().println("Types: " + bean.getTypes().toString());
            response.getWriter().println("Qualifier: " + split(bean.getQualifiers()));
            response.getWriter().println("Scope: " + bean.getScope().getSimpleName());
            response.getWriter().println("Have qualifier @Default: " + haveQualifierDefault(bean.getQualifiers()));
            response.getWriter().println("Have scope @ApplicationScoped: " + (bean.getScope() == ApplicationScoped.class));
        }
    } catch (Exception e) {
        throw new ServletException(e);
    }
}
Also used : ServletException(jakarta.servlet.ServletException) ApplicationScoped(jakarta.enterprise.context.ApplicationScoped) BeanManager(jakarta.enterprise.inject.spi.BeanManager) Any(jakarta.enterprise.inject.Any) IOException(java.io.IOException) ServletException(jakarta.servlet.ServletException) Bean(jakarta.enterprise.inject.spi.Bean)

Example 3 with Any

use of jakarta.enterprise.inject.Any in project security by jakartaee.

the class Servlet2 method doGet.

@Override
public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
    System.out.println("Inside  Servlet2 ....." + "<BR>");
    response.getWriter().write("This is a servlet \n");
    try {
        BeanManager bm = CDI.current().getBeanManager();
        Set<Bean<?>> beans = bm.getBeans(HttpAuthenticationMechanism.class, new AnnotationLiteral<Any>() {
        });
        for (Bean<?> bean : beans) {
            response.getWriter().println("Class: " + bean.getBeanClass().getName());
            response.getWriter().println("Types: " + bean.getTypes().toString());
            response.getWriter().println("Qualifier: " + split(bean.getQualifiers()));
            response.getWriter().println("Scope: " + bean.getScope().getSimpleName());
            response.getWriter().println("Have qualifier @Default: " + haveQualifierDefault(bean.getQualifiers()));
            response.getWriter().println("Have scope @ApplicationScoped: " + (bean.getScope() == ApplicationScoped.class));
        }
    } catch (Exception e) {
        throw new ServletException(e);
    }
}
Also used : ServletException(jakarta.servlet.ServletException) ApplicationScoped(jakarta.enterprise.context.ApplicationScoped) BeanManager(jakarta.enterprise.inject.spi.BeanManager) Any(jakarta.enterprise.inject.Any) IOException(java.io.IOException) ServletException(jakarta.servlet.ServletException) Bean(jakarta.enterprise.inject.spi.Bean)

Aggregations

ApplicationScoped (jakarta.enterprise.context.ApplicationScoped)3 Any (jakarta.enterprise.inject.Any)3 Bean (jakarta.enterprise.inject.spi.Bean)3 BeanManager (jakarta.enterprise.inject.spi.BeanManager)3 ServletException (jakarta.servlet.ServletException)3 IOException (java.io.IOException)3