-
1. Re: Observes injection example from Weld SE app
swd847 Nov 18, 2009 1:42 AM (in response to asookazian)@Observes means that the method is being called by the container, ego there is no way for a user to pass in a value for hello, so the only thing that makes sense is for the container to inject it.
For more info have a look in the section on observer methods in the spec.
-
2. Re: Observes injection example from Weld SE app
asookazian Nov 18, 2009 3:07 AM (in response to asookazian)I would assume the RaiseEvent/Observe model here (like in Seam). So the question is whether or not the @Observes annotation is applied to one or more params (or all params) in the method? from below, sounds like just one param, so now I'm confused...
@Target(value=PARAMETER) @Retention(value=RUNTIME) @Documented public @interface Observes Identifies the event parameter of an observer method. May be applied to a parameter of a method of a bean class or extension. public void afterLogin(@Observes LoggedInEvent event) { ... } An observer method is a non-abstract method of a managed bean class or session bean class (or of an extension). An observer method may be either static or non-static. If the bean is a session bean, the observer method must be either a business method of the EJB or a static method of the bean class. Each observer method must have exactly one event parameter, of the same type as the event type it observes. Event qualifiers may be declared by annotating the event parameter. When searching for observer methods for an event, the container considers the type and qualifiers of the event parameter. If the event parameter does not explicitly declare any qualifier, the observer method observes events with no qualifier. The event parameter type may contain a type variable or wildcard. A bean (or extension) may declare multiple observer methods. Observer methods are inherited by bean subclasses. Interceptors and decorators may not declare observer methods.
http://docs.jboss.org/cdi/api/1.0/javax/enterprise/event/Observes.html
stop drinking and read the spec
btw, why this limitation?:
Interceptors and decorators may not declare observer methods
that would be interesting, no? -
3. Re: Observes injection example from Weld SE app
nickarls Nov 18, 2009 8:36 PM (in response to asookazian)@Observes is on the annotated param, there can be only one. Other params are injected.