com.acsinet_solutions.cetia4.controller.rest
Class RestModuleSupport

java.lang.Object
  extended by com.acsinet_solutions.cetia4.controller.rest.RestModuleSupport
All Implemented Interfaces:
AttributeKeys, ControllerConstants, RestModule
Direct Known Subclasses:
CommentsModule, SinglePageCatalogModule, TopicsModule

public abstract class RestModuleSupport
extends java.lang.Object
implements RestModule, ControllerConstants

Base class for nested REST modules. The default modules' name will be taken from the module class name without the Module suffix.

Concrete subclasses should end their names with the Module suffix, and the REST level name that will be used in path info paths will be obtained eliminating that suffix ( if any ) and passing the first name of the class to lowercase. In that way, no additional configuration is needed. Maybe an annotation will be created later to provide alternatives for module naming, but that won't be done until needed.

Author:
Santiago Arriaga

Field Summary
 
Fields inherited from interface com.acsinet_solutions.cetia4.controller.ControllerConstants
_METHOD_PARAM, _PAGE_PARAM, _ROOT_PARAM, DEFAULT_VIEW, ERROR_URL, ERROR_VIEW, LOAD_CANCEL, LOAD_CURRENT, LOAD_DEFAULT, LOAD_ERROR, LOAD_PREVIOUS
 
Fields inherited from interface com.acsinet_solutions.cetia4.controller.AttributeKeys
_BUNDLE_KEY, _CONFIGURATION_KEY, _DEFAULT_CONTROLLER_KEY, _FORM_ACTION_KEY, _FORM_ATTRIBUTE_KEY, _LOCALE_KEY, _MESSAGE_KEY, _NAVIGATION_FLOW_KEY, _PORTAL_PATH_KEY, _RENDER_PARAMETERS_KEY, _SERVICE_LOCATOR_KEY, _SESSION_KEY, _SYSTEM_EXCEPTION_KEY, _VALIDATION_EXCEPTION_KEY
 
Constructor Summary
RestModuleSupport()
          A root REST module reference.
RestModuleSupport(RestModule parent)
          A rest module with 0-nested index.
RestModuleSupport(RestModule parent, int nestedIndex)
          A rest module with a nonnegative nested index.
 
Method Summary
 Configuration getConfiguration()
          Get a reference to the configuration instance for the current module.
 ServiceLocator getLocator()
          Get the service locator reference, if any was configured.
 org.apache.commons.logging.Log getLogger()
          Get the logger for the current servlet.
 java.lang.String getModuleName()
          Get the REST module name; this will be used in mappings and path-info to identify if a request belongs or not to the current module.
 int getNestedIndex()
          Get the nested index of available path-info params between this module and the previous one.
 java.util.List<RestModule> getNestedModules()
          Get the not-null maybe empty list of nested modules inside this instance.
 RestModule getParentModule()
          Get the parent module; servlets have no parent module and return null; other components always return not null.
 RestModule getRootModule()
          Returns the parent root module.
protected  void nest(java.lang.Class<? extends RestModuleSupport> c)
          Add a nested rest module that will be dynamically enhanced.
protected  void nest(RestModule module)
          Add a nested rest module.
 void setConfiguration(Configuration configuration)
          Set the configuration instance; this will be called by a dynamic factory
 void setParentModule(RestModule parent)
          Set the parent module; this will be called by a dynamic factory
 void setServiceLocator(ServiceLocator serviceLocator)
          Set the service locator; this will be called by a dynamic factory
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RestModuleSupport

public RestModuleSupport()
A root REST module reference.


RestModuleSupport

public RestModuleSupport(RestModule parent)
A rest module with 0-nested index.


RestModuleSupport

public RestModuleSupport(RestModule parent,
                         int nestedIndex)
A rest module with a nonnegative nested index.

Method Detail

setParentModule

public void setParentModule(RestModule parent)
Set the parent module; this will be called by a dynamic factory


setServiceLocator

public void setServiceLocator(ServiceLocator serviceLocator)
Set the service locator; this will be called by a dynamic factory

Parameters:
serviceLocator - A not-null valid reference

setConfiguration

public void setConfiguration(Configuration configuration)
Set the configuration instance; this will be called by a dynamic factory

Parameters:
serviceLocator - A not-null valid reference

getNestedModules

public final java.util.List<RestModule> getNestedModules()
Description copied from interface: RestModule
Get the not-null maybe empty list of nested modules inside this instance.

Specified by:
getNestedModules in interface RestModule

getParentModule

public final RestModule getParentModule()
Description copied from interface: RestModule
Get the parent module; servlets have no parent module and return null; other components always return not null.

Specified by:
getParentModule in interface RestModule

getRootModule

public final RestModule getRootModule()
Returns the parent root module. Eventually, the real root module will pop out.

Specified by:
getRootModule in interface RestModule

getNestedIndex

public final int getNestedIndex()
Description copied from interface: RestModule
Get the nested index of available path-info params between this module and the previous one. This method is irrelevant for servlets, and must be nonnegative for other components.

Specified by:
getNestedIndex in interface RestModule

getModuleName

public final java.lang.String getModuleName()
Description copied from interface: RestModule
Get the REST module name; this will be used in mappings and path-info to identify if a request belongs or not to the current module.

Specified by:
getModuleName in interface RestModule

getLogger

public final org.apache.commons.logging.Log getLogger()
Description copied from interface: RestModule
Get the logger for the current servlet. The advantage of this logger is that is related to the final class that extends this abstract class.

Specified by:
getLogger in interface RestModule

getLocator

public ServiceLocator getLocator()
Description copied from interface: RestModule
Get the service locator reference, if any was configured.

Specified by:
getLocator in interface RestModule

getConfiguration

public Configuration getConfiguration()
Description copied from interface: RestModule
Get a reference to the configuration instance for the current module.

Specified by:
getConfiguration in interface RestModule

nest

protected final void nest(RestModule module)
Add a nested rest module.


nest

protected final void nest(java.lang.Class<? extends RestModuleSupport> c)
Add a nested rest module that will be dynamically enhanced. Dynamic nested modules will be added just when a valid not-null service locator is configured in the class.