2011-09-02 3 views
1

비슷한 질문이 여기에 있습니다. Stripes 1.5 - any way to ask the system for a list of all ActionBeans? 액션 빈 코드에서만 작동하는 것 같습니다. 실제로 요청을 받았을 때입니다.
내가 원하는 것은 contextInitialized() 함수와 같은 모든 actionbeans를 contextListener 코드에 나열하는 것입니다. 오류 발생 :
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의 목록을 유지하지 않고 나중에 추가 된 모든 플러그인 클래스를 초기화하는 것입니다. 제안 사항이 있으십니까? (또는 적어도 그렇게 할 수 있습니까?)
최고 감사합니다,

+2

이것은 무엇인가? _ 내 목적은 나중에 추가 된 모든 플러그인 클래스를 코드의 어딘가에 유지하지 않고 자동으로 초기화하는 것입니다. – yihtserns

+0

안녕하세요, 더 자세히 설명하겠습니다. 우리는 webapp을 핵심 함수와 플러그인 함수의 두 가지 유형의 함수로 분리하려고합니다. 플러그인 기능은 WAR에 번들되지 않습니다. 대신, 추가 JAR에 의해 제공됩니다. 새로운 플러그인 기능을 추가하려면 웹 컨테이너 디렉토리의 webapp/classes/lib에 JAR 파일을 넣은 다음 응용 프로그램을 다시로드하면됩니다. 이 때문에 우리는 모든 액션 빈을 자동으로 스캔하는 방법이 필요하며 액션 빈이 플러그인 유형이라면 적절한 액션을 취해야한다. 감사. – ltvp1987

+0

BTW, 아마도 당신의 해답을 답으로 받아 들여 그 답을 받아 들여야합니다. – yihtserns

답변

1

좋습니다. 잠시 후 해결책을 찾아 냈습니다 : ResolverUtil 사용

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

고마워요!

관련 문제