Author: smendenh(a)redhat.com
Date: 2012-02-02 19:23:54 -0500 (Thu, 02 Feb 2012)
New Revision: 14289
Modified:
branches/enterprise/JBPAPP_5_1_2_ER2_JBPAPP-8037/src/main/org/jboss/seam/security/permission/ClassIdentifierStrategy.java
branches/enterprise/JBPAPP_5_1_2_ER2_JBPAPP-8037/src/main/org/jboss/seam/security/permission/EntityIdentifierStrategy.java
branches/enterprise/JBPAPP_5_1_2_ER2_JBPAPP-8037/src/main/org/jboss/seam/security/permission/IdentifierPolicy.java
branches/enterprise/JBPAPP_5_1_2_ER2_JBPAPP-8037/src/main/org/jboss/seam/security/permission/PermissionMetadata.java
branches/enterprise/JBPAPP_5_1_2_ER2_JBPAPP-8037/src/main/org/jboss/seam/util/AnnotatedBeanProperty.java
Log:
Changes required for
https://issues.jboss.org/browse/JBPAPP-8037
Modified:
branches/enterprise/JBPAPP_5_1_2_ER2_JBPAPP-8037/src/main/org/jboss/seam/security/permission/ClassIdentifierStrategy.java
===================================================================
---
branches/enterprise/JBPAPP_5_1_2_ER2_JBPAPP-8037/src/main/org/jboss/seam/security/permission/ClassIdentifierStrategy.java 2012-02-02
23:23:00 UTC (rev 14288)
+++
branches/enterprise/JBPAPP_5_1_2_ER2_JBPAPP-8037/src/main/org/jboss/seam/security/permission/ClassIdentifierStrategy.java 2012-02-03
00:23:54 UTC (rev 14289)
@@ -11,7 +11,7 @@
*
* @author Shane Bryzak
*/
-public class ClassIdentifierStrategy implements IdentifierStrategy
+public class ClassIdentifierStrategy implements IdentifierStrategy, java.io.Serializable
{
private Map<Class,String> identifierNames = new
ConcurrentHashMap<Class,String>();
Modified:
branches/enterprise/JBPAPP_5_1_2_ER2_JBPAPP-8037/src/main/org/jboss/seam/security/permission/EntityIdentifierStrategy.java
===================================================================
---
branches/enterprise/JBPAPP_5_1_2_ER2_JBPAPP-8037/src/main/org/jboss/seam/security/permission/EntityIdentifierStrategy.java 2012-02-02
23:23:00 UTC (rev 14288)
+++
branches/enterprise/JBPAPP_5_1_2_ER2_JBPAPP-8037/src/main/org/jboss/seam/security/permission/EntityIdentifierStrategy.java 2012-02-03
00:23:54 UTC (rev 14289)
@@ -19,23 +19,31 @@
*
* @author Shane Bryzak
*/
-public class EntityIdentifierStrategy implements IdentifierStrategy
+public class EntityIdentifierStrategy implements IdentifierStrategy,
java.io.Serializable
{
- private ValueExpression<EntityManager> entityManager;
+ private transient ValueExpression<EntityManager> entityManager;
- private PersistenceProvider persistenceProvider;
+ private transient PersistenceProvider persistenceProvider;
private Map<Class,String> identifierNames = new
ConcurrentHashMap<Class,String>();
+ 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();
}
}
Modified:
branches/enterprise/JBPAPP_5_1_2_ER2_JBPAPP-8037/src/main/org/jboss/seam/security/permission/IdentifierPolicy.java
===================================================================
---
branches/enterprise/JBPAPP_5_1_2_ER2_JBPAPP-8037/src/main/org/jboss/seam/security/permission/IdentifierPolicy.java 2012-02-02
23:23:00 UTC (rev 14288)
+++
branches/enterprise/JBPAPP_5_1_2_ER2_JBPAPP-8037/src/main/org/jboss/seam/security/permission/IdentifierPolicy.java 2012-02-03
00:23:54 UTC (rev 14289)
@@ -25,7 +25,7 @@
@Scope(APPLICATION)
@BypassInterceptors
@Install(precedence = Install.BUILT_IN)
-public class IdentifierPolicy
+public class IdentifierPolicy implements java.io.Serializable
{
private Map<Class,IdentifierStrategy> strategies = new
ConcurrentHashMap<Class,IdentifierStrategy>();
Modified:
branches/enterprise/JBPAPP_5_1_2_ER2_JBPAPP-8037/src/main/org/jboss/seam/security/permission/PermissionMetadata.java
===================================================================
---
branches/enterprise/JBPAPP_5_1_2_ER2_JBPAPP-8037/src/main/org/jboss/seam/security/permission/PermissionMetadata.java 2012-02-02
23:23:00 UTC (rev 14288)
+++
branches/enterprise/JBPAPP_5_1_2_ER2_JBPAPP-8037/src/main/org/jboss/seam/security/permission/PermissionMetadata.java 2012-02-03
00:23:54 UTC (rev 14289)
@@ -17,7 +17,7 @@
*
* @author Shane Bryzak
*/
-public class PermissionMetadata
+public class PermissionMetadata implements java.io.Serializable
{
private Map<Class,Boolean> usesActionMask = new HashMap<Class,Boolean>();
private Map<Class,Map<String,Long>> classActions = new
HashMap<Class,Map<String,Long>>();
Modified:
branches/enterprise/JBPAPP_5_1_2_ER2_JBPAPP-8037/src/main/org/jboss/seam/util/AnnotatedBeanProperty.java
===================================================================
---
branches/enterprise/JBPAPP_5_1_2_ER2_JBPAPP-8037/src/main/org/jboss/seam/util/AnnotatedBeanProperty.java 2012-02-02
23:23:00 UTC (rev 14288)
+++
branches/enterprise/JBPAPP_5_1_2_ER2_JBPAPP-8037/src/main/org/jboss/seam/util/AnnotatedBeanProperty.java 2012-02-03
00:23:54 UTC (rev 14289)
@@ -16,18 +16,28 @@
public class AnnotatedBeanProperty<T extends Annotation> implements Serializable
{
private static final long serialVersionUID = 12345678456L;
- 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<T> annotationClass;
public AnnotatedBeanProperty(Class<?> cls, Class<T> annotationClass)
{
+ this.cls = cls;
+ this.annotationClass = annotationClass;
+ init();
+ }
+
+ private void init()
+ {
// First check declared fields
for (Field f : cls.getDeclaredFields())
{
@@ -39,7 +49,7 @@
return;
}
}
-
+
// Then check public fields, in case it's inherited
for (Field f : cls.getFields())
{
@@ -51,7 +61,7 @@
return;
}
}
-
+
// Then check public methods (we ignore private methods)
for (Method m : cls.getMethods())
{
@@ -59,7 +69,7 @@
{
this.annotation = m.getAnnotation(annotationClass);
String methodName = m.getName();
-
+
if ( m.getName().startsWith("get") )
{
this.name = Introspector.decapitalize( m.getName().substring(3) );
@@ -68,7 +78,7 @@
{
this.name = Introspector.decapitalize( m.getName().substring(2) );
}
-
+
if (this.name != null)
{
this.propertyGetter = Reflections.getGetterMethod(cls, this.name);
@@ -83,9 +93,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;
@@ -98,11 +129,11 @@
{
if (isFieldProperty)
{
- Reflections.setAndWrap(propertyField, bean, value);
+ Reflections.setAndWrap(getPropertyField(), bean, value);
}
else
{
- Reflections.invokeAndWrap(propertySetter, bean, value);
+ Reflections.invokeAndWrap(getPropertySetter(), bean, value);
}
}
@@ -110,11 +141,11 @@
{
if (isFieldProperty)
{
- return Reflections.getAndWrap(propertyField, bean);
+ return Reflections.getAndWrap(getPropertyField(), bean);
}
else
{
- return Reflections.invokeAndWrap(propertyGetter, bean);
+ return Reflections.invokeAndWrap(getPropertyGetter(), bean);
}
}