[seam-commits] Seam SVN: r10840 - in examples/trunk/seamspace/ejb-jar/src/main/java/org/jboss/seam/example/seamspace: model and 1 other directory.

seam-commits at lists.jboss.org seam-commits at lists.jboss.org
Fri May 8 05:35:27 EDT 2009


Author: shane.bryzak at jboss.com
Date: 2009-05-08 05:35:27 -0400 (Fri, 08 May 2009)
New Revision: 10840

Added:
   examples/trunk/seamspace/ejb-jar/src/main/java/org/jboss/seam/example/seamspace/model/
   examples/trunk/seamspace/ejb-jar/src/main/java/org/jboss/seam/example/seamspace/model/AccountPermission.java
   examples/trunk/seamspace/ejb-jar/src/main/java/org/jboss/seam/example/seamspace/model/BlogComment.java
   examples/trunk/seamspace/ejb-jar/src/main/java/org/jboss/seam/example/seamspace/model/FriendComment.java
   examples/trunk/seamspace/ejb-jar/src/main/java/org/jboss/seam/example/seamspace/model/Member.java
   examples/trunk/seamspace/ejb-jar/src/main/java/org/jboss/seam/example/seamspace/model/MemberAccount.java
   examples/trunk/seamspace/ejb-jar/src/main/java/org/jboss/seam/example/seamspace/model/MemberBlog.java
   examples/trunk/seamspace/ejb-jar/src/main/java/org/jboss/seam/example/seamspace/model/MemberFriend.java
   examples/trunk/seamspace/ejb-jar/src/main/java/org/jboss/seam/example/seamspace/model/MemberImage.java
   examples/trunk/seamspace/ejb-jar/src/main/java/org/jboss/seam/example/seamspace/model/MemberRole.java
Removed:
   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/BlogComment.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/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
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/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/ImagePermission.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:
fix deployment errors, minor restructuring

Deleted: 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-08 07:46:31 UTC (rev 10839)
+++ examples/trunk/seamspace/ejb-jar/src/main/java/org/jboss/seam/example/seamspace/AccountPermission.java	2009-05-08 09:35:27 UTC (rev 10840)
@@ -1,81 +0,0 @@
-package org.jboss.seam.example.seamspace;
-
-import java.io.Serializable;
-
-import javax.persistence.Entity;
-import javax.persistence.GeneratedValue;
-import javax.persistence.Id;
-
-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;
-
- at Entity
-public class AccountPermission implements Serializable
-{
-   private static final long serialVersionUID = -5628863031792429938L;
-   
-   private Integer permissionId;
-   private String recipient;
-   private String target;
-   private String action;
-   private String discriminator;
-   
-   @Id @GeneratedValue
-   public Integer getPermissionId()
-   {
-      return permissionId;
-   }
-   
-   public void setPermissionId(Integer permissionId)
-   {
-      this.permissionId = permissionId;
-   }
-   
-   @PermissionUser 
-   @PermissionRole
-   public String getRecipient()
-   {
-      return recipient;
-   }
-   
-   public void setRecipient(String recipient)
-   {
-      this.recipient = recipient;
-   }
-   
-   @PermissionTarget
-   public String getTarget()
-   {
-      return target;
-   }
-   
-   public void setTarget(String target)
-   {
-      this.target = target;
-   }
-   
-   @PermissionAction
-   public String getAction()
-   {
-      return action;
-   }
-   
-   public void setAction(String action)
-   {
-      this.action = action;
-   }
-   
-   @PermissionDiscriminator
-   public String getDiscriminator()
-   {
-      return discriminator;
-   }
-   
-   public void setDiscriminator(String discriminator)
-   {
-      this.discriminator = discriminator;
-   }
-}

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-08 07:46:31 UTC (rev 10839)
+++ examples/trunk/seamspace/ejb-jar/src/main/java/org/jboss/seam/example/seamspace/BlogAction.java	2009-05-08 09:35:27 UTC (rev 10840)
@@ -1,5 +1,6 @@
 package org.jboss.seam.example.seamspace;
 
+import java.io.Serializable;
 import java.util.ArrayList;
 import java.util.Date;
 
@@ -9,17 +10,24 @@
 import javax.inject.Current;
 import javax.inject.Produces;
 import javax.persistence.EntityManager;
+import javax.persistence.PersistenceContext;
 
+import org.jboss.seam.example.seamspace.model.BlogComment;
+import org.jboss.seam.example.seamspace.model.Member;
+import org.jboss.seam.example.seamspace.model.MemberBlog;
+
 @Named("blog")
 @ConversationScoped
-public class BlogAction
+public class BlogAction implements Serializable
 {    
+   private static final long serialVersionUID = 1048001063828543101L;
+   
    private String name;   
    private Integer blogId;
    
-   @Current EntityManager entityManager;
+   @PersistenceContext EntityManager entityManager;
    
-   @Current Member authenticatedMember;
+   /*@Current */Member authenticatedMember;
    @Current Conversation conversation;
    
    private MemberBlog selectedBlog;

Deleted: 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-08 07:46:31 UTC (rev 10839)
+++ examples/trunk/seamspace/ejb-jar/src/main/java/org/jboss/seam/example/seamspace/BlogComment.java	2009-05-08 09:35:27 UTC (rev 10840)
@@ -1,91 +0,0 @@
-package org.jboss.seam.example.seamspace;
-
-import java.io.Serializable;
-import java.text.SimpleDateFormat;
-import java.util.Date;
-
-import javax.persistence.Entity;
-import javax.persistence.GeneratedValue;
-import javax.persistence.Id;
-import javax.persistence.JoinColumn;
-import javax.persistence.ManyToOne;
-import javax.persistence.Transient;
-import javax.validation.constraints.NotNull;
-
- at Entity
-public class BlogComment implements Serializable
-{
-   private static final long serialVersionUID = 5495139096911872039L;
-
-   private static SimpleDateFormat df = new SimpleDateFormat("EEEE, MMMM d, yyyy 'at' hh:mm a");   
-   
-   private Integer commentId;
-   private MemberBlog blog;
-   private Member commentor;
-   private Date commentDate;
-   private String comment;
-   
-   @Id @GeneratedValue
-   public Integer getCommentId()
-   {
-      return commentId;
-   }
-   
-   public void setCommentId(Integer commentId)
-   {
-      this.commentId = commentId;
-   }   
-   
-   @ManyToOne
-   @JoinColumn(name = "BLOG_ID")
-   public MemberBlog getBlog()
-   {
-      return blog;
-   }
-   
-   public void setBlog(MemberBlog blog)
-   {
-      this.blog = blog;
-   }
-   
-   @NotNull
-   public String getComment()
-   {
-      return comment;
-   }
-   public void setComment(String comment)
-   {
-      this.comment = comment;
-   }
-   
-   @NotNull
-   public Date getCommentDate()
-   {
-      return commentDate;
-   }
-   
-   public void setCommentDate(Date commentDate)
-   {
-      this.commentDate = commentDate;
-   }
-   
-   @Transient
-   public String getFormattedCommentDate()
-   {
-     return df.format(commentDate);  
-   }
-
-   @ManyToOne
-   @JoinColumn(name = "COMMENTOR_ID")
-   public Member getCommentor()
-   {
-      return commentor;
-   }
-   
-   public void setCommentor(Member commentor)
-   {
-      this.commentor = commentor;
-   }
-  
-   
-}

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-08 07:46:31 UTC (rev 10839)
+++ examples/trunk/seamspace/ejb-jar/src/main/java/org/jboss/seam/example/seamspace/CommentAction.java	2009-05-08 09:35:27 UTC (rev 10840)
@@ -1,5 +1,6 @@
 package org.jboss.seam.example.seamspace;
 
+import java.io.Serializable;
 import java.util.Date;
 
 import javax.annotation.Named;
@@ -7,20 +8,26 @@
 import javax.context.ConversationScoped;
 import javax.inject.Current;
 import javax.persistence.EntityManager;
+import javax.persistence.PersistenceContext;
 
+import org.jboss.seam.example.seamspace.model.BlogComment;
+import org.jboss.seam.example.seamspace.model.Member;
+import org.jboss.seam.example.seamspace.model.MemberBlog;
 import org.jboss.seam.security.Secure;
 import org.jboss.seam.security.annotations.Insert;
 
 @Named
 @ConversationScoped
 @Secure
-public class CommentAction 
+public class CommentAction implements Serializable
 {
-   @Current EntityManager entityManager;
+   private static final long serialVersionUID = -4681499577462031028L;
+
+   @PersistenceContext EntityManager entityManager;
    
    private BlogComment comment;     
    
-   @Current Member authenticatedMember;
+   /*@Current*/ Member authenticatedMember;
    
    @Current MemberBlog selectedBlog;
    

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-08 07:46:31 UTC (rev 10839)
+++ examples/trunk/seamspace/ejb-jar/src/main/java/org/jboss/seam/example/seamspace/ContentAction.java	2009-05-08 09:35:27 UTC (rev 10840)
@@ -1,15 +1,21 @@
 package org.jboss.seam.example.seamspace;
 
+import java.io.Serializable;
+
 import javax.annotation.Named;
 import javax.inject.Current;
 import javax.persistence.EntityManager;
+import javax.persistence.PersistenceContext;
 
+import org.jboss.seam.example.seamspace.model.MemberImage;
 import org.jboss.seam.security.Identity;
 
 @Named
-public class ContentAction
+public class ContentAction implements Serializable
 {
-   @Current EntityManager entityManager;
+   private static final long serialVersionUID = -3028986030113894868L;
+   
+   @PersistenceContext EntityManager entityManager;
    @Current Identity identity;
    
    public MemberImage getImage(int imageId)

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-08 07:46:31 UTC (rev 10839)
+++ examples/trunk/seamspace/ejb-jar/src/main/java/org/jboss/seam/example/seamspace/ContentServlet.java	2009-05-08 09:35:27 UTC (rev 10840)
@@ -16,6 +16,8 @@
 import javax.servlet.http.HttpServletResponse;
 import javax.swing.ImageIcon;
 
+import org.jboss.seam.example.seamspace.model.MemberImage;
+
 /**
  * Serves images and other member content
  * 

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-08 07:46:31 UTC (rev 10839)
+++ examples/trunk/seamspace/ejb-jar/src/main/java/org/jboss/seam/example/seamspace/FriendAction.java	2009-05-08 09:35:27 UTC (rev 10840)
@@ -10,7 +10,11 @@
 import javax.inject.Produces;
 import javax.persistence.EntityManager;
 import javax.persistence.NoResultException;
+import javax.persistence.PersistenceContext;
 
+import org.jboss.seam.example.seamspace.model.FriendComment;
+import org.jboss.seam.example.seamspace.model.Member;
+import org.jboss.seam.example.seamspace.model.MemberFriend;
 import org.jboss.seam.international.StatusMessages;
 import org.jboss.seam.security.Identity;
 
@@ -23,9 +27,9 @@
    // @RequestParameter("name")
    private String name;
      
-   @Current Member authenticatedMember;
+   /*@Current*/ Member authenticatedMember;
       
-   @Current EntityManager entityManager;
+   @PersistenceContext EntityManager entityManager;
    @Current Identity identity;
    @Current StatusMessages messages;
    @Current Conversation conversation;

Deleted: 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-08 07:46:31 UTC (rev 10839)
+++ examples/trunk/seamspace/ejb-jar/src/main/java/org/jboss/seam/example/seamspace/FriendComment.java	2009-05-08 09:35:27 UTC (rev 10840)
@@ -1,88 +0,0 @@
-package org.jboss.seam.example.seamspace;
-
-import java.io.Serializable;
-import java.text.SimpleDateFormat;
-import java.util.Date;
-
-import javax.persistence.Entity;
-import javax.persistence.GeneratedValue;
-import javax.persistence.Id;
-import javax.persistence.JoinColumn;
-import javax.persistence.ManyToOne;
-import javax.persistence.Transient;
-
- at Entity
-public class FriendComment implements Serializable
-{
-   private static final long serialVersionUID = -288494386341008371L;
-
-   private static SimpleDateFormat df = new SimpleDateFormat("d MMMM yyyy hh:mm a");   
-   
-   private Integer id;
-   private Member member;
-   private Member friend;
-   private Date commentDate;
-   private String comment;
-   
-   @Id @GeneratedValue
-   public Integer getId()
-   {
-      return id;
-   }
-   
-   public void setId(Integer id)
-   {
-      this.id = id;
-   }   
-   
-   public String getComment()
-   {
-      return comment;
-   }
-   
-   public void setComment(String comment)
-   {
-      this.comment = comment;
-   }
-   
-   public Date getCommentDate()
-   {
-      return commentDate;
-   }
-   
-   public void setCommentDate(Date commentDate)
-   {
-      this.commentDate = commentDate;
-   }
-   
-   @Transient
-   public String getFormattedCommentDate()
-   {
-     return df.format(commentDate);  
-   }   
-   
-   @ManyToOne
-   @JoinColumn(name = "FRIEND_ID")
-   public Member getFriend()
-   {
-      return friend;
-   }
-   
-   public void setFriend(Member friend)
-   {
-      this.friend = friend;
-   }
-      
-   @ManyToOne
-   @JoinColumn(name = "MEMBER_ID")
-   public Member getMember()
-   {
-      return member;
-   }
-   
-   public void setMember(Member member)
-   {
-      this.member = member;
-   }
-
-}

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-08 07:46:31 UTC (rev 10839)
+++ examples/trunk/seamspace/ejb-jar/src/main/java/org/jboss/seam/example/seamspace/ImagePermission.java	2009-05-08 09:35:27 UTC (rev 10840)
@@ -10,7 +10,11 @@
 import javax.context.ConversationScoped;
 import javax.inject.Current;
 import javax.persistence.EntityManager;
+import javax.persistence.PersistenceContext;
 
+import org.jboss.seam.example.seamspace.model.Member;
+import org.jboss.seam.example.seamspace.model.MemberAccount;
+import org.jboss.seam.example.seamspace.model.MemberImage;
 import org.jboss.seam.international.StatusMessages;
 import org.jboss.seam.security.Role;
 import org.jboss.seam.security.SimplePrincipal;
@@ -36,7 +40,7 @@
    @Current IdentityManager identityManager;
    @Current PermissionManager permissionManager;
    
-   @Current EntityManager entityManager;
+   @PersistenceContext EntityManager entityManager;
    
    @Current PermissionSearch permissionSearch;
    @Current Conversation conversation;

Deleted: 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-08 07:46:31 UTC (rev 10839)
+++ examples/trunk/seamspace/ejb-jar/src/main/java/org/jboss/seam/example/seamspace/Member.java	2009-05-08 09:35:27 UTC (rev 10840)
@@ -1,252 +0,0 @@
-package org.jboss.seam.example.seamspace;
-
-import java.io.Serializable;
-import java.util.Calendar;
-import java.util.Date;
-import java.util.GregorianCalendar;
-import java.util.Set;
-
-import javax.persistence.Entity;
-import javax.persistence.FetchType;
-import javax.persistence.GeneratedValue;
-import javax.persistence.Id;
-import javax.persistence.JoinColumn;
-import javax.persistence.OneToMany;
-import javax.persistence.OneToOne;
-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;
-
-/**
- * A member account
- * 
- * @author Shane Bryzak
- */
- at Entity
- at Table(uniqueConstraints = @UniqueConstraint(columnNames = "membername"))
-public class Member implements Serializable
-{
-   private static final long serialVersionUID = 5179242727836683375L;
-   
-   public enum Gender {
-      male("Male", "his"), 
-      female("Female", "her");
-      
-     private String descr;
-     private String possessive;
-     
-     Gender(String descr, String possessive) {
-       this.descr = descr;
-       this.possessive = possessive;
-      }
-     public String getDescr() {
-        return descr;
-     }
-     
-     public String getPossessive() {
-        return possessive;
-     }
-   };
-   
-   private Integer memberId;
-   private String memberName;
-   private String firstName;
-   private String lastName;
-   private String email;
-   private MemberImage picture;
-   
-   private String tagline;
-   private Gender gender;
-   private Date dob;
-   private String location;
-   private Date memberSince;
-   
-   private Set<MemberImage> images;   
-   private Set<MemberFriend> friends;
-
-   @Id @GeneratedValue
-   public Integer getMemberId()
-   {
-      return memberId;
-   }
-
-   public void setMemberId(Integer memberId)
-   {
-      this.memberId = memberId;
-   }
-   
-   @NotNull
-   @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()
-   {
-      return memberName;
-   }
-
-   public void setMemberName(String memberName)
-   {
-      this.memberName = memberName;
-   }
-   
-   @NotNull
-   @Min(3)
-   @Max(40)
-   @Pattern(regexp="[a-zA-Z]+", message="First name must only contain letters")
-   public String getFirstName()
-   {
-      return firstName;
-   }
-   
-   public void setFirstName(String firstName)
-   {
-      this.firstName = firstName;
-   }
-   
-   @NotNull
-   @Min(3)
-   @Max(40)
-   @Pattern(regexp="[a-zA-Z]+", message="Last name must only contain letters")
-   public String getLastName()
-   {
-      return lastName;
-   }
-   
-   public void setLastName(String lastName)
-   {
-      this.lastName = lastName;
-   }   
-   
-   @NotNull 
-   public String getEmail()
-   {
-      return email;
-   }
-   
-   public void setEmail(String email)
-   {
-      this.email = email;
-   }
-
-   @OneToOne(fetch = FetchType.LAZY)
-   @JoinColumn(name = "PICTURE_ID")
-   public MemberImage getPicture()
-   {
-      return picture;
-   }
-
-   public void setPicture(MemberImage picture)
-   {
-      this.picture = picture;
-   }
-
-   @NotNull
-   public Date getDob()
-   {
-      return dob;
-   }
-
-   public void setDob(Date dob)
-   {
-      this.dob = dob;
-   }
-
-   @NotNull
-   public Gender getGender()
-   {
-      return gender;
-   }
-
-   public void setGender(Gender gender)
-   {
-      this.gender = gender;
-   }
-
-   public String getLocation()
-   {
-      return location;
-   }
-
-   public void setLocation(String location)
-   {
-      this.location = location;
-   }
-   
-   @NotNull
-   public Date getMemberSince()
-   {
-      return memberSince;
-   }
-   
-   public void setMemberSince(Date memberSince)
-   {
-      this.memberSince = memberSince;
-   }
-
-   public String getTagline()
-   {
-      return tagline;
-   }
-
-   public void setTagline(String tagline)
-   {
-      this.tagline = tagline;
-   }
-
-   @OneToMany(mappedBy = "member", fetch = FetchType.LAZY)
-   public Set<MemberImage> getImages()
-   {
-      return images;
-   }
-
-   public void setImages(Set<MemberImage> images)
-   {
-      this.images = images;
-   }
-   
-   @OneToMany(mappedBy = "member")
-   public Set<MemberFriend> getFriends()
-   {
-      return friends;
-   }
-   
-   public void setFriends(Set<MemberFriend> friends)
-   {
-      this.friends = friends;   
-   }
-   
-   @Transient
-   public boolean isFriend(Member member)
-   {
-      for (MemberFriend f : friends)
-      {
-         if (f.getFriend().getMemberId().equals(member.getMemberId())) return true;          
-      }
-      
-      return false;
-   }
-   
-   @Transient
-   public String getAge()
-   {
-      Calendar birthday = new GregorianCalendar();
-      birthday.setTime(dob);
-      int by = birthday.get(Calendar.YEAR);
-      int bm = birthday.get(Calendar.MONTH);
-      int bd = birthday.get(Calendar.DATE);
-      
-      Calendar now = new GregorianCalendar();
-      now.setTimeInMillis(System.currentTimeMillis());
-      int ny = now.get(Calendar.YEAR);
-      int nm = now.get(Calendar.MONTH);
-      int nd = now.get(Calendar.DATE);      
-      
-      int age = ny - by + (nm > bm || (nm == bm && nd >= bd) ? 0 : -1);                              
-      return String.format("%d years old", age);                              
-   }
-}

Deleted: 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-08 07:46:31 UTC (rev 10839)
+++ examples/trunk/seamspace/ejb-jar/src/main/java/org/jboss/seam/example/seamspace/MemberAccount.java	2009-05-08 09:35:27 UTC (rev 10840)
@@ -1,120 +0,0 @@
-package org.jboss.seam.example.seamspace;
-
-import java.io.Serializable;
-import java.util.Set;
-
-import javax.persistence.Entity;
-import javax.persistence.GeneratedValue;
-import javax.persistence.Id;
-import javax.persistence.JoinColumn;
-import javax.persistence.JoinTable;
-import javax.persistence.ManyToMany;
-import javax.persistence.OneToOne;
-import javax.persistence.Table;
-import javax.persistence.UniqueConstraint;
-import javax.validation.constraints.NotNull;
-
-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;
-
- at Entity
- at Table(uniqueConstraints = @UniqueConstraint(columnNames = "username"))
-public class MemberAccount implements Serializable
-{
-   private static final long serialVersionUID = 6368734442192368866L;
-   
-   private Integer accountId;
-   private String username;
-   private String passwordHash;
-   private String passwordSalt;
-   private boolean enabled;   
-   
-   private Set<MemberRole> roles;
-   private Member member;   
-   
-   @Id @GeneratedValue
-   public Integer getAccountId()
-   {
-      return accountId;
-   }
-   
-   public void setAccountId(Integer accountId)
-   {
-      this.accountId = accountId;
-   }
-   
-   @NotNull @UserPrincipal
-   public String getUsername()
-   {
-      return username;
-   }
-   
-   public void setUsername(String username)
-   {
-      this.username = username;
-   }
-   
-   @UserPassword
-   public String getPasswordHash()
-   {
-      return passwordHash;
-   }
-   
-   public void setPasswordHash(String passwordHash)
-   {
-      this.passwordHash = passwordHash;      
-   }
-   
-   @PasswordSalt
-   public String getPasswordSalt()
-   {
-      return passwordSalt;
-   }
-   
-   public void setPasswordSalt(String passwordSalt)
-   {
-      this.passwordSalt = passwordSalt;
-   }
-   
-   @UserEnabled
-   public boolean isEnabled()
-   {
-      return enabled;
-   }
-
-   public void setEnabled(boolean enabled)
-   {
-      this.enabled = enabled;      
-   }   
-
-   @UserRoles
-   @ManyToMany(targetEntity = MemberRole.class)
-   @JoinTable(name = "AccountMembership", 
-         joinColumns = @JoinColumn(name = "AccountId"),
-         inverseJoinColumns = @JoinColumn(name = "MemberOf")
-      )
-   public Set<MemberRole> getRoles()
-   {
-      return roles;
-   }
-   
-   public void setRoles(Set<MemberRole> roles)
-   {
-      this.roles = roles;
-   }
-   
-   @OneToOne
-   @JoinColumn(name = "MEMBER_ID")
-   public Member getMember()
-   {
-      return member;
-   }
-   
-   public void setMember(Member member)
-   {
-      this.member = member;
-   }
-}

Deleted: 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-08 07:46:31 UTC (rev 10839)
+++ examples/trunk/seamspace/ejb-jar/src/main/java/org/jboss/seam/example/seamspace/MemberBlog.java	2009-05-08 09:35:27 UTC (rev 10840)
@@ -1,130 +0,0 @@
-package org.jboss.seam.example.seamspace;
-
-import java.io.Serializable;
-import java.text.SimpleDateFormat;
-import java.util.Collections;
-import java.util.Comparator;
-import java.util.Date;
-import java.util.List;
-
-import javax.persistence.Entity;
-import javax.persistence.GeneratedValue;
-import javax.persistence.Id;
-import javax.persistence.JoinColumn;
-import javax.persistence.ManyToOne;
-import javax.persistence.OneToMany;
-import javax.persistence.PrePersist;
-import javax.persistence.Transient;
-
- at Entity
-public class MemberBlog implements Serializable
-{
-   private static final long serialVersionUID = 7824113911888715595L;
-   
-   private static SimpleDateFormat df = new SimpleDateFormat("EEEE, MMMM d, yyyy - hh:mm a");
-   
-   private Integer blogId;
-   private Member member;
-   private Date entryDate;
-   private String title;
-   private String text;
-   
-   private List<BlogComment> comments;
-   
-   /**
-    * This is an example of a security restriction.  Any attempts to persist a
-    * new memberBlog instance requires the user to pass a permission check.  In 
-    * this case, because the method is annotated with <code>@PrePersist</code> 
-    * the required permission is memberBlog:insert    
-    */
-   @PrePersist // @Restrict
-   public void prePersist() {}
-   
-   @Id @GeneratedValue
-   public Integer getBlogId()
-   {
-      return blogId;
-   }
-   
-   public void setBlogId(Integer blogId)
-   {
-      this.blogId = blogId;
-   }
-
-   public Date getEntryDate()
-   {
-      return entryDate;
-   }
-
-   public void setEntryDate(Date entryDate)
-   {
-      this.entryDate = entryDate;
-   }
-   
-   @Transient
-   public String getFormattedEntryDate()
-   {
-      return df.format(entryDate);
-   }
-
-   @ManyToOne
-   @JoinColumn(name = "MEMBER_ID")   
-   public Member getMember()
-   {
-      return member;
-   }
-
-   public void setMember(Member member)
-   {
-      this.member = member;
-   }
-
-   public String getText()
-   {
-      return text;
-   }
-
-   public void setText(String text)
-   {
-      this.text = text;
-   }
-
-   public String getTitle()
-   {
-      return title;
-   }
-
-   public void setTitle(String title)
-   {
-      this.title = title;
-   }
-   
-   @OneToMany(mappedBy = "blog")
-   public List<BlogComment> getComments()
-   {
-      return comments;
-   }
-   
-   public void setComments(List<BlogComment> comments)
-   {
-      this.comments = comments;
-   }
-   
-   @Transient
-   public List<BlogComment> getSortedComments()
-   {
-      Collections.sort(comments, new Comparator<BlogComment>() {
-         public int compare(BlogComment o1, BlogComment o2) {
-            return (int) (o1.getCommentDate().getTime() - o2.getCommentDate().getTime());
-         }
-      });
-      
-      return comments;
-   }
-   
-   @Transient
-   public int getCommentCount()
-   {
-      return comments.size();
-   }
-}

Deleted: 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-08 07:46:31 UTC (rev 10839)
+++ examples/trunk/seamspace/ejb-jar/src/main/java/org/jboss/seam/example/seamspace/MemberFriend.java	2009-05-08 09:35:27 UTC (rev 10840)
@@ -1,89 +0,0 @@
-package org.jboss.seam.example.seamspace;
-
-import java.io.Serializable;
-
-import javax.persistence.Entity;
-import javax.persistence.GeneratedValue;
-import javax.persistence.Id;
-import javax.persistence.JoinColumn;
-import javax.persistence.ManyToOne;
-
- at Entity
-public class MemberFriend implements Serializable
-{
-   private static final long serialVersionUID = -167586088947004386L;
-   
-   private Integer id;
-   private Member member;
-   private Member friend;
-   
-   private String introduction;
-   private String response;
-   
-   private boolean authorized;
-
-   @Id @GeneratedValue
-   public Integer getId()
-   {
-      return id;
-   }
-   
-   public void setId(Integer id)
-   {
-      this.id = id;
-   }   
-   
-   public boolean isAuthorized()
-   {
-      return authorized;
-   }
-   
-   public void setAuthorized(boolean authorized)
-   {
-      this.authorized = authorized;
-   }
-   
-   @ManyToOne
-   @JoinColumn(name = "FRIEND_ID")
-   public Member getFriend()
-   {
-      return friend;
-   }
-   
-   public void setFriend(Member friend)
-   {
-      this.friend = friend;
-   }
-
-   @ManyToOne
-   @JoinColumn(name = "MEMBER_ID")
-   public Member getMember()
-   {
-      return member;
-   }
-   
-   public void setMember(Member member)
-   {
-      this.member = member;
-   }
-
-   public String getIntroduction()
-   {
-      return introduction;
-   }
-
-   public void setIntroduction(String introduction)
-   {
-      this.introduction = introduction;
-   }
-
-   public String getResponse()
-   {
-      return response;
-   }
-
-   public void setResponse(String response)
-   {
-      this.response = response;
-   }      
-}

Deleted: 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-08 07:46:31 UTC (rev 10839)
+++ examples/trunk/seamspace/ejb-jar/src/main/java/org/jboss/seam/example/seamspace/MemberImage.java	2009-05-08 09:35:27 UTC (rev 10840)
@@ -1,84 +0,0 @@
-package org.jboss.seam.example.seamspace;
-
-import java.io.Serializable;
-
-import javax.persistence.Entity;
-import javax.persistence.GeneratedValue;
-import javax.persistence.Id;
-import javax.persistence.JoinColumn;
-import javax.persistence.Lob;
-import javax.persistence.ManyToOne;
-
-import org.jboss.seam.security.annotations.permission.Permission;
-import org.jboss.seam.security.annotations.permission.Permissions;
-
- at Permissions({
-   @Permission(action = "view"),
-   @Permission(action = "comment")
-})
- at Entity
-public class MemberImage implements Serializable
-{
-   private static final long serialVersionUID = -8088455267213832920L;
-   
-   private Integer imageId;
-   private Member member;
-   private byte[] data;
-   private String contentType;
-   private String caption;
-   
-   @Id @GeneratedValue
-   public Integer getImageId()
-   {
-      return imageId;
-   }
-   
-   public void setImageId(Integer imageId)
-   {
-      this.imageId = imageId;
-   }
-   
-   @ManyToOne
-   @JoinColumn(name = "MEMBER_ID")
-   public Member getMember()
-   {
-      return member;
-   }
-   
-   public void setMember(Member member)
-   {
-      this.member = member;
-   }
-
-   public String getContentType()
-   {
-      return contentType;
-   }
-
-   public void setContentType(String contentType)
-   {
-      this.contentType = contentType;
-   }
-   
-   public String getCaption()
-   {
-      return caption;
-   }
-   
-   public void setCaption(String caption)
-   {
-      this.caption = caption;
-   }
-
-   @Lob
-   public byte[] getData()
-   {
-      return data;
-   }
-
-   public void setData(byte[] data)
-   {
-      this.data = data;
-   }
-
-}

Deleted: 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-08 07:46:31 UTC (rev 10839)
+++ examples/trunk/seamspace/ejb-jar/src/main/java/org/jboss/seam/example/seamspace/MemberRole.java	2009-05-08 09:35:27 UTC (rev 10840)
@@ -1,76 +0,0 @@
-package org.jboss.seam.example.seamspace;
-
-import java.io.Serializable;
-import java.util.Set;
-
-import javax.persistence.Entity;
-import javax.persistence.GeneratedValue;
-import javax.persistence.Id;
-import javax.persistence.JoinColumn;
-import javax.persistence.JoinTable;
-import javax.persistence.ManyToMany;
-
-import org.jboss.seam.security.annotations.management.RoleConditional;
-import org.jboss.seam.security.annotations.management.RoleGroups;
-import org.jboss.seam.security.annotations.management.RoleName;
-
- at Entity
-public class MemberRole implements Serializable
-{
-   private static final long serialVersionUID = 9177366120789064801L;
-   
-   private Integer roleId;
-   private String name;
-   private boolean conditional;
-   
-   private Set<MemberRole> groups;
-   
-   @Id @GeneratedValue
-   public Integer getRoleId()
-   {
-      return roleId;
-   }
-   
-   public void setRoleId(Integer roleId)
-   {
-      this.roleId = roleId;
-   }
-   
-   @RoleName
-   public String getName()
-   {
-      return name;
-   }
-   
-   public void setName(String name)
-   {
-      this.name = name;
-   }
-   
-   @RoleGroups
-   @ManyToMany(targetEntity = MemberRole.class)
-   @JoinTable(name = "RoleGroup", 
-         joinColumns = @JoinColumn(name = "RoleId"),
-         inverseJoinColumns = @JoinColumn(name = "MemberOf")
-      )
-   public Set<MemberRole> getGroups()
-   {
-      return groups;
-   }
-   
-   public void setGroups(Set<MemberRole> groups)
-   {
-      this.groups = groups;
-   }   
-   
-   @RoleConditional
-   public boolean isConditional()
-   {
-      return conditional;
-   }
-   
-   public void setConditional(boolean conditional)
-   {
-      this.conditional = conditional;
-   }
-}

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-08 07:46:31 UTC (rev 10839)
+++ examples/trunk/seamspace/ejb-jar/src/main/java/org/jboss/seam/example/seamspace/PictureAction.java	2009-05-08 09:35:27 UTC (rev 10840)
@@ -1,20 +1,28 @@
 package org.jboss.seam.example.seamspace;
 
+import java.io.Serializable;
+
 import javax.annotation.Named;
 import javax.context.Conversation;
 import javax.context.ConversationScoped;
 import javax.inject.Current;
 import javax.persistence.EntityManager;
+import javax.persistence.PersistenceContext;
 
+import org.jboss.seam.example.seamspace.model.Member;
+import org.jboss.seam.example.seamspace.model.MemberImage;
+
 @Named
 @ConversationScoped
-public class PictureAction
+public class PictureAction implements Serializable
 {
+   private static final long serialVersionUID = -5253276146026546823L;
+
    private MemberImage memberImage;
    
-   @Current Member authenticatedMember;
+   /*@Current*/  Member authenticatedMember;
    
-   @Current EntityManager entityManager;
+   @PersistenceContext EntityManager entityManager;
    @Current Conversation conversation;
    
    public void uploadPicture()

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-08 07:46:31 UTC (rev 10839)
+++ examples/trunk/seamspace/ejb-jar/src/main/java/org/jboss/seam/example/seamspace/PictureSearch.java	2009-05-08 09:35:27 UTC (rev 10840)
@@ -7,6 +7,9 @@
 import javax.context.RequestScoped;
 import javax.inject.Current;
 import javax.persistence.EntityManager;
+import javax.persistence.PersistenceContext;
+
+import org.jboss.seam.example.seamspace.model.MemberImage;
 import org.jboss.seam.security.Identity;
 import org.jboss.seam.security.Secure;
 import org.jboss.seam.security.annotations.Delete;
@@ -20,7 +23,7 @@
    
    private String memberName;
    
-   @Current EntityManager entityManager;
+   @PersistenceContext EntityManager entityManager;
    @Current Identity identity;
    
    private List<MemberImage> memberImages;

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-08 07:46:31 UTC (rev 10839)
+++ examples/trunk/seamspace/ejb-jar/src/main/java/org/jboss/seam/example/seamspace/ProfileAction.java	2009-05-08 09:35:27 UTC (rev 10840)
@@ -1,28 +1,35 @@
 package org.jboss.seam.example.seamspace;
 
+import java.io.Serializable;
 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 javax.persistence.PersistenceContext;
 
+import org.jboss.seam.example.seamspace.model.FriendComment;
+import org.jboss.seam.example.seamspace.model.Member;
+import org.jboss.seam.example.seamspace.model.MemberBlog;
+
 @Named("profile")
 @RequestScoped
-public class ProfileAction
+public class ProfileAction implements Serializable
 {
+   private static final long serialVersionUID = 8352519286505497298L;
+
    //@RequestParameter
    private String name;
    
-   @Current Member selectedMember;
+   /*@Current */ Member selectedMember;
    
-   @Current Member authenticatedMember;  
+   /*@Current */ Member authenticatedMember;  
    
-   @Current EntityManager entityManager;
+   @PersistenceContext EntityManager entityManager;
 
    //@Factory("selectedMember")
    public void display()

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-08 07:46:31 UTC (rev 10839)
+++ examples/trunk/seamspace/ejb-jar/src/main/java/org/jboss/seam/example/seamspace/RegisterAction.java	2009-05-08 09:35:27 UTC (rev 10840)
@@ -1,30 +1,35 @@
 package org.jboss.seam.example.seamspace;
 
+import java.io.Serializable;
 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 javax.persistence.PersistenceContext;
 
+import org.jboss.seam.example.seamspace.model.Member;
+import org.jboss.seam.example.seamspace.model.MemberAccount;
+import org.jboss.seam.example.seamspace.model.MemberImage;
 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;
 
 @Named("register")
 @ConversationScoped
-public class RegisterAction
+public class RegisterAction implements Serializable
 {
+   private static final long serialVersionUID = 2943705513616351130L;
+
    private Member member;
    
-   @Current EntityManager entityManager;
+   @PersistenceContext EntityManager entityManager;
    
    @Current Identity identity;
    @Current Credentials credentials;

Added: examples/trunk/seamspace/ejb-jar/src/main/java/org/jboss/seam/example/seamspace/model/AccountPermission.java
===================================================================
--- examples/trunk/seamspace/ejb-jar/src/main/java/org/jboss/seam/example/seamspace/model/AccountPermission.java	                        (rev 0)
+++ examples/trunk/seamspace/ejb-jar/src/main/java/org/jboss/seam/example/seamspace/model/AccountPermission.java	2009-05-08 09:35:27 UTC (rev 10840)
@@ -0,0 +1,81 @@
+package org.jboss.seam.example.seamspace.model;
+
+import java.io.Serializable;
+
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.Id;
+
+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;
+
+ at Entity
+public class AccountPermission implements Serializable
+{
+   private static final long serialVersionUID = -5628863031792429938L;
+   
+   private Integer permissionId;
+   private String recipient;
+   private String target;
+   private String action;
+   private String discriminator;
+   
+   @Id @GeneratedValue
+   public Integer getPermissionId()
+   {
+      return permissionId;
+   }
+   
+   public void setPermissionId(Integer permissionId)
+   {
+      this.permissionId = permissionId;
+   }
+   
+   @PermissionUser 
+   @PermissionRole
+   public String getRecipient()
+   {
+      return recipient;
+   }
+   
+   public void setRecipient(String recipient)
+   {
+      this.recipient = recipient;
+   }
+   
+   @PermissionTarget
+   public String getTarget()
+   {
+      return target;
+   }
+   
+   public void setTarget(String target)
+   {
+      this.target = target;
+   }
+   
+   @PermissionAction
+   public String getAction()
+   {
+      return action;
+   }
+   
+   public void setAction(String action)
+   {
+      this.action = action;
+   }
+   
+   @PermissionDiscriminator
+   public String getDiscriminator()
+   {
+      return discriminator;
+   }
+   
+   public void setDiscriminator(String discriminator)
+   {
+      this.discriminator = discriminator;
+   }
+}

Added: examples/trunk/seamspace/ejb-jar/src/main/java/org/jboss/seam/example/seamspace/model/BlogComment.java
===================================================================
--- examples/trunk/seamspace/ejb-jar/src/main/java/org/jboss/seam/example/seamspace/model/BlogComment.java	                        (rev 0)
+++ examples/trunk/seamspace/ejb-jar/src/main/java/org/jboss/seam/example/seamspace/model/BlogComment.java	2009-05-08 09:35:27 UTC (rev 10840)
@@ -0,0 +1,91 @@
+package org.jboss.seam.example.seamspace.model;
+
+import java.io.Serializable;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.Id;
+import javax.persistence.JoinColumn;
+import javax.persistence.ManyToOne;
+import javax.persistence.Transient;
+import javax.validation.constraints.NotNull;
+
+ at Entity
+public class BlogComment implements Serializable
+{
+   private static final long serialVersionUID = 5495139096911872039L;
+
+   private static SimpleDateFormat df = new SimpleDateFormat("EEEE, MMMM d, yyyy 'at' hh:mm a");   
+   
+   private Integer commentId;
+   private MemberBlog blog;
+   private Member commentor;
+   private Date commentDate;
+   private String comment;
+   
+   @Id @GeneratedValue
+   public Integer getCommentId()
+   {
+      return commentId;
+   }
+   
+   public void setCommentId(Integer commentId)
+   {
+      this.commentId = commentId;
+   }   
+   
+   @ManyToOne
+   @JoinColumn(name = "BLOG_ID")
+   public MemberBlog getBlog()
+   {
+      return blog;
+   }
+   
+   public void setBlog(MemberBlog blog)
+   {
+      this.blog = blog;
+   }
+   
+   @NotNull
+   public String getComment()
+   {
+      return comment;
+   }
+   public void setComment(String comment)
+   {
+      this.comment = comment;
+   }
+   
+   @NotNull
+   public Date getCommentDate()
+   {
+      return commentDate;
+   }
+   
+   public void setCommentDate(Date commentDate)
+   {
+      this.commentDate = commentDate;
+   }
+   
+   @Transient
+   public String getFormattedCommentDate()
+   {
+     return df.format(commentDate);  
+   }
+
+   @ManyToOne
+   @JoinColumn(name = "COMMENTOR_ID")
+   public Member getCommentor()
+   {
+      return commentor;
+   }
+   
+   public void setCommentor(Member commentor)
+   {
+      this.commentor = commentor;
+   }
+  
+   
+}

Added: examples/trunk/seamspace/ejb-jar/src/main/java/org/jboss/seam/example/seamspace/model/FriendComment.java
===================================================================
--- examples/trunk/seamspace/ejb-jar/src/main/java/org/jboss/seam/example/seamspace/model/FriendComment.java	                        (rev 0)
+++ examples/trunk/seamspace/ejb-jar/src/main/java/org/jboss/seam/example/seamspace/model/FriendComment.java	2009-05-08 09:35:27 UTC (rev 10840)
@@ -0,0 +1,88 @@
+package org.jboss.seam.example.seamspace.model;
+
+import java.io.Serializable;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.Id;
+import javax.persistence.JoinColumn;
+import javax.persistence.ManyToOne;
+import javax.persistence.Transient;
+
+ at Entity
+public class FriendComment implements Serializable
+{
+   private static final long serialVersionUID = -288494386341008371L;
+
+   private static SimpleDateFormat df = new SimpleDateFormat("d MMMM yyyy hh:mm a");   
+   
+   private Integer id;
+   private Member member;
+   private Member friend;
+   private Date commentDate;
+   private String comment;
+   
+   @Id @GeneratedValue
+   public Integer getId()
+   {
+      return id;
+   }
+   
+   public void setId(Integer id)
+   {
+      this.id = id;
+   }   
+   
+   public String getComment()
+   {
+      return comment;
+   }
+   
+   public void setComment(String comment)
+   {
+      this.comment = comment;
+   }
+   
+   public Date getCommentDate()
+   {
+      return commentDate;
+   }
+   
+   public void setCommentDate(Date commentDate)
+   {
+      this.commentDate = commentDate;
+   }
+   
+   @Transient
+   public String getFormattedCommentDate()
+   {
+     return df.format(commentDate);  
+   }   
+   
+   @ManyToOne
+   @JoinColumn(name = "FRIEND_ID")
+   public Member getFriend()
+   {
+      return friend;
+   }
+   
+   public void setFriend(Member friend)
+   {
+      this.friend = friend;
+   }
+      
+   @ManyToOne
+   @JoinColumn(name = "MEMBER_ID")
+   public Member getMember()
+   {
+      return member;
+   }
+   
+   public void setMember(Member member)
+   {
+      this.member = member;
+   }
+
+}

Added: examples/trunk/seamspace/ejb-jar/src/main/java/org/jboss/seam/example/seamspace/model/Member.java
===================================================================
--- examples/trunk/seamspace/ejb-jar/src/main/java/org/jboss/seam/example/seamspace/model/Member.java	                        (rev 0)
+++ examples/trunk/seamspace/ejb-jar/src/main/java/org/jboss/seam/example/seamspace/model/Member.java	2009-05-08 09:35:27 UTC (rev 10840)
@@ -0,0 +1,252 @@
+package org.jboss.seam.example.seamspace.model;
+
+import java.io.Serializable;
+import java.util.Calendar;
+import java.util.Date;
+import java.util.GregorianCalendar;
+import java.util.Set;
+
+import javax.persistence.Entity;
+import javax.persistence.FetchType;
+import javax.persistence.GeneratedValue;
+import javax.persistence.Id;
+import javax.persistence.JoinColumn;
+import javax.persistence.OneToMany;
+import javax.persistence.OneToOne;
+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;
+
+/**
+ * A member account
+ * 
+ * @author Shane Bryzak
+ */
+ at Entity
+ at Table(uniqueConstraints = @UniqueConstraint(columnNames = "membername"))
+public class Member implements Serializable
+{
+   private static final long serialVersionUID = 5179242727836683375L;
+   
+   public enum Gender {
+      male("Male", "his"), 
+      female("Female", "her");
+      
+     private String descr;
+     private String possessive;
+     
+     Gender(String descr, String possessive) {
+       this.descr = descr;
+       this.possessive = possessive;
+      }
+     public String getDescr() {
+        return descr;
+     }
+     
+     public String getPossessive() {
+        return possessive;
+     }
+   };
+   
+   private Integer memberId;
+   private String memberName;
+   private String firstName;
+   private String lastName;
+   private String email;
+   private MemberImage picture;
+   
+   private String tagline;
+   private Gender gender;
+   private Date dob;
+   private String location;
+   private Date memberSince;
+   
+   private Set<MemberImage> images;   
+   private Set<MemberFriend> friends;
+
+   @Id @GeneratedValue
+   public Integer getMemberId()
+   {
+      return memberId;
+   }
+
+   public void setMemberId(Integer memberId)
+   {
+      this.memberId = memberId;
+   }
+   
+   @NotNull
+   @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()
+   {
+      return memberName;
+   }
+
+   public void setMemberName(String memberName)
+   {
+      this.memberName = memberName;
+   }
+   
+   @NotNull
+   @Min(3)
+   @Max(40)
+   @Pattern(regexp="[a-zA-Z]+", message="First name must only contain letters")
+   public String getFirstName()
+   {
+      return firstName;
+   }
+   
+   public void setFirstName(String firstName)
+   {
+      this.firstName = firstName;
+   }
+   
+   @NotNull
+   @Min(3)
+   @Max(40)
+   @Pattern(regexp="[a-zA-Z]+", message="Last name must only contain letters")
+   public String getLastName()
+   {
+      return lastName;
+   }
+   
+   public void setLastName(String lastName)
+   {
+      this.lastName = lastName;
+   }   
+   
+   @NotNull 
+   public String getEmail()
+   {
+      return email;
+   }
+   
+   public void setEmail(String email)
+   {
+      this.email = email;
+   }
+
+   @OneToOne(fetch = FetchType.LAZY)
+   @JoinColumn(name = "PICTURE_ID")
+   public MemberImage getPicture()
+   {
+      return picture;
+   }
+
+   public void setPicture(MemberImage picture)
+   {
+      this.picture = picture;
+   }
+
+   @NotNull
+   public Date getDob()
+   {
+      return dob;
+   }
+
+   public void setDob(Date dob)
+   {
+      this.dob = dob;
+   }
+
+   @NotNull
+   public Gender getGender()
+   {
+      return gender;
+   }
+
+   public void setGender(Gender gender)
+   {
+      this.gender = gender;
+   }
+
+   public String getLocation()
+   {
+      return location;
+   }
+
+   public void setLocation(String location)
+   {
+      this.location = location;
+   }
+   
+   @NotNull
+   public Date getMemberSince()
+   {
+      return memberSince;
+   }
+   
+   public void setMemberSince(Date memberSince)
+   {
+      this.memberSince = memberSince;
+   }
+
+   public String getTagline()
+   {
+      return tagline;
+   }
+
+   public void setTagline(String tagline)
+   {
+      this.tagline = tagline;
+   }
+
+   @OneToMany(mappedBy = "member", fetch = FetchType.LAZY)
+   public Set<MemberImage> getImages()
+   {
+      return images;
+   }
+
+   public void setImages(Set<MemberImage> images)
+   {
+      this.images = images;
+   }
+   
+   @OneToMany(mappedBy = "member")
+   public Set<MemberFriend> getFriends()
+   {
+      return friends;
+   }
+   
+   public void setFriends(Set<MemberFriend> friends)
+   {
+      this.friends = friends;   
+   }
+   
+   @Transient
+   public boolean isFriend(Member member)
+   {
+      for (MemberFriend f : friends)
+      {
+         if (f.getFriend().getMemberId().equals(member.getMemberId())) return true;          
+      }
+      
+      return false;
+   }
+   
+   @Transient
+   public String getAge()
+   {
+      Calendar birthday = new GregorianCalendar();
+      birthday.setTime(dob);
+      int by = birthday.get(Calendar.YEAR);
+      int bm = birthday.get(Calendar.MONTH);
+      int bd = birthday.get(Calendar.DATE);
+      
+      Calendar now = new GregorianCalendar();
+      now.setTimeInMillis(System.currentTimeMillis());
+      int ny = now.get(Calendar.YEAR);
+      int nm = now.get(Calendar.MONTH);
+      int nd = now.get(Calendar.DATE);      
+      
+      int age = ny - by + (nm > bm || (nm == bm && nd >= bd) ? 0 : -1);                              
+      return String.format("%d years old", age);                              
+   }
+}

Added: examples/trunk/seamspace/ejb-jar/src/main/java/org/jboss/seam/example/seamspace/model/MemberAccount.java
===================================================================
--- examples/trunk/seamspace/ejb-jar/src/main/java/org/jboss/seam/example/seamspace/model/MemberAccount.java	                        (rev 0)
+++ examples/trunk/seamspace/ejb-jar/src/main/java/org/jboss/seam/example/seamspace/model/MemberAccount.java	2009-05-08 09:35:27 UTC (rev 10840)
@@ -0,0 +1,120 @@
+package org.jboss.seam.example.seamspace.model;
+
+import java.io.Serializable;
+import java.util.Set;
+
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.Id;
+import javax.persistence.JoinColumn;
+import javax.persistence.JoinTable;
+import javax.persistence.ManyToMany;
+import javax.persistence.OneToOne;
+import javax.persistence.Table;
+import javax.persistence.UniqueConstraint;
+import javax.validation.constraints.NotNull;
+
+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;
+
+ at Entity
+ at Table(uniqueConstraints = @UniqueConstraint(columnNames = "username"))
+public class MemberAccount implements Serializable
+{
+   private static final long serialVersionUID = 6368734442192368866L;
+   
+   private Integer accountId;
+   private String username;
+   private String passwordHash;
+   private String passwordSalt;
+   private boolean enabled;   
+   
+   private Set<MemberRole> roles;
+   private Member member;   
+   
+   @Id @GeneratedValue
+   public Integer getAccountId()
+   {
+      return accountId;
+   }
+   
+   public void setAccountId(Integer accountId)
+   {
+      this.accountId = accountId;
+   }
+   
+   @NotNull @UserPrincipal
+   public String getUsername()
+   {
+      return username;
+   }
+   
+   public void setUsername(String username)
+   {
+      this.username = username;
+   }
+   
+   @UserPassword
+   public String getPasswordHash()
+   {
+      return passwordHash;
+   }
+   
+   public void setPasswordHash(String passwordHash)
+   {
+      this.passwordHash = passwordHash;      
+   }
+   
+   @PasswordSalt
+   public String getPasswordSalt()
+   {
+      return passwordSalt;
+   }
+   
+   public void setPasswordSalt(String passwordSalt)
+   {
+      this.passwordSalt = passwordSalt;
+   }
+   
+   @UserEnabled
+   public boolean isEnabled()
+   {
+      return enabled;
+   }
+
+   public void setEnabled(boolean enabled)
+   {
+      this.enabled = enabled;      
+   }   
+
+   @UserRoles
+   @ManyToMany(targetEntity = MemberRole.class)
+   @JoinTable(name = "AccountMembership", 
+         joinColumns = @JoinColumn(name = "AccountId"),
+         inverseJoinColumns = @JoinColumn(name = "MemberOf")
+      )
+   public Set<MemberRole> getRoles()
+   {
+      return roles;
+   }
+   
+   public void setRoles(Set<MemberRole> roles)
+   {
+      this.roles = roles;
+   }
+   
+   @OneToOne
+   @JoinColumn(name = "MEMBER_ID")
+   public Member getMember()
+   {
+      return member;
+   }
+   
+   public void setMember(Member member)
+   {
+      this.member = member;
+   }
+}

Added: examples/trunk/seamspace/ejb-jar/src/main/java/org/jboss/seam/example/seamspace/model/MemberBlog.java
===================================================================
--- examples/trunk/seamspace/ejb-jar/src/main/java/org/jboss/seam/example/seamspace/model/MemberBlog.java	                        (rev 0)
+++ examples/trunk/seamspace/ejb-jar/src/main/java/org/jboss/seam/example/seamspace/model/MemberBlog.java	2009-05-08 09:35:27 UTC (rev 10840)
@@ -0,0 +1,130 @@
+package org.jboss.seam.example.seamspace.model;
+
+import java.io.Serializable;
+import java.text.SimpleDateFormat;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.Date;
+import java.util.List;
+
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.Id;
+import javax.persistence.JoinColumn;
+import javax.persistence.ManyToOne;
+import javax.persistence.OneToMany;
+import javax.persistence.PrePersist;
+import javax.persistence.Transient;
+
+ at Entity
+public class MemberBlog implements Serializable
+{
+   private static final long serialVersionUID = 7824113911888715595L;
+   
+   private static SimpleDateFormat df = new SimpleDateFormat("EEEE, MMMM d, yyyy - hh:mm a");
+   
+   private Integer blogId;
+   private Member member;
+   private Date entryDate;
+   private String title;
+   private String text;
+   
+   private List<BlogComment> comments;
+   
+   /**
+    * This is an example of a security restriction.  Any attempts to persist a
+    * new memberBlog instance requires the user to pass a permission check.  In 
+    * this case, because the method is annotated with <code>@PrePersist</code> 
+    * the required permission is memberBlog:insert    
+    */
+   @PrePersist // @Restrict
+   public void prePersist() {}
+   
+   @Id @GeneratedValue
+   public Integer getBlogId()
+   {
+      return blogId;
+   }
+   
+   public void setBlogId(Integer blogId)
+   {
+      this.blogId = blogId;
+   }
+
+   public Date getEntryDate()
+   {
+      return entryDate;
+   }
+
+   public void setEntryDate(Date entryDate)
+   {
+      this.entryDate = entryDate;
+   }
+   
+   @Transient
+   public String getFormattedEntryDate()
+   {
+      return df.format(entryDate);
+   }
+
+   @ManyToOne
+   @JoinColumn(name = "MEMBER_ID")   
+   public Member getMember()
+   {
+      return member;
+   }
+
+   public void setMember(Member member)
+   {
+      this.member = member;
+   }
+
+   public String getText()
+   {
+      return text;
+   }
+
+   public void setText(String text)
+   {
+      this.text = text;
+   }
+
+   public String getTitle()
+   {
+      return title;
+   }
+
+   public void setTitle(String title)
+   {
+      this.title = title;
+   }
+   
+   @OneToMany(mappedBy = "blog")
+   public List<BlogComment> getComments()
+   {
+      return comments;
+   }
+   
+   public void setComments(List<BlogComment> comments)
+   {
+      this.comments = comments;
+   }
+   
+   @Transient
+   public List<BlogComment> getSortedComments()
+   {
+      Collections.sort(comments, new Comparator<BlogComment>() {
+         public int compare(BlogComment o1, BlogComment o2) {
+            return (int) (o1.getCommentDate().getTime() - o2.getCommentDate().getTime());
+         }
+      });
+      
+      return comments;
+   }
+   
+   @Transient
+   public int getCommentCount()
+   {
+      return comments.size();
+   }
+}

Added: examples/trunk/seamspace/ejb-jar/src/main/java/org/jboss/seam/example/seamspace/model/MemberFriend.java
===================================================================
--- examples/trunk/seamspace/ejb-jar/src/main/java/org/jboss/seam/example/seamspace/model/MemberFriend.java	                        (rev 0)
+++ examples/trunk/seamspace/ejb-jar/src/main/java/org/jboss/seam/example/seamspace/model/MemberFriend.java	2009-05-08 09:35:27 UTC (rev 10840)
@@ -0,0 +1,89 @@
+package org.jboss.seam.example.seamspace.model;
+
+import java.io.Serializable;
+
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.Id;
+import javax.persistence.JoinColumn;
+import javax.persistence.ManyToOne;
+
+ at Entity
+public class MemberFriend implements Serializable
+{
+   private static final long serialVersionUID = -167586088947004386L;
+   
+   private Integer id;
+   private Member member;
+   private Member friend;
+   
+   private String introduction;
+   private String response;
+   
+   private boolean authorized;
+
+   @Id @GeneratedValue
+   public Integer getId()
+   {
+      return id;
+   }
+   
+   public void setId(Integer id)
+   {
+      this.id = id;
+   }   
+   
+   public boolean isAuthorized()
+   {
+      return authorized;
+   }
+   
+   public void setAuthorized(boolean authorized)
+   {
+      this.authorized = authorized;
+   }
+   
+   @ManyToOne
+   @JoinColumn(name = "FRIEND_ID")
+   public Member getFriend()
+   {
+      return friend;
+   }
+   
+   public void setFriend(Member friend)
+   {
+      this.friend = friend;
+   }
+
+   @ManyToOne
+   @JoinColumn(name = "MEMBER_ID")
+   public Member getMember()
+   {
+      return member;
+   }
+   
+   public void setMember(Member member)
+   {
+      this.member = member;
+   }
+
+   public String getIntroduction()
+   {
+      return introduction;
+   }
+
+   public void setIntroduction(String introduction)
+   {
+      this.introduction = introduction;
+   }
+
+   public String getResponse()
+   {
+      return response;
+   }
+
+   public void setResponse(String response)
+   {
+      this.response = response;
+   }      
+}

Added: examples/trunk/seamspace/ejb-jar/src/main/java/org/jboss/seam/example/seamspace/model/MemberImage.java
===================================================================
--- examples/trunk/seamspace/ejb-jar/src/main/java/org/jboss/seam/example/seamspace/model/MemberImage.java	                        (rev 0)
+++ examples/trunk/seamspace/ejb-jar/src/main/java/org/jboss/seam/example/seamspace/model/MemberImage.java	2009-05-08 09:35:27 UTC (rev 10840)
@@ -0,0 +1,84 @@
+package org.jboss.seam.example.seamspace.model;
+
+import java.io.Serializable;
+
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.Id;
+import javax.persistence.JoinColumn;
+import javax.persistence.Lob;
+import javax.persistence.ManyToOne;
+
+import org.jboss.seam.security.annotations.permission.Permission;
+import org.jboss.seam.security.annotations.permission.Permissions;
+
+ at Permissions({
+   @Permission(action = "view"),
+   @Permission(action = "comment")
+})
+ at Entity
+public class MemberImage implements Serializable
+{
+   private static final long serialVersionUID = -8088455267213832920L;
+   
+   private Integer imageId;
+   private Member member;
+   private byte[] data;
+   private String contentType;
+   private String caption;
+   
+   @Id @GeneratedValue
+   public Integer getImageId()
+   {
+      return imageId;
+   }
+   
+   public void setImageId(Integer imageId)
+   {
+      this.imageId = imageId;
+   }
+   
+   @ManyToOne
+   @JoinColumn(name = "MEMBER_ID")
+   public Member getMember()
+   {
+      return member;
+   }
+   
+   public void setMember(Member member)
+   {
+      this.member = member;
+   }
+
+   public String getContentType()
+   {
+      return contentType;
+   }
+
+   public void setContentType(String contentType)
+   {
+      this.contentType = contentType;
+   }
+   
+   public String getCaption()
+   {
+      return caption;
+   }
+   
+   public void setCaption(String caption)
+   {
+      this.caption = caption;
+   }
+
+   @Lob
+   public byte[] getData()
+   {
+      return data;
+   }
+
+   public void setData(byte[] data)
+   {
+      this.data = data;
+   }
+
+}

Added: examples/trunk/seamspace/ejb-jar/src/main/java/org/jboss/seam/example/seamspace/model/MemberRole.java
===================================================================
--- examples/trunk/seamspace/ejb-jar/src/main/java/org/jboss/seam/example/seamspace/model/MemberRole.java	                        (rev 0)
+++ examples/trunk/seamspace/ejb-jar/src/main/java/org/jboss/seam/example/seamspace/model/MemberRole.java	2009-05-08 09:35:27 UTC (rev 10840)
@@ -0,0 +1,76 @@
+package org.jboss.seam.example.seamspace.model;
+
+import java.io.Serializable;
+import java.util.Set;
+
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.Id;
+import javax.persistence.JoinColumn;
+import javax.persistence.JoinTable;
+import javax.persistence.ManyToMany;
+
+import org.jboss.seam.security.annotations.management.RoleConditional;
+import org.jboss.seam.security.annotations.management.RoleGroups;
+import org.jboss.seam.security.annotations.management.RoleName;
+
+ at Entity
+public class MemberRole implements Serializable
+{
+   private static final long serialVersionUID = 9177366120789064801L;
+   
+   private Integer roleId;
+   private String name;
+   private boolean conditional;
+   
+   private Set<MemberRole> groups;
+   
+   @Id @GeneratedValue
+   public Integer getRoleId()
+   {
+      return roleId;
+   }
+   
+   public void setRoleId(Integer roleId)
+   {
+      this.roleId = roleId;
+   }
+   
+   @RoleName
+   public String getName()
+   {
+      return name;
+   }
+   
+   public void setName(String name)
+   {
+      this.name = name;
+   }
+   
+   @RoleGroups
+   @ManyToMany(targetEntity = MemberRole.class)
+   @JoinTable(name = "RoleGroup", 
+         joinColumns = @JoinColumn(name = "RoleId"),
+         inverseJoinColumns = @JoinColumn(name = "MemberOf")
+      )
+   public Set<MemberRole> getGroups()
+   {
+      return groups;
+   }
+   
+   public void setGroups(Set<MemberRole> groups)
+   {
+      this.groups = groups;
+   }   
+   
+   @RoleConditional
+   public boolean isConditional()
+   {
+      return conditional;
+   }
+   
+   public void setConditional(boolean conditional)
+   {
+      this.conditional = conditional;
+   }
+}




More information about the seam-commits mailing list