Subversion Repositories SmartDukaan

Rev

Rev 21342 | Rev 21348 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 21342 Rev 21343
Line 1... Line 1...
1
package com.spice.profitmandi.web.config;
1
package com.spice.profitmandi.web.config;
2
 
2
 
-
 
3
import java.io.FileInputStream;
-
 
4
import java.io.IOException;
3
import org.slf4j.Logger;
5
import java.util.Properties;
4
 
6
 
-
 
7
import org.slf4j.Logger;
5
import org.slf4j.LoggerFactory;
8
import org.slf4j.LoggerFactory;
6
import org.springframework.context.annotation.Bean;
9
import org.springframework.context.annotation.Bean;
7
import org.springframework.context.annotation.ComponentScan;
10
import org.springframework.context.annotation.ComponentScan;
8
import org.springframework.context.annotation.Configuration;
11
import org.springframework.context.annotation.Configuration;
9
import org.springframework.context.support.PropertySourcesPlaceholderConfigurer;
12
import org.springframework.context.support.PropertySourcesPlaceholderConfigurer;
Line 19... Line 22...
19
 
22
 
20
	private static final String PATH_PREFIX="/WEB-INF/views/";
23
	private static final String PATH_PREFIX="/WEB-INF/views/";
21
	private static final String PATH_SUFFIX=".jsp";
24
	private static final String PATH_SUFFIX=".jsp";
22
	private static final String MESSAGE_PATH_SOURCE_NAME="classpath:message";
25
	private static final String MESSAGE_PATH_SOURCE_NAME="classpath:message";
23
	private static final Logger LOGGER=LoggerFactory.getLogger(AppConfig.class);
26
	private static final Logger LOGGER=LoggerFactory.getLogger(AppConfig.class);
24
 
27
	
25
	@Bean(name = "viewResolver")
28
	@Bean(name = "viewResolver")
26
	public InternalResourceViewResolver getViewResolver() {
29
	public InternalResourceViewResolver getViewResolver() {
27
		LOGGER.debug("creating view resolver bean with prefix : "+PATH_PREFIX+" and suffix : "+PATH_SUFFIX);
30
		LOGGER.debug("creating view resolver bean with prefix : "+PATH_PREFIX+" and suffix : "+PATH_SUFFIX);
28
		InternalResourceViewResolver viewResolver = new InternalResourceViewResolver();
31
		InternalResourceViewResolver viewResolver = new InternalResourceViewResolver();
29
		viewResolver.setPrefix(PATH_PREFIX);
32
		viewResolver.setPrefix(PATH_PREFIX);
Line 44... Line 47...
44
		LOGGER.info("creating common multipart resolver bean");
47
		LOGGER.info("creating common multipart resolver bean");
45
		return new CommonsMultipartResolver();
48
		return new CommonsMultipartResolver();
46
	}
49
	}
47
 
50
 
48
	@Bean
51
	@Bean
49
	public static PropertySourcesPlaceholderConfigurer propertyConfigurer() {
52
	public PropertySourcesPlaceholderConfigurer propertyConfigurer() {
50
		Resource resource;
53
		Resource resource;
51
		String activeProfile;
54
		String activeProfile;
52
 
55
 
53
		PropertySourcesPlaceholderConfigurer propertySourcesPlaceholderConfigurer =  new PropertySourcesPlaceholderConfigurer();
56
		PropertySourcesPlaceholderConfigurer propertySourcesPlaceholderConfigurer =  new PropertySourcesPlaceholderConfigurer();
54
 
57
		
-
 
58
		Properties properties = new Properties();
-
 
59
		try {
-
 
60
			properties.load(this.getClass().getClassLoader().getResourceAsStream("META-INF/env.property"));
-
 
61
		} catch (IOException e) {
-
 
62
			LOGGER.error("Error in reading env property file.Addin dev property"+e);
-
 
63
			properties.put("profile", "dev");
-
 
64
		}
-
 
65
		LOGGER.info("Properties "+properties.toString());
55
		activeProfile = System.getProperty("spring.profiles.active");
66
		activeProfile = (String) properties.get("profile");
-
 
67
		
56
 
68
 
57
		if ("prod".equals(activeProfile)) {
69
		if ("prod".equals(activeProfile)) {
58
			resource = new ClassPathResource("/META-INF/prod.properties");
70
			resource = new ClassPathResource("/META-INF/prod.properties");
59
		} else if ("staging".equals(activeProfile)) {
71
		} else if ("staging".equals(activeProfile)) {
60
			resource = new ClassPathResource("/META-INF/staging.properties");
72
			resource = new ClassPathResource("/META-INF/staging.properties");