use of cn.taketoday.core.ConfigurationException in project today-framework by TAKETODAY.
the class TomcatServer method configurePersistSession.
protected void configurePersistSession(Manager manager) {
if (manager instanceof StandardManager) {
try {
Class<?> mainApplicationClass = getMainApplicationClass();
File storeDirectory = getStoreDirectory(mainApplicationClass);
((StandardManager) manager).setPathname(new File(storeDirectory, "SESSIONS.ser").getAbsolutePath());
} catch (IOException e) {
throw new ConfigurationException(e);
}
}
}
use of cn.taketoday.core.ConfigurationException in project today-framework by TAKETODAY.
the class WebApplicationUtils method obtainWebServer.
/**
* Obtain a {@link WebServer} form bean-factory
*
* @param beanFactory Target bean-factory
* @return WebServer
*/
public static WebServer obtainWebServer(WebServerApplicationContext beanFactory) {
// disable web mvc xml
TodayStrategies.setProperty(WebApplicationLoader.ENABLE_WEB_MVC_XML, "false");
// Get WebServer instance
WebServer webServer = beanFactory.getBean(WebServer.class);
if (webServer == null) {
throw new ConfigurationException("The bean factory: [" + beanFactory + "] doesn't exist a [cn.taketoday.web.framework.server.WebServer] bean");
}
if (webServer instanceof ConfigurableWebServer) {
if (webServer instanceof AbstractWebServer) {
((AbstractWebServer) webServer).getWebApplicationConfiguration().configureWebServer((AbstractWebServer) webServer);
}
((ConfigurableWebServer) webServer).initialize();
}
return webServer;
}
use of cn.taketoday.core.ConfigurationException in project today-framework by TAKETODAY.
the class HandlerMethodRegistry method mappingPathVariable.
/**
* Mapping path variable.
*/
protected void mappingPathVariable(PathPattern pathPattern, ActionMappingAnnotationHandler handler) {
HashMap<String, ResolvableMethodParameter> parameterMapping = new HashMap<>();
ResolvableMethodParameter[] parameters = handler.getResolvableParameters();
for (ResolvableMethodParameter parameter : parameters) {
parameterMapping.put(parameter.getName(), parameter);
}
for (String variable : pathPattern.getVariableNames()) {
ResolvableMethodParameter parameter = parameterMapping.get(variable);
if (parameter == null) {
throw new ConfigurationException("There isn't a variable named: [" + variable + "] in the parameter list at method: [" + handler.getMethod() + "]");
}
}
}
use of cn.taketoday.core.ConfigurationException in project today-framework by TAKETODAY.
the class HandlerMethodRegistry method getInterceptors.
/**
* Get {@link HandlerInterceptor} objects
*
* @param interceptors
* {@link HandlerInterceptor} class
* @return Array of {@link HandlerInterceptor} objects
*/
public HandlerInterceptor[] getInterceptors(Class<? extends HandlerInterceptor>[] interceptors) {
if (ObjectUtils.isEmpty(interceptors)) {
return HandlerInterceptor.EMPTY_ARRAY;
}
int i = 0;
HandlerInterceptor[] ret = new HandlerInterceptor[interceptors.length];
BeanDefinitionRegistrar registrar = obtainApplicationContext().unwrap(BeanDefinitionRegistrar.class);
for (Class<? extends HandlerInterceptor> interceptor : interceptors) {
if (!registry.containsBeanDefinition(interceptor, true)) {
try {
registrar.registerBean(interceptor);
} catch (BeanDefinitionStoreException e) {
throw new ConfigurationException("Interceptor: [" + interceptor.getName() + "] register error", e);
}
}
HandlerInterceptor instance = this.beanFactory.getBean(interceptor);
Assert.state(instance != null, "Can't get target interceptor bean");
ret[i++] = instance;
}
return ret;
}
Aggregations