Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<blockquote> <p>Seam injects the Identity object from the SessionContext of the servlet that invokes the EJB and removes it after the call. Is this correct ?</p> </blockquote> <p>Yes, but do not forget you <strong>must</strong> enable EJB Seam interceptor See <a href="https://stackoverflow.com/questions/2404299/jboss-seam-components-injected-into-pojos-but-not-session-beans/2405022#2405022">here</a> how to</p> <p>...</p> <blockquote> <p>Is it now possible to access ANY EJB from another servlet</p> </blockquote> <p>Yes, you can use its Global JNDI (Vendor dependent) to retrieve it. See <a href="https://stackoverflow.com/questions/1473939/ejb-lookup-failing-with-namingexception/1496306#1496306">here</a> how you can set up and retrieve your EJB @State less / ful bean. If you have a <strong>fully</strong>-supported Java EE app server, You can retrieve it through annotations.</p> <blockquote> <p>Do I have to "inject" the correct Identity instance ?</p> </blockquote> <p>You do not have to worry about it. Seam EJB interceptor Takes care of it. Go ahead.</p> <p><strong>UPDATE</strong></p> <blockquote> <p>but in the EJB, two different instances of Identity are injected. I'm guessing the Session context that Seam is using is not correctly linked to the Session context of the servlet ? Any ideas ?</p> </blockquote> <p>Well, Identity component itself does not implement equals method which, by default, uses default equals implementation by using equals comparison (==). I do not know whether, for each EJB call, you have always a fresh Identity component (Maybe it explains why you have "Two different instances")</p> <p>If your Servlet's <strong>share The same context</strong>, you can enable IdentityFilter as a way to wrap your Identity assigned role by using <a href="http://java.sun.com/j2ee/1.4/docs/api/javax/servlet/http/HttpServletRequest.html#isUserInRole(java.lang.String)" rel="nofollow noreferrer">isUserInRole</a> method. Here goes its funcionality:</p> <blockquote> <p>A filter that provides integration between Servlet Security and the Seam identity component. This integration is accomplished by wrapping the HttpServletRequest with an HttpServletRequestWrapper implementation <strong>that delegates security-related calls to the Seam identity component</strong>.</p> </blockquote> <p><strong>If use use @Identity component, it is enabled by default</strong></p> <p>So instead of inject your EJB (And its @In-jected @Identity) and use</p> <pre><code>identity.hasRole("admin"); </code></pre> <p>You can use</p> <pre><code>request.hasUserInRole("admin"); </code></pre> <p>And maybe you want to see <a href="http://docs.jboss.org/seam/2.1.2/reference/en-US/html/remoting.html#d0e22629" rel="nofollow noreferrer">Setting and reading the Conversation ID</a> And <a href="http://docs.jboss.org/seam/2.1.2/reference/en-US/html/gwt.html" rel="nofollow noreferrer">Seam and GWT</a></p> <p>More</p> <p>The ContextFilter (not enabled by default) opens access to the Seam container and its context variables to non-JSF servlets, such as Struts, Spring MVC, and Direct Web Remoting (DWR). I do not know how to use this kind of funcionality.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload