WW-2775 refactor class instantiation decision to a protected method

Thanks to Richard Wallace for patch

git-svn-id: https://svn.apache.org/repos/asf/struts/struts2/trunk@743781 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Musachy Barroso
2009-02-12 15:37:19 +00:00
parent 585d84bc2a
commit 9a1aa35714
@@ -413,9 +413,8 @@ public class PackageBasedActionConfigBuilder implements ActionConfigBuilder {
Map<String, PackageConfig.Builder> packageConfigs = new HashMap<String, PackageConfig.Builder>();
for (Class<?> actionClass : classes) {
// Skip all interfaces, enums, annotations, and abstract classes
if (actionClass.isAnnotation() || actionClass.isInterface() || actionClass.isEnum() ||
(actionClass.getModifiers() & Modifier.ABSTRACT) != 0) {
// Skip classes that can't be instantiated
if (cannotInstantiate(actionClass)) {
continue;
}
@@ -507,6 +506,14 @@ public class PackageBasedActionConfigBuilder implements ActionConfigBuilder {
}
}
/**
* Interfaces, enums, annotations, and abstract classes cannot be instantiated.
*/
protected boolean cannotInstantiate(Class<?> actionClass) {
return actionClass.isAnnotation() || actionClass.isInterface() || actionClass.isEnum() ||
(actionClass.getModifiers() & Modifier.ABSTRACT) != 0;
}
/**
* Determines the namespace(s) for the action based on the action class. If there is a {@link Namespace}
* annotation on the class (including parent classes) or on the package that the class is in, than