mirror of
https://github.com/apache/struts.git
synced 2026-08-11 09:36:57 +00:00
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:
+10
-3
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user