如何在contextInitialized()获取所有actionbean类

时间:2011-09-02 02:25:37

标签: java stripes

这里回答了类似的问题:Stripes 1.5 - any way to ask the system for a list of all ActionBeans?它似乎只适用于actionbean代码,即:当它实际收到请求时。
我想要的是在contextListener代码中列出所有actionbeans,例如contextInitialized()函数。发生错误:

net.sourceforge.stripes.exception.StripesRuntimeException: Something is trying to access the current Stripes configuration but the current request was never routed through the StripesFilter! As a result the appropriate Configuration object cannot be located. Please take a look at the exact URL in your browser's address bar and ensure that any requests to that URL will be filtered through the StripesFilter according to the filter mappings in your web.xml.
    at net.sourceforge.stripes.controller.StripesFilter.getConfiguration(StripesFilter.java:160)
    at net.sourceforge.stripes.util.CryptoUtil.encrypt(CryptoUtil.java:123) 

我的目的是自动初始化以后添加的所有插件类,而不维护代码中某处的所有actionbeans列表。 有什么建议吗? (或者,至少可以这样做吗?)
最诚挚的问候,

1 个答案:

答案 0 :(得分:1)

行。过了一会儿,我想出了解决方案:使用Stripes ResolverUtil

ResolverUtil<ActionBean> resolver = new ResolverUtil<ActionBean>();
resolver.findImplementations(ActionBean.class, "my.base.package");
Set<Class<? extends ActionBean>> beans = resolver.getClasses();

谢谢!