Author: nickarls
Date: 2010-03-23 08:56:37 -0400 (Tue, 23 Mar 2010)
New Revision: 12250
Added:
modules/servlet/trunk/src/main/java/org/jboss/seam/servlet/event/HttpParam.java
modules/servlet/trunk/src/main/resources/META-INF/
modules/servlet/trunk/src/main/resources/META-INF/beans.xml
Modified:
modules/servlet/trunk/src/main/java/org/jboss/seam/servlet/event/HttpManager.java
Log:
HttpManager + HttpParam concept testing
Modified:
modules/servlet/trunk/src/main/java/org/jboss/seam/servlet/event/HttpManager.java
===================================================================
---
modules/servlet/trunk/src/main/java/org/jboss/seam/servlet/event/HttpManager.java 2010-03-23
09:10:17 UTC (rev 12249)
+++
modules/servlet/trunk/src/main/java/org/jboss/seam/servlet/event/HttpManager.java 2010-03-23
12:56:37 UTC (rev 12250)
@@ -1,8 +1,10 @@
package org.jboss.seam.servlet.event;
-import javax.enterprise.context.SessionScoped;
+import javax.enterprise.context.RequestScoped;
import javax.enterprise.event.Observes;
+import javax.enterprise.inject.Produces;
import javax.enterprise.inject.spi.BeanManager;
+import javax.enterprise.inject.spi.InjectionPoint;
import javax.inject.Inject;
import javax.servlet.ServletContextAttributeEvent;
import javax.servlet.ServletRequestEvent;
@@ -24,16 +26,18 @@
* @author Nicklas Karlsson
*
*/
-@SessionScoped
+@RequestScoped
public class HttpManager
{
+ private static final long serialVersionUID = 5191073522575178427L;
+
private HttpSession session;
private HttpServletRequest request;
private BeanManager beanManager;
@Inject
private Logger log;
-
+
protected void requestInitialized(@Observes @Initialized ServletRequestEvent e)
{
log.trace("Servlet request initialized with event #0", e);
@@ -130,4 +134,11 @@
return beanManager;
}
+ @Produces
+ @HttpParam("")
+ String getParamValue(InjectionPoint ip)
+ {
+ return
getRequest().getParameter(ip.getAnnotated().getAnnotation(HttpParam.class).value());
+ }
+
}
Added: modules/servlet/trunk/src/main/java/org/jboss/seam/servlet/event/HttpParam.java
===================================================================
--- modules/servlet/trunk/src/main/java/org/jboss/seam/servlet/event/HttpParam.java
(rev 0)
+++
modules/servlet/trunk/src/main/java/org/jboss/seam/servlet/event/HttpParam.java 2010-03-23
12:56:37 UTC (rev 12250)
@@ -0,0 +1,27 @@
+package org.jboss.seam.servlet.event;
+
+import static java.lang.annotation.ElementType.FIELD;
+import static java.lang.annotation.ElementType.METHOD;
+import static java.lang.annotation.ElementType.PARAMETER;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+import javax.enterprise.util.Nonbinding;
+import javax.inject.Qualifier;
+
+/**
+ * Qualifies injection points that should have their values fetched from a HTTP request
attribute
+ *
+ * @author Nicklas Karlsson
+ *
+ */
+@Qualifier
+@Retention(RUNTIME)
+@Target( { FIELD, PARAMETER, METHOD })
+public @interface HttpParam
+{
+ @Nonbinding
+ public String value();
+}
\ No newline at end of file
Added: modules/servlet/trunk/src/main/resources/META-INF/beans.xml
===================================================================
Show replies by date