openwebbeans-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From strub...@apache.org
Subject svn commit: r1640529 - /openwebbeans/trunk/samples/tomcat7-sample/src/main/java/org/apache/webbeans/samples/tomcat/InjectorServlet.java
Date Wed, 19 Nov 2014 11:34:46 GMT
Author: struberg
Date: Wed Nov 19 11:34:46 2014
New Revision: 1640529

URL: http://svn.apache.org/r1640529
Log:
improve our tomcat7 sample and insure CDI.current().getBeanManager() works properly

Modified:
    openwebbeans/trunk/samples/tomcat7-sample/src/main/java/org/apache/webbeans/samples/tomcat/InjectorServlet.java

Modified: openwebbeans/trunk/samples/tomcat7-sample/src/main/java/org/apache/webbeans/samples/tomcat/InjectorServlet.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/samples/tomcat7-sample/src/main/java/org/apache/webbeans/samples/tomcat/InjectorServlet.java?rev=1640529&r1=1640528&r2=1640529&view=diff
==============================================================================
--- openwebbeans/trunk/samples/tomcat7-sample/src/main/java/org/apache/webbeans/samples/tomcat/InjectorServlet.java
(original)
+++ openwebbeans/trunk/samples/tomcat7-sample/src/main/java/org/apache/webbeans/samples/tomcat/InjectorServlet.java
Wed Nov 19 11:34:46 2014
@@ -22,6 +22,7 @@ import java.io.IOException;
 import java.io.PrintWriter;
 
 import javax.enterprise.inject.spi.BeanManager;
+import javax.enterprise.inject.spi.CDI;
 import javax.inject.Inject;
 import javax.servlet.ServletException;
 import javax.servlet.http.HttpServlet;
@@ -39,6 +40,12 @@ public class InjectorServlet extends Htt
     @Override
     protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException,
IOException
     {
+        BeanManager bm = CDI.current().getBeanManager();
+        if (bm == null)
+        {
+            throw new IllegalArgumentException("CDI.current.getBeanManager() doesn't work!");
+        }
+
         PrintWriter writer = resp.getWriter();
         writer.write("==================Injection of Bean Instance into Servlet=================="
+ "\n\n");
         writer.write("Caller Principal name injection into DateProvider instance : " + dateProvider.getPrincipal().getName()
+ "\n\n");



Mime
View raw message