Permalink
Browse files

Fixing inheritence with superclasses in other packages

  • Loading branch information...
1 parent b01925c commit 7e9fa525a0dd55385c94976e098979bd1f5078f4 attonnnn committed Sep 14, 2010
@@ -74,10 +74,9 @@ public Taglib build(String rootPackage, String[] supportedPackages, URL[] urls)
log.debug("Creating taglib object model...");
- for (final String tapestryPkgName : supportedPackages)
- {
- String pkgname = rootPackage + "." + tapestryPkgName;
+ for(String subPackage : supportedPackages){
+ String pkgname = rootPackage +"."+ subPackage;
log.debug("Processing taglib for full package named : " + pkgname);
@@ -107,30 +106,35 @@ public Taglib build(String rootPackage, String[] supportedPackages, URL[] urls)
throw new MojoExecutionException("Class loader internal error for class :" + s, e);
}
+ if(!c.getPackage().getName().endsWith("components"))
+ continue;
+
if (!c.isAnnotation() && !c.isAnonymousClass() && !c.isEnum() && !c.isInterface() && !c.isLocalClass() && !c.isMemberClass()
&& !c.isSynthetic() && !Modifier.isAbstract(c.getModifiers()))
{
log.debug("Processing Tag : " + c.getName());
- Tag tag = buildTagFromClass(c);
+ Tag tag = buildTagFromClass(rootPackage, c);
taglib.getTags().add(tag);
}
}
}
+
log.debug("Taglib object model completed");
return taglib;
}
/**
* Return the field annotated with @Parameter for a class
*
+ * @param rootPackage The rootPackage to look for class and eventually parent abstract class
* @param c the class
* @return a list of {@link Field}
*/
- private List<Field> getFieldAnnotatedWithParameter(Class<?> c)
+ private List<Field> getFieldAnnotatedWithParameter(String rootPackage, Class<?> c)
{
- Reflections reflection = new Reflections(c.getPackage().getName(), new SingleTypeFieldAnnotationScanner(c).filterResultsBy(new FilterBuilder.Include(
+ Reflections reflection = new Reflections(rootPackage, new SingleTypeFieldAnnotationScanner(c).filterResultsBy(new FilterBuilder.Include(
Parameter.class.getCanonicalName())));
Collection<String> fieldsAsString = reflection.getStore().get(SingleTypeFieldAnnotationScanner.class).values();
List<Field> fields = new ArrayList<Field>();
@@ -144,16 +148,17 @@ public Taglib build(String rootPackage, String[] supportedPackages, URL[] urls)
/**
* Build the &lt;tag&gt; tag corresponding to a class
*
+ * @param rootPackage The rootPackage to look for class and eventually parent abstract class
* @param c the class for the tag
* @return the {@link Tag} build
*/
- private Tag buildTagFromClass(Class<?> c)
+ private Tag buildTagFromClass(String rootPackage, Class<?> c)
{
Tag tag = new Tag();
tag.setTagClass(c.getName());
tag.setName(c.getSimpleName());
- List<Field> fields = getFieldAnnotatedWithParameter(c);
+ List<Field> fields = getFieldAnnotatedWithParameter(rootPackage, c);
for (Field f : fields)
{
@@ -35,7 +35,7 @@ public void testHeritage() throws MalformedURLException, MojoExecutionException
StructureBuilder builder = new StructureBuilder(new SystemStreamLog());
Taglib t = builder.build("fr.exanpe.test.heritage", new String[]
- { "components" }, new URL[]
+ { "base", "components" }, new URL[]
{ new File("target/test-classes/").toURI().toURL() });
assertNotNull(t);
@@ -36,7 +36,7 @@
public void testOk() throws MalformedURLException
{
Reflections reflection = new Reflections(new ConfigurationBuilder().filterInputsBy(
- new FilterBuilder.Include(FilterBuilder.prefix(SubSubComponent.class.getPackage().getName()))).setUrls(new URL[]
+ new FilterBuilder.Include(FilterBuilder.prefix("fr.exanpe.test.heritage"))).setUrls(new URL[]
{ new File("target/test-classes/").toURI().toURL() }).setScanners(new SingleTypeFieldAnnotationScanner(SubSubComponent.class)));
Collection<String> fieldsAsString = reflection.getStore().get(SingleTypeFieldAnnotationScanner.class).values();
@@ -47,7 +47,7 @@ public void testOk() throws MalformedURLException
public void testOk2() throws MalformedURLException
{
Reflections reflection = new Reflections(new ConfigurationBuilder().filterInputsBy(
- new FilterBuilder.Include(FilterBuilder.prefix(Other.class.getPackage().getName()))).setUrls(new URL[]
+ new FilterBuilder.Include(FilterBuilder.prefix("fr.exanpe.test.heritage"))).setUrls(new URL[]
{ new File("target/test-classes/").toURI().toURL() }).setScanners(new SingleTypeFieldAnnotationScanner(Other.class)));
Collection<String> fieldsAsString = reflection.getStore().get(SingleTypeFieldAnnotationScanner.class).values();
@@ -14,7 +14,7 @@
// limitations under the License.
//
-package fr.exanpe.test.heritage.components;
+package fr.exanpe.test.heritage.base;
import org.apache.tapestry5.annotations.Parameter;
@@ -18,6 +18,8 @@
import org.apache.tapestry5.annotations.Parameter;
+import fr.exanpe.test.heritage.base.Component;
+
public abstract class SubComponent extends Component
{
@Parameter

0 comments on commit 7e9fa52

Please sign in to comment.