org.hippoecm.hst.component.support.spring
Class SpringBridgeHstComponent

java.lang.Object
  extended by org.hippoecm.hst.core.component.GenericHstComponent
      extended by org.hippoecm.hst.component.support.spring.SpringBridgeHstComponent
All Implemented Interfaces:
EventListener, HstComponent, org.springframework.context.ApplicationListener

public class SpringBridgeHstComponent
extends GenericHstComponent
implements org.springframework.context.ApplicationListener

A bridge component which delegates all invocation to a bean managed by the spring IoC.

By default, the delegated bean's name should be configured in the component configuration parameter value with the parameter name, 'spring-delegated-bean-param-name'. This bridge component will retrieve the bean from the spring web application context by the bean name. If you want to change the default parameter name, then you can achieve that by configuring the parameter name with an added "hst-" prefix in the web.xml. For example, if you want to change the default parameter name to 'my-bean-param', then you can configure this like the following:

<webapp ...> <!-- ... --> <init-param> <param-name>hst-spring-delegated-bean-param-name</param-name> <param-value>my-bean-param</param-value> </init-param> <!-- ... --> </webapp> With the above setting, you need to set the parameters with name, 'my-bean-param' in the component configurations in the repository.

If the root web application context has hierarchical child bean factories and one of the child bean factories has defined a bean you need, then you can set the bean name component configuration parameter with context path prefix like the following example:
com.mycompany.myapp::contactBean
In the above example, 'com.mycompany.myapp' is the name of the child bean factory name, and 'contactBean' is the bean name of the child bean factory. The bean factory paths can be multiple to represent the hierarchy like 'com.mycompany.myapp::crm::contactBean'.
The separator for hierarchical bean factory path can be changed by setting the webapp init parameter, 'hst-spring-context-name-separator-param-name'.

Version:
$Id: SpringBridgeHstComponent.java 28941 2011-07-13 15:12:07Z aschrijvers $

Field Summary
protected  String contextNameSeparator
           
protected  HstComponent delegatedBean
           
protected  org.springframework.context.support.AbstractApplicationContext delegatedBeanApplicationContext
           
protected  String delegatedBeanNameParamName
           
 
Fields inherited from class org.hippoecm.hst.core.component.GenericHstComponent
RESOURCE_PATH_BY_RESOURCE_ID
 
Constructor Summary
SpringBridgeHstComponent()
           
 
Method Summary
 void destroy()
          Allows the component to destroy itself
 void doAction(HstRequest request, HstResponse response)
          Allows the component to process actions
 void doBeforeRender(HstRequest request, HstResponse response)
          Allows the component to do some business logic processing before rendering
 void doBeforeServeResource(HstRequest request, HstResponse response)
          Allows the component to do some business logic processing before serving resource
protected  HstComponent getDelegatedBean(HstRequest request)
           
protected  String getParameter(String name, HstRequest request)
           
 void init(javax.servlet.ServletContext servletContext, ComponentConfiguration componentConfig)
          Allows the component to initialize itself
 void onApplicationEvent(org.springframework.context.ApplicationEvent event)
           
 
Methods inherited from class org.hippoecm.hst.core.component.GenericHstComponent
getComponentConfiguration
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

delegatedBeanNameParamName

protected String delegatedBeanNameParamName

contextNameSeparator

protected String contextNameSeparator

delegatedBeanApplicationContext

protected org.springframework.context.support.AbstractApplicationContext delegatedBeanApplicationContext

delegatedBean

protected HstComponent delegatedBean
Constructor Detail

SpringBridgeHstComponent

public SpringBridgeHstComponent()
Method Detail

init

public void init(javax.servlet.ServletContext servletContext,
                 ComponentConfiguration componentConfig)
          throws HstComponentException
Description copied from interface: HstComponent
Allows the component to initialize itself

Specified by:
init in interface HstComponent
Overrides:
init in class GenericHstComponent
Parameters:
servletContext - the servletConfig of the HST container servlet
componentConfig - the componentConfigBean configuration
Throws:
HstComponentException

destroy

public void destroy()
             throws HstComponentException
Description copied from interface: HstComponent
Allows the component to destroy itself

Specified by:
destroy in interface HstComponent
Overrides:
destroy in class GenericHstComponent
Throws:
HstComponentException

doAction

public void doAction(HstRequest request,
                     HstResponse response)
              throws HstComponentException
Description copied from interface: HstComponent
Allows the component to process actions

Specified by:
doAction in interface HstComponent
Overrides:
doAction in class GenericHstComponent
Throws:
HstComponentException

doBeforeRender

public void doBeforeRender(HstRequest request,
                           HstResponse response)
                    throws HstComponentException
Description copied from interface: HstComponent
Allows the component to do some business logic processing before rendering

Specified by:
doBeforeRender in interface HstComponent
Overrides:
doBeforeRender in class GenericHstComponent
Throws:
HstComponentException

doBeforeServeResource

public void doBeforeServeResource(HstRequest request,
                                  HstResponse response)
                           throws HstComponentException
Description copied from interface: HstComponent
Allows the component to do some business logic processing before serving resource

Specified by:
doBeforeServeResource in interface HstComponent
Overrides:
doBeforeServeResource in class GenericHstComponent
Throws:
HstComponentException

getParameter

protected String getParameter(String name,
                              HstRequest request)

getDelegatedBean

protected HstComponent getDelegatedBean(HstRequest request)
                                 throws HstComponentException
Throws:
HstComponentException

onApplicationEvent

public void onApplicationEvent(org.springframework.context.ApplicationEvent event)
Specified by:
onApplicationEvent in interface org.springframework.context.ApplicationListener


Copyright © 2008-2012 Hippo. All Rights Reserved.