[
https://issues.apache.org/jira/browse/OWB-871?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13680365#comment-13680365
]
Reinis Vicups commented on OWB-871:
-----------------------------------
Ok I am closing this. As Romain said limitations come from the fact that CDI is
wrapped into EJB.
The specs state these requirements clearly,
here: http://docs.jboss.org/cdi/api/1.0/javax/enterprise/event/Observes.html
and here:
http://download.oracle.com/otn-pub/jcp/ejb-3.1-fr-eval-oth-JSpec/ejb-3_1-fr-spec.pdf?AuthParam=1370936040_b5be93809dfc37e6d0aa9256f6b4ee7c
(Page 49, and Page 123 onwards)
One final comment I would like to make is that I find the integration between
CDI and EJB in this scenario is unlucky. I couldn't understand why I get so
excited about this topic until I reflected on my intention and the way (I
think) the design should be.
I my particular case I have two different implementations of one ejb business
interfaces. One implementation requires observing (to follow up the changes of
underlying state), the other implementation is fire-and-forget implementation
and would not require no observation. Since CDI observer (as I understand it)
is not only about loose coupling but also about subcriber-principle I am
getting excited that I HAVE to publish observer method on business interface
thus I ENFORCE all the implementations to observe no matter if it is needed or
not.
Luckily, in my particular case, turning observer method into static does the
trick and I don't have to "polute" business interface but all in all I think
these constraints shouldn't be there for the sake of being able to have clean
design.
br
reinis
> WebbeansConfigurationException unless method is also declared in interface
> --------------------------------------------------------------------------
>
> Key: OWB-871
> URL: https://issues.apache.org/jira/browse/OWB-871
> Project: OpenWebBeans
> Issue Type: Bug
> Components: Events
> Affects Versions: 1.2.1
> Reporter: Reinis Vicups
> Attachments: observerininterface.zip
>
>
> In this scenario I receive WebbeansConfigurationException like this:
> SEVERE - CDI Beans module deployment failed
> org.apache.webbeans.exception.WebBeansConfigurationException: @Observes
> public void
> de.orbitx.observerininterface.BasicSchedulerWorkerManager.observerMethod(de.orbitx.observerininterface.SchedulerWorker)
> neither in the ejb view of ejb BasicSchedulerWorkerManager nor static
> at
> org.apache.openejb.cdi.CdiPlugin.validateObserverMethods(CdiPlugin.java:423)
> at
> org.apache.openejb.cdi.CdiPlugin.defineSessionBean(CdiPlugin.java:368)
> This happens ONLY if following is true (see attached foobar project):
> - Bean (BasicSchedulerWorkerManager) implements interface
> (SchedulerWorkerManager);
> - Bean is annotated as @javax.ejb.Singleton;
> - The observer method is not declared in the interface;
> If I remove @Singleton from BasicSchedulerWorkerManager, testcase passes.
> If I declare observerMethod in interface, testcase passes.
> Pay attention that Singleton is from javax.ejb (yes I need ejb singleton!)
> br
> reinis
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira