You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tiles.apache.org by ap...@apache.org on 2007/03/19 16:52:36 UTC
svn commit: r519978 [1/2] - in /tiles/framework/trunk:
tiles-api/src/main/java/org/apache/tiles/mgmt/
tiles-api/src/main/java/org/apache/tiles/web/
tiles-core/src/main/java/org/apache/tiles/context/portlet/
tiles-core/src/main/java/org/apache/tiles/con...
Author: apetrelli
Date: Mon Mar 19 08:52:33 2007
New Revision: 519978
URL: http://svn.apache.org/viewvc?view=rev&rev=519978
Log:
TILES-86
Third run of JavaDocs added.
Modified:
tiles/framework/trunk/tiles-api/src/main/java/org/apache/tiles/mgmt/TileDefinition.java
tiles/framework/trunk/tiles-api/src/main/java/org/apache/tiles/web/ComponentContextMutator.java
tiles/framework/trunk/tiles-core/src/main/java/org/apache/tiles/context/portlet/PortletTilesContextFactory.java
tiles/framework/trunk/tiles-core/src/main/java/org/apache/tiles/context/servlet/ServletTilesContextFactory.java
tiles/framework/trunk/tiles-core/src/main/java/org/apache/tiles/factory/KeyedDefinitionsFactoryTilesContainerFactory.java
tiles/framework/trunk/tiles-core/src/main/java/org/apache/tiles/impl/KeyedDefinitionsFactoryTilesContainer.java
tiles/framework/trunk/tiles-core/src/main/java/org/apache/tiles/impl/mgmt/CachingKeyedDefinitionsFactoryTilesContainer.java
tiles/framework/trunk/tiles-core/src/main/java/org/apache/tiles/impl/mgmt/CachingTilesContainer.java
tiles/framework/trunk/tiles-core/src/main/java/org/apache/tiles/impl/mgmt/DefinitionManager.java
tiles/framework/trunk/tiles-core/src/main/java/org/apache/tiles/listener/TilesListener.java
tiles/framework/trunk/tiles-core/src/main/java/org/apache/tiles/preparer/BasicPreparerFactory.java
tiles/framework/trunk/tiles-core/src/main/java/org/apache/tiles/servlet/TilesServlet.java
tiles/framework/trunk/tiles-core/src/test/java/org/apache/tiles/context/enhanced/EnhancedTilesApplicationContextTest.java
tiles/framework/trunk/tiles-core/src/test/java/org/apache/tiles/context/portlet/PortletTilesRequestContextTest.java
tiles/framework/trunk/tiles-core/src/test/java/org/apache/tiles/context/servlet/ServletTilesRequestContextTest.java
tiles/framework/trunk/tiles-core/src/test/java/org/apache/tiles/factory/KeyedDefinitionsFactoryTilesContainerFactoryTest.java
tiles/framework/trunk/tiles-core/src/test/java/org/apache/tiles/factory/TilesContainerFactoryTest.java
tiles/framework/trunk/tiles-core/src/test/java/org/apache/tiles/impl/BasicTilesContainerTest.java
tiles/framework/trunk/tiles-core/src/test/java/org/apache/tiles/impl/KeyedDefinitionsFactoryTilesContainerTest.java
tiles/framework/trunk/tiles-core/src/test/java/org/apache/tiles/preparer/BasicPreparerFactoryTest.java
tiles/framework/trunk/tiles-core/src/test/java/org/apache/tiles/util/RollingVectorEnumeration.java
tiles/framework/trunk/tiles-jsp/src/main/java/org/apache/tiles/jsp/context/JspTilesContextFactory.java
tiles/framework/trunk/tiles-jsp/src/main/java/org/apache/tiles/jsp/context/JspTilesRequestContext.java
tiles/framework/trunk/tiles-jsp/src/main/java/org/apache/tiles/jsp/context/JspUtil.java
tiles/framework/trunk/tiles-jsp/src/main/java/org/apache/tiles/jsp/context/JspWriterResponse.java
tiles/framework/trunk/tiles-jsp/src/main/java/org/apache/tiles/jsp/taglib/AddAttributeTag.java
tiles/framework/trunk/tiles-jsp/src/main/java/org/apache/tiles/jsp/taglib/AddListAttributeTag.java
tiles/framework/trunk/tiles-jsp/src/main/java/org/apache/tiles/jsp/taglib/AttributeTagSupport.java
tiles/framework/trunk/tiles-jsp/src/main/java/org/apache/tiles/jsp/taglib/ContainerTagSupport.java
tiles/framework/trunk/tiles-jsp/src/main/java/org/apache/tiles/jsp/taglib/GetAsStringTag.java
tiles/framework/trunk/tiles-jsp/src/main/java/org/apache/tiles/jsp/taglib/ImportAttributeTag.java
tiles/framework/trunk/tiles-jsp/src/main/java/org/apache/tiles/jsp/taglib/InsertAttributeTag.java
tiles/framework/trunk/tiles-jsp/src/main/java/org/apache/tiles/jsp/taglib/InsertDefinitionTag.java
tiles/framework/trunk/tiles-jsp/src/main/java/org/apache/tiles/jsp/taglib/InsertTemplateTag.java
tiles/framework/trunk/tiles-jsp/src/main/java/org/apache/tiles/jsp/taglib/PutAttributeTag.java
tiles/framework/trunk/tiles-jsp/src/main/java/org/apache/tiles/jsp/taglib/PutListAttributeTag.java
tiles/framework/trunk/tiles-jsp/src/main/java/org/apache/tiles/jsp/taglib/RenderTagSupport.java
tiles/framework/trunk/tiles-jsp/src/main/java/org/apache/tiles/jsp/taglib/RoleSecurityTagSupport.java
tiles/framework/trunk/tiles-jsp/src/main/java/org/apache/tiles/jsp/taglib/definition/DefinitionTag.java
tiles/framework/trunk/tiles-jsp/src/main/java/org/apache/tiles/jsp/taglib/definition/InitContainerTag.java
tiles/framework/trunk/tiles-test/src/main/java/org/apache/tiles/test/servlet/IncludingServlet.java
tiles/framework/trunk/tiles-test/src/main/java/org/apache/tiles/test/servlet/SelectLocaleServlet.java
Modified: tiles/framework/trunk/tiles-api/src/main/java/org/apache/tiles/mgmt/TileDefinition.java
URL: http://svn.apache.org/viewvc/tiles/framework/trunk/tiles-api/src/main/java/org/apache/tiles/mgmt/TileDefinition.java?view=diff&rev=519978&r1=519977&r2=519978
==============================================================================
--- tiles/framework/trunk/tiles-api/src/main/java/org/apache/tiles/mgmt/TileDefinition.java (original)
+++ tiles/framework/trunk/tiles-api/src/main/java/org/apache/tiles/mgmt/TileDefinition.java Mon Mar 19 08:52:33 2007
@@ -60,6 +60,9 @@
protected String preparer = null;
+ /**
+ * Constructor.
+ */
public TileDefinition() {
attributes = new HashMap<String, ComponentAttribute>();
}
@@ -167,6 +170,8 @@
/**
* Get associated preparerInstance
+ *
+ * @return The preparer name.
*/
public String getPreparer() {
return preparer;
Modified: tiles/framework/trunk/tiles-api/src/main/java/org/apache/tiles/web/ComponentContextMutator.java
URL: http://svn.apache.org/viewvc/tiles/framework/trunk/tiles-api/src/main/java/org/apache/tiles/web/ComponentContextMutator.java?view=diff&rev=519978&r1=519977&r2=519978
==============================================================================
--- tiles/framework/trunk/tiles-api/src/main/java/org/apache/tiles/web/ComponentContextMutator.java (original)
+++ tiles/framework/trunk/tiles-api/src/main/java/org/apache/tiles/web/ComponentContextMutator.java Mon Mar 19 08:52:33 2007
@@ -25,8 +25,22 @@
import javax.servlet.ServletRequest;
+/**
+ * It represents an object able to manipulate a <code>ComponentContext</code>.
+ * In other words, it is able to add, replace and remove attributes from the
+ * <code>ComponentContext</code>.
+ *
+ * @since Tiles 2.0
+ * @version $Rev$ $Date$
+ */
public interface ComponentContextMutator {
+ /**
+ * Mutate a <code>ComponentContext</code>.
+ *
+ * @param context The component context to mutate.
+ * @param request The current servlet request.
+ */
void mutate(ComponentContext context, ServletRequest request);
}
Modified: tiles/framework/trunk/tiles-core/src/main/java/org/apache/tiles/context/portlet/PortletTilesContextFactory.java
URL: http://svn.apache.org/viewvc/tiles/framework/trunk/tiles-core/src/main/java/org/apache/tiles/context/portlet/PortletTilesContextFactory.java?view=diff&rev=519978&r1=519977&r2=519978
==============================================================================
--- tiles/framework/trunk/tiles-core/src/main/java/org/apache/tiles/context/portlet/PortletTilesContextFactory.java (original)
+++ tiles/framework/trunk/tiles-core/src/main/java/org/apache/tiles/context/portlet/PortletTilesContextFactory.java Mon Mar 19 08:52:33 2007
@@ -40,12 +40,11 @@
*/
public class PortletTilesContextFactory implements TilesContextFactory {
+ /** {@inheritDoc} */
public void init(Map<String, String> configParameters) {
}
- /**
- * Creates a TilesApplicationContext from the given context.
- */
+ /** {@inheritDoc} */
public TilesApplicationContext createApplicationContext(Object context) {
if (context instanceof PortletContext) {
PortletContext portletContext = (PortletContext) context;
@@ -55,6 +54,7 @@
return null;
}
+ /** {@inheritDoc} */
public TilesRequestContext createRequestContext(TilesApplicationContext context,
Object... requestItems) {
if (requestItems.length == 2) {
@@ -70,6 +70,12 @@
return null;
}
+ /**
+ * Returns the original portlet context.
+ *
+ * @param context The application context.
+ * @return The original portlet context, if found.
+ */
protected PortletContext getPortletContext(TilesApplicationContext context) {
if (context instanceof PortletTilesApplicationContext) {
PortletTilesApplicationContext app = (PortletTilesApplicationContext) context;
Modified: tiles/framework/trunk/tiles-core/src/main/java/org/apache/tiles/context/servlet/ServletTilesContextFactory.java
URL: http://svn.apache.org/viewvc/tiles/framework/trunk/tiles-core/src/main/java/org/apache/tiles/context/servlet/ServletTilesContextFactory.java?view=diff&rev=519978&r1=519977&r2=519978
==============================================================================
--- tiles/framework/trunk/tiles-core/src/main/java/org/apache/tiles/context/servlet/ServletTilesContextFactory.java (original)
+++ tiles/framework/trunk/tiles-core/src/main/java/org/apache/tiles/context/servlet/ServletTilesContextFactory.java Mon Mar 19 08:52:33 2007
@@ -40,12 +40,11 @@
*/
public class ServletTilesContextFactory implements TilesContextFactory {
+ /** {@inheritDoc} */
public void init(Map<String, String> configParameters) {
}
- /**
- * Creates a TilesApplicationContext from the given context.
- */
+ /** {@inheritDoc} */
public TilesApplicationContext createApplicationContext(Object context) {
if (context instanceof ServletContext) {
ServletContext servletContext = (ServletContext) context;
@@ -54,6 +53,7 @@
return null;
}
+ /** {@inheritDoc} */
public TilesRequestContext createRequestContext(TilesApplicationContext context,
Object... requestItems) {
if (requestItems.length == 2) {
@@ -68,6 +68,12 @@
return null;
}
+ /**
+ * Returns the original servlet context.
+ *
+ * @param context The application context.
+ * @return The original servlet context, if found.
+ */
protected ServletContext getServletContext(TilesApplicationContext context) {
if (context instanceof ServletTilesApplicationContext) {
ServletTilesApplicationContext app = (ServletTilesApplicationContext) context;
Modified: tiles/framework/trunk/tiles-core/src/main/java/org/apache/tiles/factory/KeyedDefinitionsFactoryTilesContainerFactory.java
URL: http://svn.apache.org/viewvc/tiles/framework/trunk/tiles-core/src/main/java/org/apache/tiles/factory/KeyedDefinitionsFactoryTilesContainerFactory.java?view=diff&rev=519978&r1=519977&r2=519978
==============================================================================
--- tiles/framework/trunk/tiles-core/src/main/java/org/apache/tiles/factory/KeyedDefinitionsFactoryTilesContainerFactory.java (original)
+++ tiles/framework/trunk/tiles-core/src/main/java/org/apache/tiles/factory/KeyedDefinitionsFactoryTilesContainerFactory.java Mon Mar 19 08:52:33 2007
@@ -50,9 +50,13 @@
public static final String CONTAINER_KEYS_INIT_PARAM =
"org.apache.tiles.CONTAINER.keys";
+ /**
+ * Init parameter name that contains the class name for the key extractor.
+ */
public static final String KEY_EXTRACTOR_CLASS_INIT_PARAM =
"org.apache.tiles.CONTAINER.keyExtractor";
+ /** {@inheritDoc} */
@Override
public MutableTilesContainer createMutableTilesContainer(Object context) throws TilesException {
CachingKeyedDefinitionsFactoryTilesContainer container =
@@ -61,6 +65,7 @@
return container;
}
+ /** {@inheritDoc} */
@Override
public TilesContainer createTilesContainer(Object context) throws TilesException {
KeyedDefinitionsFactoryTilesContainer container =
@@ -89,6 +94,7 @@
return retValue;
}
+ /** {@inheritDoc} */
@Override
protected void storeContainerDependencies(Object context,
Map<String, String> initParameters, Map<String, String> configuration, BasicTilesContainer container) throws TilesException {
Modified: tiles/framework/trunk/tiles-core/src/main/java/org/apache/tiles/impl/KeyedDefinitionsFactoryTilesContainer.java
URL: http://svn.apache.org/viewvc/tiles/framework/trunk/tiles-core/src/main/java/org/apache/tiles/impl/KeyedDefinitionsFactoryTilesContainer.java?view=diff&rev=519978&r1=519977&r2=519978
==============================================================================
--- tiles/framework/trunk/tiles-core/src/main/java/org/apache/tiles/impl/KeyedDefinitionsFactoryTilesContainer.java (original)
+++ tiles/framework/trunk/tiles-core/src/main/java/org/apache/tiles/impl/KeyedDefinitionsFactoryTilesContainer.java Mon Mar 19 08:52:33 2007
@@ -51,6 +51,9 @@
*/
protected Map<String, DefinitionsFactory> key2definitionsFactory;
+ /**
+ * The key extractor object.
+ */
protected KeyExtractor keyExtractor;
/**
@@ -60,6 +63,10 @@
key2definitionsFactory = new HashMap<String, DefinitionsFactory>();
}
+ /**
+ * It represents an object able to return a key from a request. Each key
+ * maps a different {@link DefinitionsFactory}.
+ */
public interface KeyExtractor {
/**
@@ -71,6 +78,10 @@
public String getDefinitionsFactoryKey(TilesRequestContext request);
}
+ /**
+ * This is the default factory key. Takes the key from the request-scoped
+ * attribute <code>DEFINITIONS_FACTORY_KEY_ATTRIBUTE_NAME</code>.
+ */
protected class DefaultKeyExtractor implements KeyExtractor {
/**
@@ -132,7 +143,10 @@
* Set the definitions factory. This method first ensures
* that the container has not yet been initialized.
*
+ * @param key The key under which the definitions factory is catalogued.
* @param definitionsFactory the definitions factory for this instance.
+ * @param initParameters The init parameters to configure the definitions
+ * factory.
* @throws TilesException If something goes wrong during initialization of
* the definitions factory.
*/
@@ -148,10 +162,16 @@
}
}
+ /**
+ * Sets the key extractor to use.
+ *
+ * @param keyExtractor The key extractor.
+ */
public void setKeyExtractor(KeyExtractor keyExtractor) {
this.keyExtractor = keyExtractor;
}
+ /** {@inheritDoc} */
@Override
protected ComponentDefinition getDefinition(String definitionName,
TilesRequestContext request) throws DefinitionsFactoryException {
Modified: tiles/framework/trunk/tiles-core/src/main/java/org/apache/tiles/impl/mgmt/CachingKeyedDefinitionsFactoryTilesContainer.java
URL: http://svn.apache.org/viewvc/tiles/framework/trunk/tiles-core/src/main/java/org/apache/tiles/impl/mgmt/CachingKeyedDefinitionsFactoryTilesContainer.java?view=diff&rev=519978&r1=519977&r2=519978
==============================================================================
--- tiles/framework/trunk/tiles-core/src/main/java/org/apache/tiles/impl/mgmt/CachingKeyedDefinitionsFactoryTilesContainer.java (original)
+++ tiles/framework/trunk/tiles-core/src/main/java/org/apache/tiles/impl/mgmt/CachingKeyedDefinitionsFactoryTilesContainer.java Mon Mar 19 08:52:33 2007
@@ -45,14 +45,25 @@
public class CachingKeyedDefinitionsFactoryTilesContainer extends
KeyedDefinitionsFactoryTilesContainer implements MutableTilesContainer {
+ /**
+ * The name prefix of the attribute that will contain custom definitions for
+ * the current request.
+ */
private static final String DEFINITIONS_ATTRIBUTE_NAME_BASE =
"org.apache.tiles.impl.mgmt.CachingKeyedDefinitionsFactoryTilesContainer.DEFINITIONS.";
+ /**
+ * The default definition manager, when no key is identified.
+ */
private DefinitionManager mgr = new DefinitionManager();
+ /**
+ * Maps a key to its definition manager.
+ */
private Map<String, DefinitionManager> key2definitionManager
= new HashMap<String, DefinitionManager>();
+ /** {@inheritDoc} */
public void register(TileDefinition definition, Object... requestItems) throws TilesException {
TilesRequestContext requestContext = getContextFactory().createRequestContext(
getApplicationContext(),
@@ -61,6 +72,7 @@
register(definition, requestContext);
}
+ /** {@inheritDoc} */
@Override
protected ComponentDefinition getDefinition(String definition,
TilesRequestContext context)
@@ -70,23 +82,27 @@
return mgr.getDefinition(definition, context);
}
+ /** {@inheritDoc} */
@Override
public DefinitionsFactory getDefinitionsFactory() {
return mgr.getFactory();
}
+ /** {@inheritDoc} */
@Override
public DefinitionsFactory getDefinitionsFactory(String key) {
DefinitionManager mgr = getProperDefinitionManager(key);
return mgr.getFactory();
}
+ /** {@inheritDoc} */
@Override
public void setDefinitionsFactory(DefinitionsFactory definitionsFactory) {
super.setDefinitionsFactory(definitionsFactory);
mgr.setFactory(definitionsFactory);
}
+ /** {@inheritDoc} */
@Override
public void setDefinitionsFactory(String key, DefinitionsFactory definitionsFactory,
Map<String, String> initParameters) throws TilesException {
@@ -98,6 +114,15 @@
mgr.setFactory(definitionsFactory);
}
+ /**
+ * Registers a custom definition.
+ *
+ * @param definition The definition to register.
+ * @param request The request inside which the definition should be
+ * registered.
+ * @throws DefinitionsFactoryException If something goes wrong during adding
+ * a definition, such as missing parent definitions.
+ */
protected void register(TileDefinition definition,
TilesRequestContext request) throws DefinitionsFactoryException {
DefinitionManager mgr = getProperDefinitionManager(
Modified: tiles/framework/trunk/tiles-core/src/main/java/org/apache/tiles/impl/mgmt/CachingTilesContainer.java
URL: http://svn.apache.org/viewvc/tiles/framework/trunk/tiles-core/src/main/java/org/apache/tiles/impl/mgmt/CachingTilesContainer.java?view=diff&rev=519978&r1=519977&r2=519978
==============================================================================
--- tiles/framework/trunk/tiles-core/src/main/java/org/apache/tiles/impl/mgmt/CachingTilesContainer.java (original)
+++ tiles/framework/trunk/tiles-core/src/main/java/org/apache/tiles/impl/mgmt/CachingTilesContainer.java Mon Mar 19 08:52:33 2007
@@ -41,8 +41,12 @@
public class CachingTilesContainer extends BasicTilesContainer
implements MutableTilesContainer {
+ /**
+ * The definition manager to store custom and main definitions.
+ */
private DefinitionManager mgr = new DefinitionManager();
+ /** {@inheritDoc} */
public void register(TileDefinition definition, Object... requestItems) throws TilesException {
TilesRequestContext requestContext = getContextFactory().createRequestContext(
getApplicationContext(),
@@ -51,6 +55,8 @@
register(definition, requestContext);
}
+ /** {@inheritDoc} */
+ @Override
protected ComponentDefinition getDefinition(String definition,
TilesRequestContext context)
throws DefinitionsFactoryException {
@@ -58,15 +64,28 @@
}
+ /** {@inheritDoc} */
+ @Override
public DefinitionsFactory getDefinitionsFactory() {
return mgr.getFactory();
}
+ /** {@inheritDoc} */
+ @Override
public void setDefinitionsFactory(DefinitionsFactory definitionsFactory) {
super.setDefinitionsFactory(definitionsFactory);
mgr.setFactory(definitionsFactory);
}
+ /**
+ * Registers a custom definition.
+ *
+ * @param definition The definition to register.
+ * @param request The request inside which the definition should be
+ * registered.
+ * @throws DefinitionsFactoryException If something goes wrong during adding
+ * a definition, such as missing parent definitions.
+ */
protected void register(TileDefinition definition,
TilesRequestContext request) throws DefinitionsFactoryException {
ComponentDefinition def = new ComponentDefinition(definition);
Modified: tiles/framework/trunk/tiles-core/src/main/java/org/apache/tiles/impl/mgmt/DefinitionManager.java
URL: http://svn.apache.org/viewvc/tiles/framework/trunk/tiles-core/src/main/java/org/apache/tiles/impl/mgmt/DefinitionManager.java?view=diff&rev=519978&r1=519977&r2=519978
==============================================================================
--- tiles/framework/trunk/tiles-core/src/main/java/org/apache/tiles/impl/mgmt/DefinitionManager.java (original)
+++ tiles/framework/trunk/tiles-core/src/main/java/org/apache/tiles/impl/mgmt/DefinitionManager.java Mon Mar 19 08:52:33 2007
@@ -39,20 +39,41 @@
*/
public class DefinitionManager {
+ /**
+ * The logging object.
+ */
private static final Log LOG =
LogFactory.getLog(DefinitionManager.class);
+ /**
+ * The default name of the attribute in which storing custom definitions.
+ */
private static final String DEFAULT_DEFINITIONS_ATTRIBUTE_NAME =
"org.apache.tiles.impl.mgmt.DefinitionManager.DEFINITIONS";
+ /**
+ * The definitions factory to use to get main definitions.
+ */
private DefinitionsFactory factory;
+ /**
+ * The name of the attribute in which storing custom definitions.
+ */
private String definitionsAttributeName;
+ /**
+ * Constructor.
+ */
public DefinitionManager() {
definitionsAttributeName = DEFAULT_DEFINITIONS_ATTRIBUTE_NAME;
}
+ /**
+ * Constructor.
+ *
+ * @param definitionsAttributeName The name of the attribute in which
+ * storing custom definitions.
+ */
public DefinitionManager(String definitionsAttributeName) {
this.definitionsAttributeName = definitionsAttributeName;
if (this.definitionsAttributeName == null) {
@@ -60,14 +81,33 @@
}
}
+ /**
+ * Returns the used definitions factory.
+ *
+ * @return The used definitions factory.
+ */
public DefinitionsFactory getFactory() {
return factory;
}
+ /**
+ * Sets the definitions factory to use.
+ *
+ * @param factory The definitions factory.
+ */
public void setFactory(DefinitionsFactory factory) {
this.factory = factory;
}
+ /**
+ * Returns a definition by name.
+ *
+ * @param definition The name of the definition.
+ * @param request The current request.
+ * @return The requested definition, either main or custom.
+ * @throws DefinitionsFactoryException If something goes wrong when
+ * obtaining a main definition.
+ */
public ComponentDefinition getDefinition(String definition, TilesRequestContext request)
throws DefinitionsFactoryException {
Map<String, ComponentDefinition> definitions =
@@ -78,6 +118,14 @@
return getFactory().getDefinition(definition, request);
}
+ /**
+ * Adds a definition to the set of custom ones.
+ *
+ * @param definition The definition to add.
+ * @param request The current request.
+ * @throws DefinitionsFactoryException If something goes wrong during the
+ * addition.
+ */
public void addDefinition(ComponentDefinition definition,
TilesRequestContext request)
throws DefinitionsFactoryException {
@@ -97,6 +145,15 @@
getOrCreateDefinitions(request).put(definition.getName(), definition);
}
+ /**
+ * Checks if an attribute is a definition.
+ *
+ * @param attribute The attribute to check.
+ * @param request The current request.
+ * @return <code>true</code> if the attribute is a definition.
+ * @throws DefinitionsFactoryException If something goes wrong during
+ * checking if the attribute is a main definition.
+ */
private boolean isDefinition(ComponentAttribute attribute,
TilesRequestContext request) throws DefinitionsFactoryException {
boolean explicit = ComponentAttribute.DEFINITION.equals(attribute.getType());
@@ -105,6 +162,11 @@
return explicit || implicit;
}
+ /**
+ * Validates a custom definition.
+ *
+ * @param definition The definition to validate.
+ */
private void validate(TileDefinition definition) {
Map<String, ComponentAttribute> attrs = definition.getAttributes();
for (ComponentAttribute attribute : attrs.values()) {
@@ -127,8 +189,8 @@
*
* @param definition The definition that needs to have its inheritances
* resolved.
- *
- * @throws NoSuchDefinitionException If an inheritance can not be solved.
+ * @param request The current request.
+ * @throws DefinitionsFactoryException If an inheritance can not be solved.
*/
protected void resolveInheritance(ComponentDefinition definition,
TilesRequestContext request)
@@ -198,6 +260,12 @@
}
}
+ /**
+ * Returns the map with custom definitions for the current request.
+ *
+ * @param request The current request.
+ * @return A map that connects a definition name to a definition.
+ */
@SuppressWarnings("unchecked")
protected Map<String, ComponentDefinition> getDefinitions(
TilesRequestContext request) {
@@ -205,6 +273,13 @@
.get(definitionsAttributeName);
}
+ /**
+ * Returns a map of type "definition name -> definition" and, if it has not
+ * been defined before, creates one.
+ *
+ * @param request The current request.
+ * @return A map that connects a definition name to a definition.
+ */
@SuppressWarnings("unchecked")
protected Map<String, ComponentDefinition> getOrCreateDefinitions(
TilesRequestContext request) {
Modified: tiles/framework/trunk/tiles-core/src/main/java/org/apache/tiles/listener/TilesListener.java
URL: http://svn.apache.org/viewvc/tiles/framework/trunk/tiles-core/src/main/java/org/apache/tiles/listener/TilesListener.java?view=diff&rev=519978&r1=519977&r2=519978
==============================================================================
--- tiles/framework/trunk/tiles-core/src/main/java/org/apache/tiles/listener/TilesListener.java (original)
+++ tiles/framework/trunk/tiles-core/src/main/java/org/apache/tiles/listener/TilesListener.java Mon Mar 19 08:52:33 2007
@@ -33,6 +33,8 @@
import javax.servlet.ServletContextListener;
/**
+ * Listener for the initialization of the Tiles container.
+ *
* @version $Rev$ $Date$
*/
public class TilesListener
@@ -64,7 +66,7 @@
/**
* Remove the tiles container from service.
*
- * @param event
+ * @param event The intercepted event.
*/
public void contextDestroyed(ServletContextEvent event) {
ServletContext servletContext = event.getServletContext();
@@ -75,6 +77,13 @@
}
}
+ /**
+ * Creates a Tiles container.
+ *
+ * @param context The servlet context to use.
+ * @return The created container
+ * @throws TilesException If something goes wrong during creation.
+ */
protected TilesContainer createContainer(ServletContext context)
throws TilesException {
TilesContainerFactory factory =
Modified: tiles/framework/trunk/tiles-core/src/main/java/org/apache/tiles/preparer/BasicPreparerFactory.java
URL: http://svn.apache.org/viewvc/tiles/framework/trunk/tiles-core/src/main/java/org/apache/tiles/preparer/BasicPreparerFactory.java?view=diff&rev=519978&r1=519977&r2=519978
==============================================================================
--- tiles/framework/trunk/tiles-core/src/main/java/org/apache/tiles/preparer/BasicPreparerFactory.java (original)
+++ tiles/framework/trunk/tiles-core/src/main/java/org/apache/tiles/preparer/BasicPreparerFactory.java Mon Mar 19 08:52:33 2007
@@ -40,11 +40,20 @@
*/
public class BasicPreparerFactory implements PreparerFactory {
+ /**
+ * The logging object.
+ */
private static final Log LOG =
LogFactory.getLog(BasicPreparerFactory.class);
+ /**
+ * Maps a preparer name to the instantiated preparer.
+ */
protected Map<String, ViewPreparer> preparers;
+ /**
+ * Constructor.
+ */
public BasicPreparerFactory() {
this.preparers = new HashMap<String, ViewPreparer>();
}
@@ -57,7 +66,7 @@
* @param name the named preparerInstance
* @param context current context
* @return ViewPreparer instance
- * @throws NoSuchPreparerException
+ * @throws TilesException If something goes wrong during preparer creation.
*/
public ViewPreparer getPreparer(String name, TilesRequestContext context)
throws TilesException {
@@ -69,6 +78,14 @@
return preparers.get(name);
}
+ /**
+ * Creates a view preparer for the given name.
+ *
+ * @param name The name of the preparer.
+ * @return The created preparer.
+ * @throws TilesException If something goes wrong during instantiation, or
+ * if the created object is not an instance of <code>ViewPreparer</code>.
+ */
protected ViewPreparer createPreparer(String name) throws TilesException {
if (LOG.isDebugEnabled()) {
Modified: tiles/framework/trunk/tiles-core/src/main/java/org/apache/tiles/servlet/TilesServlet.java
URL: http://svn.apache.org/viewvc/tiles/framework/trunk/tiles-core/src/main/java/org/apache/tiles/servlet/TilesServlet.java?view=diff&rev=519978&r1=519977&r2=519978
==============================================================================
--- tiles/framework/trunk/tiles-core/src/main/java/org/apache/tiles/servlet/TilesServlet.java (original)
+++ tiles/framework/trunk/tiles-core/src/main/java/org/apache/tiles/servlet/TilesServlet.java Mon Mar 19 08:52:33 2007
@@ -36,16 +36,30 @@
*/
public class TilesServlet extends HttpServlet {
+ /**
+ * The private listener instance, that is used to initialize Tiles
+ * container.
+ */
private TilesListener listener = new TilesListener();
+ /** {@inheritDoc} */
+ @Override
public void destroy() {
listener.contextDestroyed(createEvent());
}
+ /** {@inheritDoc} */
+ @Override
public void init() throws ServletException {
listener.contextInitialized(createEvent());
}
+ /**
+ * Creates an servlet context event starting for the servlet configuration
+ * object.
+ *
+ * @return The servlet context event.
+ */
private ServletContextEvent createEvent() {
return new ServletContextEvent(
new ServletContextAdapter(getServletConfig())
Modified: tiles/framework/trunk/tiles-core/src/test/java/org/apache/tiles/context/enhanced/EnhancedTilesApplicationContextTest.java
URL: http://svn.apache.org/viewvc/tiles/framework/trunk/tiles-core/src/test/java/org/apache/tiles/context/enhanced/EnhancedTilesApplicationContextTest.java?view=diff&rev=519978&r1=519977&r2=519978
==============================================================================
--- tiles/framework/trunk/tiles-core/src/test/java/org/apache/tiles/context/enhanced/EnhancedTilesApplicationContextTest.java (original)
+++ tiles/framework/trunk/tiles-core/src/test/java/org/apache/tiles/context/enhanced/EnhancedTilesApplicationContextTest.java Mon Mar 19 08:52:33 2007
@@ -38,14 +38,28 @@
*/
public class EnhancedTilesApplicationContextTest extends TestCase {
+ /**
+ * The root Tiles application context.
+ */
private TilesApplicationContext root;
+
+ /**
+ * The enhanced Tiles application context.
+ */
private EnhancedTilesApplicationContext context;
+ /** {@inheritDoc} */
+ @Override
public void setUp() {
root = EasyMock.createMock(TilesApplicationContext.class);
context = new EnhancedTilesApplicationContext(root);
}
+ /**
+ * Tests resource getting.
+ *
+ * @throws IOException If something goes wrong.
+ */
public void testGetResources() throws IOException {
ClassLoader original = Thread.currentThread().getContextClassLoader();
try {
@@ -65,10 +79,22 @@
}
}
+ /**
+ * An mock class loader.
+ */
public class MockClassLoader extends ClassLoader {
+ /**
+ * A vector of resources.
+ */
private Vector<URL> resources;
+ /**
+ * Constructor.
+ *
+ * @throws MalformedURLException If the URL is not valid (that should
+ * not happen).
+ */
public MockClassLoader() throws MalformedURLException {
resources = new Vector<URL>();
resources.add(new URL("file://tiles/test/test.properties"));
@@ -76,6 +102,8 @@
resources.add(new URL("file://tiles/three/test.properties"));
}
+ /** {@inheritDoc} */
+ @Override
public Enumeration<URL> findResources(String path) {
return resources.elements();
}
Modified: tiles/framework/trunk/tiles-core/src/test/java/org/apache/tiles/context/portlet/PortletTilesRequestContextTest.java
URL: http://svn.apache.org/viewvc/tiles/framework/trunk/tiles-core/src/test/java/org/apache/tiles/context/portlet/PortletTilesRequestContextTest.java?view=diff&rev=519978&r1=519977&r2=519978
==============================================================================
--- tiles/framework/trunk/tiles-core/src/test/java/org/apache/tiles/context/portlet/PortletTilesRequestContextTest.java (original)
+++ tiles/framework/trunk/tiles-core/src/test/java/org/apache/tiles/context/portlet/PortletTilesRequestContextTest.java Mon Mar 19 08:52:33 2007
@@ -38,8 +38,12 @@
*/
public class PortletTilesRequestContextTest extends TestCase {
+ /**
+ * The used request context.
+ */
private TilesRequestContext context;
+ /** {@inheritDoc} */
@Override
protected void setUp() throws Exception {
super.setUp();
@@ -69,18 +73,27 @@
applicationScope.put("applicationAttribute2", "applicationValue2");
}
+ /**
+ * Tests getting the header.
+ */
public void testGetHeader() {
Map<String, String> map = context.getHeader();
assertTrue("The portlet cannot have headers!", map.isEmpty());
doTestReadMap(map, String.class, String.class, "header map");
}
+ /**
+ * Tests getting the header values.
+ */
public void testGetHeaderValues() {
Map<String, String[]> map = context.getHeaderValues();
assertTrue("The portlet cannot have headers!", map.isEmpty());
doTestReadMap(map, String.class, String[].class, "header values map");
}
+ /**
+ * Tests getting request parameters.
+ */
public void testGetParam() {
Map<String, String> map = context.getParam();
assertTrue("The parameters do not contain a set value", "value1"
@@ -89,6 +102,9 @@
doTestReadMap(map, String.class, String.class, "parameter map");
}
+ /**
+ * Tests getting request parameters values.
+ */
public void testGetParamValues() {
Map<String, String[]> map = context.getParamValues();
String[] array = map.get("myParam");
@@ -101,6 +117,9 @@
doTestReadMap(map, String.class, String[].class, "parameter values map");
}
+ /**
+ * Tests getting request scope attributes.
+ */
public void testGetRequestScope() {
Map<String, Object> map = context.getRequestScope();
assertTrue("The request scope does not contain a set value", "value1"
@@ -110,6 +129,9 @@
doTestReadMap(map, String.class, Object.class, "request scope map");
}
+ /**
+ * Tests getting session scope attributes.
+ */
public void testGetSessionScope() {
Map<String, Object> map = context.getSessionScope();
assertTrue("The session scope does not contain a set value",
@@ -119,6 +141,9 @@
doTestReadMap(map, String.class, Object.class, "session scope map");
}
+ /**
+ * Tests getting application scope attributes.
+ */
public void testGetApplicationScope() {
Map<String, Object> map = ((TilesApplicationContext) context)
.getApplicationScope();
@@ -129,6 +154,9 @@
doTestReadMap(map, String.class, Object.class, "application scope map");
}
+ /**
+ * Tests getting init parameters..
+ */
public void testGetInitParams() {
Map<String, String> map = ((TilesApplicationContext) context)
.getInitParams();
@@ -138,6 +166,16 @@
"init parameters scope map");
}
+ /**
+ * Tests a generic map.
+ *
+ * @param <K> The key type.
+ * @param <V> The value type.
+ * @param currentMap The map to check.
+ * @param keyClass The key class.
+ * @param valueClass The value class.
+ * @param mapName The name of the map to test (for messages).
+ */
private <K, V> void doTestReadMap(Map<K, V> currentMap, Class<K> keyClass,
Class<V> valueClass, String mapName) {
int size1, size2;
Modified: tiles/framework/trunk/tiles-core/src/test/java/org/apache/tiles/context/servlet/ServletTilesRequestContextTest.java
URL: http://svn.apache.org/viewvc/tiles/framework/trunk/tiles-core/src/test/java/org/apache/tiles/context/servlet/ServletTilesRequestContextTest.java?view=diff&rev=519978&r1=519977&r2=519978
==============================================================================
--- tiles/framework/trunk/tiles-core/src/test/java/org/apache/tiles/context/servlet/ServletTilesRequestContextTest.java (original)
+++ tiles/framework/trunk/tiles-core/src/test/java/org/apache/tiles/context/servlet/ServletTilesRequestContextTest.java Mon Mar 19 08:52:33 2007
@@ -38,8 +38,12 @@
*/
public class ServletTilesRequestContextTest extends TestCase {
+ /**
+ * The request context.
+ */
private TilesRequestContext context;
+ /** {@inheritDoc} */
@Override
protected void setUp() throws Exception {
super.setUp();
@@ -70,6 +74,9 @@
applicationScope.put("applicationAttribute2", "applicationValue2");
}
+ /**
+ * Tests getting the header.
+ */
public void testGetHeader() {
Map<String, String> map = context.getHeader();
assertTrue("The header does not contain a set value", "text/html"
@@ -77,6 +84,9 @@
doTestReadMap(map, String.class, String.class, "header map");
}
+ /**
+ * Tests getting the header value.
+ */
public void testGetHeaderValues() {
Map<String, String[]> map = context.getHeaderValues();
String[] array = map.get("Content-Type");
@@ -85,6 +95,9 @@
doTestReadMap(map, String.class, String[].class, "header values map");
}
+ /**
+ * Tests getting the parameters.
+ */
public void testGetParam() {
Map<String, String> map = context.getParam();
assertTrue("The parameters do not contain a set value", "value1"
@@ -93,6 +106,9 @@
doTestReadMap(map, String.class, String.class, "parameter map");
}
+ /**
+ * Tests getting the parameter values.
+ */
public void testGetParamValues() {
Map<String, String[]> map = context.getParamValues();
String[] array = map.get("myParam");
@@ -105,6 +121,9 @@
doTestReadMap(map, String.class, String[].class, "parameter values map");
}
+ /**
+ * Tests getting request scope attributes.
+ */
public void testGetRequestScope() {
Map<String, Object> map = context.getRequestScope();
assertTrue("The request scope does not contain a set value", "value1"
@@ -114,6 +133,9 @@
doTestReadMap(map, String.class, Object.class, "request scope map");
}
+ /**
+ * Tests getting session scope attributes.
+ */
public void testGetSessionScope() {
Map<String, Object> map = context.getSessionScope();
assertTrue("The session scope does not contain a set value",
@@ -123,6 +145,9 @@
doTestReadMap(map, String.class, Object.class, "session scope map");
}
+ /**
+ * Tests getting application scope attributes.
+ */
public void testGetApplicationScope() {
Map<String, Object> map = ((TilesApplicationContext) context)
.getApplicationScope();
@@ -133,6 +158,9 @@
doTestReadMap(map, String.class, Object.class, "application scope map");
}
+ /**
+ * Tests getting init parameters.
+ */
public void testGetInitParams() {
Map<String, String> map = ((TilesApplicationContext) context)
.getInitParams();
@@ -142,6 +170,16 @@
"init parameters scope map");
}
+ /**
+ * Tests a generic map.
+ *
+ * @param <K> The key type.
+ * @param <V> The value type.
+ * @param currentMap The map to check.
+ * @param keyClass The key class.
+ * @param valueClass The value class.
+ * @param mapName The name of the map to test (for messages).
+ */
private <K, V> void doTestReadMap(Map<K, V> currentMap, Class<K> keyClass,
Class<V> valueClass, String mapName) {
int size1, size2;
Modified: tiles/framework/trunk/tiles-core/src/test/java/org/apache/tiles/factory/KeyedDefinitionsFactoryTilesContainerFactoryTest.java
URL: http://svn.apache.org/viewvc/tiles/framework/trunk/tiles-core/src/test/java/org/apache/tiles/factory/KeyedDefinitionsFactoryTilesContainerFactoryTest.java?view=diff&rev=519978&r1=519977&r2=519978
==============================================================================
--- tiles/framework/trunk/tiles-core/src/test/java/org/apache/tiles/factory/KeyedDefinitionsFactoryTilesContainerFactoryTest.java (original)
+++ tiles/framework/trunk/tiles-core/src/test/java/org/apache/tiles/factory/KeyedDefinitionsFactoryTilesContainerFactoryTest.java Mon Mar 19 08:52:33 2007
@@ -43,10 +43,18 @@
*/
public class KeyedDefinitionsFactoryTilesContainerFactoryTest extends TestCase {
+ /**
+ * The servlet context.
+ */
private ServletContext context;
+ /**
+ * Default configuration parameters.
+ */
private Map<String, String> defaults;
+ /** {@inheritDoc} */
+ @Override
public void setUp() {
context = EasyMock.createMock(ServletContext.class);
defaults = new HashMap<String, String>();
@@ -54,6 +62,11 @@
KeyedDefinitionsFactoryTilesContainerFactory.class.getName());
}
+ /**
+ * Tests getting a container factory.
+ *
+ * @throws TilesException If something goes wrong.
+ */
public void testGetFactory() throws TilesException {
Vector<String> v = new Vector<String>();
@@ -67,6 +80,13 @@
factory.getClass());
}
+ /**
+ * Tests creating a container.
+ *
+ * @throws TilesException If something goes wrong.
+ * @throws MalformedURLException If the resources have an invalid form (that
+ * should not happen).
+ */
public void testCreateContainer() throws TilesException, MalformedURLException {
Vector<String> enumeration = new Vector<String>();
EasyMock.expect(context.getInitParameter(TilesContainerFactory.CONTAINER_FACTORY_INIT_PARAM)).andReturn(null);
Modified: tiles/framework/trunk/tiles-core/src/test/java/org/apache/tiles/factory/TilesContainerFactoryTest.java
URL: http://svn.apache.org/viewvc/tiles/framework/trunk/tiles-core/src/test/java/org/apache/tiles/factory/TilesContainerFactoryTest.java?view=diff&rev=519978&r1=519977&r2=519978
==============================================================================
--- tiles/framework/trunk/tiles-core/src/test/java/org/apache/tiles/factory/TilesContainerFactoryTest.java (original)
+++ tiles/framework/trunk/tiles-core/src/test/java/org/apache/tiles/factory/TilesContainerFactoryTest.java Mon Mar 19 08:52:33 2007
@@ -41,12 +41,22 @@
*/
public class TilesContainerFactoryTest extends TestCase {
+ /**
+ * The servlet context.
+ */
private ServletContext context;
+ /** {@inheritDoc} */
+ @Override
public void setUp() {
context = EasyMock.createMock(ServletContext.class);
}
+ /**
+ * Tests getting the factory.
+ *
+ * @throws TilesException If something goes wrong.
+ */
public void testGetFactory() throws TilesException {
Vector<String> v = new Vector<String>();
Vector<String> emptyVector = new Vector<String>();
@@ -90,6 +100,12 @@
}
}
+
+ /**
+ * Tests
+ * @throws TilesException
+ * @throws MalformedURLException
+ */
public void testCreateContainer() throws TilesException, MalformedURLException {
URL url = getClass().getResource("test-defs.xml");
Vector<String> enumeration = new Vector<String>();
@@ -115,6 +131,12 @@
}
+
+ /**
+ * Tests getting init parameter map.
+ *
+ * @throws TilesException If something goes wrong.
+ */
public void testGetInitParameterMap() throws TilesException {
Vector<String> keys = new Vector<String>();
keys.add("one");
@@ -136,6 +158,9 @@
assertEquals("twoValue", map.get("two"));
}
+ /**
+ * A test factory extending directly from TilesContainerFactory.
+ */
public static class TestFactory extends TilesContainerFactory {
}
Modified: tiles/framework/trunk/tiles-core/src/test/java/org/apache/tiles/impl/BasicTilesContainerTest.java
URL: http://svn.apache.org/viewvc/tiles/framework/trunk/tiles-core/src/test/java/org/apache/tiles/impl/BasicTilesContainerTest.java?view=diff&rev=519978&r1=519977&r2=519978
==============================================================================
--- tiles/framework/trunk/tiles-core/src/test/java/org/apache/tiles/impl/BasicTilesContainerTest.java (original)
+++ tiles/framework/trunk/tiles-core/src/test/java/org/apache/tiles/impl/BasicTilesContainerTest.java Mon Mar 19 08:52:33 2007
@@ -39,8 +39,13 @@
*/
public class BasicTilesContainerTest extends TestCase {
+ /**
+ * The container.
+ */
private BasicTilesContainer container;
+ /** {@inheritDoc} */
+ @Override
public void setUp() {
ServletContext context = EasyMock.createMock(ServletContext.class);
URL url = getClass().getResource("/org/apache/tiles/factory/test-defs.xml");
@@ -67,6 +72,9 @@
}
}
+ /**
+ * Tests basic Tiles container initialization.
+ */
public void testInitialization() {
assertNotNull(container);
assertNotNull(container.getContextFactory());
Modified: tiles/framework/trunk/tiles-core/src/test/java/org/apache/tiles/impl/KeyedDefinitionsFactoryTilesContainerTest.java
URL: http://svn.apache.org/viewvc/tiles/framework/trunk/tiles-core/src/test/java/org/apache/tiles/impl/KeyedDefinitionsFactoryTilesContainerTest.java?view=diff&rev=519978&r1=519977&r2=519978
==============================================================================
--- tiles/framework/trunk/tiles-core/src/test/java/org/apache/tiles/impl/KeyedDefinitionsFactoryTilesContainerTest.java (original)
+++ tiles/framework/trunk/tiles-core/src/test/java/org/apache/tiles/impl/KeyedDefinitionsFactoryTilesContainerTest.java Mon Mar 19 08:52:33 2007
@@ -48,10 +48,18 @@
*/
public class KeyedDefinitionsFactoryTilesContainerTest extends TestCase {
+ /**
+ * The Tiles container.
+ */
private KeyedDefinitionsFactoryTilesContainer container;
+ /**
+ * Default configuration parameters.
+ */
private Map<String, String> defaults;
+ /** {@inheritDoc} */
+ @Override
public void setUp() {
defaults = new HashMap<String, String>();
defaults.put(TilesContainerFactory.CONTAINER_FACTORY_INIT_PARAM,
@@ -96,6 +104,9 @@
}
}
+ /**
+ * Tests container initialization.
+ */
public void testInitialization() {
assertNotNull(container);
assertNotNull(container.getContextFactory());
@@ -105,6 +116,13 @@
assertNotNull(container.getProperDefinitionsFactory("two"));
}
+ /**
+ * Tests initialization for postponed definitions factories.
+ *
+ * @throws MalformedURLException If sources are not valid (that should not
+ * happen).
+ * @throws TilesException If something goes wrong.
+ */
public void testPostponedDefinitionsFactoryInitialization() throws MalformedURLException, TilesException {
KeyedDefinitionsFactoryTilesContainer container;
ServletContext context = EasyMock.createMock(ServletContext.class);
@@ -152,6 +170,9 @@
assertNotNull(container.getProperDefinitionsFactory("two"));
}
+ /**
+ * Tests if the definitions factory has been used.
+ */
public void testDefinitionsFactoryUse() {
HttpServletRequest request = EasyMock.createMock(
HttpServletRequest.class);
Modified: tiles/framework/trunk/tiles-core/src/test/java/org/apache/tiles/preparer/BasicPreparerFactoryTest.java
URL: http://svn.apache.org/viewvc/tiles/framework/trunk/tiles-core/src/test/java/org/apache/tiles/preparer/BasicPreparerFactoryTest.java?view=diff&rev=519978&r1=519977&r2=519978
==============================================================================
--- tiles/framework/trunk/tiles-core/src/test/java/org/apache/tiles/preparer/BasicPreparerFactoryTest.java (original)
+++ tiles/framework/trunk/tiles-core/src/test/java/org/apache/tiles/preparer/BasicPreparerFactoryTest.java Mon Mar 19 08:52:33 2007
@@ -27,16 +27,28 @@
import org.apache.tiles.TilesException;
/**
+ * Tests the basic preparer factory.
+ *
* @version $Rev$ $Date$
*/
public class BasicPreparerFactoryTest extends TestCase {
+ /**
+ * The preparer factory.
+ */
private BasicPreparerFactory factory;
+ /** {@inheritDoc} */
+ @Override
public void setUp() {
factory = new BasicPreparerFactory();
}
+ /**
+ * Tests getting a preparer.
+ *
+ * @throws TilesException If something goes wrong.
+ */
public void testGetPreparer() throws TilesException {
String name = ViewPreparerSupport.class.getName();
ViewPreparer p = factory.getPreparer(name, null);
Modified: tiles/framework/trunk/tiles-core/src/test/java/org/apache/tiles/util/RollingVectorEnumeration.java
URL: http://svn.apache.org/viewvc/tiles/framework/trunk/tiles-core/src/test/java/org/apache/tiles/util/RollingVectorEnumeration.java?view=diff&rev=519978&r1=519977&r2=519978
==============================================================================
--- tiles/framework/trunk/tiles-core/src/test/java/org/apache/tiles/util/RollingVectorEnumeration.java (original)
+++ tiles/framework/trunk/tiles-core/src/test/java/org/apache/tiles/util/RollingVectorEnumeration.java Mon Mar 19 08:52:33 2007
@@ -26,18 +26,34 @@
import java.util.Vector;
/**
+ * It represents an vector-based enumeration when, when it has finished
+ * enumerating items, it starts from the beginning.
+ *
+ * @param <E> The type of the element of this enumeration.
* @version $Rev$ $Date$
*/
public class RollingVectorEnumeration<E> implements Enumeration<E> {
+ /**
+ * The vector.
+ */
private Vector<E> vector;
+ /**
+ * The elements.
+ */
private Enumeration<E> elements;
+ /**
+ * Constructor.
+ *
+ * @param vector The vector.
+ */
public RollingVectorEnumeration(Vector<E> vector) {
this.vector = vector;
}
+ /** {@inheritDoc} */
public boolean hasMoreElements() {
if (elements == null) {
elements = vector.elements();
@@ -46,6 +62,7 @@
return elements.hasMoreElements();
}
+ /** {@inheritDoc} */
public E nextElement() {
E retValue = elements.nextElement();
Modified: tiles/framework/trunk/tiles-jsp/src/main/java/org/apache/tiles/jsp/context/JspTilesContextFactory.java
URL: http://svn.apache.org/viewvc/tiles/framework/trunk/tiles-jsp/src/main/java/org/apache/tiles/jsp/context/JspTilesContextFactory.java?view=diff&rev=519978&r1=519977&r2=519978
==============================================================================
--- tiles/framework/trunk/tiles-jsp/src/main/java/org/apache/tiles/jsp/context/JspTilesContextFactory.java (original)
+++ tiles/framework/trunk/tiles-jsp/src/main/java/org/apache/tiles/jsp/context/JspTilesContextFactory.java Mon Mar 19 08:52:33 2007
@@ -39,12 +39,11 @@
*/
public class JspTilesContextFactory implements TilesContextFactory {
+ /** {@inheritDoc} */
public void init(Map<String, String> configParameters) {
}
- /**
- * Creates a TilesApplicationContext from the given context.
- */
+ /** {@inheritDoc} */
public TilesApplicationContext createApplicationContext(Object context) {
if (context instanceof ServletContext) {
ServletContext servletContext = (ServletContext) context;
@@ -54,6 +53,7 @@
return null;
}
+ /** {@inheritDoc} */
public TilesRequestContext createRequestContext(TilesApplicationContext context,
Object... requestItems) {
if (requestItems.length == 1) {
@@ -66,6 +66,12 @@
return null;
}
+ /**
+ * Returns the original servlet context.
+ *
+ * @param context The application context.
+ * @return The original servlet context, if found.
+ */
protected ServletContext getServletContext(TilesApplicationContext context) {
if (context instanceof ServletTilesApplicationContext) {
ServletTilesApplicationContext app = (ServletTilesApplicationContext) context;
Modified: tiles/framework/trunk/tiles-jsp/src/main/java/org/apache/tiles/jsp/context/JspTilesRequestContext.java
URL: http://svn.apache.org/viewvc/tiles/framework/trunk/tiles-jsp/src/main/java/org/apache/tiles/jsp/context/JspTilesRequestContext.java?view=diff&rev=519978&r1=519977&r2=519978
==============================================================================
--- tiles/framework/trunk/tiles-jsp/src/main/java/org/apache/tiles/jsp/context/JspTilesRequestContext.java (original)
+++ tiles/framework/trunk/tiles-jsp/src/main/java/org/apache/tiles/jsp/context/JspTilesRequestContext.java Mon Mar 19 08:52:33 2007
@@ -42,13 +42,29 @@
public class JspTilesRequestContext extends ServletTilesRequestContext
implements TilesRequestContext {
+ /**
+ * The logging object.
+ */
private static final Log LOG =
LogFactory.getLog(JspTilesRequestContext.class);
+ /**
+ * The current page context.
+ */
private PageContext pageContext;
+
+ /**
+ * The writer response to use.
+ */
private JspWriterResponse response;
+ /**
+ * Constructor.
+ *
+ * @param context The servlet context to use.
+ * @param pageContext The page context to use.
+ */
public JspTilesRequestContext(ServletContext context, PageContext pageContext) {
super(context,
(HttpServletRequest) pageContext.getRequest(),
@@ -56,10 +72,17 @@
this.pageContext = pageContext;
}
+ /**
+ * Dispatches a path. In fact it "includes" it!
+ *
+ * @param path The path to dispatch to.
+ * @see org.apache.tiles.context.servlet.ServletTilesRequestContext#dispatch(java.lang.String)
+ */
public void dispatch(String path) throws IOException {
include(path);
}
+ /** {@inheritDoc} */
public void include(String path) throws IOException {
try {
JspUtil.doInclude(pageContext, path, false);
@@ -69,6 +92,7 @@
}
}
+ /** {@inheritDoc} */
public HttpServletResponse getResponse() {
if(response == null) {
response = new JspWriterResponse(pageContext);
Modified: tiles/framework/trunk/tiles-jsp/src/main/java/org/apache/tiles/jsp/context/JspUtil.java
URL: http://svn.apache.org/viewvc/tiles/framework/trunk/tiles-jsp/src/main/java/org/apache/tiles/jsp/context/JspUtil.java?view=diff&rev=519978&r1=519977&r2=519978
==============================================================================
--- tiles/framework/trunk/tiles-jsp/src/main/java/org/apache/tiles/jsp/context/JspUtil.java (original)
+++ tiles/framework/trunk/tiles-jsp/src/main/java/org/apache/tiles/jsp/context/JspUtil.java Mon Mar 19 08:52:33 2007
@@ -38,6 +38,9 @@
*/
public class JspUtil {
+ /**
+ * The logging object.
+ */
private static final Log LOG =
LogFactory.getLog(JspUtil.class);
@@ -61,6 +64,15 @@
}
}
+ /**
+ * Includes an URI in the JSP response.
+ *
+ * @param pageContext The page context to use.
+ * @param uri The URI to include.
+ * @param flush <code>true</code> means that the buffer should be flushed at
+ * the end of this operation
+ * @throws JspException If an underlying exception happens.
+ */
public static void doInclude(PageContext pageContext, String uri, boolean flush)
throws JspException {
Modified: tiles/framework/trunk/tiles-jsp/src/main/java/org/apache/tiles/jsp/context/JspWriterResponse.java
URL: http://svn.apache.org/viewvc/tiles/framework/trunk/tiles-jsp/src/main/java/org/apache/tiles/jsp/context/JspWriterResponse.java?view=diff&rev=519978&r1=519977&r2=519978
==============================================================================
--- tiles/framework/trunk/tiles-jsp/src/main/java/org/apache/tiles/jsp/context/JspWriterResponse.java (original)
+++ tiles/framework/trunk/tiles-jsp/src/main/java/org/apache/tiles/jsp/context/JspWriterResponse.java Mon Mar 19 08:52:33 2007
@@ -23,25 +23,42 @@
import javax.servlet.http.HttpServletResponseWrapper;
import javax.servlet.http.HttpServletResponse;
+import javax.servlet.jsp.JspWriter;
import javax.servlet.jsp.PageContext;
import java.io.PrintWriter;
import java.io.IOException;
/**
+ * It works as an {@link HttpServletResponse} by wrapping a {@link JspWriter}
+ * around a {@link PrintWriter}.
+ *
* @version $Rev$ $Date$
*/
public class JspWriterResponse extends HttpServletResponseWrapper {
+ /**
+ * The page context to use.
+ */
private PageContext context;
+
+ /**
+ * The created print writer.
+ */
private PrintWriter writer;
+ /**
+ * Constructor.
+ *
+ * @param pageContext The page context to use.
+ */
public JspWriterResponse(PageContext pageContext) {
super((HttpServletResponse)pageContext.getResponse());
this.context = pageContext;
}
+ /** {@inheritDoc} */
public PrintWriter getWriter() throws IOException {
if(writer == null) {
writer = new PrintWriter(context.getOut());
Modified: tiles/framework/trunk/tiles-jsp/src/main/java/org/apache/tiles/jsp/taglib/AddAttributeTag.java
URL: http://svn.apache.org/viewvc/tiles/framework/trunk/tiles-jsp/src/main/java/org/apache/tiles/jsp/taglib/AddAttributeTag.java?view=diff&rev=519978&r1=519977&r2=519978
==============================================================================
--- tiles/framework/trunk/tiles-jsp/src/main/java/org/apache/tiles/jsp/taglib/AddAttributeTag.java (original)
+++ tiles/framework/trunk/tiles-jsp/src/main/java/org/apache/tiles/jsp/taglib/AddAttributeTag.java Mon Mar 19 08:52:33 2007
@@ -61,6 +61,9 @@
public class AddAttributeTag extends RoleSecurityTagSupport implements
ComponentConstants {
+ /**
+ * The logging object.
+ */
private static final Log LOG = LogFactory.getLog(AddAttributeTag.class);
/**
@@ -73,18 +76,60 @@
*/
private String type = null;
+ /**
+ * Returns the attribute value.
+ *
+ * @return Attribute value. Can be a String or Object.
+ */
public Object getValue() {
return value;
}
+ /**
+ * Sets the attribute value.
+ *
+ * @param value Attribute value. Can be a String or Object.
+ */
public void setValue(Object value) {
this.value = value;
}
+ /**
+ * <p>
+ * Returns content type: string, template or definition.
+ * </p>
+ * <ul>
+ * <li>String : Content is printed directly.</li>
+ * <li>template : Content is included from specified URL. Value is used as
+ * an URL.</li>
+ * <li>definition : Value denote a definition defined in factory (xml
+ * file). Definition will be searched in the inserted tile, in a
+ * <code><insert attribute="attributeName"></code> tag, where
+ * 'attributeName' is the name used for this tag.</li>
+ * </ul>
+ *
+ * @return The attribute type.
+ */
public String getType() {
return type;
}
+ /**
+ * <p>
+ * Sets content type: string, template or definition.
+ * </p>
+ * <ul>
+ * <li>String : Content is printed directly.</li>
+ * <li>template : Content is included from specified URL. Value is used as
+ * an URL.</li>
+ * <li>definition : Value denote a definition defined in factory (xml
+ * file). Definition will be searched in the inserted tile, in a
+ * <code><insert attribute="attributeName"></code> tag, where
+ * 'attributeName' is the name used for this tag.</li>
+ * </ul>
+ *
+ * @param type The attribute type.
+ */
public void setType(String type) {
this.type = type;
}
@@ -92,6 +137,7 @@
/**
* Release all allocated resources.
*/
+ @Override
public void release() {
super.release();
value = null;
@@ -101,6 +147,7 @@
/**
* Save the body content of this tag (if any)
*
+ * @return It returns <code>SKIP_BODY</code>.
* @throws JspException if a JSP exception has occurred
*/
public int doAfterBody() throws JspException {
@@ -111,6 +158,7 @@
return (SKIP_BODY);
}
+ /** {@inheritDoc} */
protected void execute() throws JspException {
AddAttributeTagParent parent = (AddAttributeTagParent)
TagSupport.findAncestorWithClass(this, AddAttributeTagParent.class);
Modified: tiles/framework/trunk/tiles-jsp/src/main/java/org/apache/tiles/jsp/taglib/AddListAttributeTag.java
URL: http://svn.apache.org/viewvc/tiles/framework/trunk/tiles-jsp/src/main/java/org/apache/tiles/jsp/taglib/AddListAttributeTag.java?view=diff&rev=519978&r1=519977&r2=519978
==============================================================================
--- tiles/framework/trunk/tiles-jsp/src/main/java/org/apache/tiles/jsp/taglib/AddListAttributeTag.java (original)
+++ tiles/framework/trunk/tiles-jsp/src/main/java/org/apache/tiles/jsp/taglib/AddListAttributeTag.java Mon Mar 19 08:52:33 2007
@@ -40,23 +40,30 @@
/**
* Get list defined in tag.
+ *
+ * @return The list of component attributes.
*/
@SuppressWarnings("unchecked")
public List<ComponentAttribute> getValue() {
return (List<ComponentAttribute>) super.getValue();
}
+ /** {@inheritDoc} */
+ @Override
public void setValue(Object object) {
throw new IllegalStateException("The value of the PutListAttributeTag must be the originally defined list.");
}
+ /** {@inheritDoc} */
public int doStartTag() throws JspException {
super.setValue(new ArrayList<ComponentAttribute>());
return super.doStartTag();
}
+
/**
* PutListAttributeTag may not have any body, except for PutAttribute tags.
*
+ * @return <code>SKIP_BODY</code>.
* @throws JspException if a JSP exception has occurred
*/
public int doAfterBody() throws JspException {
@@ -91,6 +98,11 @@
this.addValue(attribute);
}
+ /**
+ * Adds a value in this list.
+ *
+ * @param attribute The attribute to add.
+ */
private void addValue( ComponentAttribute attribute ) {
this.getValue().add(attribute);
}
Modified: tiles/framework/trunk/tiles-jsp/src/main/java/org/apache/tiles/jsp/taglib/AttributeTagSupport.java
URL: http://svn.apache.org/viewvc/tiles/framework/trunk/tiles-jsp/src/main/java/org/apache/tiles/jsp/taglib/AttributeTagSupport.java?view=diff&rev=519978&r1=519977&r2=519978
==============================================================================
--- tiles/framework/trunk/tiles-jsp/src/main/java/org/apache/tiles/jsp/taglib/AttributeTagSupport.java (original)
+++ tiles/framework/trunk/tiles-jsp/src/main/java/org/apache/tiles/jsp/taglib/AttributeTagSupport.java Mon Mar 19 08:52:33 2007
@@ -42,6 +42,9 @@
public abstract class AttributeTagSupport extends TagSupport {
+ /**
+ * Maps scope names to their constants.
+ */
private static final Map<String, Integer> scopes =
new HashMap<String, Integer>();
@@ -53,19 +56,40 @@
}
+ /**
+ * The scope name.
+ */
protected String scopeName = null;
+ /**
+ * The scope.
+ */
protected int scope = PageContext.PAGE_SCOPE;
+ /**
+ * The name of the attribute.
+ */
protected String name = null;
+ /**
+ * Flag that, if <code>true</code>, ignores exceptions.
+ */
protected boolean ignore = false;
+ /**
+ * The Tiles container to use.
+ */
protected TilesContainer container;
+ /**
+ * The current component context.
+ */
protected ComponentContext componentContext;
+ /**
+ * The found attribute.
+ */
protected ComponentAttribute attribute;
@@ -87,11 +111,13 @@
return scopeName;
}
+ /** {@inheritDoc} */
public void release() {
scopeName = null;
scope = PageContext.PAGE_SCOPE;
}
+ /** {@inheritDoc} */
public int doStartTag() throws JspException {
container = TilesAccess.getContainer(pageContext.getServletContext());
componentContext = container.getComponentContext(pageContext);
@@ -123,8 +149,15 @@
return SKIP_BODY;
}
+ /**
+ * Execute this tag. It is called inside {@link #doEndTag()}.
+ *
+ * @throws JspException If something goes wrong during rendering.
+ * @throws IOException If something goes wrong during writing content.
+ */
public abstract void execute() throws JspException, IOException;
+ /** {@inheritDoc} */
public int doEndTag() {
return EVAL_PAGE;
}
Modified: tiles/framework/trunk/tiles-jsp/src/main/java/org/apache/tiles/jsp/taglib/ContainerTagSupport.java
URL: http://svn.apache.org/viewvc/tiles/framework/trunk/tiles-jsp/src/main/java/org/apache/tiles/jsp/taglib/ContainerTagSupport.java?view=diff&rev=519978&r1=519977&r2=519978
==============================================================================
--- tiles/framework/trunk/tiles-jsp/src/main/java/org/apache/tiles/jsp/taglib/ContainerTagSupport.java (original)
+++ tiles/framework/trunk/tiles-jsp/src/main/java/org/apache/tiles/jsp/taglib/ContainerTagSupport.java Mon Mar 19 08:52:33 2007
@@ -47,13 +47,23 @@
@SuppressWarnings("unused")
private static final Log LOG = LogFactory.getLog(ContainerTagSupport.class);
+ /**
+ * The Tiles container that can be used inside the tag.
+ */
protected TilesContainer container;
+
+ /**
+ * The component context to use to store and read attribute values.
+ */
protected ComponentContext componentContext;
/**
* By default, all ContainerTags evaluate their body. Subclasses may choose to be more selective.
* In any case, children can rely upon the container and componentContext being initialized if they
* call <code>super.doStartTag()</code>
+ *
+ * @return <code>EVAL_BODY_BUFFERED</code>.
+ * @throws JspException If the container has not been initialized.
*/
public int doStartTag() throws JspException {
container = TilesAccess.getContainer(pageContext.getServletContext());
@@ -66,6 +76,7 @@
}
+ /** {@inheritDoc} */
public int doEndTag() throws JspException {
try {
return super.doEndTag();
@@ -76,18 +87,29 @@
+ /** {@inheritDoc} */
public void release() {
super.release();
this.container = null;
this.componentContext = null;
}
+ /**
+ * Starts the context when entering the tag.
+ *
+ * @param context The page context to use.
+ */
protected void startContext(PageContext context) {
if (container != null) {
componentContext = container.startContext(pageContext);
}
}
+ /**
+ * Ends the context when exiting the tag.
+ *
+ * @param context The page context to use.
+ */
protected void endContext(PageContext context) {
if (componentContext != null && container != null) {
container.endContext(pageContext);
Modified: tiles/framework/trunk/tiles-jsp/src/main/java/org/apache/tiles/jsp/taglib/GetAsStringTag.java
URL: http://svn.apache.org/viewvc/tiles/framework/trunk/tiles-jsp/src/main/java/org/apache/tiles/jsp/taglib/GetAsStringTag.java?view=diff&rev=519978&r1=519977&r2=519978
==============================================================================
--- tiles/framework/trunk/tiles-jsp/src/main/java/org/apache/tiles/jsp/taglib/GetAsStringTag.java (original)
+++ tiles/framework/trunk/tiles-jsp/src/main/java/org/apache/tiles/jsp/taglib/GetAsStringTag.java Mon Mar 19 08:52:33 2007
@@ -35,6 +35,7 @@
*/
public class GetAsStringTag extends InsertAttributeTag {
+ /** {@inheritDoc} */
@Override
protected void render(ComponentAttribute attr)
throws TilesException, IOException {
Modified: tiles/framework/trunk/tiles-jsp/src/main/java/org/apache/tiles/jsp/taglib/ImportAttributeTag.java
URL: http://svn.apache.org/viewvc/tiles/framework/trunk/tiles-jsp/src/main/java/org/apache/tiles/jsp/taglib/ImportAttributeTag.java?view=diff&rev=519978&r1=519977&r2=519978
==============================================================================
--- tiles/framework/trunk/tiles-jsp/src/main/java/org/apache/tiles/jsp/taglib/ImportAttributeTag.java (original)
+++ tiles/framework/trunk/tiles-jsp/src/main/java/org/apache/tiles/jsp/taglib/ImportAttributeTag.java Mon Mar 19 08:52:33 2007
@@ -38,12 +38,31 @@
*/
public class ImportAttributeTag extends AttributeTagSupport {
+ /**
+ * The destination attribute name.
+ */
private String toName;
+ /**
+ * <p>
+ * Returns the name of the destination attribute. If not specified, the name
+ * will be the same as specified in <code>name</code> attribute
+ * </p>
+ *
+ * @return The destination attribute name.
+ */
public String getToName() {
return toName;
}
+ /**
+ * <p>
+ * Sets the name of the destination attribute. If not specified, the name
+ * will be the same as specified in <code>name</code> attribute
+ * </p>
+ *
+ * @param toName The destination attribute name.
+ */
public void setToName(String toName) {
this.toName = toName;
}
Modified: tiles/framework/trunk/tiles-jsp/src/main/java/org/apache/tiles/jsp/taglib/InsertAttributeTag.java
URL: http://svn.apache.org/viewvc/tiles/framework/trunk/tiles-jsp/src/main/java/org/apache/tiles/jsp/taglib/InsertAttributeTag.java?view=diff&rev=519978&r1=519977&r2=519978
==============================================================================
--- tiles/framework/trunk/tiles-jsp/src/main/java/org/apache/tiles/jsp/taglib/InsertAttributeTag.java (original)
+++ tiles/framework/trunk/tiles-jsp/src/main/java/org/apache/tiles/jsp/taglib/InsertAttributeTag.java Mon Mar 19 08:52:33 2007
@@ -45,14 +45,30 @@
*/
protected String name;
+ /**
+ * The value of the attribute.
+ */
protected Object value = null;
+ /**
+ * The context used to evaluate the attribute.
+ */
protected ComponentContext evaluatingContext;
+ /**
+ * Sets the name of the attribute.
+ *
+ * @param value The name of the attribute.
+ */
public void setName(String value) {
this.name = value;
}
+ /**
+ * Returns the name of the attribute.
+ *
+ * @return The name of the attribute.
+ */
public String getName() {
return name;
}
@@ -75,12 +91,14 @@
this.value = value;
}
+ /** {@inheritDoc} */
public void release() {
super.release();
this.name = null;
this.value = null;
}
+ /** {@inheritDoc} */
protected void render() throws JspException, TilesException, IOException {
ComponentAttribute attr = (ComponentAttribute) value;
if (attr == null && evaluatingContext != null) {
@@ -100,6 +118,7 @@
render(attr);
}
+ /** {@inheritDoc} */
@Override
protected void startContext(PageContext context) {
Modified: tiles/framework/trunk/tiles-jsp/src/main/java/org/apache/tiles/jsp/taglib/InsertDefinitionTag.java
URL: http://svn.apache.org/viewvc/tiles/framework/trunk/tiles-jsp/src/main/java/org/apache/tiles/jsp/taglib/InsertDefinitionTag.java?view=diff&rev=519978&r1=519977&r2=519978
==============================================================================
--- tiles/framework/trunk/tiles-jsp/src/main/java/org/apache/tiles/jsp/taglib/InsertDefinitionTag.java (original)
+++ tiles/framework/trunk/tiles-jsp/src/main/java/org/apache/tiles/jsp/taglib/InsertDefinitionTag.java Mon Mar 19 08:52:33 2007
@@ -35,18 +35,32 @@
*/
public class InsertDefinitionTag extends RenderTagSupport implements PutAttributeTagParent {
+ /**
+ * The definition name.
+ */
private String name;
+ /**
+ * Returns the name of the definition to insert.
+ *
+ * @return The name of the definition.
+ */
public String getName() {
return name;
}
+ /**
+ * Sets the name of the definition to insert.
+ *
+ * @param name The name of the definition.
+ */
public void setName(String name) {
this.name = name;
}
+ /** {@inheritDoc} */
protected void render() throws JspException, TilesException {
container.render(name, pageContext);
}
Modified: tiles/framework/trunk/tiles-jsp/src/main/java/org/apache/tiles/jsp/taglib/InsertTemplateTag.java
URL: http://svn.apache.org/viewvc/tiles/framework/trunk/tiles-jsp/src/main/java/org/apache/tiles/jsp/taglib/InsertTemplateTag.java?view=diff&rev=519978&r1=519977&r2=519978
==============================================================================
--- tiles/framework/trunk/tiles-jsp/src/main/java/org/apache/tiles/jsp/taglib/InsertTemplateTag.java (original)
+++ tiles/framework/trunk/tiles-jsp/src/main/java/org/apache/tiles/jsp/taglib/InsertTemplateTag.java Mon Mar 19 08:52:33 2007
@@ -37,16 +37,33 @@
public class InsertTemplateTag extends RenderTagSupport
implements PutAttributeTagParent {
+
+ /**
+ * A string representing the URI of a template (for example, a JSP page).
+ */
private String template;
+ /**
+ * Returns a string representing the URI of a template (for example, a JSP
+ * page).
+ *
+ * @return The template URI.
+ */
public String getTemplate() {
return template;
}
+ /**
+ * Sets a string representing the URI of a template (for example, a JSP
+ * page).
+ *
+ * @param template The template URI.
+ */
public void setTemplate(String template) {
this.template = template;
}
+ /** {@inheritDoc} */
protected void render() throws JspException {
JspUtil.doInclude(pageContext, template, flush);
}
Modified: tiles/framework/trunk/tiles-jsp/src/main/java/org/apache/tiles/jsp/taglib/PutAttributeTag.java
URL: http://svn.apache.org/viewvc/tiles/framework/trunk/tiles-jsp/src/main/java/org/apache/tiles/jsp/taglib/PutAttributeTag.java?view=diff&rev=519978&r1=519977&r2=519978
==============================================================================
--- tiles/framework/trunk/tiles-jsp/src/main/java/org/apache/tiles/jsp/taglib/PutAttributeTag.java (original)
+++ tiles/framework/trunk/tiles-jsp/src/main/java/org/apache/tiles/jsp/taglib/PutAttributeTag.java Mon Mar 19 08:52:33 2007
@@ -72,6 +72,9 @@
*/
public class PutAttributeTag extends RoleSecurityTagSupport implements ComponentConstants {
+ /**
+ * The logging object.
+ */
private static final Log LOG = LogFactory.getLog(PutAttributeTag.class);
/**
@@ -90,26 +93,82 @@
private String type = null;
+ /**
+ * Returns the name of the attribute.
+ *
+ * @return The name of the attribute.
+ */
public String getName() {
return name;
}
+ /**
+ * Sets the name of the attribute.
+ *
+ * @param name The name of the attribute.
+ */
public void setName(String name) {
this.name = name;
}
+ /**
+ * Returns the Attribute value. Could be a String or an Object. Value can
+ * come from a direct assignment (value="aValue") or from a bean. One of
+ * 'value' 'content' or 'beanName' must be present.
+ *
+ * @return The attribute value.
+ */
public Object getValue() {
return value;
}
+ /**
+ * Sets the Attribute value. Could be a String or an Object. Value can
+ * come from a direct assignment (value="aValue") or from a bean. One of
+ * 'value' 'content' or 'beanName' must be present.
+ *
+ * @param value The attribute value.
+ */
public void setValue(Object value) {
this.value = value;
}
+ /**
+ * <p>
+ * Returns the content type: string, template or definition.
+ * </p>
+ * <ul>
+ * <li>String : Content is printed directly.</li>
+ * <li>template : Content is included from specified URL. Value is used as
+ * an URL.</li>
+ * <li>definition : Value is the name of a definition defined in factory
+ * (xml file). Definition will be searched in the inserted tile, in a
+ * <code><tiles:insert attribute="attributeName"></code> tag, where
+ * 'attributeName' is the name used for this tag.</li>
+ * </ul>
+ *
+ * @return The attribute type.
+ */
public String getType() {
return type;
}
+ /**
+ * <p>
+ * Sets the content type: string, template or definition.
+ * </p>
+ * <ul>
+ * <li>String : Content is printed directly.</li>
+ * <li>template : Content is included from specified URL. Value is used as
+ * an URL.</li>
+ * <li>definition : Value is the name of a definition defined in factory
+ * (xml file). Definition will be searched in the inserted tile, in a
+ * <code><tiles:insert attribute="attributeName"></code> tag, where
+ * 'attributeName' is the name used for this tag.</li>
+ * </ul>
+ *
+ * @param type The attribute type.
+ */
public void setType(String type) {
this.type = type;
}
@@ -127,6 +186,7 @@
/**
* Save the body content of this tag (if any)
*
+ * @return <code>SKIP_BODY</code>.
* @throws JspException if a JSP exception has occurred
*/
public int doAfterBody() throws JspException {
@@ -137,6 +197,7 @@
return (SKIP_BODY);
}
+ /** {@inheritDoc} */
protected void execute() throws JspException {
PutAttributeTagParent parent = (PutAttributeTagParent)
TagSupport.findAncestorWithClass(this, PutAttributeTagParent.class);
Modified: tiles/framework/trunk/tiles-jsp/src/main/java/org/apache/tiles/jsp/taglib/PutListAttributeTag.java
URL: http://svn.apache.org/viewvc/tiles/framework/trunk/tiles-jsp/src/main/java/org/apache/tiles/jsp/taglib/PutListAttributeTag.java?view=diff&rev=519978&r1=519977&r2=519978
==============================================================================
--- tiles/framework/trunk/tiles-jsp/src/main/java/org/apache/tiles/jsp/taglib/PutListAttributeTag.java (original)
+++ tiles/framework/trunk/tiles-jsp/src/main/java/org/apache/tiles/jsp/taglib/PutListAttributeTag.java Mon Mar 19 08:52:33 2007
@@ -40,23 +40,31 @@
/**
* Get list defined in tag.
+ *
+ * @return The value of this list attribute.
*/
@SuppressWarnings("unchecked")
public List<ComponentAttribute> getValue() {
return (List<ComponentAttribute>) super.getValue();
}
+ /** {@inheritDoc} */
+ @Override
public void setValue(Object object) {
throw new IllegalStateException("The value of the PutListAttributeTag must be the originally defined list.");
}
+ /** {@inheritDoc} */
+ @Override
public int doStartTag() throws JspException {
super.setValue(new ArrayList<ComponentAttribute>());
return super.doStartTag();
}
+
/**
* PutListAttributeTag may not have any body, except for PutAttribute tags.
*
+ * @return <code>SKIP_BODY</code>.
* @throws JspException if a JSP exception has occurred
*/
public int doAfterBody() throws JspException {
@@ -91,6 +99,11 @@
this.addValue(attribute);
}
+ /**
+ * Adds an attribute value to the list.
+ *
+ * @param attribute The attribute to add.
+ */
private void addValue( ComponentAttribute attribute ) {
this.getValue().add(attribute);
}
Modified: tiles/framework/trunk/tiles-jsp/src/main/java/org/apache/tiles/jsp/taglib/RenderTagSupport.java
URL: http://svn.apache.org/viewvc/tiles/framework/trunk/tiles-jsp/src/main/java/org/apache/tiles/jsp/taglib/RenderTagSupport.java?view=diff&rev=519978&r1=519977&r2=519978
==============================================================================
--- tiles/framework/trunk/tiles-jsp/src/main/java/org/apache/tiles/jsp/taglib/RenderTagSupport.java (original)
+++ tiles/framework/trunk/tiles-jsp/src/main/java/org/apache/tiles/jsp/taglib/RenderTagSupport.java Mon Mar 19 08:52:33 2007
@@ -50,37 +50,91 @@
public abstract class RenderTagSupport extends ContainerTagSupport
implements TryCatchFinally, PutAttributeTagParent {
+ /**
+ * The logging object.
+ */
private static Log LOG = LogFactory.getLog(RenderTagSupport.class);
+ /**
+ * The view preparer to use before the rendering.
+ */
protected String preparer;
+
+ /**
+ * This flag, if <code>true</code>, flushes the content before rendering.
+ */
protected boolean flush;
+
+ /**
+ * This flag, if <code>true</code>, ignores exception thrown by preparers
+ * and those caused by problems with definitions.
+ */
protected boolean ignore;
+ /**
+ * Returns the preparer name.
+ *
+ * @return The preparer name.
+ */
public String getPreparer() {
return preparer;
}
+ /**
+ * Sets the preparer name.
+ *
+ * @param preparer The preparer name.
+ */
public void setPreparer(String preparer) {
this.preparer = preparer;
}
+ /**
+ * Returns the flush flag. If <code>true</code>, current page out stream
+ * is flushed before insertion.
+ *
+ * @return The flush flag.
+ */
public boolean isFlush() {
return flush;
}
+ /**
+ * Sets the flush flag. If <code>true</code>, current page out stream
+ * is flushed before insertion.
+ *
+ * @param flush The flush flag.
+ */
public void setFlush(boolean flush) {
this.flush = flush;
}
+ /**
+ * Returns the ignore flag. If it is set to true, and the attribute
+ * specified by the name does not exist, simply return without writing
+ * anything. The default value is false, which will cause a runtime
+ * exception to be thrown.
+ *
+ * @return The ignore flag.
+ */
public boolean isIgnore() {
return ignore;
}
+ /**
+ * Sets the ignore flag. If this attribute is set to true, and the attribute
+ * specified by the name does not exist, simply return without writing
+ * anything. The default value is false, which will cause a runtime
+ * exception to be thrown.
+ *
+ * @param ignore The ignore flag.
+ */
public void setIgnore(boolean ignore) {
this.ignore = ignore;
}
+ /** {@inheritDoc} */
public void release() {
preparer = null;
flush = false;
@@ -88,15 +142,18 @@
super.release();
}
+ /** {@inheritDoc} */
public int doStartTag() throws JspException {
super.doStartTag();
return isAccessAllowed() ? EVAL_BODY_BUFFERED : SKIP_BODY;
}
+ /** {@inheritDoc} */
public void doCatch(Throwable throwable) throws Throwable {
LOG.error("Error during rendering", throwable);
}
+ /** {@inheritDoc} */
public void doFinally() {
}
Modified: tiles/framework/trunk/tiles-jsp/src/main/java/org/apache/tiles/jsp/taglib/RoleSecurityTagSupport.java
URL: http://svn.apache.org/viewvc/tiles/framework/trunk/tiles-jsp/src/main/java/org/apache/tiles/jsp/taglib/RoleSecurityTagSupport.java?view=diff&rev=519978&r1=519977&r2=519978
==============================================================================
--- tiles/framework/trunk/tiles-jsp/src/main/java/org/apache/tiles/jsp/taglib/RoleSecurityTagSupport.java (original)
+++ tiles/framework/trunk/tiles-jsp/src/main/java/org/apache/tiles/jsp/taglib/RoleSecurityTagSupport.java Mon Mar 19 08:52:33 2007
@@ -43,16 +43,33 @@
*/
private static final Log LOG = LogFactory.getLog(RoleSecurityTagSupport.class);
+ /**
+ * The role to check. If the user is in the specified role, the tag is taken
+ * into account; otherwise, the tag is ignored (skipped).
+ */
private String role;
+ /**
+ * Returns the role to check. If the user is in the specified role, the tag is
+ * taken into account; otherwise, the tag is ignored (skipped).
+ *
+ * @return The role to check.
+ */
public String getRole() {
return role;
}
+ /**
+ * Sets the role to check. If the user is in the specified role, the tag is
+ * taken into account; otherwise, the tag is ignored (skipped).
+ *
+ * @param role The role to check.
+ */
public void setRole(String role) {
this.role = role;
}
+ /** {@inheritDoc} */
public int doEndTag() throws JspException {
try {
if (isAccessAllowed()) {
@@ -73,13 +90,27 @@
+ /** {@inheritDoc} */
public void release() {
super.release();
this.role = null;
}
+ /**
+ * Executes the tag. It is called inside {@link #doEndTag()}.
+ *
+ * @throws TilesException If something goews wrong during the use of Tiles.
+ * @throws JspException If something goes wrong during rendering.
+ * @throws IOException If something goes wrong during writing content.
+ */
protected abstract void execute() throws TilesException, JspException, IOException;
+ /**
+ * Checks if the user is inside the specified role.
+ *
+ * @return <code>true</code> if the user is allowed to have the tag
+ * rendered.
+ */
protected boolean isAccessAllowed() {
HttpServletRequest req = (HttpServletRequest) pageContext.getRequest();
return (role == null || req.isUserInRole(role));