org.apache.struts.tiles
Class TilesPlugin

java.lang.Object
  |
  +--org.apache.struts.tiles.TilesPlugin
All Implemented Interfaces:
org.apache.struts.action.PlugIn

public class TilesPlugin
extends java.lang.Object
implements org.apache.struts.action.PlugIn

Tiles Plugin used to initialize Tiles. This plugin is to be used with Struts 1.1 in association with TilesRequestProcessor.
This plugin create one definition factory for each struts module. The definition factory configuration is read first from 'web.xml' (backward compatibility), then it is overloaded by values found in plugin property values.
The plugin changes Struts configuration by specifying a TilesRequestProcessor as request processor. If the user has also specified another request processor, this later should subclass TilesRequestProcessor.
This plugin can also be used to create one single factory for all module. This behavior is enable 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 intialize the request processor.

Since:
1.1
Author:
Cedric Dumoulin

Field Summary
protected  DefinitionsFactory definitionFactory
          Associated definition factory
protected static org.apache.commons.logging.Log log
          Commons Logging instance.
protected  boolean moduleAware
          Does the factory is module aware ?
 
Constructor Summary
TilesPlugin()
           
 
Method Summary
 void destroy()
          End plugin.
protected  java.util.Map findStrutsPlugInConfigProperties(org.apache.struts.action.ActionServlet servlet, org.apache.struts.config.ApplicationConfig config)
          Find original properties set in the struts PlugInConfig object.
 void init(org.apache.struts.action.ActionServlet servlet, org.apache.struts.config.ApplicationConfig config)
          Receive notification that the specified module is being started up.
protected  void initRequestProcessorClass(org.apache.struts.config.ApplicationConfig config)
          Set RequestProcessor to appropriate Tiles RequestProcessor.
 boolean isModuleAware()
          Get the module aware flag.
protected  DefinitionsFactoryConfig readFactoryConfig(org.apache.struts.action.ActionServlet servlet, org.apache.struts.config.ApplicationConfig config)
          Create FactoryConfig and initialize it from web.xml and struts-config.xml.
 void setModuleAware(boolean moduleAware)
          Set the module aware flag.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

log

protected static org.apache.commons.logging.Log log
Commons Logging instance.


moduleAware

protected boolean moduleAware
Does the factory is module aware ?


definitionFactory

protected DefinitionsFactory definitionFactory
Associated definition factory

Constructor Detail

TilesPlugin

public TilesPlugin()
Method Detail

isModuleAware

public boolean isModuleAware()
Get the module aware flag. true: user want a single factory instance false: user want multiple factory instance (one per module with Struts)


setModuleAware

public void setModuleAware(boolean moduleAware)
Set the module aware flag. true: user want a single factory instance false: user want multiple factory instance (one per module with Struts)


init

public void init(org.apache.struts.action.ActionServlet servlet,
                 org.apache.struts.config.ApplicationConfig config)
          throws javax.servlet.ServletException

Receive notification that the specified module is being started up.

Specified by:
init in interface org.apache.struts.action.PlugIn
Parameters:
servlet - ActionServlet that is managing all the modules in this web application
config - ApplicationConfig for the module with which this plug in is associated
Throws:
javax.servlet.ServletException - if this PlugIn cannot be successfully initialized

destroy

public void destroy()
End plugin.

Specified by:
destroy in interface org.apache.struts.action.PlugIn

readFactoryConfig

protected DefinitionsFactoryConfig readFactoryConfig(org.apache.struts.action.ActionServlet servlet,
                                                     org.apache.struts.config.ApplicationConfig config)
                                              throws javax.servlet.ServletException
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 - ApplicationConfig for the module with which this plug in is associated
Throws:
javax.servlet.ServletException - if this PlugIn cannot be successfully initialized

findStrutsPlugInConfigProperties

protected java.util.Map findStrutsPlugInConfigProperties(org.apache.struts.action.ActionServlet servlet,
                                                         org.apache.struts.config.ApplicationConfig config)
                                                  throws javax.servlet.ServletException
Find original properties set in the struts PlugInConfig object. First, need to find the index of this plugin. Then retrieve array of configs and then the object for this plugin.

Parameters:
servlet - ActionServlet that is managing all the modules in this web application
config - ApplicationConfig for the module with which this plug in is associated
Throws:
javax.servlet.ServletException - if this PlugIn cannot be successfully initialized

initRequestProcessorClass

protected void initRequestProcessorClass(org.apache.struts.config.ApplicationConfig config)
                                  throws javax.servlet.ServletException
Set RequestProcessor to appropriate Tiles RequestProcessor. First check if a requestprocessor is specified. If yes, check if it extends appropriate TilesRequestProcessor class. If no, set processor class to TilesRequestProcessor

Parameters:
config - ApplicationConfig for the module with which this plug in is associated
Throws:
javax.servlet.ServletException - If an error occur


Copyright 2000-2002 - Cedric Dumoulin and Apache Software Foundation