Signed-off-by: Andrew DeMaria <lostonamountain@gmail.com>master
							parent
							
								
									bdcfc78b85
								
							
						
					
					
						commit
						fa1a700ebd
					
				| @ -0,0 +1,105 @@ | |||||||
|  | package org.airsonic.player.spring; | ||||||
|  | 
 | ||||||
|  | import org.airsonic.player.dao.DaoHelper; | ||||||
|  | import org.airsonic.player.dao.GenericDaoHelper; | ||||||
|  | import org.airsonic.player.dao.LegacyHsqlDaoHelper; | ||||||
|  | import org.airsonic.player.service.SettingsService; | ||||||
|  | import org.airsonic.player.util.Util; | ||||||
|  | import org.apache.commons.dbcp2.BasicDataSource; | ||||||
|  | import org.springframework.beans.factory.annotation.Value; | ||||||
|  | import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; | ||||||
|  | import org.springframework.context.annotation.Bean; | ||||||
|  | import org.springframework.context.annotation.Configuration; | ||||||
|  | import org.springframework.context.annotation.Profile; | ||||||
|  | import org.springframework.jdbc.datasource.DataSourceTransactionManager; | ||||||
|  | import org.springframework.jdbc.datasource.DriverManagerDataSource; | ||||||
|  | import org.springframework.jdbc.datasource.lookup.JndiDataSourceLookup; | ||||||
|  | import org.springframework.transaction.annotation.EnableTransactionManagement; | ||||||
|  | 
 | ||||||
|  | import javax.sql.DataSource; | ||||||
|  | 
 | ||||||
|  | import java.io.File; | ||||||
|  | import java.util.HashMap; | ||||||
|  | import java.util.Map; | ||||||
|  | 
 | ||||||
|  | @Configuration | ||||||
|  | @EnableTransactionManagement | ||||||
|  | public class DatabaseConfiguration { | ||||||
|  | 
 | ||||||
|  |     @Bean | ||||||
|  |     public DataSourceTransactionManager transactionManager(DataSource dataSource) { | ||||||
|  |         return new DataSourceTransactionManager(dataSource); | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     @Bean | ||||||
|  |     @Profile("legacy") | ||||||
|  |     public DaoHelper legacyDaoHelper(DataSource dataSource) { | ||||||
|  |         return new LegacyHsqlDaoHelper(dataSource); | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     @Bean | ||||||
|  |     @ConditionalOnMissingBean | ||||||
|  |     public DaoHelper daoHelper(DataSource dataSource) { | ||||||
|  |         return new GenericDaoHelper(dataSource); | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     @Bean | ||||||
|  |     @Profile("legacy") | ||||||
|  |     public DataSource legacyDataSource() { | ||||||
|  |         DriverManagerDataSource dataSource = new DriverManagerDataSource(); | ||||||
|  |         dataSource.setDriverClassName("org.hsqldb.jdbcDriver"); | ||||||
|  |         dataSource.setUrl(SettingsService.getDefaultJDBCUrl()); | ||||||
|  |         dataSource.setUsername("sa"); | ||||||
|  |         dataSource.setPassword(""); | ||||||
|  |         return dataSource; | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     @Bean | ||||||
|  |     @Profile("embed") | ||||||
|  |     public DataSource embedDataSource(@Value("${DatabaseConfigEmbedDriver}") String driver, | ||||||
|  |                                            @Value("${DatabaseConfigEmbedUrl}") String url, | ||||||
|  |                                            @Value("${DatabaseConfigEmbedUsername}") String username, | ||||||
|  |                                            @Value("${DatabaseConfigEmbedPassword}") String password) { | ||||||
|  |         BasicDataSource basicDataSource = new BasicDataSource(); | ||||||
|  |         basicDataSource.setDriverClassName(driver); | ||||||
|  |         basicDataSource.setUrl(url); | ||||||
|  |         basicDataSource.setUsername(username); | ||||||
|  |         basicDataSource.setPassword(password); | ||||||
|  |         return basicDataSource; | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     @Bean | ||||||
|  |     @Profile("jndi") | ||||||
|  |     public DataSource jndiDataSource(@Value("${DatabaseConfigJNDIName}") String jndiName) { | ||||||
|  |         JndiDataSourceLookup jndiLookup = new JndiDataSourceLookup(); | ||||||
|  |         return jndiLookup.getDataSource(jndiName); | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     @Bean | ||||||
|  |     public File rollbackFile() { | ||||||
|  |         return new File(SettingsService.getAirsonicHome(), "rollback.sql"); | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     @Bean | ||||||
|  |     public String userTableQuote(@Value("${DatabaseUsertableQuote:}") String value) { | ||||||
|  |         return value; | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     @Bean | ||||||
|  |     public SpringLiquibase liquibase(DataSource dataSource, | ||||||
|  |                                      @Value("${DatabaseMysqlMaxlength:512}") | ||||||
|  |                                      String mysqlVarcharLimit, | ||||||
|  |                                      String userTableQuote) { | ||||||
|  |         SpringLiquibase springLiquibase = new SpringLiquibase(); | ||||||
|  |         springLiquibase.setDataSource(dataSource); | ||||||
|  |         springLiquibase.setChangeLog("classpath:liquibase/db-changelog.xml"); | ||||||
|  |         springLiquibase.setRollbackFile(rollbackFile()); | ||||||
|  |         Map<String, String> parameters = new HashMap<>(); | ||||||
|  |         parameters.put("defaultMusicFolder", Util.getDefaultMusicFolder()); | ||||||
|  |         parameters.put("mysqlVarcharLimit", mysqlVarcharLimit); | ||||||
|  |         parameters.put("userTableQuote", userTableQuote); | ||||||
|  |         springLiquibase.setChangeLogParameters(parameters); | ||||||
|  |         return springLiquibase; | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  | } | ||||||
| @ -0,0 +1,33 @@ | |||||||
|  | package org.airsonic.player.spring; | ||||||
|  | 
 | ||||||
|  | import net.sf.ehcache.Ehcache; | ||||||
|  | import net.sf.ehcache.constructs.web.ShutdownListener; | ||||||
|  | import org.airsonic.player.cache.CacheFactory; | ||||||
|  | import org.springframework.context.annotation.Bean; | ||||||
|  | import org.springframework.context.annotation.Configuration; | ||||||
|  | 
 | ||||||
|  | import javax.servlet.ServletContextListener; | ||||||
|  | 
 | ||||||
|  | @Configuration | ||||||
|  | public class EhcacheConfiguration { | ||||||
|  | 
 | ||||||
|  |     @Bean | ||||||
|  |     public ServletContextListener ehCacheShutdownListener() { | ||||||
|  |         return new ShutdownListener(); | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     @Bean | ||||||
|  |     public Ehcache userCache(CacheFactory cacheFactory) { | ||||||
|  |         return cacheFactory.getCache("userCache"); | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     @Bean | ||||||
|  |     public Ehcache mediaFileMemoryCache(CacheFactory cacheFactory) { | ||||||
|  |         return cacheFactory.getCache("mediaFileMemoryCache"); | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     @Bean | ||||||
|  |     public CacheFactory cacheFactory() { | ||||||
|  |         return new CacheFactory(); | ||||||
|  |     } | ||||||
|  | } | ||||||
| @ -0,0 +1,34 @@ | |||||||
|  | package org.airsonic.player.spring; | ||||||
|  | 
 | ||||||
|  | import org.airsonic.player.controller.PodcastController; | ||||||
|  | import org.springframework.context.annotation.Bean; | ||||||
|  | import org.springframework.context.annotation.Configuration; | ||||||
|  | import org.springframework.web.servlet.ViewResolver; | ||||||
|  | import org.springframework.web.servlet.handler.SimpleUrlHandlerMapping; | ||||||
|  | import org.springframework.web.servlet.view.InternalResourceViewResolver; | ||||||
|  | import org.springframework.web.servlet.view.JstlView; | ||||||
|  | 
 | ||||||
|  | import java.util.Properties; | ||||||
|  | 
 | ||||||
|  | @Configuration | ||||||
|  | public class ServletConfiguration { | ||||||
|  | 
 | ||||||
|  |     @Bean | ||||||
|  |     public SimpleUrlHandlerMapping podcastUrlMapping(PodcastController podcastController) { | ||||||
|  |         SimpleUrlHandlerMapping handlerMapping = new SimpleUrlHandlerMapping(); | ||||||
|  |         handlerMapping.setAlwaysUseFullPath(true); | ||||||
|  |         Properties properties = new Properties(); | ||||||
|  |         properties.put("/podcast/**", podcastController); | ||||||
|  |         handlerMapping.setMappings(properties); | ||||||
|  |         return handlerMapping; | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     @Bean | ||||||
|  |     public ViewResolver viewResolver() { | ||||||
|  |         InternalResourceViewResolver resolver = new InternalResourceViewResolver(); | ||||||
|  |         resolver.setViewClass(JstlView.class); | ||||||
|  |         resolver.setPrefix("/WEB-INF/jsp/"); | ||||||
|  |         resolver.setSuffix(".jsp"); | ||||||
|  |         return resolver; | ||||||
|  |     } | ||||||
|  | } | ||||||
| @ -0,0 +1,26 @@ | |||||||
|  | package org.airsonic.player.spring; | ||||||
|  | 
 | ||||||
|  | import org.airsonic.player.service.SonosService; | ||||||
|  | import org.airsonic.player.service.sonos.SonosFaultInterceptor; | ||||||
|  | import org.apache.cxf.jaxws.EndpointImpl; | ||||||
|  | import org.springframework.context.annotation.Bean; | ||||||
|  | import org.springframework.context.annotation.Configuration; | ||||||
|  | import org.springframework.context.annotation.ImportResource; | ||||||
|  | 
 | ||||||
|  | import javax.xml.ws.Endpoint; | ||||||
|  | 
 | ||||||
|  | import java.util.Collections; | ||||||
|  | 
 | ||||||
|  | @Configuration | ||||||
|  | @ImportResource({"classpath:META-INF/cxf/cxf.xml", "classpath:META-INF/cxf/cxf-servlet.xml"}) | ||||||
|  | public class SonosConfiguration { | ||||||
|  | 
 | ||||||
|  |     @Bean | ||||||
|  |     public Endpoint sonosEndpoint(SonosService sonosService, SonosFaultInterceptor sonosFaultInterceptor) { | ||||||
|  |         EndpointImpl endpoint = new EndpointImpl(sonosService); | ||||||
|  |         endpoint.publish("/Sonos"); | ||||||
|  |         endpoint.setOutFaultInterceptors(Collections.singletonList(sonosFaultInterceptor)); | ||||||
|  |         return endpoint; | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  | } | ||||||
| @ -1,17 +0,0 @@ | |||||||
| <?xml version="1.0" encoding="UTF-8"?> |  | ||||||
| 
 |  | ||||||
| <beans xmlns="http://www.springframework.org/schema/beans" |  | ||||||
|        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" |  | ||||||
|        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd"> |  | ||||||
| 
 |  | ||||||
|     <bean id="cacheFactory" class="org.airsonic.player.cache.CacheFactory"/> |  | ||||||
| 
 |  | ||||||
|     <bean id="userCache" factory-bean="cacheFactory" factory-method="getCache"> |  | ||||||
|         <constructor-arg value="userCache"/> |  | ||||||
|     </bean> |  | ||||||
| 
 |  | ||||||
|     <bean id="mediaFileMemoryCache" factory-bean="cacheFactory" factory-method="getCache"> |  | ||||||
|         <constructor-arg value="mediaFileMemoryCache"/> |  | ||||||
|     </bean> |  | ||||||
| 
 |  | ||||||
| </beans> |  | ||||||
| @ -1,14 +0,0 @@ | |||||||
| <?xml version="1.0" encoding="UTF-8"?> |  | ||||||
| <beans xmlns="http://www.springframework.org/schema/beans" |  | ||||||
|        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" |  | ||||||
|        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd" |  | ||||||
|        profile="embed"> |  | ||||||
|     <bean id="dataSource" |  | ||||||
|           class="org.apache.commons.dbcp2.BasicDataSource"> |  | ||||||
| 
 |  | ||||||
|         <property name="driverClassName" value="${DatabaseConfigEmbedDriver}" /> |  | ||||||
|         <property name="url" value="${DatabaseConfigEmbedUrl}" /> |  | ||||||
|         <property name="username" value="${DatabaseConfigEmbedUsername}" /> |  | ||||||
|         <property name="password" value="${DatabaseConfigEmbedPassword}" /> |  | ||||||
|     </bean> |  | ||||||
| </beans> |  | ||||||
| @ -1,12 +0,0 @@ | |||||||
| <?xml version="1.0" encoding="UTF-8"?> |  | ||||||
| <beans xmlns="http://www.springframework.org/schema/beans" |  | ||||||
|        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" |  | ||||||
|        xmlns:jee="http://www.springframework.org/schema/jee" |  | ||||||
|        xsi:schemaLocation=" |  | ||||||
|        http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd |  | ||||||
|        http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee.xsd" |  | ||||||
|        profile="jndi"> |  | ||||||
|     <jee:jndi-lookup id="dataSource" |  | ||||||
|                      jndi-name="${DatabaseConfigJNDIName}" |  | ||||||
|                      expected-type="javax.sql.DataSource" /> |  | ||||||
| </beans> |  | ||||||
| @ -1,22 +0,0 @@ | |||||||
| <?xml version="1.0" encoding="UTF-8"?> |  | ||||||
| <beans xmlns="http://www.springframework.org/schema/beans" |  | ||||||
|        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" |  | ||||||
|        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd" |  | ||||||
|        profile="legacy"> |  | ||||||
| 
 |  | ||||||
|     <bean id="dataSource" |  | ||||||
|           class="org.springframework.jdbc.datasource.DriverManagerDataSource"> |  | ||||||
|         <property name="driverClassName" value="org.hsqldb.jdbcDriver" /> |  | ||||||
|         <property name="url" |  | ||||||
|                   value="#{T(org.airsonic.player.service.SettingsService).defaultJDBCUrl}" /> |  | ||||||
|         <property name="username" value="sa" /> |  | ||||||
|         <property name="password" value="" /> |  | ||||||
|     </bean> |  | ||||||
| 
 |  | ||||||
|     <!-- Overwrite the GenericDaoHelper bean defined in applicationContext-db.xml --> |  | ||||||
|     <!-- This bean is specific to the legacy embedded HSQLDB database --> |  | ||||||
|     <bean id="daoHelper" class="org.airsonic.player.dao.LegacyHsqlDaoHelper"> |  | ||||||
|         <constructor-arg name="dataSource" ref="dataSource" /> |  | ||||||
|     </bean> |  | ||||||
| 
 |  | ||||||
| </beans> |  | ||||||
| @ -1,41 +0,0 @@ | |||||||
| <?xml version="1.0" encoding="UTF-8"?> |  | ||||||
| <beans xmlns="http://www.springframework.org/schema/beans" |  | ||||||
|        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:tx="http://www.springframework.org/schema/tx" |  | ||||||
|        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsd"> |  | ||||||
| 
 |  | ||||||
|     <bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager"> |  | ||||||
|         <constructor-arg ref="dataSource"/> |  | ||||||
|     </bean> |  | ||||||
| 
 |  | ||||||
|     <bean id="daoHelper" class="org.airsonic.player.dao.GenericDaoHelper"> |  | ||||||
|         <constructor-arg name="dataSource" ref="dataSource" /> |  | ||||||
|     </bean> |  | ||||||
| 
 |  | ||||||
|     <import resource="applicationContext-db-jndi.xml" /> |  | ||||||
|     <import resource="applicationContext-db-embed.xml" /> |  | ||||||
|     <import resource="applicationContext-db-legacy.xml" /> |  | ||||||
| 
 |  | ||||||
|     <tx:annotation-driven/> |  | ||||||
| 
 |  | ||||||
|     <bean id="rollbackFile" class="java.io.File"> |  | ||||||
|         <constructor-arg type="java.io.File" index="0" value="#{T(org.airsonic.player.service.SettingsService).airsonicHome}" /> |  | ||||||
|         <constructor-arg type="java.lang.String" index="1" value="rollback.sql" /> |  | ||||||
|     </bean> |  | ||||||
| 
 |  | ||||||
|     <bean id="userTableQuote" class="java.lang.String"> |  | ||||||
|         <constructor-arg value="${DatabaseUsertableQuote:}" /> |  | ||||||
|     </bean> |  | ||||||
| 
 |  | ||||||
|     <bean id="liquibase" class="org.airsonic.player.spring.SpringLiquibase"> |  | ||||||
|         <property name="dataSource" ref="dataSource" /> |  | ||||||
|         <property name="changeLog" value="classpath:liquibase/db-changelog.xml" /> |  | ||||||
|         <property name="rollbackFile" ref="rollbackFile" /> |  | ||||||
|         <property name="changeLogParameters"> |  | ||||||
|             <map> |  | ||||||
|                 <entry key="defaultMusicFolder" value="#{T(org.airsonic.player.util.Util).getDefaultMusicFolder()}" /> |  | ||||||
|                 <entry key="mysqlVarcharLimit" value="${DatabaseMysqlMaxlength:512}" /> |  | ||||||
|                 <entry key="userTableQuote" value-ref="userTableQuote" /> |  | ||||||
|             </map> |  | ||||||
|         </property> |  | ||||||
|     </bean> |  | ||||||
| </beans> |  | ||||||
| @ -1,34 +0,0 @@ | |||||||
| <?xml version="1.0" encoding="UTF-8"?> |  | ||||||
| 
 |  | ||||||
| <beans xmlns="http://www.springframework.org/schema/beans" |  | ||||||
|        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" |  | ||||||
|        xmlns:context="http://www.springframework.org/schema/context" |  | ||||||
|        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd"> |  | ||||||
| 
 |  | ||||||
|     <context:property-placeholder /> |  | ||||||
| 
 |  | ||||||
|     <import resource="applicationContext-db.xml" /> |  | ||||||
| 
 |  | ||||||
|     <!-- DAO's --> |  | ||||||
|      |  | ||||||
|     <context:component-scan base-package="org.airsonic.player.dao,  |  | ||||||
|         org.airsonic.player.service,  |  | ||||||
|         org.airsonic.player.monitor,  |  | ||||||
|         org.airsonic.player.ajax,  |  | ||||||
|         org.airsonic.player.i18n." /> |  | ||||||
| 
 |  | ||||||
|     <!-- Services --> |  | ||||||
| 
 |  | ||||||
|     <bean id="metaDataParserFactory" class="org.airsonic.player.service.metadata.MetaDataParserFactory"> |  | ||||||
|         <property name="parsers"> |  | ||||||
|             <list> |  | ||||||
|                 <ref bean="jaudiotaggerParser" /> |  | ||||||
|                 <ref bean="ffmpegParser" /> |  | ||||||
|                 <ref bean="defaultMetaDataParser" /> |  | ||||||
|             </list> |  | ||||||
|         </property> |  | ||||||
|     </bean> |  | ||||||
| 
 |  | ||||||
|     <!-- AJAX services --> |  | ||||||
| 
 |  | ||||||
| </beans> |  | ||||||
| @ -1,30 +0,0 @@ | |||||||
| <?xml version="1.0" encoding="UTF-8"?> |  | ||||||
| <beans xmlns="http://www.springframework.org/schema/beans" |  | ||||||
|        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" |  | ||||||
|        xmlns:jaxws="http://cxf.apache.org/jaxws" |  | ||||||
|        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://cxf.apache.org/jaxws http://cxf.apache.org/schemas/jaxws.xsd"> |  | ||||||
| 
 |  | ||||||
|     <import resource="classpath:META-INF/cxf/cxf.xml"/> |  | ||||||
|     <import resource="classpath:META-INF/cxf/cxf-servlet.xml"/> |  | ||||||
| 
 |  | ||||||
|     <jaxws:endpoint id="sonosEndpoint" implementor="#sonosService" address="/Sonos"> |  | ||||||
|         <jaxws:outFaultInterceptors> |  | ||||||
|             <bean class="org.airsonic.player.service.sonos.SonosFaultInterceptor"/> |  | ||||||
|         </jaxws:outFaultInterceptors> |  | ||||||
|     </jaxws:endpoint> |  | ||||||
| 
 |  | ||||||
|     <bean id="sonosHelper" class="org.airsonic.player.service.sonos.SonosHelper"> |  | ||||||
|         <property name="mediaFileService" ref="mediaFileService"/> |  | ||||||
|         <property name="settingsService" ref="settingsService"/> |  | ||||||
|         <property name="playlistService" ref="playlistService"/> |  | ||||||
|         <property name="playerService" ref="playerService"/> |  | ||||||
|         <property name="transcodingService" ref="transcodingService"/> |  | ||||||
|         <property name="musicIndexService" ref="musicIndexService"/> |  | ||||||
|         <property name="searchService" ref="searchServiceImpl"/> |  | ||||||
|         <property name="ratingService" ref="ratingService"/> |  | ||||||
|         <property name="lastFmService" ref="lastFmService"/> |  | ||||||
|         <property name="podcastService" ref="podcastService"/> |  | ||||||
|         <property name="mediaFileDao" ref="mediaFileDao"/> |  | ||||||
|     </bean> |  | ||||||
| 
 |  | ||||||
| </beans> |  | ||||||
| @ -1,52 +0,0 @@ | |||||||
| <?xml version="1.0" encoding="UTF-8"?> |  | ||||||
| 
 |  | ||||||
| <beans xmlns="http://www.springframework.org/schema/beans" |  | ||||||
|        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" |  | ||||||
|        xmlns:context="http://www.springframework.org/schema/context" |  | ||||||
|        xmlns:mvc="http://www.springframework.org/schema/mvc" |  | ||||||
|        xsi:schemaLocation=" |  | ||||||
|         http://www.springframework.org/schema/beans |  | ||||||
|         http://www.springframework.org/schema/beans/spring-beans.xsd |  | ||||||
|         http://www.springframework.org/schema/context |  | ||||||
|         http://www.springframework.org/schema/context/spring-context.xsd |  | ||||||
|         http://www.springframework.org/schema/mvc |  | ||||||
|         http://www.springframework.org/schema/mvc/spring-mvc.xsd"> |  | ||||||
| 
 |  | ||||||
|     <mvc:annotation-driven /> |  | ||||||
|     <context:component-scan base-package="org.airsonic.player.controller, |  | ||||||
|         org.airsonic.player.validator, |  | ||||||
|         org.airsonic.player.security"/> |  | ||||||
| 
 |  | ||||||
| 
 |  | ||||||
|     <bean id="urlMapping" class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping"> |  | ||||||
|         <property name="alwaysUseFullPath" value="true"/> |  | ||||||
|         <property name="mappings"> |  | ||||||
|             <props> |  | ||||||
|                 <prop key="/podcast/**">podcastController</prop> |  | ||||||
|             </props> |  | ||||||
|         </property> |  | ||||||
|     </bean> |  | ||||||
| 
 |  | ||||||
|     <bean id="messageSource" class="org.springframework.context.support.ResourceBundleMessageSource"> |  | ||||||
|         <property name="basename" value="org.airsonic.player.i18n.ResourceBundle"/> |  | ||||||
|     </bean> |  | ||||||
| 
 |  | ||||||
|     <bean id="themeSource" class="org.airsonic.player.theme.CustomThemeSource"> |  | ||||||
|         <property name="basenamePrefix" value="org.airsonic.player.theme."/> |  | ||||||
|         <property name="settingsService" ref="settingsService"/> |  | ||||||
|     </bean> |  | ||||||
| 
 |  | ||||||
|     <bean id="themeResolver" class="org.airsonic.player.theme.CustomThemeResolver"> |  | ||||||
|         <property name="securityService" ref="securityService"/> |  | ||||||
|         <property name="settingsService" ref="settingsService"/> |  | ||||||
|     </bean> |  | ||||||
| 
 |  | ||||||
|     <bean id="viewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver"> |  | ||||||
|         <property name="viewClass" value="org.springframework.web.servlet.view.JstlView"/> |  | ||||||
|         <property name="prefix" value="/WEB-INF/jsp/"/> |  | ||||||
|         <property name="suffix" value=".jsp"/> |  | ||||||
|     </bean> |  | ||||||
| 
 |  | ||||||
|     <bean class="org.airsonic.player.spring.LoggingExceptionResolver" /> |  | ||||||
| 
 |  | ||||||
| </beans> |  | ||||||
| @ -0,0 +1,75 @@ | |||||||
|  | package org.airsonic.player.service.metadata; | ||||||
|  | 
 | ||||||
|  | import org.airsonic.player.service.SettingsService; | ||||||
|  | import org.airsonic.player.util.HomeRule; | ||||||
|  | import org.junit.*; | ||||||
|  | import org.junit.rules.TemporaryFolder; | ||||||
|  | import org.junit.runner.Description; | ||||||
|  | import org.junit.runners.model.Statement; | ||||||
|  | import org.springframework.beans.factory.annotation.Autowired; | ||||||
|  | import org.springframework.boot.test.context.SpringBootTest; | ||||||
|  | import org.springframework.test.annotation.DirtiesContext; | ||||||
|  | import org.springframework.test.context.junit4.rules.SpringClassRule; | ||||||
|  | import org.springframework.test.context.junit4.rules.SpringMethodRule; | ||||||
|  | 
 | ||||||
|  | import java.io.File; | ||||||
|  | import java.io.IOException; | ||||||
|  | 
 | ||||||
|  | import static org.hamcrest.CoreMatchers.instanceOf; | ||||||
|  | import static org.junit.Assert.assertThat; | ||||||
|  | 
 | ||||||
|  | @SpringBootTest | ||||||
|  | @DirtiesContext(classMode = DirtiesContext.ClassMode.AFTER_EACH_TEST_METHOD) | ||||||
|  | public class MetaDataFactoryTestCase { | ||||||
|  | 
 | ||||||
|  |     @ClassRule | ||||||
|  |     public static final SpringClassRule classRule = new SpringClassRule() { | ||||||
|  |         HomeRule homeRule = new HomeRule(); | ||||||
|  | 
 | ||||||
|  |         @Override | ||||||
|  |         public Statement apply(Statement base, Description description) { | ||||||
|  |             Statement spring = super.apply(base, description); | ||||||
|  |             return homeRule.apply(spring, description); | ||||||
|  |         } | ||||||
|  |     }; | ||||||
|  | 
 | ||||||
|  |     @ClassRule | ||||||
|  |     public static TemporaryFolder temporaryFolder = new TemporaryFolder(); | ||||||
|  | 
 | ||||||
|  |     private static File someMp3; | ||||||
|  |     private static File someFlv; | ||||||
|  |     private static File someJunk; | ||||||
|  | 
 | ||||||
|  |     @BeforeClass | ||||||
|  |     public static void createTestFiles() throws IOException { | ||||||
|  |         someMp3 = temporaryFolder.newFile("some.mp3"); | ||||||
|  |         someFlv = temporaryFolder.newFile("some.flv"); | ||||||
|  |         someJunk = temporaryFolder.newFile("some.junk"); | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     @Rule | ||||||
|  |     public final SpringMethodRule springMethodRule = new SpringMethodRule(); | ||||||
|  | 
 | ||||||
|  |     @Autowired | ||||||
|  |     MetaDataParserFactory metaDataParserFactory; | ||||||
|  | 
 | ||||||
|  |     @Autowired | ||||||
|  |     SettingsService settingsService; | ||||||
|  | 
 | ||||||
|  |     @Test | ||||||
|  |     public void testorder() { | ||||||
|  |         MetaDataParser parser; | ||||||
|  | 
 | ||||||
|  |         settingsService.setVideoFileTypes("mp3 flv"); | ||||||
|  | 
 | ||||||
|  |         parser = metaDataParserFactory.getParser(someMp3); | ||||||
|  |         assertThat(parser, instanceOf(JaudiotaggerParser.class)); | ||||||
|  | 
 | ||||||
|  |         parser = metaDataParserFactory.getParser(someFlv); | ||||||
|  |         assertThat(parser, instanceOf(FFmpegParser.class)); | ||||||
|  | 
 | ||||||
|  |         parser = metaDataParserFactory.getParser(someJunk); | ||||||
|  |         assertThat(parser, instanceOf(DefaultMetaDataParser.class)); | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  | } | ||||||
| @ -1,11 +0,0 @@ | |||||||
| <?xml version="1.0" encoding="UTF-8"?> |  | ||||||
| <beans xmlns="http://www.springframework.org/schema/beans" |  | ||||||
|        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" |  | ||||||
|        xmlns:jaxws="http://cxf.apache.org/jaxws" |  | ||||||
|        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://cxf.apache.org/jaxws http://cxf.apache.org/schemas/jaxws.xsd"> |  | ||||||
| 
 |  | ||||||
|     <bean id="sonosHelper" class="org.mockito.Mockito" factory-method="mock"> |  | ||||||
|         <constructor-arg value="org.airsonic.player.service.sonos.SonosHelper" /> |  | ||||||
|     </bean> |  | ||||||
| 
 |  | ||||||
| </beans> |  | ||||||
| @ -1,15 +0,0 @@ | |||||||
| <?xml version="1.0" encoding="UTF-8"?> |  | ||||||
| <beans xmlns="http://www.springframework.org/schema/beans" |  | ||||||
|        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" |  | ||||||
|        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd"> |  | ||||||
| 
 |  | ||||||
|     <bean id="dataSource" |  | ||||||
|           class="org.springframework.jdbc.datasource.DriverManagerDataSource"> |  | ||||||
| 
 |  | ||||||
|         <property name="driverClassName" value="org.hsqldb.jdbcDriver" /> |  | ||||||
|         <property name="url" |  | ||||||
|                   value="#{T(org.airsonic.player.service.SettingsService).defaultJDBCUrl}" /> |  | ||||||
|         <property name="username" value="sa" /> |  | ||||||
|         <property name="password" value="" /> |  | ||||||
|     </bean> |  | ||||||
| </beans> |  | ||||||
					Loading…
					
					
				
		Reference in new issue