Revision: 940
http://stripes.svn.sourceforge.net/stripes/?rev=940&view=rev
Author: javelotinfo
Date: 2008-06-19 13:36:39 -0700 (Thu, 19 Jun 2008)
Log Message:
-----------
Moved the ['Bean', 'Action'] suffixes to protected getActionBeanSuffixes()
method for easier customization
Modified Paths:
--------------
trunk/stripes/src/net/sourceforge/stripes/controller/NameBasedActionResolver.java
Modified:
trunk/stripes/src/net/sourceforge/stripes/controller/NameBasedActionResolver.java
===================================================================
---
trunk/stripes/src/net/sourceforge/stripes/controller/NameBasedActionResolver.java
2008-06-19 20:12:32 UTC (rev 939)
+++
trunk/stripes/src/net/sourceforge/stripes/controller/NameBasedActionResolver.java
2008-06-19 20:36:39 UTC (rev 940)
@@ -28,6 +28,7 @@
import java.lang.reflect.Modifier;
import java.net.MalformedURLException;
import java.util.Collections;
+import java.util.List;
import java.util.Set;
/**
@@ -46,9 +47,11 @@
* [EMAIL PROTECTED] getBasePackages()} method. By default this method
returns the set
* [web, www, stripes, action]. These packages (and their parents) are
removed from the
* class name. E.g. [EMAIL PROTECTED] com.myco.web.foo.BarActionBean} would
become [EMAIL PROTECTED] foo.BarActionBean}.
- * Continuing on, we would trim this further to [EMAIL PROTECTED] foo.Bar} and
then translate it to
- * [EMAIL PROTECTED] /foo/Bar}. Lastly the suffix returned by [EMAIL
PROTECTED] getBindingSuffix()} is appended
- * giving the binding [EMAIL PROTECTED] /foo/Bar.action}.</p>
+ * Continuing on, the list of Action Bean suffixes, specified by the [EMAIL
PROTECTED] getActionBeanSuffixes()}
+ * method, are trimmed from the end of the Action Bean class name. With the
defaults,
+ * [Bean, Action], we would trim [EMAIL PROTECTED] foo.BarActionBean} further
to [EMAIL PROTECTED] foo.Bar}, and then
+ * translate it to [EMAIL PROTECTED] /foo/Bar}. Lastly the suffix returned by
[EMAIL PROTECTED] getBindingSuffix()}
+ * is appended, giving the binding [EMAIL PROTECTED] /foo/Bar.action}.</p>
*
* <p>The translation of class names into URL bindings is designed to be easy
to override and
* customize. To that end you can easily change how this translation is done
by overriding
@@ -96,11 +99,17 @@
* of class names when translating them to URL bindings.
*/
public static final Set<String> BASE_PACKAGES =
- Collections.unmodifiableSet(Literal.set("web", "www", "stripes",
"action"));
+ Collections.unmodifiableSet(Literal.set("web", "www", "stripes",
"action"));
/** Default suffix (.action) to add to URL bindings.*/
public static final String DEFAULT_BINDING_SUFFIX = ".action";
+ /**
+ * Default list of suffixes (Bean, Action) to remove to the end of the
Action Bean class name.
+ */
+ public static final List<String> DEFAULT_ACTION_BEAN_SUFFIXES =
+ Collections.unmodifiableList(Literal.list("Bean", "Action"));
+
/** Log instance used to log information from this class. */
private static final Log log =
Log.getInstance(NameBasedActionResolver.class);
@@ -163,13 +172,12 @@
}
}
- // If it ends in Action or Bean (or ActionBean) take that off
- if (name.endsWith("Bean")) {
- name = name.substring(0, name.length() - 4);
+ // If it ends in any of the Action Bean suffixes, remove them
+ for (String suffix : getActionBeanSuffixes()) {
+ if (name.endsWith(suffix)) {
+ name = name.substring(0, name.length() - suffix.length());
+ }
}
- if (name.endsWith("Action")) {
- name = name.substring(0, name.length() - 6);
- }
// Replace periods with slashes and make sure it starts with one
name = name.replace('.', '/');
@@ -202,6 +210,14 @@
}
/**
+ * Returns a list of suffixes to be removed from the end of the Action
Bean class name, if present.
+ * The defaults are ["Bean", "Action"].
+ */
+ protected List<String> getActionBeanSuffixes() {
+ return DEFAULT_ACTION_BEAN_SUFFIXES;
+ }
+
+ /**
* First checks with the super class to see if an annotated event name is
present, and if
* not then returns the name of the handler method itself. Will return
null for methods
* that do not return a resolution or are non-public or abstract.
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://sourceforge.net/services/buy/index.php
_______________________________________________
Stripes-development mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/stripes-development