Missing bean params should throw servlet exceptions

git-svn-id: https://svn.apache.org/repos/asf/archiva/branches/archiva-with-new-repoapi@744783 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
James William Dumay 2009-02-16 00:00:04 +00:00
parent da6a8034d8
commit 7dc57607e2
1 changed files with 21 additions and 3 deletions

View File

@ -64,11 +64,29 @@ public class RepositoryServlet extends HttpServlet
@Override
public void init(ServletConfig config) throws ServletException
{
final String repositoryManagerFactoryName = config.getInitParameter(REPOSITORY_MANAGER_FACTORY);
if (repositoryManagerFactoryName == null)
{
throw new ServletException(REPOSITORY_MANAGER_FACTORY + " cannot be null");
}
final String preRepositoryInterceptorFactoryName = config.getInitParameter(PREREPOSITORY_INTERCEPTOR_FACTORY);
if (preRepositoryInterceptorFactoryName == null)
{
throw new ServletException(PREREPOSITORY_INTERCEPTOR_FACTORY + " cannot be null");
}
final String postRepositoryInterceptorFactoryName = config.getInitParameter(POSTREPOSITORY_INTERCEPTOR_FACTORY);
if (postRepositoryInterceptorFactoryName == null)
{
throw new ServletException(POSTREPOSITORY_INTERCEPTOR_FACTORY + " cannot be null");
}
super.init(config);
final ApplicationContext applicationContext = WebApplicationContextUtils.getRequiredWebApplicationContext(config.getServletContext());
repositoryManagerFactory = (RepositoryManagerFactory)applicationContext.getBean(config.getInitParameter(REPOSITORY_MANAGER_FACTORY));
preRepositoryInterceptorFactory = (RepositoryInterceptorFactory<PreRepositoryInterceptor>)applicationContext.getBean(config.getInitParameter(PREREPOSITORY_INTERCEPTOR_FACTORY));
postRepositoryInterceptorFactory = (RepositoryInterceptorFactory<PostRepositoryInterceptor>)applicationContext.getBean(config.getInitParameter(POSTREPOSITORY_INTERCEPTOR_FACTORY));
repositoryManagerFactory = (RepositoryManagerFactory)applicationContext.getBean(repositoryManagerFactoryName);
preRepositoryInterceptorFactory = (RepositoryInterceptorFactory<PreRepositoryInterceptor>)applicationContext.getBean(preRepositoryInterceptorFactoryName);
postRepositoryInterceptorFactory = (RepositoryInterceptorFactory<PostRepositoryInterceptor>)applicationContext.getBean(postRepositoryInterceptorFactoryName);
}
@Override