You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@struts.apache.org by ce...@apache.org on 2002/11/05 15:16:41 UTC
cvs commit: jakarta-struts/src/share/org/apache/struts/tiles DefaultTilesUtilImpl.java StrutsModulesTilesUtilImpl.java TilesUtil.java TilesUtilInterface.java
cedric 2002/11/05 06:16:41
Added: src/share/org/apache/struts/tiles DefaultTilesUtilImpl.java
StrutsModulesTilesUtilImpl.java TilesUtil.java
TilesUtilInterface.java
Log:
Let TilesPlugin be struts 1.1 module aware:
Change the initialization method,
Add a configurable TilesUtil class
Change other class accordingly
Revision Changes Path
1.1 jakarta-struts/src/share/org/apache/struts/tiles/DefaultTilesUtilImpl.java
Index: DefaultTilesUtilImpl.java
===================================================================
/*
* $Header: /home/cvs/jakarta-struts/src/share/org/apache/struts/tiles/DefaultTilesUtilImpl.java,v 1.1 2002/11/05 14:16:41 cedric Exp $
* $Revision: 1.1 $
* $Date: 2002/11/05 14:16:41 $
*
* ====================================================================
*
* The Apache Software License, Version 1.1
*
* Copyright (c) 1999-2002 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution, if
* any, must include the following acknowlegement:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowlegement may appear in the software itself,
* if and wherever such third-party acknowlegements normally appear.
*
* 4. The names "The Jakarta Project", "Struts", and "Apache Software
* Foundation" must not be used to endorse or promote products derived
* from this software without prior written permission. For written
* permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache"
* nor may "Apache" appear in their names without prior written
* permission of the Apache Group.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*
*/
package org.apache.struts.tiles;
import org.apache.struts.tiles.definition.ComponentDefinitionsFactoryWrapper;
import javax.servlet.*;
import javax.servlet.http.*;
import java.io.IOException;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
/**
* Default implementation of TilesUtil.
* This class conatains default implementation of utilities. This implementation
* is intended to be used without Struts
*/
public class DefaultTilesUtilImpl implements TilesUtilInterface
{
/** Commons Logging instance.*/
protected Log log = LogFactory.getLog(DefaultTilesUtilImpl.class);
/** Constant name used to store factory in servlet context */
public static final String DEFINITIONS_FACTORY = "org.apache.struts.tiles.DEFINITIONS_FACTORY";
/**
* Do a forward using request dispatcher.
*
* This method is used by the Tiles package anytime a forward is required.
* @param uri Uri or Definition name to forward
* @param request Current page request
* @param servletContext Current servlet context
*/
public void doForward(String uri, HttpServletRequest request, HttpServletResponse response,
ServletContext servletContext)
throws IOException, ServletException
{
request.getRequestDispatcher( uri ).forward(request, response);
}
/**
* Do an include using request dispatcher.
*
* This method is used by the Tiles package anytime an include is required.
* @param uri Uri or Definition name to forward
* @param request Current page request
* @param response Current page response
* @param servletContext Current servlet context
*/
public void doInclude(String uri, HttpServletRequest request, HttpServletResponse response,
ServletContext servletContext)
throws IOException, ServletException
{
request.getRequestDispatcher( uri ).include(request, response);
}
/**
* Get the default definition factory from appropriate servlet context.
* @param servletContext Current servlet context
* @return Definitions factory or null if not found.
*/
public DefinitionsFactory getDefaultDefinitionsFactory(ServletContext servletContext)
{
return (DefinitionsFactory)servletContext.getAttribute(DEFINITIONS_FACTORY);
}
/**
* Get definition factory from appropriate servlet context.
* @return Definitions factory or null if not found.
*/
public DefinitionsFactory getDefinitionsFactory(ServletRequest request, ServletContext servletContext)
{
return (DefinitionsFactory)servletContext.getAttribute(DEFINITIONS_FACTORY);
}
/**
* Create Definition factory from specified configuration object.
* Create an instance of the factory , with the class specified in the config
* object. Then, initialize this factory, and finally store the factory in
* appropriate context by the way of
* {@link #makeDefinitionsFactoryAccessible(DefinitionsFactory, ServletContext)}.
* Factory creation is done by the way of {@link #createDefinitionFactoryInstance(String)}
* <p>
*
* @param servletContext Servlet Context passed to newly created factory.
* @param factoryConfig Configuration object passed to factory.
* @return newly created factory of type specified in the config object.
* @throws DefinitionsFactoryException If an error occur while initializing factory
*/
public DefinitionsFactory createDefinitionsFactory(ServletContext servletContext, DefinitionsFactoryConfig factoryConfig)
throws DefinitionsFactoryException
{
// Create configurable factory
DefinitionsFactory factory = createDefinitionFactoryInstance(factoryConfig.getFactoryClassname());
factory.init( factoryConfig, servletContext );
// Make factory accessible from jsp tags (push it in appropriate context)
makeDefinitionsFactoryAccessible(factory, servletContext );
return factory;
}
/**
* Create Definition factory of specified classname.
* Factory class must extends the {@link DefinitionsFactory} class.
* The factory is wrapped appropriately with {@link ComponentDefinitionsFactoryWrapper}
* if it is instance of the deprecated ComponentDefinitionsFactory class.
* @param classname Class name of the factory to create.
* @return newly created factory.
* @throws DefinitionsFactoryException If an error occur while initializing factory
*/
protected DefinitionsFactory createDefinitionFactoryInstance(String classname)
throws DefinitionsFactoryException
{
try
{
Class factoryClass = Class.forName(classname);
Object factory = factoryClass.newInstance();
// Backward compatibility : if factory classes implements old interface,
// provide appropriate wrapper
if( factory instanceof ComponentDefinitionsFactory )
{
factory = new ComponentDefinitionsFactoryWrapper( (ComponentDefinitionsFactory)factory );
} // end if
return (DefinitionsFactory)factory;
}
catch( ClassCastException ex )
{ // Bad classname
throw new DefinitionsFactoryException( "Error - createDefinitionsFactory : Factory class '"
+ classname +" must implements 'TilesDefinitionsFactory'.", ex );
}
catch( ClassNotFoundException ex )
{ // Bad classname
throw new DefinitionsFactoryException( "Error - createDefinitionsFactory : Bad class name '"
+ classname +"'.", ex );
}
catch( InstantiationException ex )
{ // Bad constructor or error
throw new DefinitionsFactoryException( ex );
}
catch( IllegalAccessException ex )
{ //
throw new DefinitionsFactoryException( ex );
}
}
/**
* Make definition factory accessible to Tags.
* Factory is stored in servlet context.
* @param factory Factory to make accessible
* @param servletContext Current servlet context
*/
protected void makeDefinitionsFactoryAccessible(DefinitionsFactory factory, ServletContext servletContext)
{
servletContext.setAttribute(DEFINITIONS_FACTORY, factory);
}
}
1.1 jakarta-struts/src/share/org/apache/struts/tiles/StrutsModulesTilesUtilImpl.java
Index: StrutsModulesTilesUtilImpl.java
===================================================================
/*
* $Header: /home/cvs/jakarta-struts/src/share/org/apache/struts/tiles/StrutsModulesTilesUtilImpl.java,v 1.1 2002/11/05 14:16:41 cedric Exp $
* $Revision: 1.1 $
* $Date: 2002/11/05 14:16:41 $
*
* ====================================================================
*
* The Apache Software License, Version 1.1
*
* Copyright (c) 1999-2002 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution, if
* any, must include the following acknowlegement:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowlegement may appear in the software itself,
* if and wherever such third-party acknowlegements normally appear.
*
* 4. The names "The Jakarta Project", "Struts", and "Apache Software
* Foundation" must not be used to endorse or promote products derived
* from this software without prior written permission. For written
* permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache"
* nor may "Apache" appear in their names without prior written
* permission of the Apache Group.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*
*/
package org.apache.struts.tiles;
import org.apache.struts.tiles.definition.ComponentDefinitionsFactoryWrapper;
import org.apache.struts.tiles.TilesRequestProcessor;
import org.apache.struts.util.RequestUtils;
import org.apache.struts.config.ApplicationConfig;
import org.apache.struts.action.Action;
import javax.servlet.*;
import javax.servlet.http.*;
import java.io.IOException;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
/**
* Implementation of TilesUtil for Struts multi modules.
* Methods in this implementation are aware of the Struts module context.
* <br>
* <ul>
* <li>The method getFactory(...) return the factory for the current struts
* module.</li>
* <li>Methods doForward() and doInclude() use their counterparts in the
* current RequestProcessor.</li>
* <li>The method createFactory(...) creates a factory for the current module and
* stores it under appropriate property name.</li>
* </ul>
*/
public class StrutsModulesTilesUtilImpl extends DefaultTilesUtilImpl implements TilesUtilInterface
{
/** Commons Logging instance.*/
protected Log log = LogFactory.getLog(StrutsModulesTilesUtilImpl.class);
/**
* Do a forward using request dispatcher.
*
* This method is used by the Tiles package anytime a forward is required.
* @param uri Uri or Definition name to forward
* @param request Current page request
* @param response Current page response
* @param servletContext Current servlet context
*/
public void doForward(String uri, HttpServletRequest request, HttpServletResponse response,
ServletContext servletContext)
throws IOException, ServletException
{
request.getRequestDispatcher( uri ).include(request, response);
}
/**
* Do an include using request dispatcher.
*
* This method is used by the Tiles package anytime an include is required.
* @param uri Uri or Definition name to forward
* @param request Current page request
* @param response Current page response
* @param servletContext Current servlet context
*/
public void doInclude(String uri, HttpServletRequest request, HttpServletResponse response,
ServletContext servletContext)
throws IOException, ServletException
{
// modify uri
request.getRequestDispatcher( uri ).forward(request, response);
}
/**
* Get definition factory from appropriate servlet context.
* @return Definitions factory or null if not found.
*/
public DefinitionsFactory getDefinitionsFactory(ServletRequest request, ServletContext servletContext)
{
ApplicationConfig appConfig = getModuleConfig( (HttpServletRequest)request, servletContext);
return (DefinitionsFactory)servletContext.getAttribute(DEFINITIONS_FACTORY+appConfig.getPrefix() );
}
/**
* Create Definition factory from specified configuration object.
* Create a ConfigurableDefinitionsFactory and initialize it with the configuration
* object. This later can contains the factory classname to use.
* Factory is made accessible from tags.
* <p>
* Fallback of several factory creation methods.
*
* @param servletContext Servlet Context passed to newly created factory.
* @param factoryConfig Configuration object passed to factory.
* @return newly created factory of type ConfigurableDefinitionsFactory.
* @throws DefinitionsFactoryException If an error occur while initializing factory
*/
public DefinitionsFactory createDefinitionsFactory(ServletContext servletContext, DefinitionsFactoryConfig factoryConfig)
throws DefinitionsFactoryException
{
// Create configurable factory
DefinitionsFactory factory = createDefinitionFactoryInstance(factoryConfig.getFactoryClassname());
factory.init( factoryConfig, servletContext );
// Make factory accessible from jsp tags (push it in appropriate context)
makeDefinitionsFactoryAccessible(factory, servletContext );
return factory;
}
/**
* Make definition factory accessible to Tags.
* Factory is stored in servlet context.
* @param factory Factory to make accessible
* @param servletContext Current servlet context
*/
protected void makeDefinitionsFactoryAccessible(DefinitionsFactory factory, ServletContext servletContext)
{
String prefix = factory.getConfig().getFactoryName();
servletContext.setAttribute(DEFINITIONS_FACTORY+prefix, factory);
}
/**
* Get Tiles request processor associated to the current module.
*/
protected TilesRequestProcessor getRequestProcessor(HttpServletRequest request, ServletContext servletContext)
{
ApplicationConfig appConfig = getModuleConfig( request, servletContext);
return (TilesRequestProcessor)servletContext.getAttribute(Action.REQUEST_PROCESSOR_KEY+appConfig.getPrefix() );
}
/**
* Get the current ApplicationConfig.
* <br>
* Lookup in the request, and do selectApplication if not found. The side effect
* is that the Application object is set in the request if it was not present.
*/
protected ApplicationConfig getModuleConfig(HttpServletRequest request, ServletContext servletContext)
{
ApplicationConfig appConfig = RequestUtils.getModuleConfig( request, servletContext);
if(appConfig==null)
{
// ApplicationConfig not found in current request. Select it.
RequestUtils.selectApplication(request, servletContext);
appConfig = RequestUtils.getModuleConfig( request, servletContext);
}
return appConfig;
}
}
1.1 jakarta-struts/src/share/org/apache/struts/tiles/TilesUtil.java
Index: TilesUtil.java
===================================================================
/*
* $Header: /home/cvs/jakarta-struts/src/share/org/apache/struts/tiles/TilesUtil.java,v 1.1 2002/11/05 14:16:41 cedric Exp $
* $Revision: 1.1 $
* $Date: 2002/11/05 14:16:41 $
*
* ====================================================================
*
* The Apache Software License, Version 1.1
*
* Copyright (c) 1999-2002 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution, if
* any, must include the following acknowlegement:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowlegement may appear in the software itself,
* if and wherever such third-party acknowlegements normally appear.
*
* 4. The names "The Jakarta Project", "Struts", and "Apache Software
* Foundation" must not be used to endorse or promote products derived
* from this software without prior written permission. For written
* permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache"
* nor may "Apache" appear in their names without prior written
* permission of the Apache Group.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*
*/
package org.apache.struts.tiles;
import javax.servlet.*;
import javax.servlet.http.*;
import java.io.IOException;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
/**
* Class containing utilities for Tiles.
*/
public class TilesUtil
{
/** Commons Logging instance.*/
protected static Log log = LogFactory.getLog(TilesUtil.class);
/** The implementation of tilesUtilImpl */
protected static TilesUtilInterface tilesUtilImpl = new DefaultTilesUtilImpl();
protected static String test=null;
/**
* Static constructor for tests
*/
public TilesUtil()
{
if(test==null)
{
test="initialized";
log.warn( "TilesUtil is called for the first time" );
}
else
{
log.error( "TilesUtil is already initialized" );
} // end if
}
/**
* Get the real implementation.
*/
static public TilesUtilInterface getTilesUtil()
{
return tilesUtilImpl;
}
/**
* Set the real implementation.
* This method should be called only once.
* Successive calls have no effect.
*/
static public void setTilesUtil(TilesUtilInterface tilesUtil)
{
if( implAlreadySet)
return;
tilesUtilImpl = tilesUtil;
implAlreadySet = true;
}
/** Flag to know if internal implementation have been set by the setter method */
private static boolean implAlreadySet=false;
/**
* Do a forward using request dispatcher.
*
* This method is used by the Tiles package anytime a forward is required.
* @param uri Uri or Definition name to forward
* @param request Current page request
* @param response Current page response
* @param servletContext Current servlet context
*/
public static void doForward(String uri, HttpServletRequest request, HttpServletResponse response,
ServletContext servletContext)
throws IOException, ServletException
{
tilesUtilImpl.doForward(uri, request, response, servletContext);
}
/**
* Do an include using request dispatcher.
*
* This method is used by the Tiles package anytime an include is required.
* @param uri Uri or Definition name to forward
* @param request Current page request
* @param response Current page response
* @param servletContext Current servlet context
*/
public static void doInclude(String uri, HttpServletRequest request, HttpServletResponse response,
ServletContext servletContext)
throws IOException, ServletException
{
tilesUtilImpl.doInclude(uri, request, response, servletContext);
}
/**
* @param servletContext Current servlet context
* @return Definitions factory or null if not found.
*/
static public DefinitionsFactory getDefaultDefinitionsFactory(ServletContext servletContext)
{
return tilesUtilImpl.getDefaultDefinitionsFactory(servletContext);
}
/**
* Get definition factory from appropriate servlet context.
* @return Definitions factory or null if not found.
*/
static public DefinitionsFactory getDefinitionsFactory(ServletRequest request, ServletContext servletContext)
{
return tilesUtilImpl.getDefinitionsFactory(request, servletContext);
}
/**
* Create Definition factory from specified configuration object.
* Create a ConfigurableDefinitionsFactory and initialize it with the configuration
* object. This later can contains the factory classname to use.
* Factory is made accessible from tags.
* <p>
* Fallback of several factory creation methods.
*
* @param servletContext Servlet Context passed to newly created factory.
* @param factoryConfig Configuration object passed to factory.
* @return newly created factory of type ConfigurableDefinitionsFactory.
* @throws DefinitionsFactoryException If an error occur while initializing factory
*/
public static DefinitionsFactory createDefinitionsFactory(ServletContext servletContext, DefinitionsFactoryConfig factoryConfig)
throws DefinitionsFactoryException
{
return tilesUtilImpl.createDefinitionsFactory(servletContext, factoryConfig);
}
/**
* Get a definition by its name.
* First, retrieve definition factory, and then get requested definition.
* Throw appropriate exception if definition or definition factory is not found.
* @param definitionName Name of requested definition.
* @param request Current servelet request
* @param servletContext current servlet context
* @throws FactoryNotFoundException Can't find definition factory.
* @throws DefinitionsFactoryException General error in factory while getting definition.
* @throws NoSuchDefinitionException No definition found for specified name
*/
static public ComponentDefinition getDefinition(String definitionName, ServletRequest request, ServletContext servletContext)
throws FactoryNotFoundException, DefinitionsFactoryException
{
try
{
return getDefinitionsFactory(request, servletContext).getDefinition(definitionName,
(HttpServletRequest)request,
servletContext);
}
catch( NullPointerException ex )
{ // Factory not found in context
throw new FactoryNotFoundException( "Can't get definitions factory from context." );
}
}
}
1.1 jakarta-struts/src/share/org/apache/struts/tiles/TilesUtilInterface.java
Index: TilesUtilInterface.java
===================================================================
/*
* $Header: /home/cvs/jakarta-struts/src/share/org/apache/struts/tiles/TilesUtilInterface.java,v 1.1 2002/11/05 14:16:41 cedric Exp $
* $Revision: 1.1 $
* $Date: 2002/11/05 14:16:41 $
*
* ====================================================================
*
* The Apache Software License, Version 1.1
*
* Copyright (c) 1999-2002 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution, if
* any, must include the following acknowlegement:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowlegement may appear in the software itself,
* if and wherever such third-party acknowlegements normally appear.
*
* 4. The names "The Jakarta Project", "Struts", and "Apache Software
* Foundation" must not be used to endorse or promote products derived
* from this software without prior written permission. For written
* permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache"
* nor may "Apache" appear in their names without prior written
* permission of the Apache Group.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*
*/
package org.apache.struts.tiles;
import javax.servlet.*;
import javax.servlet.http.*;
import java.io.IOException;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
/**
* Class containing utilities for Tiles.
*/
public interface TilesUtilInterface
{
/**
* Do a forward using request dispatcher.
*
* This method is used by the Tiles package anytime a forward is required.
* @param uri Uri or Definition name to forward
* @param request Current page request
* @param response Current page response
* @param servletContext Current servlet context
*/
public void doForward(String uri, HttpServletRequest request, HttpServletResponse response,
ServletContext servletContext)
throws IOException, ServletException;
/**
* Do an include using request dispatcher.
*
* This method is used by the Tiles package anytime an include is required.
* @param uri Uri or Definition name to forward
* @param request Current page request
* @param response Current page response
* @param servletContext Current servlet context
*/
public void doInclude(String uri, HttpServletRequest request, HttpServletResponse response,
ServletContext servletContext)
throws IOException, ServletException;
/**
* Get the default definition factory from appropriate servlet context.
* @param servletContext Current servlet context
* @return Definitions factory or null if not found.
*/
public DefinitionsFactory getDefaultDefinitionsFactory(ServletContext servletContext);
/**
* Get definition factory from appropriate servlet context.
* Implementation can use the request to select the factory.
* @param response Current page response
* @param servletContext Current servlet context
* @return Definitions factory or null if not found.
*/
public DefinitionsFactory getDefinitionsFactory(ServletRequest request, ServletContext servletContext);
/**
* Create Definition factory from specified configuration object.
* Create a ConfigurableDefinitionsFactory and initialize it with the configuration
* object. This later can contains the factory classname to use.
* Factory is made accessible from tags.
* <p>
* Fallback of several factory creation methods.
*
* @param servletContext Servlet Context passed to newly created factory.
* @param factoryConfig Configuration object passed to factory.
* @return newly created factory of type ConfigurableDefinitionsFactory.
* @throws DefinitionsFactoryException If an error occur while initializing factory
*/
public DefinitionsFactory createDefinitionsFactory(ServletContext servletContext, DefinitionsFactoryConfig factoryConfig)
throws DefinitionsFactoryException;
}
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>