Changed ajax services to use autowired and be loaded with component scan

Signed-off-by: Derrek Bond <yoyo007@gmail.com>
master
Derrek Bond 7 years ago
parent 1b4d319491
commit 5635f52641
  1. 6
      airsonic-main/src/main/java/org/airsonic/player/ajax/CoverArtService.java
  2. 2
      airsonic-main/src/main/java/org/airsonic/player/ajax/LyricsService.java
  3. 7
      airsonic-main/src/main/java/org/airsonic/player/ajax/MultiService.java
  4. 7
      airsonic-main/src/main/java/org/airsonic/player/ajax/NowPlayingService.java
  5. 17
      airsonic-main/src/main/java/org/airsonic/player/ajax/PlayQueueService.java
  6. 10
      airsonic-main/src/main/java/org/airsonic/player/ajax/PlaylistService.java
  7. 5
      airsonic-main/src/main/java/org/airsonic/player/ajax/StarService.java
  8. 5
      airsonic-main/src/main/java/org/airsonic/player/ajax/TagService.java
  9. 3
      airsonic-main/src/main/java/org/airsonic/player/ajax/TransferService.java
  10. 6
      airsonic-main/src/main/java/org/airsonic/player/i18n/LocaleResolver.java
  11. 2
      airsonic-main/src/main/java/org/airsonic/player/monitor/MetricsManager.java
  12. 75
      airsonic-main/src/main/resources/applicationContext-service.xml

@ -33,6 +33,8 @@ import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.io.File;
import java.io.FileOutputStream;
@ -47,12 +49,16 @@ import java.util.List;
*
* @author Sindre Mehus
*/
@Service("ajaxCoverArtService")
public class CoverArtService {
private static final Logger LOG = LoggerFactory.getLogger(CoverArtService.class);
@Autowired
private SecurityService securityService;
@Autowired
private MediaFileService mediaFileService;
@Autowired
private LastFmService lastFmService;
public List<LastFmCoverArt> searchCoverArt(String artist, String album) {

@ -33,6 +33,7 @@ import org.jdom.Namespace;
import org.jdom.input.SAXBuilder;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;
import java.io.IOException;
import java.io.StringReader;
@ -47,6 +48,7 @@ import java.net.SocketException;
*
* @author Sindre Mehus
*/
@Service("ajaxLyricsService")
public class LyricsService {
private static final Logger LOG = LoggerFactory.getLogger(LyricsService.class);

@ -30,6 +30,8 @@ import org.airsonic.player.service.SettingsService;
import org.directwebremoting.WebContextFactory;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import javax.servlet.http.HttpServletRequest;
@ -45,13 +47,18 @@ import java.util.List;
*
* @author Sindre Mehus
*/
@Service("ajaxMultiService")
public class MultiService {
private static final Logger LOG = LoggerFactory.getLogger(MultiService.class);
@Autowired
private MediaFileService mediaFileService;
@Autowired
private LastFmService lastFmService;
@Autowired
private SecurityService securityService;
@Autowired
private SettingsService settingsService;
public ArtistInfo getArtistInfo(int mediaFileId, int maxSimilarArtists, int maxTopSongs) {

@ -27,6 +27,8 @@ import org.directwebremoting.WebContext;
import org.directwebremoting.WebContextFactory;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import javax.servlet.http.HttpServletRequest;
@ -40,13 +42,18 @@ import java.util.List;
*
* @author Sindre Mehus
*/
@Service("ajaxNowPlayingService")
public class NowPlayingService {
private static final Logger LOG = LoggerFactory.getLogger(NowPlayingService.class);
@Autowired
private PlayerService playerService;
@Autowired
private StatusService statusService;
@Autowired
private SettingsService settingsService;
@Autowired
private MediaScannerService mediaScannerService;
/**

@ -28,6 +28,8 @@ import org.airsonic.player.service.*;
import org.airsonic.player.service.PlaylistService;
import org.airsonic.player.util.StringUtil;
import org.directwebremoting.WebContextFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.servlet.support.RequestContextUtils;
import javax.servlet.http.HttpServletRequest;
@ -41,22 +43,37 @@ import java.util.*;
*
* @author Sindre Mehus
*/
@Service("ajaxPlayQueueService")
@SuppressWarnings("UnusedDeclaration")
public class PlayQueueService {
@Autowired
private PlayerService playerService;
@Autowired
private JukeboxService jukeboxService;
@Autowired
private TranscodingService transcodingService;
@Autowired
private SettingsService settingsService;
@Autowired
private MediaFileService mediaFileService;
@Autowired
private LastFmService lastFmService;
@Autowired
private SecurityService securityService;
@Autowired
private SearchService searchService;
@Autowired
private RatingService ratingService;
@Autowired
private PodcastService podcastService;
@Autowired
private PlaylistService playlistService;
@Autowired
private MediaFileDao mediaFileDao;
@Autowired
private PlayQueueDao playQueueDao;
@Autowired
private JWTSecurityService jwtSecurityService;
/**

@ -30,6 +30,8 @@ import org.airsonic.player.service.PlayerService;
import org.airsonic.player.service.SecurityService;
import org.airsonic.player.service.SettingsService;
import org.directwebremoting.WebContextFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
@ -43,14 +45,22 @@ import java.util.*;
*
* @author Sindre Mehus
*/
@Service("ajaxPlaylistService")
public class PlaylistService {
@Autowired
private MediaFileService mediaFileService;
@Autowired
private SecurityService securityService;
@Autowired
private org.airsonic.player.service.PlaylistService playlistService;
@Autowired
private MediaFileDao mediaFileDao;
@Autowired
private SettingsService settingsService;
@Autowired
private PlayerService playerService;
@Autowired
private LocaleResolver localeResolver;
public List<Playlist> getReadablePlaylists() {

@ -26,6 +26,8 @@ import org.directwebremoting.WebContext;
import org.directwebremoting.WebContextFactory;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
/**
* Provides AJAX-enabled services for starring.
@ -34,11 +36,14 @@ import org.slf4j.LoggerFactory;
*
* @author Sindre Mehus
*/
@Service("ajaxStarService")
public class StarService {
private static final Logger LOG = LoggerFactory.getLogger(StarService.class);
@Autowired
private SecurityService securityService;
@Autowired
private MediaFileDao mediaFileDao;
public void star(int id) {

@ -29,6 +29,8 @@ import org.apache.commons.lang.ObjectUtils;
import org.apache.commons.lang.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
/**
* Provides AJAX-enabled services for editing tags in music files.
@ -36,11 +38,14 @@ import org.slf4j.LoggerFactory;
*
* @author Sindre Mehus
*/
@Service("ajaxTagService")
public class TagService {
private static final Logger LOG = LoggerFactory.getLogger(TagService.class);
@Autowired
private MetaDataParserFactory metaDataParserFactory;
@Autowired
private MediaFileService mediaFileService;
/**

@ -22,15 +22,16 @@ package org.airsonic.player.ajax;
import org.airsonic.player.controller.UploadController;
import org.airsonic.player.domain.TransferStatus;
import org.directwebremoting.WebContextFactory;
import org.springframework.stereotype.Service;
import javax.servlet.http.HttpSession;
/**
* Provides AJAX-enabled services for retrieving the status of ongoing transfers.
* This class is used by the DWR framework (http://getahead.ltd.uk/dwr/).
*
* @author Sindre Mehus
*/
@Service("ajaxTransferService")
public class TransferService {
/**

@ -22,6 +22,8 @@ package org.airsonic.player.i18n;
import org.airsonic.player.domain.UserSettings;
import org.airsonic.player.service.SecurityService;
import org.airsonic.player.service.SettingsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
@ -30,15 +32,17 @@ import java.util.Arrays;
import java.util.HashSet;
import java.util.Locale;
import java.util.Set;
/**
* Locale resolver implementation which returns the locale selected in the settings.
*
* @author Sindre Mehus
*/
@Service
public class LocaleResolver implements org.springframework.web.servlet.LocaleResolver {
@Autowired
private SecurityService securityService;
@Autowired
private SettingsService settingsService;
private Set<Locale> locales;

@ -4,12 +4,14 @@ import com.codahale.metrics.JmxReporter;
import com.codahale.metrics.MetricRegistry;
import org.airsonic.player.service.ApacheCommonsConfigurationService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.concurrent.TimeUnit;
/**
* Created by remi on 17/01/17.
*/
@Service
public class MetricsManager {
@Autowired

@ -11,11 +11,14 @@
<!-- DAO's -->
<context:component-scan base-package="org.airsonic.player.dao" />
<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 -->
<context:component-scan base-package="org.airsonic.player.service" />
<bean id="metaDataParserFactory" class="org.airsonic.player.service.metadata.MetaDataParserFactory">
<property name="parsers">
<list>
@ -25,75 +28,7 @@
</list>
</property>
</bean>
<bean id="metricsManager" class="org.airsonic.player.monitor.MetricsManager"></bean>
<!-- AJAX services -->
<bean id="ajaxMultiService" class="org.airsonic.player.ajax.MultiService">
<property name="mediaFileService" ref="mediaFileService"/>
<property name="settingsService" ref="settingsService"/>
<property name="securityService" ref="securityService"/>
<property name="lastFmService" ref="lastFmService"/>
</bean>
<bean id="ajaxNowPlayingService" class="org.airsonic.player.ajax.NowPlayingService">
<property name="playerService" ref="playerService"/>
<property name="statusService" ref="statusService"/>
<property name="settingsService" ref="settingsService"/>
<property name="mediaScannerService" ref="mediaScannerService"/>
</bean>
<bean id="ajaxPlayQueueService" class="org.airsonic.player.ajax.PlayQueueService">
<property name="playerService" ref="playerService"/>
<property name="playlistService" ref="playlistService"/>
<property name="mediaFileService" ref="mediaFileService"/>
<property name="lastFmService" ref="lastFmService"/>
<property name="mediaFileDao" ref="mediaFileDao"/>
<property name="playQueueDao" ref="playQueueDao"/>
<property name="jukeboxService" ref="jukeboxService"/>
<property name="transcodingService" ref="transcodingService"/>
<property name="settingsService" ref="settingsService"/>
<property name="searchService" ref="searchService"/>
<property name="ratingService" ref="ratingService"/>
<property name="securityService" ref="securityService"/>
<property name="podcastService" ref="podcastService"/>
<property name="jwtSecurityService" ref="jwtSecurityService" />
</bean>
<bean id="ajaxPlaylistService" class="org.airsonic.player.ajax.PlaylistService">
<property name="playlistService" ref="playlistService"/>
<property name="securityService" ref="securityService"/>
<property name="settingsService" ref="settingsService"/>
<property name="mediaFileService" ref="mediaFileService"/>
<property name="playerService" ref="playerService"/>
<property name="mediaFileDao" ref="mediaFileDao"/>
<property name="localeResolver" ref="localeResolver"/>
</bean>
<bean id="ajaxLyricsService" class="org.airsonic.player.ajax.LyricsService"/>
<bean id="ajaxCoverArtService" class="org.airsonic.player.ajax.CoverArtService">
<property name="securityService" ref="securityService"/>
<property name="mediaFileService" ref="mediaFileService"/>
<property name="lastFmService" ref="lastFmService"/>
</bean>
<bean id="ajaxStarService" class="org.airsonic.player.ajax.StarService">
<property name="securityService" ref="securityService"/>
<property name="mediaFileDao" ref="mediaFileDao"/>
</bean>
<bean id="ajaxTagService" class="org.airsonic.player.ajax.TagService">
<property name="mediaFileService" ref="mediaFileService"/>
<property name="metaDataParserFactory" ref="metaDataParserFactory"/>
</bean>
<bean id="ajaxTransferService" class="org.airsonic.player.ajax.TransferService"/>
<bean id="localeResolver" class="org.airsonic.player.i18n.LocaleResolver">
<property name="securityService" ref="securityService"/>
<property name="settingsService" ref="settingsService"/>
</bean>
</beans>

Loading…
Cancel
Save