[jboss-user] [JBoss Seam] - Re: Stateless Injection
ovidiucn
do-not-reply at jboss.com
Wed Jul 26 06:49:03 EDT 2006
Ok.
/* WEB-INF/classes/seam.properties exists & is empty */
/* service-security.jar#!seam.properties exists & is empty */
/* ejb-jar.xml */
| <ejb-jar>
| <assembly-descriptor>
| <interceptor-binding>
| <ejb-name>*</ejb-name>
| <interceptor-class>org.jboss.seam.ejb.SeamInterceptor</interceptor-class>
| </interceptor-binding>
| </assembly-descriptor>
| </ejb-jar>
|
/* WEB-INF/components.xml */
| <components>
| <component name="org.jboss.seam.core.init">
| <property name="debug">true</property>
| <property name="myFacesLifecycleBug">false</property>
| <property name="jndiPattern">emp/#{ejbName}/local</property>
| </component>
| <component class="org.jboss.seam.core.Microcontainer" installed="false"/>
| </components>
|
/* faces-config.xml snippet */
| <?xml version='1.1' encoding='UTF-8'?>
|
| <!DOCTYPE faces-config PUBLIC
| "-//Sun Microsystems, Inc.//DTD JavaServer Faces Config 1.1//EN"
| "http://java.sun.com/dtd/web-facesconfig_1_1.dtd">
|
| <faces-config>
| <lifecycle>
| <phase-listener>org.jboss.seam.jsf.SeamPhaseListener</phase-listener>
| </lifecycle>
| </faces-config>
|
/* web.xml snippet */
| <?xml version="1.0" encoding="UTF-8"?>
| <web-app version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee"
| xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
| xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
|
| <!-- Seam -->
| <listener>
| <listener-class>
| org.jboss.seam.servlet.SeamListener
| </listener-class>
| </listener>
|
| <!-- MyFaces -->
| <listener>
| <listener-class>
| org.apache.myfaces.webapp.StartupServletContextListener
| </listener-class>
| </listener>
|
| <!-- Faces Servlet -->
| <servlet>
| <servlet-name>Faces Servlet</servlet-name>
| <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
| <load-on-startup>1</load-on-startup>
| </servlet>
|
| <!-- Faces Servlet Mappings -->
| <servlet-mapping>
| <servlet-name>Faces Servlet</servlet-name>
| <url-pattern>*.xhtml</url-pattern>
| </servlet-mapping>
| </web-app>
|
/* code */
| /* local interface */
| @Local
| public interface UserManagementLocal {
| public Collection getUsers ();
| }
|
| /* business logic */
| @Name("userManagement")
| @Stateless
| public class UserManagement implements UserManagementLocal {
|
| /* The login context created when a user previously logged-in. */
| @In(value="loginContext", create=false, required=true)
| private LoginContext loginContext;
|
| @In (value="user", create=true, required=true)
| private User user;
|
| @In
| Context sessionContext;
|
| public Collection getUsers() {
| Collection users = new ArrayList ();
|
| /* user bean is null !!! */
| /* sessionContext is null !!! */
| /* the loginContext is null !!! */
|
| System.out.println("user: " + user);
| System.out.println("sessionContext: " + sessionContext);
| System.out.println("loginContext: " + loginContext);
|
| try {
| SecurityDataService sds = SecurityDataServiceFactory.getService(loginContext.getSub
| ject());
|
| Set attributeNames = new HashSet();
| users.addAll(sds.getAllUsers(attributeNames));
| } catch (SSDataManagementException e) {
| e.printStackTrace();
| users.clear();
| }
|
| return users;
| }
| }
|
Environment:
JRE 1.5.0_06
JBOSS Release ID: JBoss [Zion] 4.0.4.GA (build: CVSTag=JBoss_4_0_4_GA date=200605151000) - installed with JEMS & ejb3 configuration enabled
JBoss Seam 1.0.1.GA
MyFaces 1.1.3
Thanks!
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3960932#3960932
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3960932
More information about the jboss-user
mailing list