[seam-commits] Seam SVN: r10627 - in modules/trunk/security/src/main/java/org/jboss/seam/security: management and 3 other directories.

seam-commits at lists.jboss.org seam-commits at lists.jboss.org
Fri Apr 24 09:13:27 EDT 2009


Author: shane.bryzak at jboss.com
Date: 2009-04-24 09:13:27 -0400 (Fri, 24 Apr 2009)
New Revision: 10627

Added:
   modules/trunk/security/src/main/java/org/jboss/seam/security/events/PrePersistUserEvent.java
   modules/trunk/security/src/main/java/org/jboss/seam/security/events/PrePersistUserRoleEvent.java
   modules/trunk/security/src/main/java/org/jboss/seam/security/events/UserAuthenticatedEvent.java
   modules/trunk/security/src/main/java/org/jboss/seam/security/events/UserCreatedEvent.java
   modules/trunk/security/src/main/java/org/jboss/seam/security/util/AnnotatedBeanProperty.java
   modules/trunk/security/src/main/java/org/jboss/seam/security/util/Reflections.java
   modules/trunk/security/src/main/java/org/jboss/seam/security/util/TypedBeanProperty.java
Removed:
   modules/trunk/security/src/main/java/org/jboss/seam/security/management/package-info.java
   modules/trunk/security/src/main/java/org/jboss/seam/security/permission/package-info.java
Modified:
   modules/trunk/security/src/main/java/org/jboss/seam/security/management/IdentityManager.java
   modules/trunk/security/src/main/java/org/jboss/seam/security/management/JpaIdentityStore.java
   modules/trunk/security/src/main/java/org/jboss/seam/security/management/LdapIdentityStore.java
   modules/trunk/security/src/main/java/org/jboss/seam/security/management/action/RoleAction.java
   modules/trunk/security/src/main/java/org/jboss/seam/security/management/action/RoleSearch.java
   modules/trunk/security/src/main/java/org/jboss/seam/security/management/action/UserAction.java
   modules/trunk/security/src/main/java/org/jboss/seam/security/management/action/UserSearch.java
   modules/trunk/security/src/main/java/org/jboss/seam/security/util/Strings.java
Log:
more porting

Added: modules/trunk/security/src/main/java/org/jboss/seam/security/events/PrePersistUserEvent.java
===================================================================
--- modules/trunk/security/src/main/java/org/jboss/seam/security/events/PrePersistUserEvent.java	                        (rev 0)
+++ modules/trunk/security/src/main/java/org/jboss/seam/security/events/PrePersistUserEvent.java	2009-04-24 13:13:27 UTC (rev 10627)
@@ -0,0 +1,21 @@
+package org.jboss.seam.security.events;
+
+/**
+ * This event is raised just before a new user is persisted
+ * 
+ * @author Shane Bryzak
+ */
+public class PrePersistUserEvent
+{
+   private Object user;
+   
+   public PrePersistUserEvent(Object user)
+   {
+      this.user = user;
+   }
+   
+   public Object getUser()
+   {
+      return user;
+   }
+}

Added: modules/trunk/security/src/main/java/org/jboss/seam/security/events/PrePersistUserRoleEvent.java
===================================================================
--- modules/trunk/security/src/main/java/org/jboss/seam/security/events/PrePersistUserRoleEvent.java	                        (rev 0)
+++ modules/trunk/security/src/main/java/org/jboss/seam/security/events/PrePersistUserRoleEvent.java	2009-04-24 13:13:27 UTC (rev 10627)
@@ -0,0 +1,21 @@
+package org.jboss.seam.security.events;
+
+/**
+ * This event is raised just before a user role is persisted
+ *  
+ * @author Shane Bryzak
+ */
+public class PrePersistUserRoleEvent
+{
+   private Object xref;
+   
+   public PrePersistUserRoleEvent(Object xref)
+   {
+      this.xref = xref;
+   }
+   
+   public Object getXref()
+   {
+      return xref;
+   }
+}

Added: modules/trunk/security/src/main/java/org/jboss/seam/security/events/UserAuthenticatedEvent.java
===================================================================
--- modules/trunk/security/src/main/java/org/jboss/seam/security/events/UserAuthenticatedEvent.java	                        (rev 0)
+++ modules/trunk/security/src/main/java/org/jboss/seam/security/events/UserAuthenticatedEvent.java	2009-04-24 13:13:27 UTC (rev 10627)
@@ -0,0 +1,21 @@
+package org.jboss.seam.security.events;
+
+/**
+ * This event is raised when a user is authenticated
+ *  
+ * @author Shane Bryzak
+ */
+public class UserAuthenticatedEvent
+{
+   private Object user;
+   
+   public UserAuthenticatedEvent(Object user)
+   {
+      this.user = user;
+   }
+   
+   public Object getUser()
+   {
+      return user;
+   }
+}

Added: modules/trunk/security/src/main/java/org/jboss/seam/security/events/UserCreatedEvent.java
===================================================================
--- modules/trunk/security/src/main/java/org/jboss/seam/security/events/UserCreatedEvent.java	                        (rev 0)
+++ modules/trunk/security/src/main/java/org/jboss/seam/security/events/UserCreatedEvent.java	2009-04-24 13:13:27 UTC (rev 10627)
@@ -0,0 +1,21 @@
+package org.jboss.seam.security.events;
+
+/**
+ * This event is raised immediately after a user is created
+ *  
+ * @author Shane Bryzak
+ */
+public class UserCreatedEvent
+{
+   private Object user;
+   
+   public UserCreatedEvent(Object user)
+   {
+      this.user = user;
+   }
+   
+   public Object getUser()
+   {
+      return user;
+   }
+}

Modified: modules/trunk/security/src/main/java/org/jboss/seam/security/management/IdentityManager.java
===================================================================
--- modules/trunk/security/src/main/java/org/jboss/seam/security/management/IdentityManager.java	2009-04-24 12:36:43 UTC (rev 10626)
+++ modules/trunk/security/src/main/java/org/jboss/seam/security/management/IdentityManager.java	2009-04-24 13:13:27 UTC (rev 10627)
@@ -10,6 +10,7 @@
 import javax.context.RequestScoped;
 import javax.inject.Current;
 import javax.inject.Initializer;
+import javax.inject.manager.Bean;
 import javax.inject.manager.Manager;
 
 import org.jboss.webbeans.log.LogProvider;
@@ -55,7 +56,8 @@
       // Default to JpaIdentityStore
       if (identityStore == null)
       {         
-         identityStore = (IdentityStore) Component.getInstance(JpaIdentityStore.class, true);
+         Bean<JpaIdentityStore> jpaIdentityStoreBean = manager.resolveByType(JpaIdentityStore.class).iterator().next();
+         identityStore = (IdentityStore) manager.getInstance(jpaIdentityStoreBean);
       }
       
       if (roleIdentityStore == null && identityStore != null)

Modified: modules/trunk/security/src/main/java/org/jboss/seam/security/management/JpaIdentityStore.java
===================================================================
--- modules/trunk/security/src/main/java/org/jboss/seam/security/management/JpaIdentityStore.java	2009-04-24 12:36:43 UTC (rev 10626)
+++ modules/trunk/security/src/main/java/org/jboss/seam/security/management/JpaIdentityStore.java	2009-04-24 13:13:27 UTC (rev 10627)
@@ -1,8 +1,5 @@
 package org.jboss.seam.security.management;
 
-import static org.jboss.seam.ScopeType.APPLICATION;
-import static org.jboss.seam.annotations.Install.BUILT_IN;
-
 import java.io.Serializable;
 import java.lang.reflect.ParameterizedType;
 import java.lang.reflect.Type;
@@ -14,66 +11,63 @@
 import java.util.List;
 import java.util.Set;
 
+import javax.annotation.Named;
+import javax.context.ApplicationScoped;
+import javax.event.Observes;
+import javax.inject.Current;
+import javax.inject.Initializer;
+import javax.inject.manager.Bean;
+import javax.inject.manager.Manager;
 import javax.persistence.EntityManager;
 import javax.persistence.NoResultException;
 
-import org.jboss.seam.annotations.Create;
-import org.jboss.seam.annotations.Install;
-import org.jboss.seam.annotations.Name;
-import org.jboss.seam.annotations.Observer;
-import org.jboss.seam.annotations.Scope;
-import org.jboss.seam.annotations.intercept.BypassInterceptors;
-import org.jboss.seam.annotations.security.management.PasswordSalt;
-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.annotations.security.management.UserEnabled;
-import org.jboss.seam.annotations.security.management.UserFirstName;
-import org.jboss.seam.annotations.security.management.UserLastName;
-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.RoleConditional;
+import org.jboss.seam.security.annotations.management.RoleGroups;
+import org.jboss.seam.security.annotations.management.RoleName;
+import org.jboss.seam.security.annotations.management.UserEnabled;
+import org.jboss.seam.security.annotations.management.UserFirstName;
+import org.jboss.seam.security.annotations.management.UserLastName;
+import org.jboss.seam.security.annotations.management.UserPassword;
+import org.jboss.seam.security.annotations.management.UserPrincipal;
+import org.jboss.seam.security.annotations.management.UserRoles;
 import org.jboss.seam.contexts.Contexts;
-import org.jboss.seam.core.Events;
 import org.jboss.seam.core.Expressions;
 import org.jboss.seam.core.Expressions.ValueExpression;
-import org.jboss.seam.log.LogProvider;
-import org.jboss.seam.log.Logging;
+import org.jboss.webbeans.log.LogProvider;
+import org.jboss.webbeans.log.Logging;
 import org.jboss.seam.security.Identity;
 import org.jboss.seam.security.Role;
 import org.jboss.seam.security.SimplePrincipal;
 import org.jboss.seam.security.crypto.BinTools;
-import org.jboss.seam.util.AnnotatedBeanProperty;
-import org.jboss.seam.util.TypedBeanProperty;
+import org.jboss.seam.security.events.PostAuthenticateEvent;
+import org.jboss.seam.security.events.PrePersistUserEvent;
+import org.jboss.seam.security.events.PrePersistUserRoleEvent;
+import org.jboss.seam.security.events.UserAuthenticatedEvent;
+import org.jboss.seam.security.events.UserCreatedEvent;
+import org.jboss.seam.security.util.AnnotatedBeanProperty;
+import org.jboss.seam.security.util.TypedBeanProperty;
 
 /**
  * The default identity store implementation, uses JPA as its persistence mechanism.
  * 
  * @author Shane Bryzak
  */
- at Name("org.jboss.seam.security.identityStore")
- at Install(precedence = BUILT_IN, value=false) 
- at Scope(APPLICATION)
- at BypassInterceptors
+ at Named("identityStore")
+ at ApplicationScoped
 public class JpaIdentityStore implements IdentityStore, Serializable
-{  
-   public static final String AUTHENTICATED_USER = "org.jboss.seam.security.management.authenticatedUser";
-   
-   public static final String EVENT_USER_CREATED = "org.jboss.seam.security.management.userCreated";
-   public static final String EVENT_PRE_PERSIST_USER = "org.jboss.seam.security.management.prePersistUser";
-   public static final String EVENT_USER_AUTHENTICATED = "org.jboss.seam.security.management.userAuthenticated";
-   
-   public static final String EVENT_PRE_PERSIST_USER_ROLE = "org.jboss.seam.security.management.prePersistUserRole";
-   
+{     
    private static final LogProvider log = Logging.getLogProvider(JpaIdentityStore.class);    
    
    protected FeatureSet featureSet;
    
    private ValueExpression<EntityManager> entityManager;  
+   private Bean<EntityManager> entityManagerBean;
+   @Current Manager manager;
    
-   private Class userClass;
-   private Class roleClass;   
-   private Class xrefClass;
+   private Class<?> userClass;
+   private Class<?> roleClass;   
+   private Class<?> xrefClass;
    private TypedBeanProperty xrefUserProperty;
    private TypedBeanProperty xrefRoleProperty;
    
@@ -103,7 +97,7 @@
       return featureSet.supports(feature);
    }
    
-   @Create
+   @Initializer
    public void init()
    {                  
       if (featureSet == null)
@@ -128,13 +122,13 @@
    
    private void initProperties()
    {
-      userPrincipalProperty = new AnnotatedBeanProperty(userClass, UserPrincipal.class);
-      userPasswordProperty = new AnnotatedBeanProperty(userClass, UserPassword.class);
-      passwordSaltProperty = new AnnotatedBeanProperty(userClass, PasswordSalt.class);
-      userRolesProperty = new AnnotatedBeanProperty(userClass, UserRoles.class);
-      userEnabledProperty = new AnnotatedBeanProperty(userClass, UserEnabled.class);
-      userFirstNameProperty = new AnnotatedBeanProperty(userClass, UserFirstName.class);
-      userLastNameProperty = new AnnotatedBeanProperty(userClass, UserLastName.class);
+      userPrincipalProperty = new AnnotatedBeanProperty<UserPrincipal>(userClass, UserPrincipal.class);
+      userPasswordProperty = new AnnotatedBeanProperty<UserPassword>(userClass, UserPassword.class);
+      passwordSaltProperty = new AnnotatedBeanProperty<PasswordSalt>(userClass, PasswordSalt.class);
+      userRolesProperty = new AnnotatedBeanProperty<UserRoles>(userClass, UserRoles.class);
+      userEnabledProperty = new AnnotatedBeanProperty<UserEnabled>(userClass, UserEnabled.class);
+      userFirstNameProperty = new AnnotatedBeanProperty<UserFirstName>(userClass, UserFirstName.class);
+      userLastNameProperty = new AnnotatedBeanProperty<UserLastName>(userClass, UserLastName.class);
              
       if (!userPrincipalProperty.isSet()) 
       {
@@ -150,9 +144,9 @@
       
       if (roleClass != null)
       {         
-         roleNameProperty = new AnnotatedBeanProperty(roleClass, RoleName.class);
-         roleGroupsProperty = new AnnotatedBeanProperty(roleClass, RoleGroups.class);
-         roleConditionalProperty = new AnnotatedBeanProperty(roleClass, RoleConditional.class);
+         roleNameProperty = new AnnotatedBeanProperty<RoleName>(roleClass, RoleName.class);
+         roleGroupsProperty = new AnnotatedBeanProperty<RoleGroups>(roleClass, RoleGroups.class);
+         roleConditionalProperty = new AnnotatedBeanProperty<RoleConditional>(roleClass, RoleConditional.class);
          
          if (!roleNameProperty.isSet())
          {
@@ -162,7 +156,7 @@
                  
          Type type = userRolesProperty.getPropertyType();
          if (type instanceof ParameterizedType && 
-               Collection.class.isAssignableFrom((Class) ((ParameterizedType) type).getRawType()))
+               Collection.class.isAssignableFrom((Class<?>) ((ParameterizedType) type).getRawType()))
          {
             Type genType = Object.class;
 
@@ -176,7 +170,7 @@
             // is going through a cross-reference table            
             if (!genType.equals(roleClass))
             {
-               xrefClass = (Class) genType;
+               xrefClass = (Class<?>) genType;
                xrefUserProperty = new TypedBeanProperty(xrefClass, userClass);
                xrefRoleProperty = new TypedBeanProperty(xrefClass, roleClass);
                
@@ -227,12 +221,12 @@
             if (userEnabledProperty.isSet()) userEnabledProperty.setValue(user, true);
          }
          
-         if (Events.exists()) Events.instance().raiseEvent(EVENT_PRE_PERSIST_USER, user);
+         manager.fireEvent(new PrePersistUserEvent(user));
          
          persistEntity(user);
+
+         manager.fireEvent(new UserCreatedEvent(user));
          
-         if (Events.exists()) Events.instance().raiseEvent(EVENT_USER_CREATED, user);
-         
          return true;
       }
       catch (Exception ex)
@@ -331,7 +325,7 @@
          throw new NoSuchRoleException("Could not grant role, role '" + role + "' does not exist");
       }
       
-      Collection userRoles = (Collection) userRolesProperty.getValue(user); 
+      Collection<?> userRoles = (Collection<?>) userRolesProperty.getValue(user); 
       if (userRoles == null)
       {
          Type propType = userRolesProperty.getPropertyType();
@@ -382,7 +376,7 @@
             xrefUserProperty.setValue(xref, user);
             xrefRoleProperty.setValue(xref, roleToGrant);
             
-            Events.instance().raiseEvent(EVENT_PRE_PERSIST_USER_ROLE, xref);
+            manager.fireEvent(new PrePersistUserRoleEvent(xref));
             
             ((Collection) userRolesProperty.getValue(user)).add(mergeEntity(xref));
          }
@@ -830,21 +824,19 @@
        
       boolean success = passwordHash.equals(userPasswordProperty.getValue(user));
             
-      if (success && Events.exists())
+      if (success)
       {
          if (Contexts.isEventContextActive())
          {
             Contexts.getEventContext().set(AUTHENTICATED_USER, user);
          }
          
-         Events.instance().raiseEvent(EVENT_USER_AUTHENTICATED, user);
-      }
+         manager.fireEvent(new UserAuthenticatedEvent(user));
       
       return success;
    }
    
-   @Observer(Identity.EVENT_POST_AUTHENTICATE)
-   public void setUserAccountForSession()
+   public void setUserAccountForSession(@Observes PostAuthenticateEvent event)
    {
       if (Contexts.isEventContextActive() && Contexts.isSessionContextActive())
       {
@@ -1049,15 +1041,5 @@
    private EntityManager lookupEntityManager()
    {
       return entityManager.getValue();
-   }
-   
-   public ValueExpression getEntityManager()
-   {
-      return entityManager;
-   }
-   
-   public void setEntityManager(ValueExpression expression)
-   {
-      this.entityManager = expression;
-   }      
+   }     
 }

Modified: modules/trunk/security/src/main/java/org/jboss/seam/security/management/LdapIdentityStore.java
===================================================================
--- modules/trunk/security/src/main/java/org/jboss/seam/security/management/LdapIdentityStore.java	2009-04-24 12:36:43 UTC (rev 10626)
+++ modules/trunk/security/src/main/java/org/jboss/seam/security/management/LdapIdentityStore.java	2009-04-24 13:13:27 UTC (rev 10627)
@@ -1,8 +1,5 @@
 package org.jboss.seam.security.management;
 
-import static org.jboss.seam.ScopeType.APPLICATION;
-import static org.jboss.seam.annotations.Install.BUILT_IN;
-
 import java.io.Serializable;
 import java.security.Principal;
 import java.util.ArrayList;
@@ -11,6 +8,8 @@
 import java.util.Properties;
 import java.util.Set;
 
+import javax.annotation.Named;
+import javax.context.ApplicationScoped;
 import javax.naming.Context;
 import javax.naming.NamingEnumeration;
 import javax.naming.NamingException;
@@ -24,24 +23,20 @@
 import javax.naming.directory.SearchResult;
 import javax.naming.ldap.InitialLdapContext;
 
-import org.jboss.seam.annotations.Install;
-import org.jboss.seam.annotations.Name;
-import org.jboss.seam.annotations.Scope;
-import org.jboss.seam.annotations.intercept.BypassInterceptors;
-import org.jboss.seam.log.LogProvider;
-import org.jboss.seam.log.Logging;
+import org.jboss.webbeans.log.LogProvider;
+import org.jboss.webbeans.log.Logging;
 
 /**
  * An IdentityStore implementation that integrates with a directory service.
  * 
  * @author Shane Bryzak
  */
- at Name("org.jboss.seam.security.identityStore")
- at Install(precedence = BUILT_IN, value=false) 
- at Scope(APPLICATION)
- at BypassInterceptors
+ at Named("identityStore")
+ at ApplicationScoped
 public class LdapIdentityStore implements IdentityStore, Serializable
 {
+   private static final long serialVersionUID = 1854090869689846220L;
+   
    // constants for LDAP syntax 1.3.6.1.4.1.1466.115.121.1.7 (boolean)
    private static final String LDAP_BOOLEAN_TRUE = "TRUE";
    private static final String LDAP_BOOLEAN_FALSE = "FALSE";

Modified: modules/trunk/security/src/main/java/org/jboss/seam/security/management/action/RoleAction.java
===================================================================
--- modules/trunk/security/src/main/java/org/jboss/seam/security/management/action/RoleAction.java	2009-04-24 12:36:43 UTC (rev 10626)
+++ modules/trunk/security/src/main/java/org/jboss/seam/security/management/action/RoleAction.java	2009-04-24 13:13:27 UTC (rev 10627)
@@ -1,40 +1,39 @@
 package org.jboss.seam.security.management.action;
 
-import static org.jboss.seam.ScopeType.CONVERSATION;
-import static org.jboss.seam.annotations.Install.BUILT_IN;
-
 import java.io.Serializable;
 import java.util.ArrayList;
 import java.util.List;
 
-import org.jboss.seam.annotations.Begin;
-import org.jboss.seam.annotations.In;
-import org.jboss.seam.annotations.Install;
-import org.jboss.seam.annotations.Name;
-import org.jboss.seam.annotations.Scope;
-import org.jboss.seam.core.Conversation;
+import javax.annotation.Named;
+import javax.context.Conversation;
+import javax.context.ConversationScoped;
+import javax.inject.Current;
+
 import org.jboss.seam.security.management.IdentityManager;
 
- at Name("org.jboss.seam.security.management.roleAction")
- at Scope(CONVERSATION)
- at Install(precedence = BUILT_IN)
+ at Named
+ at ConversationScoped
 public class RoleAction implements Serializable
 {
+   private static final long serialVersionUID = -4215849488301658353L;
+   
    private String originalRole;
    private String role;
    private List<String> groups;
    
-   @In IdentityManager identityManager;
+   @Current IdentityManager identityManager;
+   @Current Conversation conversation;
    
-   @Begin
    public void createRole()
    {
+      conversation.begin();
       groups = new ArrayList<String>();
    }
    
-   @Begin
    public void editRole(String role)
    {
+      conversation.begin();
+      
       this.originalRole = role;
       this.role = role;
       groups = identityManager.getRoleGroups(role);
@@ -68,7 +67,7 @@
             identityManager.addRoleToGroup(role, r);
          }
          
-         Conversation.instance().end();
+         conversation.end();
       }
       
       return "success";      
@@ -91,7 +90,7 @@
          if (grantedRoles == null || !grantedRoles.contains(r)) identityManager.addRoleToGroup(role, r);
       }
                
-      Conversation.instance().end();
+      conversation.end();
       return "success";
    }
    

Modified: modules/trunk/security/src/main/java/org/jboss/seam/security/management/action/RoleSearch.java
===================================================================
--- modules/trunk/security/src/main/java/org/jboss/seam/security/management/action/RoleSearch.java	2009-04-24 12:36:43 UTC (rev 10626)
+++ modules/trunk/security/src/main/java/org/jboss/seam/security/management/action/RoleSearch.java	2009-04-24 13:13:27 UTC (rev 10627)
@@ -1,31 +1,27 @@
 package org.jboss.seam.security.management.action;
 
-import static org.jboss.seam.ScopeType.SESSION;
-import static org.jboss.seam.annotations.Install.BUILT_IN;
-
 import java.io.Serializable;
 import java.util.List;
 
-import org.jboss.seam.annotations.In;
-import org.jboss.seam.annotations.Install;
-import org.jboss.seam.annotations.Name;
-import org.jboss.seam.annotations.Scope;
-import org.jboss.seam.annotations.datamodel.DataModel;
-import org.jboss.seam.annotations.datamodel.DataModelSelection;
+import javax.annotation.Named;
+import javax.context.SessionScoped;
+import javax.inject.Current;
+
 import org.jboss.seam.security.management.IdentityManager;
 
- at Name("org.jboss.seam.security.management.roleSearch")
- at Scope(SESSION)
- at Install(precedence = BUILT_IN)
+ at Named
+ at SessionScoped
 public class RoleSearch implements Serializable
 {
+   private static final long serialVersionUID = -1014495134519417515L;
+
    @DataModel
    List<String> roles;
    
    @DataModelSelection
    String selectedRole;
    
-   @In IdentityManager identityManager;
+   @Current IdentityManager identityManager;
    
    public void loadRoles()
    {

Modified: modules/trunk/security/src/main/java/org/jboss/seam/security/management/action/UserAction.java
===================================================================
--- modules/trunk/security/src/main/java/org/jboss/seam/security/management/action/UserAction.java	2009-04-24 12:36:43 UTC (rev 10626)
+++ modules/trunk/security/src/main/java/org/jboss/seam/security/management/action/UserAction.java	2009-04-24 13:13:27 UTC (rev 10627)
@@ -1,19 +1,15 @@
 package org.jboss.seam.security.management.action;
 
-import static org.jboss.seam.ScopeType.CONVERSATION;
-import static org.jboss.seam.annotations.Install.BUILT_IN;
-
 import java.io.Serializable;
 import java.util.ArrayList;
 import java.util.List;
 
-import org.jboss.seam.annotations.Begin;
-import org.jboss.seam.annotations.In;
-import org.jboss.seam.annotations.Install;
-import org.jboss.seam.annotations.Name;
-import org.jboss.seam.annotations.Scope;
-import org.jboss.seam.core.Conversation;
-import org.jboss.seam.international.StatusMessages;
+import javax.annotation.Named;
+import javax.context.Conversation;
+import javax.context.ConversationScoped;
+import javax.inject.Current;
+
+//import org.jboss.seam.international.StatusMessages;
 import org.jboss.seam.security.management.IdentityManager;
 
 /**
@@ -21,9 +17,8 @@
  * 
  * @author Shane Bryzak
  */
- at Name("org.jboss.seam.security.management.userAction")
- at Scope(CONVERSATION)
- at Install(precedence = BUILT_IN)
+ at Named
+ at ConversationScoped
 public class UserAction implements Serializable
 {
    private String firstname;
@@ -36,18 +31,19 @@
    
    private boolean newUserFlag;   
    
-   @In IdentityManager identityManager;
+   @Current IdentityManager identityManager;
+   @Current Conversation conversation;
       
-   @Begin
    public void createUser()
    {
+      conversation.begin();
       roles = new ArrayList<String>();
       newUserFlag = true;
    }
    
-   @Begin
    public void editUser(String username)
-   {      
+   {
+      conversation.begin();
       this.username = username;
       roles = identityManager.getGrantedRoles(username);
       enabled = identityManager.isUserEnabled(username);
@@ -70,7 +66,8 @@
    {      
       if (password == null || !password.equals(confirm))
       {
-         StatusMessages.instance().addToControl("password", "Passwords do not match");
+         // TODO - add control message
+         //StatusMessages.instance().addToControl("password", "Passwords do not match");
          return "failure";
       }
       
@@ -88,7 +85,7 @@
             identityManager.disableUser(username);   
          }
          
-         Conversation.instance().end();
+         conversation.end();
          
          return "success";
       }
@@ -103,7 +100,8 @@
       {
          if (!password.equals(confirm))
          {
-            StatusMessages.instance().addToControl("password", "Passwords do not match");
+            // TODO - add control message
+            // StatusMessages.instance().addToControl("password", "Passwords do not match");
             return "failure";
          }
          else
@@ -139,7 +137,7 @@
          identityManager.disableUser(username);
       }
          
-      Conversation.instance().end();
+      conversation.end();
       return "success";
    }
    

Modified: modules/trunk/security/src/main/java/org/jboss/seam/security/management/action/UserSearch.java
===================================================================
--- modules/trunk/security/src/main/java/org/jboss/seam/security/management/action/UserSearch.java	2009-04-24 12:36:43 UTC (rev 10626)
+++ modules/trunk/security/src/main/java/org/jboss/seam/security/management/action/UserSearch.java	2009-04-24 13:13:27 UTC (rev 10627)
@@ -1,22 +1,18 @@
 package org.jboss.seam.security.management.action;
 
-import static org.jboss.seam.ScopeType.SESSION;
-import static org.jboss.seam.annotations.Install.BUILT_IN;
-
 import java.io.Serializable;
 import java.util.List;
 
-import org.jboss.seam.annotations.In;
-import org.jboss.seam.annotations.Install;
-import org.jboss.seam.annotations.Name;
-import org.jboss.seam.annotations.Scope;
+import javax.annotation.Named;
+import javax.context.SessionScoped;
+import javax.inject.Current;
+
 import org.jboss.seam.annotations.datamodel.DataModel;
 import org.jboss.seam.annotations.datamodel.DataModelSelection;
 import org.jboss.seam.security.management.IdentityManager;
 
- at Name("org.jboss.seam.security.management.userSearch")
- at Scope(SESSION)
- at Install(precedence = BUILT_IN)
+ at Named
+ at SessionScoped
 public class UserSearch implements Serializable
 {
    private static final long serialVersionUID = 8592034786339372510L;
@@ -27,7 +23,7 @@
    @DataModelSelection
    String selectedUser;
    
-   @In IdentityManager identityManager;
+   @Current IdentityManager identityManager;
    
    public void loadUsers()
    {

Deleted: modules/trunk/security/src/main/java/org/jboss/seam/security/management/package-info.java
===================================================================
--- modules/trunk/security/src/main/java/org/jboss/seam/security/management/package-info.java	2009-04-24 12:36:43 UTC (rev 10626)
+++ modules/trunk/security/src/main/java/org/jboss/seam/security/management/package-info.java	2009-04-24 13:13:27 UTC (rev 10627)
@@ -1,11 +0,0 @@
-/**
- * Seam Identity Management
- * 
- * @see org.jboss.seam.security.management.IdentityManager
- */
- at Namespace(value="http://jboss.com/products/seam/security", prefix="org.jboss.seam.security")
- at AutoCreate
-package org.jboss.seam.security.management;
-
-import org.jboss.seam.annotations.AutoCreate;
-import org.jboss.seam.annotations.Namespace;

Deleted: modules/trunk/security/src/main/java/org/jboss/seam/security/permission/package-info.java
===================================================================
--- modules/trunk/security/src/main/java/org/jboss/seam/security/permission/package-info.java	2009-04-24 12:36:43 UTC (rev 10626)
+++ modules/trunk/security/src/main/java/org/jboss/seam/security/permission/package-info.java	2009-04-24 13:13:27 UTC (rev 10627)
@@ -1,11 +0,0 @@
-/**
- * Seam Security Permissions
- * 
- * @see org.jboss.seam.security.permission.PermissionManager
- */
- at Namespace(value="http://jboss.com/products/seam/security", prefix="org.jboss.seam.security")
- at AutoCreate
-package org.jboss.seam.security.permission;
-
-import org.jboss.seam.annotations.AutoCreate;
-import org.jboss.seam.annotations.Namespace;

Added: modules/trunk/security/src/main/java/org/jboss/seam/security/util/AnnotatedBeanProperty.java
===================================================================
--- modules/trunk/security/src/main/java/org/jboss/seam/security/util/AnnotatedBeanProperty.java	                        (rev 0)
+++ modules/trunk/security/src/main/java/org/jboss/seam/security/util/AnnotatedBeanProperty.java	2009-04-24 13:13:27 UTC (rev 10627)
@@ -0,0 +1,138 @@
+package org.jboss.seam.security.util;
+
+import java.beans.Introspector;
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Field;
+import java.lang.reflect.Method;
+import java.lang.reflect.Type;
+
+/**
+ * A convenience class for working with an annotated property (either a field or method) of
+ * a JavaBean class.
+ *  
+ * @author Shane Bryzak
+ */
+public class AnnotatedBeanProperty<T extends Annotation>
+{
+   private Field propertyField;
+   private Method propertyGetter;
+   private Method propertySetter;
+   private String name;
+   private Type propertyType;
+   private T annotation;
+   
+   private boolean isFieldProperty;
+   private boolean set = false;
+   
+   public AnnotatedBeanProperty(Class<?> cls, Class<T> annotationClass)
+   {      
+      // First check declared fields
+      for (Field f : cls.getDeclaredFields())
+      {
+         if (f.isAnnotationPresent(annotationClass)) 
+         {
+            setupFieldProperty(f);
+            this.annotation = f.getAnnotation(annotationClass);            
+            set = true;
+            return;
+         }
+      }      
+      
+      // Then check public fields, in case it's inherited
+      for (Field f : cls.getFields())
+      {
+         if (f.isAnnotationPresent(annotationClass)) 
+         {
+            this.annotation = f.getAnnotation(annotationClass);
+            setupFieldProperty(f);
+            set = true;
+            return;
+         }
+      }
+      
+      // Then check public methods (we ignore private methods)
+      for (Method m : cls.getMethods())
+      {
+         if (m.isAnnotationPresent(annotationClass))
+         {
+            this.annotation = m.getAnnotation(annotationClass);
+            String methodName = m.getName();
+            
+            if ( m.getName().startsWith("get") )
+            {
+               this.name = Introspector.decapitalize( m.getName().substring(3) );
+            }
+            else if ( methodName.startsWith("is") )
+            {
+               this.name = Introspector.decapitalize( m.getName().substring(2) );
+            }            
+            
+            if (this.name != null)
+            {
+               this.propertyGetter = Reflections.getGetterMethod(cls, this.name);
+               this.propertySetter = Reflections.getSetterMethod(cls, this.name);
+               this.propertyType = this.propertyGetter.getGenericReturnType();
+               isFieldProperty = false;               
+               set = true;
+            }
+            else
+            {
+               throw new IllegalStateException("Invalid accessor method, must start with 'get' or 'is'.  " +
+                     "Method: " + m + " in class: " + cls);
+            }
+         }
+      }      
+   }
+
+   private void setupFieldProperty(Field propertyField)
+   {
+      this.propertyField = propertyField;
+      isFieldProperty = true;
+      this.name = propertyField.getName();
+      this.propertyType = propertyField.getGenericType();
+   }
+
+   public void setValue(Object bean, Object value)
+   {
+      if (isFieldProperty)
+      {
+         Reflections.setAndWrap(propertyField, bean, value);         
+      }
+      else
+      {
+         Reflections.invokeAndWrap(propertySetter, bean, value);
+      }
+   }
+   
+   public Object getValue(Object bean)
+   {
+      if (isFieldProperty)
+      {
+         return Reflections.getAndWrap(propertyField, bean);  
+      }
+      else
+      {
+         return Reflections.invokeAndWrap(propertyGetter, bean);
+      }
+   }
+   
+   public String getName()
+   {
+      return name;
+   }
+   
+   public T getAnnotation()
+   {
+      return annotation;
+   }
+   
+   public Type getPropertyType()
+   {
+      return propertyType;
+   }
+   
+   public boolean isSet()
+   {
+      return set;
+   }
+}
\ No newline at end of file

Added: modules/trunk/security/src/main/java/org/jboss/seam/security/util/Reflections.java
===================================================================
--- modules/trunk/security/src/main/java/org/jboss/seam/security/util/Reflections.java	                        (rev 0)
+++ modules/trunk/security/src/main/java/org/jboss/seam/security/util/Reflections.java	2009-04-24 13:13:27 UTC (rev 10627)
@@ -0,0 +1,401 @@
+package org.jboss.seam.security.util;
+
+import java.beans.Introspector;
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Field;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Member;
+import java.lang.reflect.Method;
+import java.lang.reflect.ParameterizedType;
+import java.lang.reflect.Type;
+import java.util.ArrayList;
+import java.util.List;
+
+public class Reflections
+{
+   
+   public static Object invoke(Method method, Object target, Object... args) throws Exception
+   {
+      try
+      {
+         return method.invoke( target, args );
+      }
+      catch (IllegalArgumentException iae)
+      {
+         String message = "Could not invoke method by reflection: " + toString(method);
+         if (args!=null && args.length>0) 
+         {
+            message += " with parameters: (" + Strings.toClassNameString(", ", args) + ')';
+         }
+         message += " on: " + target.getClass().getName();
+         throw new IllegalArgumentException(message, iae);
+      }
+      catch (InvocationTargetException ite)
+      {
+         if ( ite.getCause() instanceof Exception )
+         {
+            throw (Exception) ite.getCause();
+         }
+         else
+         {
+            throw ite;
+         }
+      }
+   }
+   
+   public static Object get(Field field, Object target) throws Exception
+   {
+      boolean accessible = field.isAccessible();
+      try
+      {
+         field.setAccessible(true);
+         return field.get(target);
+      }
+      catch (IllegalArgumentException iae)
+      {
+         String message = "Could not get field value by reflection: " + toString(field) + 
+            " on: " + target.getClass().getName();
+         throw new IllegalArgumentException(message, iae);
+      }
+      finally
+      {
+         field.setAccessible(accessible);
+      }
+   }
+   
+   public static void set(Field field, Object target, Object value) throws Exception
+   {
+      try
+      {
+         field.set(target, value);
+      }
+      catch (IllegalArgumentException iae)
+      {
+         // target may be null if field is static so use field.getDeclaringClass() instead
+         String message = "Could not set field value by reflection: " + toString(field) +
+            " on: " + field.getDeclaringClass().getName();
+         if (value==null)
+         {
+            message += " with null value";
+         }
+         else
+         {
+            message += " with value: " + value.getClass();
+         }
+         throw new IllegalArgumentException(message, iae);
+      }
+   }
+   
+   public static Object getAndWrap(Field field, Object target)
+   {
+      boolean accessible = field.isAccessible();
+      try
+      {
+         field.setAccessible(true);
+         return get(field, target);
+      }
+      catch (Exception e)
+      {
+         if (e instanceof RuntimeException)
+         {
+            throw (RuntimeException) e;
+         }
+         else
+         {
+            throw new IllegalArgumentException("exception setting: " + field.getName(), e);
+         }
+      }
+      finally
+      {
+         field.setAccessible(accessible);
+      }
+   }
+   
+   public static void setAndWrap(Field field, Object target, Object value)
+   {
+      boolean accessible = field.isAccessible();
+      try
+      {
+         field.setAccessible(true);
+         set(field, target, value);
+      }
+      catch (Exception e)
+      {
+         if (e instanceof RuntimeException)
+         {
+            throw (RuntimeException) e;
+         }
+         else
+         {
+            throw new IllegalArgumentException("exception setting: " + field.getName(), e);
+         }
+      }
+      finally
+      {
+         field.setAccessible(accessible);
+      }
+   }
+   
+   public static Object invokeAndWrap(Method method, Object target, Object... args)
+   {
+      try
+      {
+         return invoke(method, target, args);
+      }
+      catch (Exception e)
+      {
+         if (e instanceof RuntimeException)
+         {
+            throw (RuntimeException) e;
+         }
+         else
+         {
+            throw new RuntimeException("exception invoking: " + method.getName(), e);
+         }
+      }
+   }
+   
+   public static String toString(Method method)
+   {
+      return Strings.unqualify( method.getDeclaringClass().getName() ) + 
+            '.' + 
+            method.getName() + 
+            '(' + 
+            Strings.toString( ", ", method.getParameterTypes() ) + 
+            ')';
+   }
+   
+   public static String toString(Member member)
+   {
+      return Strings.unqualify( member.getDeclaringClass().getName() ) + 
+            '.' + 
+            member.getName();
+   }
+   
+   public static Class classForName(String name) throws ClassNotFoundException
+   {
+      try 
+      {
+         return Thread.currentThread().getContextClassLoader().loadClass(name);
+      }
+      catch (Exception e)
+      {
+         return Class.forName(name);
+      }
+   }
+   
+   /**
+    * Return's true if the class can be loaded using Reflections.classForName()
+    */
+   public static boolean isClassAvailable(String name)
+   {
+      try 
+      {
+         classForName(name);
+      }
+      catch (ClassNotFoundException e) {
+         return false;
+      }
+      return true;
+   }
+
+   public static Class getCollectionElementType(Type collectionType)
+   {
+      if ( !(collectionType instanceof ParameterizedType) )
+      {
+         throw new IllegalArgumentException("collection type not parameterized");
+      }
+      Type[] typeArguments = ( (ParameterizedType) collectionType ).getActualTypeArguments();
+      if (typeArguments.length==0)
+      {
+         throw new IllegalArgumentException("no type arguments for collection type");
+      }
+      Type typeArgument = typeArguments.length==1 ? typeArguments[0] : typeArguments[1]; //handle Maps
+      if (typeArgument instanceof ParameterizedType)
+      {
+         typeArgument = ((ParameterizedType) typeArgument).getRawType();
+      }
+      if ( !(typeArgument instanceof Class) )
+      {
+         throw new IllegalArgumentException("type argument not a class");
+      }
+      return (Class) typeArgument;
+   }
+   
+   public static Class getMapKeyType(Type collectionType)
+   {
+      if ( !(collectionType instanceof ParameterizedType) )
+      {
+         throw new IllegalArgumentException("collection type not parameterized");
+      }
+      Type[] typeArguments = ( (ParameterizedType) collectionType ).getActualTypeArguments();
+      if (typeArguments.length==0)
+      {
+         throw new IllegalArgumentException("no type arguments for collection type");
+      }
+      Type typeArgument = typeArguments[0];
+      if ( !(typeArgument instanceof Class) )
+      {
+         throw new IllegalArgumentException("type argument not a class");
+      }
+      return (Class) typeArgument;
+   }
+   
+   public static Method getSetterMethod(Class clazz, String name)
+   {
+      Method[] methods = clazz.getMethods();
+      for (Method method: methods)
+      {
+         String methodName = method.getName();
+         if ( methodName.startsWith("set") && method.getParameterTypes().length==1 )
+         {
+            if ( Introspector.decapitalize( methodName.substring(3) ).equals(name) )
+            {
+               return method;
+            }
+         }
+      }
+      throw new IllegalArgumentException("no such setter method: " + clazz.getName() + '.' + name);
+   }
+   
+   public static Method getGetterMethod(Class clazz, String name)
+   {
+      Method[] methods = clazz.getMethods();
+      for (Method method: methods)
+      {
+         String methodName = method.getName();
+         if ( method.getParameterTypes().length==0 )
+         {
+            if ( methodName.startsWith("get") )
+            {
+               if ( Introspector.decapitalize( methodName.substring(3) ).equals(name) )
+               {
+                  return method;
+               }
+            }
+            else if ( methodName.startsWith("is") )
+            {
+               if ( Introspector.decapitalize( methodName.substring(2) ).equals(name) )
+               {
+                  return method;
+               }
+            }
+         }
+      }
+      throw new IllegalArgumentException("no such getter method: " + clazz.getName() + '.' + name);
+   }
+   
+   /**
+    * Get all the getter methods annotated with the given annotation. Returns an empty list if
+    * none are found
+    */
+   public static List<Method> getGetterMethods(Class clazz, Class annotation) 
+   {
+      List<Method> methods = new ArrayList<Method>();
+      for (Method method : clazz.getMethods())
+      {
+         if (method.isAnnotationPresent(annotation))
+         {
+            methods.add(method);
+         }
+      }
+      return methods;
+   }
+   
+   public static Field getField(Class clazz, String name)
+   {
+      for ( Class superClass = clazz; superClass!=Object.class; superClass=superClass.getSuperclass() )
+      {
+         try
+         {
+            return superClass.getDeclaredField(name);
+         }
+         catch (NoSuchFieldException nsfe) {}
+      }
+      throw new IllegalArgumentException("no such field: " + clazz.getName() + '.' + name);
+   }
+   
+   /**
+    * Get all the fields which are annotated with the given annotation. Returns an empty list
+    * if none are found
+    */
+   public static List<Field> getFields(Class clazz, Class annotation)
+   {
+      List<Field> fields = new ArrayList<Field>();
+      for (Class superClass = clazz; superClass!=Object.class; superClass=superClass.getSuperclass())
+      {
+         for (Field field : superClass.getDeclaredFields())
+         {
+            if (field.isAnnotationPresent(annotation))
+            {
+               fields.add(field);
+            }
+         }
+      }
+      return fields;
+   }
+
+   public static Method getMethod(Annotation annotation, String name)
+   {
+      try
+      {
+         return annotation.annotationType().getMethod(name);
+      }
+      catch (NoSuchMethodException nsme)
+      {
+         return null;
+      }
+   }
+   
+   public static Method getMethod(Class clazz, String name)
+   {
+      for ( Class superClass = clazz; superClass!=Object.class; superClass=superClass.getSuperclass() )
+      {
+         try
+         {
+            return superClass.getDeclaredMethod(name);
+         }
+         catch (NoSuchMethodException nsme) {}
+      }
+      throw new IllegalArgumentException("no such method: " + clazz.getName() + '.' + name);
+   }
+   
+   /**
+    * Check to see if clazz is an instance of name
+    */
+   public static boolean isInstanceOf(Class clazz, String name)
+   {
+      if (name == null)
+      {
+         throw new IllegalArgumentException("name cannot be null");
+      }
+      for (Class c = clazz; c != Object.class; c = c.getSuperclass())
+      {
+         if (instanceOf(c, name))
+         {
+            return true;
+         }
+      }
+      return false;
+   }
+   
+   private static boolean instanceOf(Class clazz, String name)
+   {  
+      if (name.equals(clazz.getName()))
+      {
+         return true;
+      }
+      else
+      {
+         boolean found = false;
+         Class[] interfaces = clazz.getInterfaces();
+         for (int i = 0; i < interfaces.length && !found; i++)
+         {
+            found = instanceOf(interfaces[i], name);
+         }
+         return found;
+      }
+      
+   }
+
+}

Modified: modules/trunk/security/src/main/java/org/jboss/seam/security/util/Strings.java
===================================================================
--- modules/trunk/security/src/main/java/org/jboss/seam/security/util/Strings.java	2009-04-24 12:36:43 UTC (rev 10626)
+++ modules/trunk/security/src/main/java/org/jboss/seam/security/util/Strings.java	2009-04-24 13:13:27 UTC (rev 10627)
@@ -2,6 +2,16 @@
 
 public class Strings
 {
+   public static String unqualify(String name)
+   {
+      return unqualify(name, '.');
+   }
+   
+   public static String unqualify(String name, char sep)
+   {
+      return name.substring( name.lastIndexOf(sep)+1, name.length() );
+   }
+   
    public static boolean isEmpty(String string)
    {
       int len;
@@ -19,4 +29,39 @@
       }
       return true;
    }
+   
+   public static String toClassNameString(String sep, Object... objects)
+   {
+      if (objects.length==0) return "";
+      StringBuilder builder = new StringBuilder();
+      for (Object object: objects)
+      {
+         builder.append(sep);
+         if (object==null)
+         {
+            builder.append("null");
+         }
+         else
+         {
+            builder.append( object.getClass().getName() );
+         }
+      }
+      return builder.substring(sep.length());
+   }   
+   
+   public static String toString(Object... objects)
+   {
+      return toString(" ", objects);
+   }
+   
+   public static String toString(String sep, Object... objects)
+   {
+      if (objects.length==0) return "";
+      StringBuilder builder = new StringBuilder();
+      for (Object object: objects)
+      {
+         builder.append(sep).append(object);
+      }
+      return builder.substring(sep.length());
+   }   
 }

Added: modules/trunk/security/src/main/java/org/jboss/seam/security/util/TypedBeanProperty.java
===================================================================
--- modules/trunk/security/src/main/java/org/jboss/seam/security/util/TypedBeanProperty.java	                        (rev 0)
+++ modules/trunk/security/src/main/java/org/jboss/seam/security/util/TypedBeanProperty.java	2009-04-24 13:13:27 UTC (rev 10627)
@@ -0,0 +1,114 @@
+package org.jboss.seam.security.util;
+
+import java.beans.Introspector;
+import java.lang.reflect.Field;
+import java.lang.reflect.Method;
+
+public class TypedBeanProperty
+{
+   private Field propertyField;
+   private Method propertyGetter;
+   private Method propertySetter;
+   
+   private String name;
+   
+   private boolean isFieldProperty;
+   private boolean set = false;
+   
+   public TypedBeanProperty(Class<?> cls, Class type)
+   {      
+      // First check declared fields
+      for (Field f : cls.getDeclaredFields())
+      {
+         if (f.getGenericType().equals(type)) 
+         {
+            setupFieldProperty(f);           
+            set = true;
+            return;
+         }
+      }      
+      
+      // Then check public fields, in case it's inherited
+      for (Field f : cls.getFields())
+      {
+         if (f.getGenericType().equals(type)) 
+         {
+            setupFieldProperty(f);
+            set = true;
+            return;
+         }
+      }
+      
+      // Then check public methods (we ignore private methods)
+      for (Method m : cls.getMethods())
+      {
+         if (m.getGenericReturnType().equals(type))
+         {
+            String methodName = m.getName();
+            
+            if ( m.getName().startsWith("get") )
+            {
+               this.name = Introspector.decapitalize( m.getName().substring(3) );
+            }
+            else if ( methodName.startsWith("is") )
+            {
+               this.name = Introspector.decapitalize( m.getName().substring(2) );
+            }            
+            
+            if (this.name != null)
+            {
+               this.propertyGetter = Reflections.getGetterMethod(cls, this.name);
+               this.propertySetter = Reflections.getSetterMethod(cls, this.name);
+               isFieldProperty = false;               
+               set = true;
+            }
+            else
+            {
+               throw new IllegalStateException("Invalid accessor method, must start with 'get' or 'is'.  " +
+                     "Method: " + m + " in class: " + cls);
+            }
+         }
+      }      
+   }
+   
+   private void setupFieldProperty(Field propertyField)
+   {
+      this.propertyField = propertyField;
+      isFieldProperty = true;
+      this.name = propertyField.getName();
+   }   
+   
+   public void setValue(Object bean, Object value)
+   {
+      if (isFieldProperty)
+      {
+         Reflections.setAndWrap(propertyField, bean, value);         
+      }
+      else
+      {
+         Reflections.invokeAndWrap(propertySetter, bean, value);
+      }
+   }
+   
+   public Object getValue(Object bean)
+   {
+      if (isFieldProperty)
+      {
+         return Reflections.getAndWrap(propertyField, bean);  
+      }
+      else
+      {
+         return Reflections.invokeAndWrap(propertyGetter, bean);
+      }
+   }   
+   
+   public String getName()
+   {
+      return name;
+   }
+   
+   public boolean isSet()
+   {
+      return set;
+   }
+}
\ No newline at end of file




More information about the seam-commits mailing list