Search in sources :

Example 6 with ConfigurationSource

use of com.manydesigns.portofino.config.ConfigurationSource in project Portofino by ManyDesigns.

the class PortofinoContextLoaderListener method setupGrandParentContext.

@NotNull
public static ApplicationContext setupGrandParentContext(PortofinoDispatcherInitializer initializer) {
    GenericApplicationContext grandParent = new GenericApplicationContext();
    grandParent.refresh();
    grandParent.getBeanFactory().registerSingleton("codeBase", initializer.getCodeBase());
    grandParent.getBeanFactory().registerSingleton(PortofinoSpringConfiguration.APPLICATION_DIRECTORY, initializer.getApplicationRoot());
    grandParent.getBeanFactory().registerSingleton(PortofinoSpringConfiguration.PORTOFINO_CONFIGURATION, initializer.getConfiguration());
    if (initializer.getConfigurationFile() != null) {
        grandParent.getBeanFactory().registerSingleton(PortofinoSpringConfiguration.PORTOFINO_CONFIGURATION_FILE, initializer.getConfigurationFile());
    }
    ConfigurationSource configSource = new ConfigurationSource(initializer.getConfiguration(), initializer.getConfigurationFile());
    grandParent.getBeanFactory().registerSingleton(PortofinoSpringConfiguration.CONFIGURATION_SOURCE, configSource);
    initializer.getConfiguration().addConfiguration(new SpringEnvironmentConfiguration(grandParent.getEnvironment()));
    return grandParent;
}
Also used : GenericApplicationContext(org.springframework.context.support.GenericApplicationContext) ConfigurationSource(com.manydesigns.portofino.config.ConfigurationSource) NotNull(org.jetbrains.annotations.NotNull)

Example 7 with ConfigurationSource

use of com.manydesigns.portofino.config.ConfigurationSource in project Portofino by ManyDesigns.

the class PortofinoContextLoaderListener method setupParentContext.

protected void setupParentContext() {
    AnnotationConfigWebApplicationContext parentContext = new AnnotationConfigWebApplicationContext();
    parentContext.setParent(setupGrandParentContext(initializer));
    parentContext.setId(PARENT_CONTEXT);
    parentContext.setServletContext(servletContext);
    ConfigurableEnvironment environment = parentContext.getEnvironment();
    MutablePropertySources sources = environment.getPropertySources();
    ConfigurationSource configuration = (ConfigurationSource) servletContext.getAttribute(PortofinoSpringConfiguration.CONFIGURATION_SOURCE);
    sources.addFirst(new ConfigurationPropertySource("portofino.properties", configuration.getProperties()));
    for (Class<?> moduleClass : moduleClasses) {
        parentContext.register(moduleClass);
    }
    parentContext.register(PortofinoWebSpringConfiguration.class);
    parentContext.register(PortofinoSpringConfiguration.class);
    logger.info("Refreshing parent application context");
    parentContext.refresh();
    this.parentContext = parentContext;
}
Also used : ConfigurableEnvironment(org.springframework.core.env.ConfigurableEnvironment) ConfigurationSource(com.manydesigns.portofino.config.ConfigurationSource) MutablePropertySources(org.springframework.core.env.MutablePropertySources) AnnotationConfigWebApplicationContext(org.springframework.web.context.support.AnnotationConfigWebApplicationContext)

Example 8 with ConfigurationSource

use of com.manydesigns.portofino.config.ConfigurationSource in project Portofino by ManyDesigns.

the class SecurityFacade method isAdministrator.

public boolean isAdministrator(ServletRequest request) {
    ServletContext servletContext = ElementsThreadLocals.getServletContext();
    ConfigurationSource conf = (ConfigurationSource) servletContext.getAttribute(PortofinoSpringConfiguration.CONFIGURATION_SOURCE);
    return isAdministrator(conf.getProperties());
}
Also used : ConfigurationSource(com.manydesigns.portofino.config.ConfigurationSource) ServletContext(javax.servlet.ServletContext)

Aggregations

ConfigurationSource (com.manydesigns.portofino.config.ConfigurationSource)8 ServletContext (javax.servlet.ServletContext)3 H2DatabasePlatform (com.manydesigns.portofino.database.platforms.H2DatabasePlatform)2 DatabasePlatformsRegistry (com.manydesigns.portofino.model.database.platforms.DatabasePlatformsRegistry)2 Configuration (org.apache.commons.configuration2.Configuration)2 PropertiesConfiguration (org.apache.commons.configuration2.PropertiesConfiguration)2 Permissions (com.manydesigns.portofino.actions.Permissions)1 CacheResetListenerRegistry (com.manydesigns.portofino.cache.CacheResetListenerRegistry)1 DatabaseModule (com.manydesigns.portofino.modules.DatabaseModule)1 Persistence (com.manydesigns.portofino.persistence.Persistence)1 CrudConfiguration (com.manydesigns.portofino.resourceactions.crud.configuration.database.CrudConfiguration)1 HttpServletRequest (javax.servlet.http.HttpServletRequest)1 HttpServletResponse (javax.servlet.http.HttpServletResponse)1 AuthenticationException (org.apache.shiro.authc.AuthenticationException)1 UsernamePasswordToken (org.apache.shiro.authc.UsernamePasswordToken)1 Subject (org.apache.shiro.subject.Subject)1 NotNull (org.jetbrains.annotations.NotNull)1 GenericApplicationContext (org.springframework.context.support.GenericApplicationContext)1 ConfigurableEnvironment (org.springframework.core.env.ConfigurableEnvironment)1 MutablePropertySources (org.springframework.core.env.MutablePropertySources)1