Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.apache.struts2.config
Class ClasspathPackageProvider

    java.lang.Object
      org.apache.struts2.config.ClasspathPackageProvider

All Implemented Interfaces:
  PackageProvider

    public class ClasspathPackageProvider

extends Object
implements PackageProvider

ClasspathPackageProvider 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` | `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.

Field Summary
`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 Summary
`ClasspathPackageProvider()`

Method Summary
`protected com.opensymphony.xwork2.util.ResolverUtil.ClassTest` | `createActionClassTest()`
`void` | `destroy()` Default destructor.
`protected String` | `getClassSuffix()`
`void` | `init(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)`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### DEFAULT_PAGE_PREFIX

    protected static final String DEFAULT_PAGE_PREFIX

  The default page prefix (or "path"). Some applications may place pages under "/WEB-INF" as an extreme security precaution.

  See Also:
    Constant Field Values

### DEFAULT_PAGE_EXTENSION

    protected static final String DEFAULT_PAGE_EXTENSION

  The default page extension, to use in place of ".jsp".

  See Also:
    Constant Field Values

### DEFAULT_PARENT_PACKAGE

    protected static final String DEFAULT_PARENT_PACKAGE

  A setting to indicate a custom default parent package, to use in place of "struts-default".

  See Also:
    Constant Field Values

### DISABLE_ACTION_SCANNING

    protected static final String DISABLE_ACTION_SCANNING

  A setting to disable action scanning.

  See Also:
    Constant Field Values

### FORCE_LOWER_CASE

    protected static final String FORCE_LOWER_CASE

  The default page prefix (or "path"). Some applications may place pages under "/WEB-INF" as an extreme security precaution.

  See Also:
    Constant Field Values

### CLASS_SUFFIX

    protected static final String CLASS_SUFFIX

See Also:
  Constant Field Values

### classSuffix

    protected String classSuffix

  Default suffix that can be used to indicate POJO "Action" classes.

### CHECK_IMPLEMENTS_ACTION

    protected static final String CHECK_IMPLEMENTS_ACTION

See Also:
  Constant Field Values

### checkImplementsAction

    protected boolean checkImplementsAction

  When testing a class, check that it implements Action

### CHECK_ANNOTATION

    protected static final String CHECK_ANNOTATION

See Also:
  Constant Field Values

### checkAnnotation

    protected boolean checkAnnotation

  When testing a class, check that it has an @Action annotation

Constructor Detail

### ClasspathPackageProvider

    public ClasspathPackageProvider()

Method Detail

### setActionPackages

    public void setActionPackages(String packages)

### setServletContext

    public void setServletContext(javax.servlet.ServletContext ctx)

### setDisableActionScanning

    public void setDisableActionScanning(String disableActionScanning)

  Disables action scanning.

  Parameters:
    `disableActionScanning` - True to disable

### setCheckImplementsAction

    public void setCheckImplementsAction(String checkImplementsAction)

  Check that the class implements Action

  Parameters:
    `checkImplementsAction` - True to check

### setCheckAnnotation

    public void setCheckAnnotation(String checkAnnotation)

  Check that the class has an @Action annotation

  Parameters:
    `checkImplementsAction` - True to check

### setDefaultParentPackage

    public void setDefaultParentPackage(String defaultParentPackage)

  Register a default parent package for the actions.

  Parameters:
    `defaultParentPackage` - the new defaultParentPackage

### setDefaultPageExtension

    public void setDefaultPageExtension(String defaultPageExtension)

  Register a default page extension to use when locating pages.

  Parameters:
    `defaultPageExtension` - the new defaultPageExtension

### setDefaultPagePrefix

    public void setDefaultPagePrefix(String defaultPagePrefix)

  Reigster a default page prefix to use when locating pages.

  Parameters:
    `defaultPagePrefix` - the defaultPagePrefix to set

### setClassSuffix

    public void setClassSuffix(String classSuffix)

  Default suffix that can be used to indicate POJO "Action" classes.

  Parameters:
    `classSuffix` - the classSuffix to set

### setForceLowerCase

    public void setForceLowerCase(String force)

  Whether to use a lowercase letter as the initial letter of an action.

  Parameters:
    `force` - If false, actions will retain the initial uppercase letter from the Action class. (`view.action` (true) versus `View.action` (false)).

### setPageLocator

    public void setPageLocator(ClasspathPackageProvider.PageLocator locator)

  Register a PageLocation to use to scan for server pages.

  Parameters:
    `locator` -

### loadPackages

    protected void loadPackages(String[] pkgs)

  Scan a list of packages for Action classes. This method loads classes that implement the Action interface or have a class name that ends with the letters "Action".

  Parameters:
    `pkgs` - A list of packages to load
  See Also:
    `processActionClass(java.lang.Class, java.lang.String[])`

### createActionClassTest

    protected com.opensymphony.xwork2.util.ResolverUtil.ClassTest createActionClassTest()

### getClassSuffix

    protected String getClassSuffix()

### processActionClass

    protected void processActionClass(Class<?> cls,
                                      String[] pkgs)

  Create a default action mapping for a class instance. The namespace annotation is honored, if found, otherwise the Java package is converted into the namespace by changing the dots (".") to slashes ("/").

  Parameters:
    `cls` - Action or POJO instance to process
    `pkgs` - List of packages that were scanned for Actions

### loadPackageConfig

    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. The namespace annotation is honored, if found, and the namespace is checked for a parent configuration.

  Parameters:
    `actionNamespace` - The configuration namespace
    `actionPackage` - The Java package containing our Action classes
    `actionClass` - The Action class instance
  Returns:
    PackageConfig object for the Action class

### destroy

    public void destroy()

  Default destructor. Override to provide behavior.

### init

    public void init(Configuration config)

  Register this application's configuration.

  Specified by:
    `init` in interface `PackageProvider`
  Parameters:
    `config` - The configuration for this application.

### loadPackages

    public void loadPackages()
                      throws ConfigurationException

  Clears and loads the list of packages registered at construction.

  Specified by:
    `loadPackages` in interface `PackageProvider`
  Throws:
    `ConfigurationException`

### needsReload

    public boolean needsReload()

  Indicates whether the packages have been initialized.

  Specified by:
    `needsReload` in interface `PackageProvider`
  Returns:
    True if the packages have been initialized

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 2000–2018 Apache Software Foundation. All rights reserved.