无法加载 Alfresco bean

Unable to load Alfresco bean

我希望使用 Alfresco 的 org.alfresco.repo.search.impl.solr.SolrAdminHTTPClient class 对 solr 进行一些调用。但是,我似乎无法从标准应用程序上下文中访问那个 bean search.solrAdminHTTPCLient。尝试为我自己的 bean 添加依赖项和 属性 引用(通过 xml)也失败了。这是无法访问的任何原因?

public class MyClass extends DeclarativeWebScript implements ApplicationContextAware{
...
SolrAdminHTTPClient adminClient = (SolrAdminHTTPClient) appContext.getBean("search.solrAdminHTTPCLient");

希望避免为标准 solr 管理查询创建自己的客户端。

根据通向 this file 的文件夹树判断,我会说 bean 在搜索 SubSystem 中可用,这意味着它完全存在于不同的上下文中,a实际上是子上下文。 因此,在尝试检索您的 bean 之前,您需要先查找该上下文!


更新: 我做了一些挖掘,我猜你的 window 到那个子上下文在 this particular bean 中。 所以我认为您可以执行以下操作:

SwitchableApplicationContextFactory search = (SwitchableApplicationContextFactory)applicationContext.getBean("Search");
ApplicationContext searchCtx = search.getApplicationContext();
SolrAdminHTTPClient adminClient = (SolrAdminHTTPClient) searchCtx.getBean("search.solrAdminHTTPCLient");

来自 IRC 频道的一位朋友提出了一个替代解决方案: 为您要在子上下文中访问的每个 bean 设置一个单独的 ChildApplicationContextFactory,他建议您从 this.

中获得一些灵感