public class ClasspathPackageProvider extends Object implements com.opensymphony.xwork2.config.PackageProvider
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".
Modifier and Type | Class and Description |
---|---|
static class |
ClasspathPackageProvider.ClasspathPageLocator
ClasspathPathLocator searches the classpath for server pages.
|
static interface |
ClasspathPackageProvider.PageLocator
PageLocator defines a locate method that can be used to discover server pages.
|
Modifier and Type | Field and Description |
---|---|
protected static String |
CHECK_ANNOTATION |
protected static String |
CHECK_IMPLEMENTS_ACTION |
protected boolean |
checkAnnotation
When testing a class, check that it has an @Action annotation
|
protected boolean |
checkImplementsAction
When testing a class, check that it implements Action
|
protected static String |
CLASS_SUFFIX |
protected String |
classSuffix
Default suffix that can be used to indicate POJO "Action" classes.
|
protected static String |
DEFAULT_PAGE_EXTENSION
The default page extension, to use in place of ".jsp".
|
protected static String |
DEFAULT_PAGE_PREFIX
The default page prefix (or "path").
|
protected static String |
DEFAULT_PARENT_PACKAGE
A setting to indicate a custom default parent package,
to use in place of "struts-default".
|
protected static String |
DISABLE_ACTION_SCANNING
A setting to disable action scanning.
|
protected static String |
FORCE_LOWER_CASE
The default page prefix (or "path").
|
Constructor and Description |
---|
ClasspathPackageProvider() |
Modifier and Type | Method and Description |
---|---|
protected com.opensymphony.xwork2.util.ResolverUtil.ClassTest |
createActionClassTest() |
void |
destroy()
Default destructor.
|
protected String |
getClassSuffix() |
void |
init(com.opensymphony.xwork2.config.Configuration config)
Register this application's configuration.
|
protected com.opensymphony.xwork2.config.entities.PackageConfig.Builder |
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 |
setActionPackages(String packages) |
void |
setCheckAnnotation(String checkAnnotation)
Check that the class has an @Action annotation
|
void |
setCheckImplementsAction(String checkImplementsAction)
Check that the class implements Action
|
void |
setClassSuffix(String classSuffix)
Default suffix that can be used to indicate POJO "Action" classes.
|
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 |
setDisableActionScanning(String disableActionScanning)
Disables action scanning.
|
void |
setForceLowerCase(String force)
Whether to use a lowercase letter as the initial letter of an action.
|
void |
setPageLocator(ClasspathPackageProvider.PageLocator locator)
Register a PageLocation to use to scan for server pages.
|
void |
setServletContext(javax.servlet.ServletContext ctx) |
protected static final String DEFAULT_PAGE_PREFIX
protected static final String DEFAULT_PAGE_EXTENSION
protected static final String DEFAULT_PARENT_PACKAGE
protected static final String DISABLE_ACTION_SCANNING
protected static final String FORCE_LOWER_CASE
protected static final String CLASS_SUFFIX
protected String classSuffix
protected static final String CHECK_IMPLEMENTS_ACTION
protected boolean checkImplementsAction
protected static final String CHECK_ANNOTATION
protected boolean checkAnnotation
public void setActionPackages(String packages)
public void setServletContext(javax.servlet.ServletContext ctx)
public void setDisableActionScanning(String disableActionScanning)
disableActionScanning
- True to disablepublic void setCheckImplementsAction(String checkImplementsAction)
checkImplementsAction
- True to checkpublic void setCheckAnnotation(String checkAnnotation)
checkImplementsAction
- True to checkpublic 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 setClassSuffix(String classSuffix)
classSuffix
- the classSuffix 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(ClasspathPackageProvider.PageLocator locator)
locator
- protected void loadPackages(String[] pkgs)
pkgs
- A list of packages to loadprocessActionClass(java.lang.Class<?>, java.lang.String[])
protected com.opensymphony.xwork2.util.ResolverUtil.ClassTest createActionClassTest()
protected String getClassSuffix()
protected void processActionClass(Class<?> cls, String[] pkgs)
cls
- Action or POJO instance to processpkgs
- List of packages that were scanned for Actionsprotected com.opensymphony.xwork2.config.entities.PackageConfig.Builder loadPackageConfig(String actionNamespace, String actionPackage, Class actionClass)
actionNamespace
- The configuration namespaceactionPackage
- The Java package containing our Action classesactionClass
- The Action class instancepublic void destroy()
public void init(com.opensymphony.xwork2.config.Configuration config)
init
in interface com.opensymphony.xwork2.config.PackageProvider
config
- The configuration for this application.public void loadPackages() throws com.opensymphony.xwork2.config.ConfigurationException
loadPackages
in interface com.opensymphony.xwork2.config.PackageProvider
com.opensymphony.xwork2.config.ConfigurationException
public boolean needsReload()
needsReload
in interface com.opensymphony.xwork2.config.PackageProvider
Copyright © 2000-2014 Apache Software Foundation. All Rights Reserved.