[seam-commits] Seam SVN: r10830 - examples/trunk/seamspace/ejb-jar/src/main/java/org/jboss/seam/example/seamspace.

seam-commits at lists.jboss.org seam-commits at lists.jboss.org
Thu May 7 04:16:38 EDT 2009


Author: shane.bryzak at jboss.com
Date: 2009-05-07 04:16:38 -0400 (Thu, 07 May 2009)
New Revision: 10830

Removed:
   examples/trunk/seamspace/ejb-jar/src/main/java/org/jboss/seam/example/seamspace/Hash.java
   examples/trunk/seamspace/ejb-jar/src/main/java/org/jboss/seam/example/seamspace/HashGenerator.java
Modified:
   examples/trunk/seamspace/ejb-jar/src/main/java/org/jboss/seam/example/seamspace/AccountPermission.java
   examples/trunk/seamspace/ejb-jar/src/main/java/org/jboss/seam/example/seamspace/AuthenticationEvents.java
   examples/trunk/seamspace/ejb-jar/src/main/java/org/jboss/seam/example/seamspace/BlogAction.java
   examples/trunk/seamspace/ejb-jar/src/main/java/org/jboss/seam/example/seamspace/BlogComment.java
   examples/trunk/seamspace/ejb-jar/src/main/java/org/jboss/seam/example/seamspace/CommentAction.java
   examples/trunk/seamspace/ejb-jar/src/main/java/org/jboss/seam/example/seamspace/ContentAction.java
   examples/trunk/seamspace/ejb-jar/src/main/java/org/jboss/seam/example/seamspace/ContentServlet.java
   examples/trunk/seamspace/ejb-jar/src/main/java/org/jboss/seam/example/seamspace/FriendAction.java
   examples/trunk/seamspace/ejb-jar/src/main/java/org/jboss/seam/example/seamspace/FriendComment.java
   examples/trunk/seamspace/ejb-jar/src/main/java/org/jboss/seam/example/seamspace/ImagePermission.java
   examples/trunk/seamspace/ejb-jar/src/main/java/org/jboss/seam/example/seamspace/Member.java
   examples/trunk/seamspace/ejb-jar/src/main/java/org/jboss/seam/example/seamspace/MemberAccount.java
   examples/trunk/seamspace/ejb-jar/src/main/java/org/jboss/seam/example/seamspace/MemberBlog.java
   examples/trunk/seamspace/ejb-jar/src/main/java/org/jboss/seam/example/seamspace/MemberFriend.java
   examples/trunk/seamspace/ejb-jar/src/main/java/org/jboss/seam/example/seamspace/MemberImage.java
   examples/trunk/seamspace/ejb-jar/src/main/java/org/jboss/seam/example/seamspace/MemberRole.java
   examples/trunk/seamspace/ejb-jar/src/main/java/org/jboss/seam/example/seamspace/PictureAction.java
   examples/trunk/seamspace/ejb-jar/src/main/java/org/jboss/seam/example/seamspace/PictureSearch.java
   examples/trunk/seamspace/ejb-jar/src/main/java/org/jboss/seam/example/seamspace/ProfileAction.java
   examples/trunk/seamspace/ejb-jar/src/main/java/org/jboss/seam/example/seamspace/RegisterAction.java
Log:
get seamspace example compiling

Modified: examples/trunk/seamspace/ejb-jar/src/main/java/org/jboss/seam/example/seamspace/AccountPermission.java
===================================================================
--- examples/trunk/seamspace/ejb-jar/src/main/java/org/jboss/seam/example/seamspace/AccountPermission.java	2009-05-07 08:16:04 UTC (rev 10829)
+++ examples/trunk/seamspace/ejb-jar/src/main/java/org/jboss/seam/example/seamspace/AccountPermission.java	2009-05-07 08:16:38 UTC (rev 10830)
@@ -6,11 +6,11 @@
 import javax.persistence.GeneratedValue;
 import javax.persistence.Id;
 
-import org.jboss.seam.annotations.security.permission.PermissionAction;
-import org.jboss.seam.annotations.security.permission.PermissionDiscriminator;
-import org.jboss.seam.annotations.security.permission.PermissionRole;
-import org.jboss.seam.annotations.security.permission.PermissionTarget;
-import org.jboss.seam.annotations.security.permission.PermissionUser;
+import org.jboss.seam.security.annotations.permission.PermissionAction;
+import org.jboss.seam.security.annotations.permission.PermissionDiscriminator;
+import org.jboss.seam.security.annotations.permission.PermissionRole;
+import org.jboss.seam.security.annotations.permission.PermissionTarget;
+import org.jboss.seam.security.annotations.permission.PermissionUser;
 
 @Entity
 public class AccountPermission implements Serializable

Modified: examples/trunk/seamspace/ejb-jar/src/main/java/org/jboss/seam/example/seamspace/AuthenticationEvents.java
===================================================================
--- examples/trunk/seamspace/ejb-jar/src/main/java/org/jboss/seam/example/seamspace/AuthenticationEvents.java	2009-05-07 08:16:04 UTC (rev 10829)
+++ examples/trunk/seamspace/ejb-jar/src/main/java/org/jboss/seam/example/seamspace/AuthenticationEvents.java	2009-05-07 08:16:38 UTC (rev 10830)
@@ -1,16 +1,14 @@
 package org.jboss.seam.example.seamspace;
 
-import org.jboss.seam.annotations.Name;
-import org.jboss.seam.annotations.Observer;
-import org.jboss.seam.contexts.Contexts;
-import org.jboss.seam.security.management.JpaIdentityStore;
+import javax.event.Observes;
 
- at Name("authenticationEvents")
+import org.jboss.seam.security.events.UserAuthenticatedEvent;
+
 public class AuthenticationEvents
 {
-   @Observer(JpaIdentityStore.EVENT_USER_AUTHENTICATED)
-   public void loginSuccessful(MemberAccount account)
+   public void loginSuccessful(@Observes UserAuthenticatedEvent event)
    {
-      Contexts.getSessionContext().set("authenticatedMember", account.getMember());
+      //FIXME
+      //Contexts.getSessionContext().set("authenticatedMember", account.getMember());
    }
 }

Modified: examples/trunk/seamspace/ejb-jar/src/main/java/org/jboss/seam/example/seamspace/BlogAction.java
===================================================================
--- examples/trunk/seamspace/ejb-jar/src/main/java/org/jboss/seam/example/seamspace/BlogAction.java	2009-05-07 08:16:04 UTC (rev 10829)
+++ examples/trunk/seamspace/ejb-jar/src/main/java/org/jboss/seam/example/seamspace/BlogAction.java	2009-05-07 08:16:38 UTC (rev 10830)
@@ -1,62 +1,44 @@
 package org.jboss.seam.example.seamspace;
 
-import static org.jboss.seam.ScopeType.CONVERSATION;
-
 import java.util.ArrayList;
 import java.util.Date;
 
+import javax.annotation.Named;
+import javax.context.Conversation;
+import javax.context.ConversationScoped;
+import javax.inject.Current;
+import javax.inject.Produces;
 import javax.persistence.EntityManager;
-import javax.persistence.NoResultException;
 
-import org.jboss.seam.annotations.Begin;
-import org.jboss.seam.annotations.End;
-import org.jboss.seam.annotations.Factory;
-import org.jboss.seam.annotations.In;
-import org.jboss.seam.annotations.Name;
-import org.jboss.seam.annotations.Out;
-import org.jboss.seam.annotations.Scope;
-
- at Scope(CONVERSATION)
- at Name("blog")
+ at Named("blog")
+ at ConversationScoped
 public class BlogAction
 {    
    private String name;   
    private Integer blogId;
    
-   @In
-   private EntityManager entityManager;
+   @Current EntityManager entityManager;
    
-   @In(required = false) @Out(required = false)
+   @Current Member authenticatedMember;
+   @Current Conversation conversation;
+   
    private MemberBlog selectedBlog;
    
-   @In(required = false)
-   private Member authenticatedMember;
-   
-   /**
-    * Used to read a single blog entry for a member
-    */
-   @Factory("selectedBlog") 
-   @Begin(join=true)
-   public void getBlog()
+   public @Produces MemberBlog getBlog()
    {     
-      try
-      {
-         selectedBlog = (MemberBlog) entityManager.createQuery(
-           "from MemberBlog b where b.blogId = :blogId and b.member.memberName = :memberName")
-           .setParameter("blogId", blogId)
-           .setParameter("memberName", name)
-           .getSingleResult();
-      }
-      catch (NoResultException ex) { }
+      return (MemberBlog) entityManager.createQuery(
+        "from MemberBlog b where b.blogId = :blogId and b.member.memberName = :memberName")
+        .setParameter("blogId", blogId)
+        .setParameter("memberName", name)
+        .getSingleResult();
    }   
    
-   @Begin
    public void createEntry()
    {
+      conversation.begin();
       selectedBlog = new MemberBlog();              
    }
    
-   @End
    public void saveEntry()
    {
       selectedBlog.setMember(authenticatedMember);
@@ -64,6 +46,7 @@
       selectedBlog.setComments(new ArrayList<BlogComment>());
       
       entityManager.persist(selectedBlog);
+      conversation.end();
    }
    
    public String getName()

Modified: examples/trunk/seamspace/ejb-jar/src/main/java/org/jboss/seam/example/seamspace/BlogComment.java
===================================================================
--- examples/trunk/seamspace/ejb-jar/src/main/java/org/jboss/seam/example/seamspace/BlogComment.java	2009-05-07 08:16:04 UTC (rev 10829)
+++ examples/trunk/seamspace/ejb-jar/src/main/java/org/jboss/seam/example/seamspace/BlogComment.java	2009-05-07 08:16:38 UTC (rev 10830)
@@ -10,12 +10,9 @@
 import javax.persistence.JoinColumn;
 import javax.persistence.ManyToOne;
 import javax.persistence.Transient;
+import javax.validation.constraints.NotNull;
 
-import org.hibernate.validator.NotNull;
-import org.jboss.seam.annotations.Name;
-
 @Entity
- at Name("blogComment")
 public class BlogComment implements Serializable
 {
    private static final long serialVersionUID = 5495139096911872039L;

Modified: examples/trunk/seamspace/ejb-jar/src/main/java/org/jboss/seam/example/seamspace/CommentAction.java
===================================================================
--- examples/trunk/seamspace/ejb-jar/src/main/java/org/jboss/seam/example/seamspace/CommentAction.java	2009-05-07 08:16:04 UTC (rev 10829)
+++ examples/trunk/seamspace/ejb-jar/src/main/java/org/jboss/seam/example/seamspace/CommentAction.java	2009-05-07 08:16:38 UTC (rev 10830)
@@ -1,38 +1,35 @@
 package org.jboss.seam.example.seamspace;
 
-import static org.jboss.seam.ScopeType.CONVERSATION;
-
 import java.util.Date;
 
+import javax.annotation.Named;
+import javax.context.Conversation;
+import javax.context.ConversationScoped;
+import javax.inject.Current;
 import javax.persistence.EntityManager;
 
-import org.jboss.seam.annotations.Begin;
-import org.jboss.seam.annotations.In;
-import org.jboss.seam.annotations.Name;
-import org.jboss.seam.annotations.Scope;
-import org.jboss.seam.annotations.Transactional;
-import org.jboss.seam.annotations.security.Insert;
-import org.jboss.seam.core.Conversation;
+import org.jboss.seam.security.Secure;
+import org.jboss.seam.security.annotations.Insert;
 
- at Scope(CONVERSATION)
- at Name("commentAction")
- at Transactional
+ at Named
+ at ConversationScoped
+ at Secure
 public class CommentAction 
 {
-   @In
-   private EntityManager entityManager;
+   @Current EntityManager entityManager;
    
    private BlogComment comment;     
    
-   @In(required = false)
-   private Member authenticatedMember;
+   @Current Member authenticatedMember;
    
-   @In(required = false)
-   private MemberBlog selectedBlog;
+   @Current MemberBlog selectedBlog;
    
-   @Begin(nested = true) @Insert(BlogComment.class) 
+   @Current Conversation conversation;
+   
+   @Insert(BlogComment.class) 
    public void createComment()
-   {            
+   { 
+      conversation.begin();
       comment = new BlogComment();
       comment.setCommentor(authenticatedMember);              
       comment.setBlog(selectedBlog);
@@ -45,7 +42,7 @@
             
       entityManager.refresh(selectedBlog);
       
-      Conversation.instance().end();
+      conversation.end();
    }    
    
    public BlogComment getComment()

Modified: examples/trunk/seamspace/ejb-jar/src/main/java/org/jboss/seam/example/seamspace/ContentAction.java
===================================================================
--- examples/trunk/seamspace/ejb-jar/src/main/java/org/jboss/seam/example/seamspace/ContentAction.java	2009-05-07 08:16:04 UTC (rev 10829)
+++ examples/trunk/seamspace/ejb-jar/src/main/java/org/jboss/seam/example/seamspace/ContentAction.java	2009-05-07 08:16:38 UTC (rev 10830)
@@ -1,25 +1,22 @@
 package org.jboss.seam.example.seamspace;
 
-import static org.jboss.seam.ScopeType.STATELESS;
-
+import javax.annotation.Named;
+import javax.inject.Current;
 import javax.persistence.EntityManager;
 
-import org.jboss.seam.annotations.In;
-import org.jboss.seam.annotations.Name;
-import org.jboss.seam.annotations.Scope;
 import org.jboss.seam.security.Identity;
 
- at Scope(STATELESS)
- at Name("contentAction")
+ at Named
 public class ContentAction
 {
-   @In EntityManager entityManager;   
+   @Current EntityManager entityManager;
+   @Current Identity identity;
    
    public MemberImage getImage(int imageId)
    {
       MemberImage img = entityManager.find(MemberImage.class, imageId);
       
-      if (img == null || !Identity.instance().hasPermission(img, "view"))
+      if (img == null || !identity.hasPermission(img, "view"))
          return null;
       else
          return img;

Modified: examples/trunk/seamspace/ejb-jar/src/main/java/org/jboss/seam/example/seamspace/ContentServlet.java
===================================================================
--- examples/trunk/seamspace/ejb-jar/src/main/java/org/jboss/seam/example/seamspace/ContentServlet.java	2009-05-07 08:16:04 UTC (rev 10829)
+++ examples/trunk/seamspace/ejb-jar/src/main/java/org/jboss/seam/example/seamspace/ContentServlet.java	2009-05-07 08:16:38 UTC (rev 10830)
@@ -7,25 +7,28 @@
 import java.io.IOException;
 import java.io.InputStream;
 
+import javax.context.RequestScoped;
 import javax.imageio.ImageIO;
+import javax.inject.Current;
 import javax.servlet.ServletException;
 import javax.servlet.http.HttpServlet;
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 import javax.swing.ImageIcon;
 
-import org.jboss.seam.Component;
-
 /**
  * Serves images and other member content
  * 
  * @author Shane Bryzak
  */
+ at RequestScoped
 public class ContentServlet extends HttpServlet
 {
    private static final long serialVersionUID = -8461940507242022217L;
 
    private static final String IMAGES_PATH = "/images";
+   
+   @Current ContentAction contentAction;
 
    /**
     * The maximum width allowed for image rescaling
@@ -63,8 +66,6 @@
    {
       if (IMAGES_PATH.equals(request.getPathInfo()))
       {
-         ContentAction contentAction = (ContentAction) Component.getInstance(ContentAction.class);
-
          String id = request.getParameter("id");
          MemberImage mi = (id != null && !"".equals(id)) ? 
                contentAction.getImage(Integer.parseInt(id)) : null;

Modified: examples/trunk/seamspace/ejb-jar/src/main/java/org/jboss/seam/example/seamspace/FriendAction.java
===================================================================
--- examples/trunk/seamspace/ejb-jar/src/main/java/org/jboss/seam/example/seamspace/FriendAction.java	2009-05-07 08:16:04 UTC (rev 10829)
+++ examples/trunk/seamspace/ejb-jar/src/main/java/org/jboss/seam/example/seamspace/FriendAction.java	2009-05-07 08:16:38 UTC (rev 10830)
@@ -1,79 +1,70 @@
 package org.jboss.seam.example.seamspace;
 
-import static org.jboss.seam.ScopeType.CONVERSATION;
-
 import java.io.Serializable;
 import java.util.Date;
 
-import javax.ejb.Remove;
+import javax.annotation.Named;
+import javax.context.Conversation;
+import javax.context.ConversationScoped;
+import javax.inject.Current;
+import javax.inject.Produces;
 import javax.persistence.EntityManager;
 import javax.persistence.NoResultException;
 
-import org.jboss.seam.annotations.Begin;
-import org.jboss.seam.annotations.Destroy;
-import org.jboss.seam.annotations.End;
-import org.jboss.seam.annotations.Factory;
-import org.jboss.seam.annotations.In;
-import org.jboss.seam.annotations.Name;
-import org.jboss.seam.annotations.Out;
-import org.jboss.seam.annotations.Scope;
-import org.jboss.seam.annotations.web.RequestParameter;
-import org.jboss.seam.contexts.Contexts;
-import org.jboss.seam.faces.FacesMessages;
+import org.jboss.seam.international.StatusMessages;
 import org.jboss.seam.security.Identity;
 
- at Scope(CONVERSATION)
- at Name("friendAction")
+ at Named
+ at ConversationScoped
 public class FriendAction implements Serializable
 {
    private static final long serialVersionUID = 4565339001481077911L;
 
-   @RequestParameter("name")
+   // @RequestParameter("name")
    private String name;
+     
+   @Current Member authenticatedMember;
+      
+   @Current EntityManager entityManager;
+   @Current Identity identity;
+   @Current StatusMessages messages;
+   @Current Conversation conversation;
    
-   @Out(required = false)
-   private FriendComment friendComment;
-   
-   @Out(required = false)
-   private MemberFriend friendRequest;
-   
-   @In(required = false)
-   private Member authenticatedMember;
+   FriendComment friendComment;
+   MemberFriend friendRequest;
       
-   @In
-   private EntityManager entityManager;
-      
-   @Factory("friendComment") @Begin
-   public void createComment()
+   public @Produces @Named FriendComment createComment()
    {      
       try
       {
+         conversation.begin();
          Member member = (Member) entityManager.createQuery(
          "from Member where memberName = :memberName")
          .setParameter("memberName", name)
          .getSingleResult();
                   
-         Contexts.getMethodContext().set("friends", member.getFriends());
-         Identity.instance().checkPermission(member, "createFriendComment");
+         // Contexts.getMethodContext().set("friends", member.getFriends());
+         identity.checkPermission(member, "createFriendComment");
 
          friendComment = new FriendComment();
          friendComment.setFriend(authenticatedMember);
          friendComment.setMember(member);
+         return friendComment;
       }
       catch (NoResultException ex) 
       { 
-         FacesMessages.instance().add("Member not found.");
+         messages.add("Member not found.");
+         throw ex;
       }
    }
    
-   @End
    public void saveComment()
    {
       friendComment.setCommentDate(new Date());
       entityManager.persist(friendComment);
+      conversation.end();
    }
    
-   @Factory("friendRequest") @Begin
    public void createRequest()
    {
       try
@@ -83,8 +74,8 @@
          .setParameter("memberName", name)
          .getSingleResult();
                   
-         Contexts.getMethodContext().set("friends", member.getFriends());
-         Identity.instance().checkPermission(member, "createFriendRequest");
+         // Contexts.getMethodContext().set("friends", member.getFriends());
+         identity.checkPermission(member, "createFriendRequest");
 
          friendRequest = new MemberFriend();
          friendRequest.setFriend(authenticatedMember);
@@ -92,17 +83,15 @@
       }
       catch (NoResultException ex) 
       { 
-         FacesMessages.instance().add("Member not found.");
+         messages.add("Member not found.");
       }
    }
 
-   @End
    public void saveRequest()
    {
       friendRequest.getMember().getFriends().add(friendRequest);
-      entityManager.persist(friendRequest);      
+      entityManager.persist(friendRequest);
+      conversation.end();
    }
    
-   @Remove @Destroy
-   public void destroy() { }    
 }

Modified: examples/trunk/seamspace/ejb-jar/src/main/java/org/jboss/seam/example/seamspace/FriendComment.java
===================================================================
--- examples/trunk/seamspace/ejb-jar/src/main/java/org/jboss/seam/example/seamspace/FriendComment.java	2009-05-07 08:16:04 UTC (rev 10829)
+++ examples/trunk/seamspace/ejb-jar/src/main/java/org/jboss/seam/example/seamspace/FriendComment.java	2009-05-07 08:16:38 UTC (rev 10830)
@@ -11,10 +11,7 @@
 import javax.persistence.ManyToOne;
 import javax.persistence.Transient;
 
-import org.jboss.seam.annotations.Name;
-
 @Entity
- at Name("friendComment")
 public class FriendComment implements Serializable
 {
    private static final long serialVersionUID = -288494386341008371L;

Deleted: examples/trunk/seamspace/ejb-jar/src/main/java/org/jboss/seam/example/seamspace/Hash.java
===================================================================
--- examples/trunk/seamspace/ejb-jar/src/main/java/org/jboss/seam/example/seamspace/Hash.java	2009-05-07 08:16:04 UTC (rev 10829)
+++ examples/trunk/seamspace/ejb-jar/src/main/java/org/jboss/seam/example/seamspace/Hash.java	2009-05-07 08:16:38 UTC (rev 10830)
@@ -1,45 +0,0 @@
-package org.jboss.seam.example.seamspace;
-
-import java.security.MessageDigest;
-
-import org.jboss.seam.Component;
-import org.jboss.seam.annotations.Name;
-import org.jboss.seam.util.Hex;
-
- at Name("hash")
-public class Hash {
-    String hashFunction = "MD5";
-    String charset      = "UTF-8";
-    
-    public String hash(String password) {
-        try {
-            MessageDigest md = MessageDigest.getInstance(hashFunction);
-            md.update(password.getBytes(charset));
-            byte[] raw = md.digest();
-            return new String(Hex.encodeHex(raw));
-        } 
-        catch (Exception e) {
-            throw new RuntimeException(e);        
-        }
-    }
-
-    public String getCharset() {
-        return charset;
-    }
-
-    public void setCharset(String charset) {
-        this.charset = charset;
-    }
-
-    public String getHashFunction() {
-        return hashFunction;
-    }
-
-    public void setHashFunction(String hashFunction) {
-        this.hashFunction = hashFunction;
-    }    
-    
-    public static Hash instance() {
-        return (Hash) Component.getInstance(Hash.class);
-    }
-}

Deleted: examples/trunk/seamspace/ejb-jar/src/main/java/org/jboss/seam/example/seamspace/HashGenerator.java
===================================================================
--- examples/trunk/seamspace/ejb-jar/src/main/java/org/jboss/seam/example/seamspace/HashGenerator.java	2009-05-07 08:16:04 UTC (rev 10829)
+++ examples/trunk/seamspace/ejb-jar/src/main/java/org/jboss/seam/example/seamspace/HashGenerator.java	2009-05-07 08:16:38 UTC (rev 10830)
@@ -1,78 +0,0 @@
-package org.jboss.seam.example.seamspace;
-
-import org.jboss.seam.ScopeType;
-import org.jboss.seam.annotations.In;
-import org.jboss.seam.annotations.Name;
-import org.jboss.seam.annotations.Scope;
-import org.jboss.seam.security.crypto.BinTools;
-import org.jboss.seam.security.management.JpaIdentityStore;
-import org.jboss.seam.security.management.PasswordHash;
-
- at Scope(ScopeType.EVENT)
- at Name("hashgenerator")
-public class HashGenerator
-{
-   @In JpaIdentityStore identityStore;
-   
-   private String password;
-   private String passwordHash;
-   private String passwordSalt;
-   
-   public String getPassword()
-   {
-      return password;
-   }
-   
-   public void setPassword(String password)
-   {
-      this.password = password;
-   }
-   
-   public String getPasswordHash()
-   {
-      return passwordHash;
-   }
-   
-   public void setPasswordHash(String passwordHash)
-   {
-      this.passwordHash = passwordHash;
-   }
-   
-   public String getPasswordSalt()
-   {
-      return passwordSalt;
-   }
-   
-   public void setPasswordSalt(String passwordSalt)
-   {
-      this.passwordSalt = passwordSalt;
-   }
-   
-   public void generate()
-   {
-      byte[] salt;
-      
-      if (passwordSalt == null || "".equals(passwordSalt.trim()))
-      {
-         salt = PasswordHash.instance().generateRandomSalt();
-         passwordSalt = BinTools.bin2hex(salt);
-      }
-      else
-      {
-         salt = BinTools.hex2bin(passwordSalt);
-      }
-      
-      passwordHash = identityStore.generatePasswordHash(password, salt);
-   }
-   
-   public String getSql()
-   {
-      StringBuilder sb = new StringBuilder();
-      sb.append("INSERT INTO USER_ACCOUNT (username, password_hash, password_salt) values ('johnsmith', '");
-      sb.append(passwordHash);
-      sb.append("', '");
-      sb.append(passwordSalt);
-      sb.append("');");      
-      return sb.toString();
-   }
-}

Modified: examples/trunk/seamspace/ejb-jar/src/main/java/org/jboss/seam/example/seamspace/ImagePermission.java
===================================================================
--- examples/trunk/seamspace/ejb-jar/src/main/java/org/jboss/seam/example/seamspace/ImagePermission.java	2009-05-07 08:16:04 UTC (rev 10829)
+++ examples/trunk/seamspace/ejb-jar/src/main/java/org/jboss/seam/example/seamspace/ImagePermission.java	2009-05-07 08:16:38 UTC (rev 10830)
@@ -1,20 +1,17 @@
 package org.jboss.seam.example.seamspace;
 
-import static org.jboss.seam.ScopeType.CONVERSATION;
-
 import java.io.Serializable;
 import java.security.Principal;
 import java.util.ArrayList;
 import java.util.List;
 
+import javax.annotation.Named;
+import javax.context.Conversation;
+import javax.context.ConversationScoped;
+import javax.inject.Current;
 import javax.persistence.EntityManager;
 
-import org.jboss.seam.annotations.Begin;
-import org.jboss.seam.annotations.In;
-import org.jboss.seam.annotations.Name;
-import org.jboss.seam.annotations.Scope;
-import org.jboss.seam.core.Conversation;
-import org.jboss.seam.faces.FacesMessages;
+import org.jboss.seam.international.StatusMessages;
 import org.jboss.seam.security.Role;
 import org.jboss.seam.security.SimplePrincipal;
 import org.jboss.seam.security.management.IdentityManager;
@@ -22,8 +19,8 @@
 import org.jboss.seam.security.permission.PermissionManager;
 import org.jboss.seam.security.permission.action.PermissionSearch;
 
- at Name("imagePermission")
- at Scope(CONVERSATION)
+ at Named
+ at ConversationScoped
 public class ImagePermission implements Serializable
 {
    private static final long serialVersionUID = -4943654157860780587L;
@@ -36,21 +33,23 @@
    
    private List<Member> availableFriends;   
    
-   @In IdentityManager identityManager;
-   @In PermissionManager permissionManager;
+   @Current IdentityManager identityManager;
+   @Current PermissionManager permissionManager;
    
-   @In EntityManager entityManager;
+   @Current EntityManager entityManager;
    
-   @In PermissionSearch permissionSearch;   
+   @Current PermissionSearch permissionSearch;
+   @Current Conversation conversation;
+   @Current StatusMessages messages;
    
    private MemberImage target; 
    
    private Principal recipient;
    
    @SuppressWarnings("unchecked")
-   @Begin(nested = true)
    public void createPermission()
    {
+      conversation.begin();
       target = (MemberImage) permissionSearch.getTarget();
       
       selectedFriends = new ArrayList<Member>();
@@ -61,9 +60,9 @@
             .getResultList();      
    }
    
-   @Begin(nested = true)
    public void editPermission()
    {
+      conversation.begin();
       target = (MemberImage) permissionSearch.getTarget();
       recipient = permissionSearch.getSelectedRecipient();
             
@@ -147,7 +146,7 @@
       {
          if (selectedActions.size() == 0)
          {
-            FacesMessages.instance().add("You must select at least one action");
+            messages.add("You must select at least one action");
             return "failure";
          }
          
@@ -179,7 +178,7 @@
          
          permissionManager.grantPermissions(permissions);
       }
-      Conversation.instance().endBeforeRedirect();
+      conversation.end();
       return "success";
    }
    

Modified: examples/trunk/seamspace/ejb-jar/src/main/java/org/jboss/seam/example/seamspace/Member.java
===================================================================
--- examples/trunk/seamspace/ejb-jar/src/main/java/org/jboss/seam/example/seamspace/Member.java	2009-05-07 08:16:04 UTC (rev 10829)
+++ examples/trunk/seamspace/ejb-jar/src/main/java/org/jboss/seam/example/seamspace/Member.java	2009-05-07 08:16:38 UTC (rev 10830)
@@ -16,20 +16,17 @@
 import javax.persistence.Table;
 import javax.persistence.Transient;
 import javax.persistence.UniqueConstraint;
+import javax.validation.constraints.NotNull;
+import javax.validation.constraints.Min;
+import javax.validation.constraints.Max;
+import javax.validation.constraints.Pattern;
 
-import org.hibernate.validator.Email;
-import org.hibernate.validator.Length;
-import org.hibernate.validator.NotNull;
-import org.hibernate.validator.Pattern;
-import org.jboss.seam.annotations.Name;
-
 /**
  * A member account
  * 
  * @author Shane Bryzak
  */
 @Entity
- at Name("member")
 @Table(uniqueConstraints = @UniqueConstraint(columnNames = "membername"))
 public class Member implements Serializable
 {
@@ -83,8 +80,9 @@
    }
    
    @NotNull
-   @Length(min = 3, max = 40)
-   @Pattern(regex="[a-zA-Z]?[a-zA-Z0-9_]+", 
+   @Min(3)
+   @Max(40)
+   @Pattern(regexp="[a-zA-Z]?[a-zA-Z0-9_]+", 
          message="Member name must start with a letter, and only contain letters, numbers or underscores")
    public String getMemberName()
    {
@@ -97,8 +95,9 @@
    }
    
    @NotNull
-   @Length(min = 3, max = 40)
-   @Pattern(regex="[a-zA-Z]+", message="First name must only contain letters")
+   @Min(3)
+   @Max(40)
+   @Pattern(regexp="[a-zA-Z]+", message="First name must only contain letters")
    public String getFirstName()
    {
       return firstName;
@@ -110,8 +109,9 @@
    }
    
    @NotNull
-   @Length(min = 3, max = 40)
-   @Pattern(regex="[a-zA-Z]+", message="Last name must only contain letters")
+   @Min(3)
+   @Max(40)
+   @Pattern(regexp="[a-zA-Z]+", message="Last name must only contain letters")
    public String getLastName()
    {
       return lastName;
@@ -122,7 +122,7 @@
       this.lastName = lastName;
    }   
    
-   @NotNull @Email
+   @NotNull 
    public String getEmail()
    {
       return email;

Modified: examples/trunk/seamspace/ejb-jar/src/main/java/org/jboss/seam/example/seamspace/MemberAccount.java
===================================================================
--- examples/trunk/seamspace/ejb-jar/src/main/java/org/jboss/seam/example/seamspace/MemberAccount.java	2009-05-07 08:16:04 UTC (rev 10829)
+++ examples/trunk/seamspace/ejb-jar/src/main/java/org/jboss/seam/example/seamspace/MemberAccount.java	2009-05-07 08:16:38 UTC (rev 10830)
@@ -12,13 +12,13 @@
 import javax.persistence.OneToOne;
 import javax.persistence.Table;
 import javax.persistence.UniqueConstraint;
+import javax.validation.constraints.NotNull;
 
-import org.hibernate.validator.NotNull;
-import org.jboss.seam.annotations.security.management.PasswordSalt;
-import org.jboss.seam.annotations.security.management.UserEnabled;
-import org.jboss.seam.annotations.security.management.UserPassword;
-import org.jboss.seam.annotations.security.management.UserPrincipal;
-import org.jboss.seam.annotations.security.management.UserRoles;
+import org.jboss.seam.security.annotations.management.PasswordSalt;
+import org.jboss.seam.security.annotations.management.UserEnabled;
+import org.jboss.seam.security.annotations.management.UserPassword;
+import org.jboss.seam.security.annotations.management.UserPrincipal;
+import org.jboss.seam.security.annotations.management.UserRoles;
 
 @Entity
 @Table(uniqueConstraints = @UniqueConstraint(columnNames = "username"))

Modified: examples/trunk/seamspace/ejb-jar/src/main/java/org/jboss/seam/example/seamspace/MemberBlog.java
===================================================================
--- examples/trunk/seamspace/ejb-jar/src/main/java/org/jboss/seam/example/seamspace/MemberBlog.java	2009-05-07 08:16:04 UTC (rev 10829)
+++ examples/trunk/seamspace/ejb-jar/src/main/java/org/jboss/seam/example/seamspace/MemberBlog.java	2009-05-07 08:16:38 UTC (rev 10830)
@@ -16,11 +16,7 @@
 import javax.persistence.PrePersist;
 import javax.persistence.Transient;
 
-import org.jboss.seam.annotations.Name;
-import org.jboss.seam.annotations.security.Restrict;
-
 @Entity
- at Name("memberBlog")
 public class MemberBlog implements Serializable
 {
    private static final long serialVersionUID = 7824113911888715595L;
@@ -41,7 +37,7 @@
     * this case, because the method is annotated with <code>@PrePersist</code> 
     * the required permission is memberBlog:insert    
     */
-   @PrePersist @Restrict
+   @PrePersist // @Restrict
    public void prePersist() {}
    
    @Id @GeneratedValue

Modified: examples/trunk/seamspace/ejb-jar/src/main/java/org/jboss/seam/example/seamspace/MemberFriend.java
===================================================================
--- examples/trunk/seamspace/ejb-jar/src/main/java/org/jboss/seam/example/seamspace/MemberFriend.java	2009-05-07 08:16:04 UTC (rev 10829)
+++ examples/trunk/seamspace/ejb-jar/src/main/java/org/jboss/seam/example/seamspace/MemberFriend.java	2009-05-07 08:16:38 UTC (rev 10830)
@@ -8,10 +8,7 @@
 import javax.persistence.JoinColumn;
 import javax.persistence.ManyToOne;
 
-import org.jboss.seam.annotations.Name;
-
 @Entity
- at Name("memberFriend")
 public class MemberFriend implements Serializable
 {
    private static final long serialVersionUID = -167586088947004386L;

Modified: examples/trunk/seamspace/ejb-jar/src/main/java/org/jboss/seam/example/seamspace/MemberImage.java
===================================================================
--- examples/trunk/seamspace/ejb-jar/src/main/java/org/jboss/seam/example/seamspace/MemberImage.java	2009-05-07 08:16:04 UTC (rev 10829)
+++ examples/trunk/seamspace/ejb-jar/src/main/java/org/jboss/seam/example/seamspace/MemberImage.java	2009-05-07 08:16:38 UTC (rev 10830)
@@ -9,8 +9,8 @@
 import javax.persistence.Lob;
 import javax.persistence.ManyToOne;
 
-import org.jboss.seam.annotations.security.permission.Permission;
-import org.jboss.seam.annotations.security.permission.Permissions;
+import org.jboss.seam.security.annotations.permission.Permission;
+import org.jboss.seam.security.annotations.permission.Permissions;
 
 @Permissions({
    @Permission(action = "view"),

Modified: examples/trunk/seamspace/ejb-jar/src/main/java/org/jboss/seam/example/seamspace/MemberRole.java
===================================================================
--- examples/trunk/seamspace/ejb-jar/src/main/java/org/jboss/seam/example/seamspace/MemberRole.java	2009-05-07 08:16:04 UTC (rev 10829)
+++ examples/trunk/seamspace/ejb-jar/src/main/java/org/jboss/seam/example/seamspace/MemberRole.java	2009-05-07 08:16:38 UTC (rev 10830)
@@ -10,9 +10,9 @@
 import javax.persistence.JoinTable;
 import javax.persistence.ManyToMany;
 
-import org.jboss.seam.annotations.security.management.RoleConditional;
-import org.jboss.seam.annotations.security.management.RoleGroups;
-import org.jboss.seam.annotations.security.management.RoleName;
+import org.jboss.seam.security.annotations.management.RoleConditional;
+import org.jboss.seam.security.annotations.management.RoleGroups;
+import org.jboss.seam.security.annotations.management.RoleName;
 
 @Entity
 public class MemberRole implements Serializable

Modified: examples/trunk/seamspace/ejb-jar/src/main/java/org/jboss/seam/example/seamspace/PictureAction.java
===================================================================
--- examples/trunk/seamspace/ejb-jar/src/main/java/org/jboss/seam/example/seamspace/PictureAction.java	2009-05-07 08:16:04 UTC (rev 10829)
+++ examples/trunk/seamspace/ejb-jar/src/main/java/org/jboss/seam/example/seamspace/PictureAction.java	2009-05-07 08:16:38 UTC (rev 10830)
@@ -1,29 +1,25 @@
 package org.jboss.seam.example.seamspace;
 
-import static org.jboss.seam.ScopeType.CONVERSATION;
-
+import javax.annotation.Named;
+import javax.context.Conversation;
+import javax.context.ConversationScoped;
+import javax.inject.Current;
 import javax.persistence.EntityManager;
 
-import org.jboss.seam.annotations.Begin;
-import org.jboss.seam.annotations.In;
-import org.jboss.seam.annotations.Name;
-import org.jboss.seam.annotations.Scope;
-import org.jboss.seam.core.Conversation;
-
- at Scope(CONVERSATION)
- at Name("pictureAction")
+ at Named
+ at ConversationScoped
 public class PictureAction
 {
    private MemberImage memberImage;
    
-   @In(required = false)
-   private Member authenticatedMember;
+   @Current Member authenticatedMember;
    
-   @In EntityManager entityManager;
+   @Current EntityManager entityManager;
+   @Current Conversation conversation;
    
-   @Begin
    public void uploadPicture()
    {
+      conversation.begin();
       memberImage = new MemberImage();
    }
    
@@ -31,7 +27,7 @@
    {
       memberImage.setMember(entityManager.find(Member.class, authenticatedMember.getMemberId()));
       entityManager.persist(memberImage);
-      Conversation.instance().end();
+      conversation.end();
    }
 
    public MemberImage getMemberImage()

Modified: examples/trunk/seamspace/ejb-jar/src/main/java/org/jboss/seam/example/seamspace/PictureSearch.java
===================================================================
--- examples/trunk/seamspace/ejb-jar/src/main/java/org/jboss/seam/example/seamspace/PictureSearch.java	2009-05-07 08:16:04 UTC (rev 10829)
+++ examples/trunk/seamspace/ejb-jar/src/main/java/org/jboss/seam/example/seamspace/PictureSearch.java	2009-05-07 08:16:38 UTC (rev 10830)
@@ -1,35 +1,31 @@
 package org.jboss.seam.example.seamspace;
 
-import static org.jboss.seam.ScopeType.EVENT;
-
 import java.io.Serializable;
 import java.util.List;
 
+import javax.annotation.Named;
+import javax.context.RequestScoped;
+import javax.inject.Current;
 import javax.persistence.EntityManager;
-
-import org.jboss.seam.annotations.In;
-import org.jboss.seam.annotations.Name;
-import org.jboss.seam.annotations.Out;
-import org.jboss.seam.annotations.Scope;
-import org.jboss.seam.annotations.security.Delete;
-import org.jboss.seam.annotations.web.RequestParameter;
 import org.jboss.seam.security.Identity;
+import org.jboss.seam.security.Secure;
+import org.jboss.seam.security.annotations.Delete;
 
- at Name("pictureSearch")
- at Scope(EVENT)
+ at Named
+ at RequestScoped
+ at Secure
 public class PictureSearch implements Serializable
 {
    private static final long serialVersionUID = -1868188969326866331L;
    
    private String memberName;
    
-   @In
-   private EntityManager entityManager;
+   @Current EntityManager entityManager;
+   @Current Identity identity;
    
-   @Out(required = false)
    private List<MemberImage> memberImages;
    
-   @RequestParameter
+   //@RequestParameter
    private Integer imageId;
    
    public String getMemberName()
@@ -59,6 +55,6 @@
             "select i from MemberImage i where i.member.memberName = :name and not i = i.member.picture")
             .setParameter("name", memberName)
             .getResultList();      
-      Identity.instance().filterByPermission(memberImages, "view");
+      identity.filterByPermission(memberImages, "view");
    }
 }

Modified: examples/trunk/seamspace/ejb-jar/src/main/java/org/jboss/seam/example/seamspace/ProfileAction.java
===================================================================
--- examples/trunk/seamspace/ejb-jar/src/main/java/org/jboss/seam/example/seamspace/ProfileAction.java	2009-05-07 08:16:04 UTC (rev 10829)
+++ examples/trunk/seamspace/ejb-jar/src/main/java/org/jboss/seam/example/seamspace/ProfileAction.java	2009-05-07 08:16:38 UTC (rev 10830)
@@ -1,46 +1,30 @@
 package org.jboss.seam.example.seamspace;
 
-import static org.jboss.seam.ScopeType.CONVERSATION;
-import static org.jboss.seam.ScopeType.EVENT;
-
 import java.util.List;
 import java.util.Random;
 
+import javax.annotation.Named;
+import javax.context.RequestScoped;
 import javax.ejb.Remove;
+import javax.inject.Current;
+import javax.inject.Produces;
 import javax.persistence.EntityManager;
 import javax.persistence.NoResultException;
 
-import org.jboss.seam.annotations.Destroy;
-import org.jboss.seam.annotations.Factory;
-import org.jboss.seam.annotations.In;
-import org.jboss.seam.annotations.Name;
-import org.jboss.seam.annotations.Out;
-import org.jboss.seam.annotations.web.RequestParameter;
-import org.jboss.seam.annotations.Scope;
-
- at Name("profile")
- at Scope(EVENT)
+ at Named("profile")
+ at RequestScoped
 public class ProfileAction
 {
-   @RequestParameter
+   //@RequestParameter
    private String name;
-
-   @In(required = false) @Out(required = false, scope = CONVERSATION)
-   private Member selectedMember;
    
-   @In(required = false)
-   private Member authenticatedMember;
+   @Current Member selectedMember;
    
-   @Out(required = false)
-   List<Member> newMembers;
+   @Current Member authenticatedMember;  
    
-   @Out(required = false)
-   List<MemberBlog> memberBlogs;   
-   
-   @In
-   private EntityManager entityManager;
+   @Current EntityManager entityManager;
 
-   @Factory("selectedMember")
+   //@Factory("selectedMember")
    public void display()
    {      
       if (name == null && authenticatedMember != null)
@@ -78,9 +62,10 @@
     * Used to read all blog entries for a member
     */
    @SuppressWarnings("unchecked")
-   @Factory("memberBlogs")
-   public void getMemberBlogs()
+   public @Produces @Named("memberBlogs") List<MemberBlog> getMemberBlogs()
    {
+      List<MemberBlog> memberBlogs;
+      
       if (name == null && authenticatedMember != null)
       {
          name = authenticatedMember.getMemberName();
@@ -90,13 +75,14 @@
             "from MemberBlog b where b.member.memberName = :memberName order by b.entryDate desc")
             .setParameter("memberName", name)
             .getResultList();
+      
+      return memberBlogs;
    }   
    
    @SuppressWarnings("unchecked")
-   @Factory("newMembers")
-   public void newMembers()
+   public @Produces @Named("newMembers") List<Member> newMembers()
    {
-      newMembers = entityManager.createQuery(
+      List<Member> newMembers = entityManager.createQuery(
             "from Member order by memberSince desc")
             .setMaxResults(10)
             .getResultList();
@@ -107,6 +93,8 @@
       {
          newMembers.remove(rnd.nextInt(newMembers.size()));
       }
+      
+      return newMembers;
    }
    
    @SuppressWarnings("unchecked")
@@ -126,7 +114,4 @@
             .setParameter("member", selectedMember)
             .getResultList();
    }
-   
-   @Remove @Destroy
-   public void destroy() { }   
 }

Modified: examples/trunk/seamspace/ejb-jar/src/main/java/org/jboss/seam/example/seamspace/RegisterAction.java
===================================================================
--- examples/trunk/seamspace/ejb-jar/src/main/java/org/jboss/seam/example/seamspace/RegisterAction.java	2009-05-07 08:16:04 UTC (rev 10829)
+++ examples/trunk/seamspace/ejb-jar/src/main/java/org/jboss/seam/example/seamspace/RegisterAction.java	2009-05-07 08:16:38 UTC (rev 10830)
@@ -1,39 +1,38 @@
 package org.jboss.seam.example.seamspace;
 
-import static org.jboss.seam.ScopeType.CONVERSATION;
-
 import java.util.Date;
 
+import javax.annotation.Named;
+import javax.context.Conversation;
+import javax.context.ConversationScoped;
 import javax.ejb.Remove;
+import javax.event.Observes;
+import javax.inject.Current;
 import javax.persistence.EntityManager;
 
-import org.jboss.seam.annotations.Begin;
-import org.jboss.seam.annotations.Destroy;
-import org.jboss.seam.annotations.End;
-import org.jboss.seam.annotations.In;
-import org.jboss.seam.annotations.Name;
-import org.jboss.seam.annotations.Observer;
-import org.jboss.seam.annotations.Scope;
-import org.jboss.seam.faces.FacesMessages;
+import org.jboss.seam.international.StatusMessages;
+import org.jboss.seam.security.Credentials;
 import org.jboss.seam.security.Identity;
 import org.jboss.seam.security.RunAsOperation;
+import org.jboss.seam.security.events.UserCreatedEvent;
 import org.jboss.seam.security.management.IdentityManager;
 import org.jboss.seam.security.management.JpaIdentityStore;
 
- at Scope(CONVERSATION)
- at Name("register")
+ at Named("register")
+ at ConversationScoped
 public class RegisterAction
 {
    private Member member;
    
-   @In
-   private EntityManager entityManager;
+   @Current EntityManager entityManager;
    
-   @In
-   private Identity identity;
+   @Current Identity identity;
+   @Current Credentials credentials;
    
-   @In
-   private IdentityManager identityManager;
+   @Current IdentityManager identityManager;
+   
+   @Current Conversation conversation;
+   @Current StatusMessages messages;
       
    private MemberAccount newAccount;
    
@@ -52,9 +51,9 @@
    
    private boolean verified;
 
-   @Begin
    public void start()
    {
+      conversation.begin();
       member = new Member();
    }
    
@@ -66,13 +65,14 @@
       
       if (!verified)
       {
-         FacesMessages.instance().addToControl("confirmPassword", "Passwords do not match");
+         messages.addToControl("confirmPassword", "Passwords do not match");
       }           
    }
    
-   @Observer(JpaIdentityStore.EVENT_USER_CREATED)
-   public void accountCreated(MemberAccount account)
+   public void accountCreated(@Observes UserCreatedEvent event)
    {
+      MemberAccount account = (MemberAccount) event.getUser();
+      
       // The user *may* have been created from the user manager screen. In that
       // case, create a dummy Member record just for the purpose of demonstrating the
       // identity management API
@@ -93,19 +93,18 @@
       this.newAccount = account;
    }
 
-   @End
    public void uploadPicture() 
    {  
       member.setMemberSince(new Date());      
       entityManager.persist(member);      
       
-      new RunAsOperation() {
+      identity.runAs(
+        new RunAsOperation() {
          public void execute() {
             identityManager.createUser(username, password);
             identityManager.grantRole(username, "user");            
          }         
-      }.addRole("admin")
-       .run();
+      }.addRole("admin"));
             
       newAccount.setMember(member);
       newAccount = entityManager.merge(newAccount);
@@ -123,9 +122,11 @@
       }
       
       // Login the user
-      identity.getCredentials().setUsername(username);
-      identity.getCredentials().setPassword(password);
+      credentials.setUsername(username);
+      credentials.setPassword(password);
       identity.login();
+      
+      conversation.end();
    }
    
    public Member getMember()
@@ -197,7 +198,4 @@
    {
       return verified;
    }
-   
-   @Destroy @Remove
-   public void destroy() {}
 }




More information about the seam-commits mailing list