我在 Hippo CMS 中结合目录设置 Spring 时遇到问题。
我有一个配置了componentclassname:ServiceLinkListComponent的目录,因此我可以将组件拖放到频道管理器页面上的占位符中。
在遵循http://svn.onehippo.org/repos/hippo/hippo-cms7/testsuite/trunk/的示例之后,我添加了 Spring 支持,因此我必须将 componentclassname 更改为componentclassname:SpringBridgeHstComponent
不幸的是,我无法再将任何文档与组件链接,因为无法识别@ParametersInfo,因为它位于 SpringBridgeHstComponent 的 bean 中。
如何使用 spring 管理的目录组件?
组件类
@ParametersInfo(type = ServiceLinkListComponentInfo.class)
@Component
@Scope(value = "prototype")
public class ServiceLinkListComponent extends CommonComponent {
private static Logger log = LoggerFactory.getLogger(ServiceLinkListComponent.class);
@Autowired
public TestService testService;
@Override
public void doBeforeRender(final HstRequest request, final HstResponse response) {
super.doBeforeRender(request, response);
final ServiceLinkListComponentInfo paramInfo = getComponentParametersInfo(request);
final String documentPath = paramInfo.getDocument();
log.debug("Calling EssentialsDocumentComponent for document path: [{}]", documentPath);
//String test = testService.test();
setContentBeanForPath(documentPath, request, response);
request.setAttribute(REQUEST_ATTR_PARAM_INFO, paramInfo);
}
}
服务等级
@Component("testService")
public class TestService {
public String test(){
return "hello";
}
}
applicationContext.xml(在资源/META-INF.hst-assembly.overrides 中)
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd">
<context:component-scan base-package="com.xxx.yyy" />
</beans>
回购