Index: src/main/org/jboss/seam/security/permission/EntityIdentifierStrategy.java =================================================================== --- src/main/org/jboss/seam/security/permission/EntityIdentifierStrategy.java (.../tags/JBPAPP_5_1_1) (revision 14193) +++ src/main/org/jboss/seam/security/permission/EntityIdentifierStrategy.java (.../branches/enterprise/JBPAPP_5_1_1_JBPAPP-6925) (revision 14193) @@ -19,23 +19,31 @@ * * @author Shane Bryzak */ -public class EntityIdentifierStrategy implements IdentifierStrategy +public class EntityIdentifierStrategy implements IdentifierStrategy, java.io.Serializable { - private ValueExpression entityManager; + private transient ValueExpression entityManager; - private PersistenceProvider persistenceProvider; + private transient PersistenceProvider persistenceProvider; private Map identifierNames = new ConcurrentHashMap(); + public void init() + { + if (persistenceProvider == null) + { + persistenceProvider = (PersistenceProvider) Component.getInstance(PersistenceProvider.class, true); + } + + if (entityManager == null) + { + entityManager = Expressions.instance().createValueExpression("#{entityManager}", EntityManager.class); + } + + } + public EntityIdentifierStrategy() { - persistenceProvider = (PersistenceProvider) Component.getInstance(PersistenceProvider.class, true); - - if (entityManager == null) - { - entityManager = Expressions.instance().createValueExpression("#{entityManager}", - EntityManager.class); - } + init(); } public boolean canIdentify(Class targetClass) @@ -45,6 +53,7 @@ public String getIdentifier(Object target) { + if(persistenceProvider == null) init(); Object persProviderId = persistenceProvider.getId(target, lookupEntityManager()); return String.format("%s:%s", getIdentifierName(target.getClass()), persProviderId); } @@ -83,6 +92,7 @@ private EntityManager lookupEntityManager() { + if(entityManager == null) init(); return entityManager.getValue(); } } Index: src/main/org/jboss/seam/security/permission/IdentifierPolicy.java =================================================================== --- src/main/org/jboss/seam/security/permission/IdentifierPolicy.java (.../tags/JBPAPP_5_1_1) (revision 14193) +++ src/main/org/jboss/seam/security/permission/IdentifierPolicy.java (.../branches/enterprise/JBPAPP_5_1_1_JBPAPP-6925) (revision 14193) @@ -25,7 +25,7 @@ @Scope(APPLICATION) @BypassInterceptors @Install(precedence = Install.BUILT_IN) -public class IdentifierPolicy +public class IdentifierPolicy implements java.io.Serializable { private Map strategies = new ConcurrentHashMap(); Index: src/main/org/jboss/seam/security/permission/PermissionMetadata.java =================================================================== --- src/main/org/jboss/seam/security/permission/PermissionMetadata.java (.../tags/JBPAPP_5_1_1) (revision 14193) +++ src/main/org/jboss/seam/security/permission/PermissionMetadata.java (.../branches/enterprise/JBPAPP_5_1_1_JBPAPP-6925) (revision 14193) @@ -17,7 +17,7 @@ * * @author Shane Bryzak */ -public class PermissionMetadata +public class PermissionMetadata implements java.io.Serializable { private Map usesActionMask = new HashMap(); private Map> classActions = new HashMap>(); Index: src/main/org/jboss/seam/security/permission/ClassIdentifierStrategy.java =================================================================== --- src/main/org/jboss/seam/security/permission/ClassIdentifierStrategy.java (.../tags/JBPAPP_5_1_1) (revision 14193) +++ src/main/org/jboss/seam/security/permission/ClassIdentifierStrategy.java (.../branches/enterprise/JBPAPP_5_1_1_JBPAPP-6925) (revision 14193) @@ -11,7 +11,7 @@ * * @author Shane Bryzak */ -public class ClassIdentifierStrategy implements IdentifierStrategy +public class ClassIdentifierStrategy implements IdentifierStrategy, java.io.Serializable { private Map identifierNames = new ConcurrentHashMap(); Index: src/main/org/jboss/seam/util/AnnotatedBeanProperty.java =================================================================== --- src/main/org/jboss/seam/util/AnnotatedBeanProperty.java (.../tags/JBPAPP_5_1_1) (revision 14193) +++ src/main/org/jboss/seam/util/AnnotatedBeanProperty.java (.../branches/enterprise/JBPAPP_5_1_1_JBPAPP-6925) (revision 14193) @@ -12,20 +12,30 @@ * * @author Shane Bryzak */ -public class AnnotatedBeanProperty +public class AnnotatedBeanProperty implements java.io.Serializable { - private Field propertyField; - private Method propertyGetter; - private Method propertySetter; + private transient Field propertyField; + private transient Method propertyGetter; + private transient Method propertySetter; private String name; private Type propertyType; private T annotation; private boolean isFieldProperty; private boolean set = false; + + private Class cls; + private Class annotationClass; public AnnotatedBeanProperty(Class cls, Class annotationClass) { + this.cls = cls; + this.annotationClass = annotationClass; + init(); + } + + private void init() + { // First check declared fields for (Field f : cls.getDeclaredFields()) { @@ -37,7 +47,7 @@ return; } } - + // Then check public fields, in case it's inherited for (Field f : cls.getFields()) { @@ -49,7 +59,7 @@ return; } } - + // Then check public methods (we ignore private methods) for (Method m : cls.getMethods()) { @@ -57,7 +67,7 @@ { this.annotation = m.getAnnotation(annotationClass); String methodName = m.getName(); - + if ( m.getName().startsWith("get") ) { this.name = Introspector.decapitalize( m.getName().substring(3) ); @@ -66,7 +76,7 @@ { this.name = Introspector.decapitalize( m.getName().substring(2) ); } - + if (this.name != null) { this.propertyGetter = Reflections.getGetterMethod(cls, this.name); @@ -81,9 +91,30 @@ "Method: " + m + " in class: " + cls); } } - } + } } + public Field getPropertyField() + { + if (propertyField == null) + init(); + return propertyField; + } + + public Method getPropertyGetter() + { + if (propertyGetter == null) + init(); + return propertyGetter; + } + + public Method getPropertySetter() + { + if (propertySetter == null) + init(); + return propertySetter; + } + private void setupFieldProperty(Field propertyField) { this.propertyField = propertyField; @@ -96,11 +127,11 @@ { if (isFieldProperty) { - Reflections.setAndWrap(propertyField, bean, value); + Reflections.setAndWrap(getPropertyField(), bean, value); } else { - Reflections.invokeAndWrap(propertySetter, bean, value); + Reflections.invokeAndWrap(getPropertySetter(), bean, value); } } @@ -108,11 +139,11 @@ { if (isFieldProperty) { - return Reflections.getAndWrap(propertyField, bean); + return Reflections.getAndWrap(getPropertyField(), bean); } else { - return Reflections.invokeAndWrap(propertyGetter, bean); + return Reflections.invokeAndWrap(getPropertyGetter(), bean); } }