Java tutorial
/* * * Springstrap * * @author Jan Philipp Knller <info@pksoftware.de> * * Homepage: http://ui5strap.com/springstrap * * Copyright (c) 2013-2014 Jan Philipp Knller <info@pksoftware.de> * * 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. * Released under Apache2 license: http://www.apache.org/licenses/LICENSE-2.0.txt * */ package de.pksoftware.springstrap.core.config; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.config.PropertyPlaceholderConfigurer; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.EnableAspectJAutoProxy; import org.springframework.context.support.ReloadableResourceBundleMessageSource; import org.springframework.core.io.ClassPathResource; import org.springframework.web.multipart.commons.CommonsMultipartResolver; @Configuration @EnableAspectJAutoProxy public class RootConfigBase { protected static final Logger logger = LoggerFactory.getLogger(RootConfigBase.class); /** * Returns the base name for the message source. * @return */ protected String getMessageSourceBaseName() { return "classpath:i18n"; } /** * Returns the property file name. * @return */ protected String getPropertyFileName() { return "server.properties"; } /** * Configure MessageSource. This Bean must have the name "messageSource"! * @return */ @Bean(name = "messageSource") public ReloadableResourceBundleMessageSource messageSourceBean() { ReloadableResourceBundleMessageSource messageSource = new ReloadableResourceBundleMessageSource(); messageSource.setBasename(getMessageSourceBaseName()); return messageSource; } /** * Configure PropertyPlaceholderConfigurer. * @return */ @Bean public PropertyPlaceholderConfigurer propertyPlaceholderConfigurerBean() { logger.info("Creating PPC Bean..."); PropertyPlaceholderConfigurer propertyPlaceholderConfigurer = new PropertyPlaceholderConfigurer(); propertyPlaceholderConfigurer.setLocation(new ClassPathResource(getPropertyFileName())); //propertyPlaceholderConfigurer.setIgnoreResourceNotFound(true); //propertyPlaceholderConfigurer.setIgnoreUnresolvablePlaceholders(true); return propertyPlaceholderConfigurer; //ClassPathResource[] resources = new ClassPathResource[ ] // { new ClassPathResource( getPropertyFileName() ) }; } @Bean public SpringstrapConfiguration serverConfiguration() { return new SpringstrapConfiguration(); } /** * Expose MultipartResolver as Bean. * @return */ @Bean public CommonsMultipartResolver filterMultipartResolver() { return new CommonsMultipartResolver(); } }