You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tapestry.apache.org by hl...@apache.org on 2010/05/04 19:35:53 UTC
svn commit: r940978 - in /tapestry/tapestry5/trunk:
tapestry-core/src/main/java/org/apache/tapestry5/internal/services/
tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/data/
tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal...
Author: hlship
Date: Tue May 4 17:35:53 2010
New Revision: 940978
URL: http://svn.apache.org/viewvc?rev=940978&view=rev
Log:
TAP5-1105: BeanModelSource should recognize public field as properties, but doesn't
Modified:
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/BeanModelSourceImpl.java
tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/data/RegistrationData.java
tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/services/PropertyAdapterImpl.java
tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/services/PropertyAdapter.java
tapestry/tapestry5/trunk/tapestry-ioc/src/test/java/org/apache/tapestry5/ioc/internal/services/PropertyAccessImplTest.java
Modified: tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/BeanModelSourceImpl.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/BeanModelSourceImpl.java?rev=940978&r1=940977&r2=940978&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/BeanModelSourceImpl.java (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/BeanModelSourceImpl.java Tue May 4 17:35:53 2010
@@ -103,7 +103,7 @@ public class BeanModelSourceImpl impleme
int line = location == null ? -1 : location.getLine();
- properties.add(new PropertyOrder(name, computeDepth(readMethod), line));
+ properties.add(new PropertyOrder(name, computeDepth(pa), line));
}
Collections.sort(properties);
@@ -116,10 +116,10 @@ public class BeanModelSourceImpl impleme
}
}
- private static int computeDepth(Method method)
+ private static int computeDepth(PropertyAdapter pa)
{
int depth = 0;
- Class c = method.getDeclaringClass();
+ Class c = pa.getDeclaringClass();
// When the method originates in an interface, the parent may be null, not Object.
Modified: tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/data/RegistrationData.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/data/RegistrationData.java?rev=940978&r1=940977&r2=940978&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/data/RegistrationData.java (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/data/RegistrationData.java Tue May 4 17:35:53 2010
@@ -1,10 +1,10 @@
-// Copyright 2007, 2008 The Apache Software Foundation
+// Copyright 2007, 2008, 2010 The Apache Software Foundation
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
-// http://www.apache.org/licenses/LICENSE-2.0
+// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
@@ -14,14 +14,14 @@
package org.apache.tapestry5.integration.app1.data;
+import java.util.List;
+
import org.apache.tapestry5.beaneditor.DataType;
import org.apache.tapestry5.beaneditor.ReorderProperties;
import org.apache.tapestry5.beaneditor.Validate;
import org.apache.tapestry5.beaneditor.Width;
import org.apache.tapestry5.ioc.internal.util.CollectionFactory;
-import java.util.List;
-
@ReorderProperties("firstname,lastname,birthyear,sex")
public class RegistrationData
{
@@ -31,7 +31,7 @@ public class RegistrationData
private int birthYear;
- private Sex sex = Sex.MALE;
+ public Sex sex = Sex.MALE;
private boolean citizen;
@@ -48,11 +48,6 @@ public class RegistrationData
return birthYear;
}
- public Sex getSex()
- {
- return sex;
- }
-
public String getFirstName()
{
return firstName;
@@ -97,11 +92,6 @@ public class RegistrationData
this.lastName = lastName;
}
- public void setSex(Sex sex)
- {
- this.sex = sex;
- }
-
public void setCitizen(boolean citizen)
{
this.citizen = citizen;
Modified: tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/services/PropertyAdapterImpl.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/services/PropertyAdapterImpl.java?rev=940978&r1=940977&r2=940978&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/services/PropertyAdapterImpl.java (original)
+++ tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/services/PropertyAdapterImpl.java Tue May 4 17:35:53 2010
@@ -43,6 +43,8 @@ public class PropertyAdapterImpl impleme
private final Field field;
+ private final Class declaringClass;
+
PropertyAdapterImpl(ClassPropertyAdapter classAdapter, String name, Class type, Method readMethod,
Method writeMethod)
{
@@ -53,6 +55,8 @@ public class PropertyAdapterImpl impleme
this.readMethod = readMethod;
this.writeMethod = writeMethod;
+ declaringClass = readMethod != null ? readMethod.getDeclaringClass() : writeMethod.getDeclaringClass();
+
castRequired = readMethod != null && readMethod.getReturnType() != type;
field = null;
@@ -66,6 +70,8 @@ public class PropertyAdapterImpl impleme
this.field = field;
+ declaringClass = field.getDeclaringClass();
+
castRequired = field.getType() != type;
readMethod = null;
@@ -224,4 +230,8 @@ public class PropertyAdapterImpl impleme
return field != null;
}
+ public Class getDeclaringClass()
+ {
+ return declaringClass;
+ }
}
Modified: tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/services/PropertyAdapter.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/services/PropertyAdapter.java?rev=940978&r1=940977&r2=940978&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/services/PropertyAdapter.java (original)
+++ tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/services/PropertyAdapter.java Tue May 4 17:35:53 2010
@@ -108,4 +108,11 @@ public interface PropertyAdapter extends
* @since 5.2
*/
boolean isField();
+
+ /**
+ * The class in which the property (or public field) is defined.
+ *
+ * @since 5.2
+ */
+ Class getDeclaringClass();
}
Modified: tapestry/tapestry5/trunk/tapestry-ioc/src/test/java/org/apache/tapestry5/ioc/internal/services/PropertyAccessImplTest.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-ioc/src/test/java/org/apache/tapestry5/ioc/internal/services/PropertyAccessImplTest.java?rev=940978&r1=940977&r2=940978&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-ioc/src/test/java/org/apache/tapestry5/ioc/internal/services/PropertyAccessImplTest.java (original)
+++ tapestry/tapestry5/trunk/tapestry-ioc/src/test/java/org/apache/tapestry5/ioc/internal/services/PropertyAccessImplTest.java Tue May 4 17:35:53 2010
@@ -574,6 +574,8 @@ public class PropertyAccessImplTest exte
assertSame(pa1.getType(), String.class);
assertTrue(pa1.isCastRequired());
+ assertSame(pa1.getDeclaringClass(), Pair.class);
+
PropertyAdapter pa2 = cpa1.getPropertyAdapter("value");
assertSame(pa2.getType(), Long.class);
assertTrue(pa2.isCastRequired());
@@ -658,5 +660,6 @@ public class PropertyAccessImplTest exte
assertTrue(pa.isCastRequired());
assertEquals(pa.getType(), String.class);
+ assertSame(pa.getDeclaringClass(), GenericBean.class);
}
}