public class SpringBridgeHstComponent extends GenericHstComponent implements org.springframework.context.ApplicationListener<org.springframework.context.ApplicationEvent>
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:
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 fully qualified bean name
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 or
the child HST component module name, and 'contactBean' is the bean name of the child bean factory
or the child HST component module.
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'.
Also, if the delegatee bean should be found in a web application context initialized by a
Spring MVC Servlet derived from org.springframework.web.servlet.FrameworkServlet
such as org.hippoecm.hst.component.support.spring.mvc.HstDispatcherServlet
or
org.springframework.web.servlet.DispatcherServlet
, instead of the root web
application context, then the fully qualified bean name must be prefixed by the servlet
context attribute name prefix (see FrameworkServlet.SERVLET_CONTEXT_PREFIX
).
For example, if you want to retrieve a bean named 'contactBean' from the application context
initialized by a org.hippoecm.hst.component.support.spring.mvc.HstDispatcherServlet
separately from the root web application context and the servlet's name is 'springapp',
then you can specify the paramaeter like the following:
org.springframework.web.servlet.FrameworkServlet.CONTEXT.springapp::contactBean
Modifier and Type | Field and Description |
---|---|
protected String |
contextNameSeparator |
protected HstComponent |
delegatedBean |
protected org.springframework.context.support.AbstractApplicationContext |
delegatedBeanApplicationContext |
protected String |
delegatedBeanNameParamName |
RESOURCE_PATH_BY_RESOURCE_ID
Constructor and Description |
---|
SpringBridgeHstComponent() |
Modifier and Type | Method and Description |
---|---|
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 org.springframework.beans.factory.BeanFactory |
getContextBeanFactory(javax.servlet.ServletContext servletContext,
String[] contextNames) |
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) |
getComponentConfiguration
protected String delegatedBeanNameParamName
protected String contextNameSeparator
protected org.springframework.context.support.AbstractApplicationContext delegatedBeanApplicationContext
protected HstComponent delegatedBean
public void init(javax.servlet.ServletContext servletContext, ComponentConfiguration componentConfig) throws HstComponentException
HstComponent
init
in interface HstComponent
init
in class GenericHstComponent
servletContext
- the servletConfig of the HST container servletcomponentConfig
- the componentConfigBean configurationHstComponentException
public void destroy() throws HstComponentException
HstComponent
destroy
in interface HstComponent
destroy
in class GenericHstComponent
HstComponentException
public void doAction(HstRequest request, HstResponse response) throws HstComponentException
HstComponent
doAction
in interface HstComponent
doAction
in class GenericHstComponent
HstComponentException
public void doBeforeRender(HstRequest request, HstResponse response) throws HstComponentException
HstComponent
doBeforeRender
in interface HstComponent
doBeforeRender
in class GenericHstComponent
HstComponentException
public void doBeforeServeResource(HstRequest request, HstResponse response) throws HstComponentException
HstComponent
doBeforeServeResource
in interface HstComponent
doBeforeServeResource
in class GenericHstComponent
HstComponentException
protected String getParameter(String name, HstRequest request)
protected HstComponent getDelegatedBean(HstRequest request) throws HstComponentException
HstComponentException
public void onApplicationEvent(org.springframework.context.ApplicationEvent event)
onApplicationEvent
in interface org.springframework.context.ApplicationListener<org.springframework.context.ApplicationEvent>
protected org.springframework.beans.factory.BeanFactory getContextBeanFactory(javax.servlet.ServletContext servletContext, String[] contextNames)
Copyright © 2008–2016 Hippo B.V. (http://www.onehippo.com). All rights reserved.