Search in sources :

Example 6 with ConfigurationException

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);
        }
    }
}
Also used : ConfigurationException(cn.taketoday.core.ConfigurationException) StandardManager(org.apache.catalina.session.StandardManager) IOException(java.io.IOException) File(java.io.File)

Example 7 with ConfigurationException

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;
}
Also used : ConfigurableWebServer(cn.taketoday.web.framework.server.ConfigurableWebServer) AbstractWebServer(cn.taketoday.web.framework.server.AbstractWebServer) WebServer(cn.taketoday.web.framework.server.WebServer) ConfigurationException(cn.taketoday.core.ConfigurationException) ConfigurableWebServer(cn.taketoday.web.framework.server.ConfigurableWebServer) AbstractWebServer(cn.taketoday.web.framework.server.AbstractWebServer)

Example 8 with ConfigurationException

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() + "]");
        }
    }
}
Also used : HashMap(java.util.HashMap) ConfigurationException(cn.taketoday.core.ConfigurationException) ResolvableMethodParameter(cn.taketoday.web.handler.method.ResolvableMethodParameter)

Example 9 with ConfigurationException

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;
}
Also used : HandlerInterceptor(cn.taketoday.web.interceptor.HandlerInterceptor) BeanDefinitionStoreException(cn.taketoday.beans.factory.BeanDefinitionStoreException) ConfigurationException(cn.taketoday.core.ConfigurationException) BeanDefinitionRegistrar(cn.taketoday.context.loader.BeanDefinitionRegistrar)

Aggregations

ConfigurationException (cn.taketoday.core.ConfigurationException)9 Resource (cn.taketoday.core.io.Resource)2 IOException (java.io.IOException)2 SuppliedMethodInterceptor (cn.taketoday.aop.support.SuppliedMethodInterceptor)1 BeanDefinitionStoreException (cn.taketoday.beans.factory.BeanDefinitionStoreException)1 BeanFactory (cn.taketoday.beans.factory.BeanFactory)1 AnnotatedBeanDefinition (cn.taketoday.beans.factory.annotation.AnnotatedBeanDefinition)1 AutowireCapableBeanFactory (cn.taketoday.beans.factory.config.AutowireCapableBeanFactory)1 BeanDefinition (cn.taketoday.beans.factory.config.BeanDefinition)1 BeanDefinitionRegistry (cn.taketoday.beans.factory.support.BeanDefinitionRegistry)1 BeanDefinitionRegistrar (cn.taketoday.context.loader.BeanDefinitionRegistrar)1 JspServletConfiguration (cn.taketoday.web.framework.config.JspServletConfiguration)1 WebDocumentConfiguration (cn.taketoday.web.framework.config.WebDocumentConfiguration)1 AbstractWebServer (cn.taketoday.web.framework.server.AbstractWebServer)1 ConfigurableWebServer (cn.taketoday.web.framework.server.ConfigurableWebServer)1 WebServer (cn.taketoday.web.framework.server.WebServer)1 WebServerApplicationLoader (cn.taketoday.web.framework.server.WebServerApplicationLoader)1 ResolvableMethodParameter (cn.taketoday.web.handler.method.ResolvableMethodParameter)1 HandlerInterceptor (cn.taketoday.web.interceptor.HandlerInterceptor)1 WebServletInitializer (cn.taketoday.web.servlet.initializer.WebServletInitializer)1