|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.apache.struts2.config.ClasspathConfigurationProvider
public class ClasspathConfigurationProvider
ClasspathConfigurationProvider loads the configuration by scanning the classpath or selected packages for Action classes.
This provider is only invoked if one or more action packages are passed to the dispatcher, usually from the web.xml. Configurations are created for objects that either implement Action or have classnames that end with "Action".
Nested Class Summary | |
---|---|
static class |
ClasspathConfigurationProvider.ClasspathPageLocator
ClasspathPathLocator searches the classpath for server pages. |
static interface |
ClasspathConfigurationProvider.PageLocator
PageLocator defines a locate method that can be used to discover server pages. |
(package private) class |
ClasspathConfigurationProvider.ResultMap<K,V>
Creates ResultConfig objects from result annotations, and if a result isn't found, creates it on the fly. |
Field Summary | |
---|---|
private static String |
ACTION
Default suffix that can be used to indicate POJO "Action" classes. |
private Configuration |
configuration
The XWork Configuration for this application. |
private static String |
DEFAULT_PAGE_EXTENSION
The default page extension, to use in place of ".jsp". |
private static String |
DEFAULT_PAGE_PREFIX
The default page prefix (or "path"). |
private static String |
DEFAULT_PARENT_PACKAGE
A setting to indicate a custom default parent package, to use in place of "struts-default". |
private String |
defaultPageExtension
The defacto default page extension, usually associated with JavaServer Pages. |
private String |
defaultPagePrefix
The default page prefix (none). |
private String |
defaultParentPackage
Name of the framework's default configuration package, that application configuration packages automatically inherit. |
private static String |
FORCE_LOWER_CASE
The default page prefix (or "path"). |
private boolean |
forceLowerCase
Whether to use a lowercase letter as the initial letter of an action. |
private boolean |
initialized
Flag to indicate the packages have been loaded. |
private Map<String,PackageConfig> |
loadedPackageConfigs
The package configurations for scanned Actions. |
private static Log |
LOG
Logging instance for this class. |
private String[] |
packages
The list of packages to scan for Action classes. |
private ClasspathConfigurationProvider.PageLocator |
pageLocator
Helper class to scan class path for server pages. |
Constructor Summary | |
---|---|
ClasspathConfigurationProvider(String[] pkgs)
Create instance utilizing a list of packages to scan for Action classes. |
Method Summary | |
---|---|
void |
destroy()
Default destructor. |
void |
init(Configuration config)
Register this application's configuration. |
protected PackageConfig |
loadPackageConfig(String actionNamespace,
String actionPackage,
Class actionClass)
Finds or creates the package configuration for an Action class. |
void |
loadPackages()
Clears and loads the list of packages registered at construction. |
protected void |
loadPackages(String[] pkgs)
Scan a list of packages for Action classes. |
boolean |
needsReload()
Indicates whether the packages have been initialized. |
protected void |
processActionClass(Class cls,
String[] pkgs)
Create a default action mapping for a class instance. |
void |
register(ContainerBuilder builder,
LocatableProperties props)
|
void |
setDefaultPageExtension(String defaultPageExtension)
Register a default page extension to use when locating pages. |
void |
setDefaultPagePrefix(String defaultPagePrefix)
Reigster a default page prefix to use when locating pages. |
void |
setDefaultParentPackage(String defaultParentPackage)
Register a default parent package for the actions. |
void |
setForceLowerCase(String force)
Whether to use a lowercase letter as the initial letter of an action. |
void |
setPageLocator(ClasspathConfigurationProvider.PageLocator locator)
Register a PageLocation to use to scan for server pages. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
private static final String DEFAULT_PAGE_PREFIX
private String defaultPagePrefix
private static final String DEFAULT_PAGE_EXTENSION
private String defaultPageExtension
private static final String DEFAULT_PARENT_PACKAGE
private String defaultParentPackage
private static final String FORCE_LOWER_CASE
private boolean forceLowerCase
view.action
(true) versus View.action
(false)).
private static final String ACTION
private ClasspathConfigurationProvider.PageLocator pageLocator
private boolean initialized
loadPackages(java.lang.String[])
,
needsReload()
private String[] packages
private Map<String,PackageConfig> loadedPackageConfigs
loadPackageConfig(java.lang.String, java.lang.String, java.lang.Class)
private static final Log LOG
private Configuration configuration
init(com.opensymphony.xwork2.config.Configuration)
Constructor Detail |
---|
public ClasspathConfigurationProvider(String[] pkgs)
pkgs
- List of pacaktges to scan for Action Classes.Method Detail |
---|
public void setDefaultParentPackage(String defaultParentPackage)
defaultParentPackage
- the new defaultParentPackagepublic void setDefaultPageExtension(String defaultPageExtension)
defaultPageExtension
- the new defaultPageExtensionpublic void setDefaultPagePrefix(String defaultPagePrefix)
defaultPagePrefix
- the defaultPagePrefix to setpublic void setForceLowerCase(String force)
force
- If false, actions will retain the initial uppercase letter from the Action class.
(view.action
(true) versus View.action
(false)).public void setPageLocator(ClasspathConfigurationProvider.PageLocator locator)
locator
- protected void loadPackages(String[] pkgs)
pkgs
- A list of packages to loadprocessActionClass(java.lang.Class, java.lang.String[])
protected void processActionClass(Class cls, String[] pkgs)
cls
- Action or POJO instance to processpkgs
- List of packages that were scanned for Actionsprotected PackageConfig loadPackageConfig(String actionNamespace, String actionPackage, Class actionClass)
actionNamespace
- The configuration namespaceactionPackage
- The Java package containing our Action classesactionClass
- The Action class instance
public void destroy()
destroy
in interface ConfigurationProvider
public void init(Configuration config)
init
in interface ConfigurationProvider
config
- The configuration for this application.public void loadPackages() throws ConfigurationException
loadPackages
in interface ConfigurationProvider
ConfigurationException
public boolean needsReload()
needsReload
in interface ConfigurationProvider
public void register(ContainerBuilder builder, LocatableProperties props) throws ConfigurationException
register
in interface ConfigurationProvider
ConfigurationException
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |