Java tutorial
/** * Copyright 2016 REPLACE ME OWNER (REPLACE ME YEAR) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.homiefund.test.config; import org.dozer.DozerBeanMapper; import org.dozer.Mapper; import org.homiefund.api.support.HomeAccessVoter; import org.homiefund.api.support.HomeAccessVoterImpl; import org.homiefund.api.support.MailService; import org.homiefund.api.support.MailServiceImpl; import org.homiefund.api.support.UserPreferencesBean; import org.homiefund.api.support.WiserFactoryBean; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.ComponentScan; import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.EnableAspectJAutoProxy; import org.springframework.context.annotation.Import; import org.springframework.context.annotation.Scope; import org.springframework.context.annotation.ScopedProxyMode; import org.springframework.mail.MailSender; import org.springframework.mail.SimpleMailMessage; import org.springframework.mail.javamail.JavaMailSenderImpl; import org.springframework.scheduling.annotation.EnableAsync; import org.springframework.security.config.annotation.method.configuration.EnableGlobalMethodSecurity; /** * Created by Dominik Szalai - emptulik at gmail.com on 25.9.2016. */ @Configuration @Import(DatabaseConfigurationTest.class) @EnableAspectJAutoProxy(proxyTargetClass = true) @EnableAsync @EnableGlobalMethodSecurity(prePostEnabled = true) @ComponentScan({ "org.homiefund.api.service" }) public class IntegrationConfiguration { @Bean public MailService mailService() { return new MailServiceImpl(mailSender(), simpleMailMessage()); } @Bean @Scope(value = "session", proxyMode = ScopedProxyMode.TARGET_CLASS) public UserPreferencesBean pageModel() { return new UserPreferencesBean(); } @Bean public MailSender mailSender() { JavaMailSenderImpl mailSender = new JavaMailSenderImpl(); mailSender.setHost("localhost"); mailSender.setPort(20025); return mailSender; } @Bean(name = "templateMessage") public SimpleMailMessage simpleMailMessage() { SimpleMailMessage simpleMailMessage = new SimpleMailMessage(); simpleMailMessage.setFrom("demo@localhost"); simpleMailMessage.setSubject("Invitiation to homiefund"); return simpleMailMessage; } @Bean public WiserFactoryBean wiserFactoryBean() { return new WiserFactoryBean(); } @Bean public Mapper mapper() { DozerBeanMapper mapper = new DozerBeanMapper(); return mapper; } @Bean(name = "homeVoter") public HomeAccessVoter homeAccessVoter() { return new HomeAccessVoterImpl(); } }