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

@ -33,6 +33,7 @@ import org.jdom.Namespace;
import org.jdom.input.SAXBuilder; import org.jdom.input.SAXBuilder;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;
import java.io.IOException; import java.io.IOException;
import java.io.StringReader; import java.io.StringReader;
@ -47,6 +48,7 @@ import java.net.SocketException;
* *
* @author Sindre Mehus * @author Sindre Mehus
*/ */
@Service("ajaxLyricsService")
public class LyricsService { public class LyricsService {
private static final Logger LOG = LoggerFactory.getLogger(LyricsService.class); 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.directwebremoting.WebContextFactory;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
@ -45,13 +47,18 @@ import java.util.List;
* *
* @author Sindre Mehus * @author Sindre Mehus
*/ */
@Service("ajaxMultiService")
public class MultiService { public class MultiService {
private static final Logger LOG = LoggerFactory.getLogger(MultiService.class); private static final Logger LOG = LoggerFactory.getLogger(MultiService.class);
@Autowired
private MediaFileService mediaFileService; private MediaFileService mediaFileService;
@Autowired
private LastFmService lastFmService; private LastFmService lastFmService;
@Autowired
private SecurityService securityService; private SecurityService securityService;
@Autowired
private SettingsService settingsService; private SettingsService settingsService;
public ArtistInfo getArtistInfo(int mediaFileId, int maxSimilarArtists, int maxTopSongs) { public ArtistInfo getArtistInfo(int mediaFileId, int maxSimilarArtists, int maxTopSongs) {

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

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

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

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

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

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

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

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

@ -11,11 +11,14 @@
<!-- DAO's --> <!-- 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 --> <!-- Services -->
<context:component-scan base-package="org.airsonic.player.service" />
<bean id="metaDataParserFactory" class="org.airsonic.player.service.metadata.MetaDataParserFactory"> <bean id="metaDataParserFactory" class="org.airsonic.player.service.metadata.MetaDataParserFactory">
<property name="parsers"> <property name="parsers">
<list> <list>
@ -25,75 +28,7 @@
</list> </list>
</property> </property>
</bean> </bean>
<bean id="metricsManager" class="org.airsonic.player.monitor.MetricsManager"></bean>
<!-- AJAX services --> <!-- 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> </beans>

Loading…
Cancel
Save