| Line 4... |
Line 4... |
| 4 |
|
4 |
|
| 5 |
import org.slf4j.LoggerFactory;
|
5 |
import org.slf4j.LoggerFactory;
|
| 6 |
import org.springframework.context.annotation.Bean;
|
6 |
import org.springframework.context.annotation.Bean;
|
| 7 |
import org.springframework.context.annotation.ComponentScan;
|
7 |
import org.springframework.context.annotation.ComponentScan;
|
| 8 |
import org.springframework.context.annotation.Configuration;
|
8 |
import org.springframework.context.annotation.Configuration;
|
| - |
|
9 |
import org.springframework.context.support.PropertySourcesPlaceholderConfigurer;
|
| 9 |
import org.springframework.context.support.ReloadableResourceBundleMessageSource;
|
10 |
import org.springframework.context.support.ReloadableResourceBundleMessageSource;
|
| - |
|
11 |
import org.springframework.core.io.ClassPathResource;
|
| - |
|
12 |
import org.springframework.core.io.Resource;
|
| 10 |
import org.springframework.web.multipart.commons.CommonsMultipartResolver;
|
13 |
import org.springframework.web.multipart.commons.CommonsMultipartResolver;
|
| 11 |
import org.springframework.web.servlet.view.InternalResourceViewResolver;
|
14 |
import org.springframework.web.servlet.view.InternalResourceViewResolver;
|
| 12 |
|
15 |
|
| 13 |
@Configuration
|
16 |
@Configuration
|
| 14 |
@ComponentScan("com.spice.profitmandi.*")
|
17 |
@ComponentScan("com.spice.profitmandi.*")
|
| 15 |
public class AppConfig {
|
18 |
public class AppConfig {
|
| 16 |
|
19 |
|
| 17 |
private static final String PATH_PREFIX="/WEB-INF/views/";
|
20 |
private static final String PATH_PREFIX="/WEB-INF/views/";
|
| 18 |
private static final String PATH_SUFFIX=".jsp";
|
21 |
private static final String PATH_SUFFIX=".jsp";
|
| 19 |
private static final String MESSAGE_PATH_SOURCE_NAME="classpath:message";
|
22 |
private static final String MESSAGE_PATH_SOURCE_NAME="classpath:message";
|
| 20 |
private static final Logger LOGGER=LoggerFactory.getLogger(AppConfig.class);
|
23 |
private static final Logger LOGGER=LoggerFactory.getLogger(AppConfig.class);
|
| 21 |
|
24 |
|
| 22 |
@Bean(name = "viewResolver")
|
25 |
@Bean(name = "viewResolver")
|
| 23 |
public InternalResourceViewResolver getViewResolver() {
|
26 |
public InternalResourceViewResolver getViewResolver() {
|
| 24 |
LOGGER.debug("creating view resolver bean with prefix : "+PATH_PREFIX+" and suffix : "+PATH_SUFFIX);
|
27 |
LOGGER.debug("creating view resolver bean with prefix : "+PATH_PREFIX+" and suffix : "+PATH_SUFFIX);
|
| 25 |
InternalResourceViewResolver viewResolver = new InternalResourceViewResolver();
|
28 |
InternalResourceViewResolver viewResolver = new InternalResourceViewResolver();
|
| 26 |
viewResolver.setPrefix(PATH_PREFIX);
|
29 |
viewResolver.setPrefix(PATH_PREFIX);
|
| 27 |
viewResolver.setSuffix(PATH_SUFFIX);
|
30 |
viewResolver.setSuffix(PATH_SUFFIX);
|
| 28 |
return viewResolver;
|
31 |
return viewResolver;
|
| 29 |
}
|
32 |
}
|
| 30 |
|
33 |
|
| 31 |
@Bean(name="messageSource")
|
34 |
@Bean(name="messageSource")
|
| 32 |
public ReloadableResourceBundleMessageSource getReloadableResourceBundleMessageSource() {
|
35 |
public ReloadableResourceBundleMessageSource getReloadableResourceBundleMessageSource() {
|
| 33 |
LOGGER.debug("creating messageSource bean with message path source name : "+MESSAGE_PATH_SOURCE_NAME);
|
36 |
LOGGER.debug("creating messageSource bean with message path source name : "+MESSAGE_PATH_SOURCE_NAME);
|
| 34 |
ReloadableResourceBundleMessageSource messageSource=new ReloadableResourceBundleMessageSource();
|
37 |
ReloadableResourceBundleMessageSource messageSource=new ReloadableResourceBundleMessageSource();
|
| 35 |
messageSource.setBasename(MESSAGE_PATH_SOURCE_NAME);
|
38 |
messageSource.setBasename(MESSAGE_PATH_SOURCE_NAME);
|
| 36 |
return messageSource;
|
39 |
return messageSource;
|
| 37 |
}
|
40 |
}
|
| 38 |
|
41 |
|
| 39 |
@Bean(name="multipartResolver")
|
42 |
@Bean(name="multipartResolver")
|
| 40 |
public CommonsMultipartResolver getCommonsMultipartResolver() {
|
43 |
public CommonsMultipartResolver getCommonsMultipartResolver() {
|
| 41 |
LOGGER.info("creating common multipart resolver bean");
|
44 |
LOGGER.info("creating common multipart resolver bean");
|
| 42 |
return new CommonsMultipartResolver();
|
45 |
return new CommonsMultipartResolver();
|
| - |
|
46 |
}
|
| - |
|
47 |
|
| - |
|
48 |
@Bean
|
| - |
|
49 |
public static PropertySourcesPlaceholderConfigurer propertyConfigurer() {
|
| - |
|
50 |
Resource resource;
|
| - |
|
51 |
String activeProfile;
|
| - |
|
52 |
|
| - |
|
53 |
PropertySourcesPlaceholderConfigurer propertySourcesPlaceholderConfigurer = new PropertySourcesPlaceholderConfigurer();
|
| - |
|
54 |
|
| - |
|
55 |
activeProfile = System.getProperty("spring.profiles.active");
|
| - |
|
56 |
|
| - |
|
57 |
if ("prod".equals(activeProfile)) {
|
| - |
|
58 |
resource = new ClassPathResource("/META-INF/prod.properties");
|
| - |
|
59 |
} else if ("staging".equals(activeProfile)) {
|
| - |
|
60 |
resource = new ClassPathResource("/META-INF/test.properties");
|
| - |
|
61 |
} else {
|
| - |
|
62 |
resource = new ClassPathResource("/META-INF/dev.properties");
|
| 43 |
}
|
63 |
}
|
| - |
|
64 |
|
| - |
|
65 |
propertySourcesPlaceholderConfigurer.setLocation(resource);
|
| - |
|
66 |
|
| - |
|
67 |
return propertySourcesPlaceholderConfigurer;
|
| - |
|
68 |
}
|
| 44 |
}
|
69 |
}
|
| 45 |
|
70 |
|