Subversion Repositories SmartDukaan

Rev

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

Rev 24637 Rev 24639
Line 26... Line 26...
26
@SuppressWarnings("deprecation")
26
@SuppressWarnings("deprecation")
27
@Configuration
27
@Configuration
28
@ComponentScan("com.spice.profitmandi.*")
28
@ComponentScan("com.spice.profitmandi.*")
29
public class AppConfig {
29
public class AppConfig {
30
 
30
 
31
	private static final String VELOCITY_PATH_PREFIX="/WEB-INF/views/ftl/";
31
	private static final String VELOCITY_PATH_PREFIX = "/WEB-INF/views/ftl/";
32
	private static final String VELOCITY_PATH_SUFFIX=".vm";
32
	private static final String VELOCITY_PATH_SUFFIX = ".vm";
33
	private static final String MESSAGE_PATH_SOURCE_NAME="classpath:message";
33
	private static final String MESSAGE_PATH_SOURCE_NAME = "classpath:message";
34
	private static final Logger LOGGER=LogManager.getLogger(AppConfig.class);
34
	private static final Logger LOGGER = LogManager.getLogger(AppConfig.class);
35
	private static Resource resource;
35
	private static Resource resource;
36
	
36
 
37
	public static Resource getResource() {
37
	public static Resource getResource() {
38
		return resource;
38
		return resource;
39
	}
39
	}
40
 
40
 
41
	public void setResource(Resource resource) {
41
	public void setResource(Resource resource) {
42
		AppConfig.resource = resource;
42
		AppConfig.resource = resource;
43
	}
43
	}
44
 
44
 
45
	@Bean
45
	@Bean
46
	public ViewResolver viewResolver()
46
	public ViewResolver viewResolver() {
47
	{
-
 
48
		VelocityLayoutViewResolver bean = new VelocityLayoutViewResolver();
47
		VelocityLayoutViewResolver bean = new VelocityLayoutViewResolver();
49
		bean.setPrefix("");
48
		bean.setPrefix("");
50
		bean.setSuffix(VELOCITY_PATH_SUFFIX);
49
		bean.setSuffix(VELOCITY_PATH_SUFFIX);
51
		bean.setRequestContextAttribute("rc");
50
		bean.setRequestContextAttribute("rc");
52
		Map<String, Object> attributesMap = new HashMap<>();
51
		Map<String, Object> attributesMap = new HashMap<>();
Line 57... Line 56...
57
		attributesMap.put("version", "40");
56
		attributesMap.put("version", "40");
58
		attributesMap.put("cssVersion", "1");
57
		attributesMap.put("cssVersion", "1");
59
		bean.setAttributesMap(attributesMap);
58
		bean.setAttributesMap(attributesMap);
60
		return bean;
59
		return bean;
61
	}
60
	}
62
	
-
 
63
	  @Bean
-
 
64
	  public ViewResolver beanNameViewResolver() {
-
 
65
	      BeanNameViewResolver resolver = new BeanNameViewResolver();
-
 
66
	      return resolver;
-
 
67
	  }
-
 
68
 
-
 
69
	
-
 
70
 
61
 
-
 
62
	@Bean
-
 
63
	public ViewResolver beanNameViewResolver() {
-
 
64
		BeanNameViewResolver resolver = new BeanNameViewResolver();
-
 
65
		return resolver;
-
 
66
	}
71
 
67
 
72
	@Bean
68
	@Bean
73
	public VelocityConfigurer velocityConfig() {
69
	public VelocityConfigurer velocityConfig() {
74
		VelocityConfigurer velocityConfigurer = new VelocityConfigurer();
70
		VelocityConfigurer velocityConfigurer = new VelocityConfigurer();
75
		velocityConfigurer.setResourceLoaderPath(VELOCITY_PATH_PREFIX);
71
		velocityConfigurer.setResourceLoaderPath(VELOCITY_PATH_PREFIX);
76
		return velocityConfigurer;
72
		return velocityConfigurer;
77
	}
73
	}
78
 
74
 
79
	@Bean(name="messageSource")
75
	@Bean(name = "messageSource")
80
	public ReloadableResourceBundleMessageSource getReloadableResourceBundleMessageSource() {
76
	public ReloadableResourceBundleMessageSource getReloadableResourceBundleMessageSource() {
81
		LOGGER.debug("creating messageSource bean with message path source name : "+MESSAGE_PATH_SOURCE_NAME);
77
		LOGGER.debug("creating messageSource bean with message path source name : " + MESSAGE_PATH_SOURCE_NAME);
82
		ReloadableResourceBundleMessageSource messageSource=new ReloadableResourceBundleMessageSource();
78
		ReloadableResourceBundleMessageSource messageSource = new ReloadableResourceBundleMessageSource();
83
		messageSource.setBasename(MESSAGE_PATH_SOURCE_NAME);
79
		messageSource.setBasename(MESSAGE_PATH_SOURCE_NAME);
84
		return messageSource;
80
		return messageSource;
85
	}
81
	}
86
 
82
 
87
	@Bean(name="multipartResolver")
83
	@Bean(name = "multipartResolver")
88
	public CommonsMultipartResolver getCommonsMultipartResolver() {
84
	public CommonsMultipartResolver getCommonsMultipartResolver() {
89
		LOGGER.info("creating common multipart resolver bean");
85
		LOGGER.info("creating common multipart resolver bean");
90
		return new CommonsMultipartResolver();
86
		return new CommonsMultipartResolver();
91
	}
87
	}
92
 
88
 
93
	@Bean
89
	@Bean
94
	public PropertySourcesPlaceholderConfigurer propertyConfigurer1() {
90
	public PropertySourcesPlaceholderConfigurer propertyConfigurer1() {
95
		String activeProfile;
91
		String activeProfile;
96
 
92
 
97
		PropertySourcesPlaceholderConfigurer propertySourcesPlaceholderConfigurer =  new PropertySourcesPlaceholderConfigurer();
93
		PropertySourcesPlaceholderConfigurer propertySourcesPlaceholderConfigurer = new PropertySourcesPlaceholderConfigurer();
98
 
94
 
99
		Properties properties = new Properties();
95
		Properties properties = new Properties();
100
		try {
96
		try {
101
			properties.load(this.getClass().getClassLoader().getResourceAsStream("META-INF/env.property"));
97
			properties.load(this.getClass().getClassLoader().getResourceAsStream("META-INF/env.property"));
102
		} catch (IOException e) {
98
		} catch (IOException e) {
103
			LOGGER.error("Error in reading env property file.Adding default property"+e);
99
			LOGGER.error("Error in reading env property file.Adding default property" + e);
104
			properties.put("profile", "dev");
100
			properties.put("profile", "dev");
105
		}
101
		}
106
		activeProfile = (String) properties.get("profile");
102
		activeProfile = (String) properties.get("profile");
107
 
103
 
108
 
-
 
109
		if ("prod".equals(activeProfile)) {
104
		if ("prod".equals(activeProfile)) {
110
			resource = new ClassPathResource("/META-INF/prod.properties");
105
			resource = new ClassPathResource("/META-INF/prod.properties");
111
		} else if ("staging".equals(activeProfile)) {
106
		} else if ("staging".equals(activeProfile)) {
112
			resource = new ClassPathResource("/META-INF/staging.properties");
107
			resource = new ClassPathResource("/META-INF/staging.properties");
113
		} else {
108
		} else {
Line 116... Line 111...
116
 
111
 
117
		propertySourcesPlaceholderConfigurer.setLocation(resource);
112
		propertySourcesPlaceholderConfigurer.setLocation(resource);
118
 
113
 
119
		return propertySourcesPlaceholderConfigurer;
114
		return propertySourcesPlaceholderConfigurer;
120
	}
115
	}
121
	
116
 
122
	@Bean(name="mailSender")
117
	@Bean(name = "mailSender")
123
    public JavaMailSender getGmailSender(){
118
	public JavaMailSender getGmailSender() {
124
        JavaMailSenderImpl mailSender = new JavaMailSenderImpl();
119
		JavaMailSenderImpl mailSender = new JavaMailSenderImpl();
125
         
120
 
126
        //Using gmail
121
		// Using gmail
127
        mailSender.setHost("smtp.sendgrid.net");
122
		mailSender.setHost("smtp.sendgrid.net");
128
        mailSender.setPort(587);
123
		mailSender.setPort(587);
129
        mailSender.setUsername("shop2020");
124
		mailSender.setUsername("shop2020");
130
        mailSender.setPassword("U2/=fP,t");
125
		mailSender.setPassword("U2/=fP,t");
131
         
126
 
132
        Properties javaMailProperties = new Properties();
127
		Properties javaMailProperties = new Properties();
133
        javaMailProperties.put("mail.smtp.starttls.enable", "false");
128
		javaMailProperties.put("mail.smtp.starttls.enable", "false");
134
        javaMailProperties.put("mail.smtp.auth", "true");
129
		javaMailProperties.put("mail.smtp.auth", "true");
135
        javaMailProperties.put("mail.transport.protocol", "smtp");
130
		javaMailProperties.put("mail.transport.protocol", "smtp");
136
        javaMailProperties.put("mail.debug", "true");//Prints out everything on screen
131
		javaMailProperties.put("mail.debug", "true");// Prints out everything on
137
         
132
														// screen
-
 
133
 
138
        mailSender.setJavaMailProperties(javaMailProperties);
134
		mailSender.setJavaMailProperties(javaMailProperties);
139
        return mailSender;
135
		return mailSender;
140
    }
136
	}
141
 
137
 
142
}
138
}
143
139