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 ClasspathConfigurationProvider

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

All Implemented Interfaces:
  ConfigurationProvider

    public class ClasspathConfigurationProvider

extends Object
implements ConfigurationProvider

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

### DEFAULT_PAGE_PREFIX

    private 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

### defaultPagePrefix

    private String defaultPagePrefix

  The default page prefix (none).

### DEFAULT_PAGE_EXTENSION

    private static final String DEFAULT_PAGE_EXTENSION

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

  See Also:
    Constant Field Values

### defaultPageExtension

    private String defaultPageExtension

  The defacto default page extension, usually associated with JavaServer Pages.

### DEFAULT_PARENT_PACKAGE

    private 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

### defaultParentPackage

    private String defaultParentPackage

  Name of the framework's default configuration package, that application configuration packages automatically inherit.

### FORCE_LOWER_CASE

    private 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

### forceLowerCase

    private boolean forceLowerCase

  Whether to use a lowercase letter as the initial letter of an action. If false, actions will retain the initial uppercase letter from the Action class. (`view.action` (true) versus `View.action` (false)).

### ACTION

    private static final String ACTION

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

  See Also:
    Constant Field Values

### pageLocator

    private ClasspathConfigurationProvider.PageLocator pageLocator

  Helper class to scan class path for server pages.

### initialized

    private boolean initialized

  Flag to indicate the packages have been loaded.

  See Also:
    `loadPackages(java.lang.String[])`, `needsReload()`

### packages

    private String[] packages

  The list of packages to scan for Action classes.

### loadedPackageConfigs

    private Map<String,PackageConfig> loadedPackageConfigs

  The package configurations for scanned Actions.

  See Also:
    `loadPackageConfig(java.lang.String, java.lang.String, java.lang.Class)`

### LOG

    private static final Log LOG

  Logging instance for this class.

### configuration

    private Configuration configuration

  The XWork Configuration for this application.

  See Also:
    `init(com.opensymphony.xwork2.config.Configuration)`

Constructor Detail

### ClasspathConfigurationProvider

    public ClasspathConfigurationProvider(String[] pkgs)

  Create instance utilizing a list of packages to scan for Action classes.

  Parameters:
    `pkgs` - List of pacaktges to scan for Action Classes.

Method Detail

### 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

### 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(ClasspathConfigurationProvider.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[])`

### 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 PackageConfig 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.

  Specified by:
    `destroy` in interface `ConfigurationProvider`

### init

    public void init(Configuration config)

  Register this application's configuration.

  Specified by:
    `init` in interface `ConfigurationProvider`
  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 `ConfigurationProvider`
  Throws:
    `ConfigurationException`

### needsReload

    public boolean needsReload()

  Indicates whether the packages have been initialized.

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

### register

    public void register(ContainerBuilder builder,
                         LocatableProperties props)
                  throws ConfigurationException

  Specified by:
    `register` in interface `ConfigurationProvider`
  Throws:
    `ConfigurationException`

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-2007 Apache Software Foundation. All Rights Reserved.