org.apache.struts.tiles

Class TilesPlugin

public class TilesPlugin extends Object implements PlugIn

Tiles Plugin used to initialize Tiles. This plugin is to be used with Struts 1.1 in association with {@link TilesRequestProcessor}.
This plugin creates one definition factory for each Struts-module. The definition factory configuration is read first from 'web.xml' (backward compatibility), then it is overloaded with values found in the plugin property values.
The plugin changes the Struts configuration by specifying a {@link TilesRequestProcessor} as request processor. If you want to use your own RequestProcessor, it should subclass TilesRequestProcessor.
This plugin can also be used to create one single factory for all modules. This behavior is enabled by specifying moduleAware=false in each plugin properties. In this case, the definition factory configuration file is read by the first Tiles plugin to be initialized. The order is determined by the order of modules declaration in web.xml. The first module is always the default one if it exists. The plugin should be declared in each struts-config.xml file in order to properly initialize the request processor.

Since: Struts 1.1

Field Summary
protected PlugInConfigcurrentPlugInConfigObject
The plugin config object provided by the ActionServlet initializing this plugin.
protected DefinitionsFactorydefinitionFactory
Associated definition factory.
protected static Loglog
Commons Logging instance.
protected booleanmoduleAware
Is the factory module aware?
protected StringtilesUtilImplClassname
Tiles util implementation classname.
Method Summary
voiddestroy()
End plugin.
protected MapfindStrutsPlugInConfigProperties(ActionServlet servlet, ModuleConfig config)
Find original properties set in the Struts PlugInConfig object.
StringgetTilesUtilImplClassname()
Get Tiles util implemention classname.
voidinit(ActionServlet servlet, ModuleConfig moduleConfig)

Receive notification that the specified module is being started up.

voidinitDefinitionsFactory(ServletContext servletContext, ModuleConfig moduleConfig, DefinitionsFactoryConfig factoryConfig)
Initialize the DefinitionsFactory this module will use.
protected voidinitRequestProcessorClass(ModuleConfig config)
Set RequestProcessor to appropriate Tiles {@link RequestProcessor}.
voidinitTilesUtil()
Set TilesUtil implementation according to properties 'tilesUtilImplClassname' and 'moduleAware'.
booleanisModuleAware()
Get the module aware flag.
protected DefinitionsFactoryConfigreadFactoryConfig(ActionServlet servlet, ModuleConfig config)
Create FactoryConfig and initialize it from web.xml and struts-config.xml.
voidsetCurrentPlugInConfigObject(PlugInConfig plugInConfigObject)
Method used by the ActionServlet initializing this plugin.
voidsetModuleAware(boolean moduleAware)
Set the module aware flag.
voidsetTilesUtilImplClassname(String tilesUtilImplClassname)
Set Tiles util implemention classname.

Field Detail

currentPlugInConfigObject

protected PlugInConfig currentPlugInConfigObject
The plugin config object provided by the ActionServlet initializing this plugin.

definitionFactory

protected DefinitionsFactory definitionFactory
Associated definition factory.

log

protected static Log log
Commons Logging instance.

moduleAware

protected boolean moduleAware
Is the factory module aware?

tilesUtilImplClassname

protected String tilesUtilImplClassname
Tiles util implementation classname. This property can be set by user in the plugin declaration.

Method Detail

destroy

public void destroy()
End plugin.

findStrutsPlugInConfigProperties

protected Map findStrutsPlugInConfigProperties(ActionServlet servlet, ModuleConfig config)
Find original properties set in the Struts PlugInConfig object. First, we need to find the index of this plugin. Then we retrieve the array of configs and then the object for this plugin.

Parameters: servlet ActionServlet that is managing all the modules in this web application. config ModuleConfig for the module with which this plug in is associated.

Throws: ServletException if this PlugIn cannot be successfully initialized.

getTilesUtilImplClassname

public String getTilesUtilImplClassname()
Get Tiles util implemention classname.

Returns: The classname or null if none is set.

init

public void init(ActionServlet servlet, ModuleConfig moduleConfig)

Receive notification that the specified module is being started up.

Parameters: servlet ActionServlet that is managing all the modules in this web application. moduleConfig ModuleConfig for the module with which this plugin is associated.

Throws: ServletException if this PlugIn cannot be successfully initialized.

initDefinitionsFactory

private void initDefinitionsFactory(ServletContext servletContext, ModuleConfig moduleConfig, DefinitionsFactoryConfig factoryConfig)
Initialize the DefinitionsFactory this module will use.

Parameters: servletContext moduleConfig factoryConfig

Throws: ServletException

initRequestProcessorClass

protected void initRequestProcessorClass(ModuleConfig config)
Set RequestProcessor to appropriate Tiles {@link RequestProcessor}. First, check if a RequestProcessor is specified. If yes, check if it extends the appropriate {@link TilesRequestProcessor} class. If not, set processor class to TilesRequestProcessor.

Parameters: config ModuleConfig for the module with which this plugin is associated.

Throws: ServletException On errors.

initTilesUtil

private void initTilesUtil()
Set TilesUtil implementation according to properties 'tilesUtilImplClassname' and 'moduleAware'. These properties are taken into account only once. A side effect is that only the values set in the first initialized plugin are effectively taken into account.

Throws: ServletException

isModuleAware

public boolean isModuleAware()
Get the module aware flag.

Returns: true: user wants a single factory instance, false: user wants multiple factory instances (one per module with Struts)

readFactoryConfig

protected DefinitionsFactoryConfig readFactoryConfig(ActionServlet servlet, ModuleConfig config)
Create FactoryConfig and initialize it from web.xml and struts-config.xml.

Parameters: servlet ActionServlet that is managing all the modules in this web application. config ModuleConfig for the module with which this plugin is associated.

Throws: ServletException if this PlugIn cannot be successfully initialized.

setCurrentPlugInConfigObject

public void setCurrentPlugInConfigObject(PlugInConfig plugInConfigObject)
Method used by the ActionServlet initializing this plugin. Set the plugin config object read from module config.

Parameters: plugInConfigObject PlugInConfig.

setModuleAware

public void setModuleAware(boolean moduleAware)
Set the module aware flag. This flag is only meaningful if the property tilesUtilImplClassname is not set.

Parameters: moduleAware true: user wants a single factory instance, false: user wants multiple factory instances (one per module with Struts)

setTilesUtilImplClassname

public void setTilesUtilImplClassname(String tilesUtilImplClassname)
Set Tiles util implemention classname. If this property is set, the flag moduleAware will not be used anymore.

Parameters: tilesUtilImplClassname Classname.

Copyright © 2000-2008 - The Apache Software Foundation