Extract ApiServices from PlanSystem
This commit is contained in:
parent
b7344f833e
commit
0e0a19c0bc
|
@ -0,0 +1,119 @@
|
|||
/*
|
||||
* This file is part of Player Analytics (Plan).
|
||||
*
|
||||
* Plan is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License v3 as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Plan is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Plan. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.djrapitops.plan;
|
||||
|
||||
import com.djrapitops.plan.component.ComponentSvc;
|
||||
import com.djrapitops.plan.delivery.web.ResolverSvc;
|
||||
import com.djrapitops.plan.delivery.web.ResourceSvc;
|
||||
import com.djrapitops.plan.extension.ExtensionSvc;
|
||||
import com.djrapitops.plan.query.QuerySvc;
|
||||
import com.djrapitops.plan.settings.ListenerSvc;
|
||||
import com.djrapitops.plan.settings.SchedulerSvc;
|
||||
import com.djrapitops.plan.settings.SettingsSvc;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import javax.inject.Singleton;
|
||||
|
||||
/**
|
||||
* Breaks up {@link PlanSystem} to be a smaller class.
|
||||
*
|
||||
* @author AuroraLS3
|
||||
*/
|
||||
@Singleton
|
||||
public class ApiServices {
|
||||
|
||||
private final ComponentSvc componentService;
|
||||
private final ResolverSvc resolverService;
|
||||
private final ResourceSvc resourceService;
|
||||
private final ExtensionSvc extensionService;
|
||||
private final QuerySvc queryService;
|
||||
private final ListenerSvc listenerService;
|
||||
private final SettingsSvc settingsService;
|
||||
private final SchedulerSvc schedulerService;
|
||||
|
||||
@Inject
|
||||
public ApiServices(
|
||||
ComponentSvc componentService,
|
||||
ResolverSvc resolverService,
|
||||
ResourceSvc resourceService,
|
||||
ExtensionSvc extensionService,
|
||||
QuerySvc queryService,
|
||||
ListenerSvc listenerService,
|
||||
SettingsSvc settingsService,
|
||||
SchedulerSvc schedulerService
|
||||
) {
|
||||
this.componentService = componentService;
|
||||
this.resolverService = resolverService;
|
||||
this.resourceService = resourceService;
|
||||
this.extensionService = extensionService;
|
||||
this.queryService = queryService;
|
||||
this.listenerService = listenerService;
|
||||
this.settingsService = settingsService;
|
||||
this.schedulerService = schedulerService;
|
||||
}
|
||||
|
||||
public void register() {
|
||||
extensionService.register();
|
||||
componentService.register();
|
||||
resolverService.register();
|
||||
resourceService.register();
|
||||
listenerService.register();
|
||||
settingsService.register();
|
||||
schedulerService.register();
|
||||
queryService.register();
|
||||
}
|
||||
|
||||
public void registerExtensions() {
|
||||
extensionService.registerExtensions();
|
||||
}
|
||||
|
||||
public void disableExtensionDataUpdates() {
|
||||
extensionService.disableUpdates();
|
||||
}
|
||||
|
||||
public ComponentSvc getComponentService() {
|
||||
return componentService;
|
||||
}
|
||||
|
||||
public ResolverSvc getResolverService() {
|
||||
return resolverService;
|
||||
}
|
||||
|
||||
public ResourceSvc getResourceService() {
|
||||
return resourceService;
|
||||
}
|
||||
|
||||
public ExtensionSvc getExtensionService() {
|
||||
return extensionService;
|
||||
}
|
||||
|
||||
public QuerySvc getQueryService() {
|
||||
return queryService;
|
||||
}
|
||||
|
||||
public ListenerSvc getListenerService() {
|
||||
return listenerService;
|
||||
}
|
||||
|
||||
public SettingsSvc getSettingsService() {
|
||||
return settingsService;
|
||||
}
|
||||
|
||||
public SchedulerSvc getSchedulerService() {
|
||||
return schedulerService;
|
||||
}
|
||||
}
|
|
@ -17,25 +17,17 @@
|
|||
package com.djrapitops.plan;
|
||||
|
||||
import com.djrapitops.plan.api.PlanAPI;
|
||||
import com.djrapitops.plan.component.ComponentSvc;
|
||||
import com.djrapitops.plan.delivery.DeliveryUtilities;
|
||||
import com.djrapitops.plan.delivery.export.ExportSystem;
|
||||
import com.djrapitops.plan.delivery.formatting.Formatters;
|
||||
import com.djrapitops.plan.delivery.web.ResolverSvc;
|
||||
import com.djrapitops.plan.delivery.web.ResourceSvc;
|
||||
import com.djrapitops.plan.delivery.webserver.NonProxyWebserverDisableChecker;
|
||||
import com.djrapitops.plan.delivery.webserver.WebServerSystem;
|
||||
import com.djrapitops.plan.extension.ExtensionSvc;
|
||||
import com.djrapitops.plan.gathering.cache.CacheSystem;
|
||||
import com.djrapitops.plan.gathering.importing.ImportSystem;
|
||||
import com.djrapitops.plan.gathering.listeners.ListenerSystem;
|
||||
import com.djrapitops.plan.identification.ServerInfo;
|
||||
import com.djrapitops.plan.processing.Processing;
|
||||
import com.djrapitops.plan.query.QuerySvc;
|
||||
import com.djrapitops.plan.settings.ConfigSystem;
|
||||
import com.djrapitops.plan.settings.ListenerSvc;
|
||||
import com.djrapitops.plan.settings.SchedulerSvc;
|
||||
import com.djrapitops.plan.settings.SettingsSvc;
|
||||
import com.djrapitops.plan.settings.locale.LocaleSystem;
|
||||
import com.djrapitops.plan.storage.database.DBSystem;
|
||||
import com.djrapitops.plan.storage.file.PlanFiles;
|
||||
|
@ -77,14 +69,7 @@ public class PlanSystem implements SubSystem {
|
|||
private final ImportSystem importSystem;
|
||||
private final ExportSystem exportSystem;
|
||||
private final DeliveryUtilities deliveryUtilities;
|
||||
private final ComponentSvc componentService;
|
||||
private final ResolverSvc resolverService;
|
||||
private final ResourceSvc resourceService;
|
||||
private final ExtensionSvc extensionService;
|
||||
private final QuerySvc queryService;
|
||||
private final ListenerSvc listenerService;
|
||||
private final SettingsSvc settingsService;
|
||||
private final SchedulerSvc schedulerService;
|
||||
private final ApiServices apiServices;
|
||||
private final PluginLogger logger;
|
||||
private final ErrorLogger errorLogger;
|
||||
|
||||
|
@ -104,16 +89,9 @@ public class PlanSystem implements SubSystem {
|
|||
ImportSystem importSystem,
|
||||
ExportSystem exportSystem,
|
||||
DeliveryUtilities deliveryUtilities,
|
||||
ComponentSvc componentService,
|
||||
ResolverSvc resolverService,
|
||||
ResourceSvc resourceService,
|
||||
ExtensionSvc extensionService,
|
||||
QuerySvc queryService,
|
||||
ListenerSvc listenerService,
|
||||
SettingsSvc settingsService,
|
||||
SchedulerSvc schedulerService,
|
||||
PluginLogger logger,
|
||||
ErrorLogger errorLogger,
|
||||
ApiServices apiServices, // API v5
|
||||
@SuppressWarnings("deprecation") PlanAPI.PlanAPIHolder apiHolder // Deprecated PlanAPI, backwards compatibility
|
||||
) {
|
||||
this.files = files;
|
||||
|
@ -130,16 +108,9 @@ public class PlanSystem implements SubSystem {
|
|||
this.importSystem = importSystem;
|
||||
this.exportSystem = exportSystem;
|
||||
this.deliveryUtilities = deliveryUtilities;
|
||||
this.componentService = componentService;
|
||||
this.resolverService = resolverService;
|
||||
this.resourceService = resourceService;
|
||||
this.extensionService = extensionService;
|
||||
this.queryService = queryService;
|
||||
this.listenerService = listenerService;
|
||||
this.settingsService = settingsService;
|
||||
this.schedulerService = schedulerService;
|
||||
this.logger = logger;
|
||||
this.errorLogger = errorLogger;
|
||||
this.apiServices = apiServices;
|
||||
|
||||
logger.info("§2");
|
||||
logger.info("§2 ██▌");
|
||||
|
@ -162,14 +133,7 @@ public class PlanSystem implements SubSystem {
|
|||
* Enables the rest of the systems that are not enabled in {@link #enableForCommands()}.
|
||||
*/
|
||||
public void enableOtherThanCommands() {
|
||||
extensionService.register();
|
||||
componentService.register();
|
||||
resolverService.register();
|
||||
resourceService.register();
|
||||
listenerService.register();
|
||||
settingsService.register();
|
||||
schedulerService.register();
|
||||
queryService.register();
|
||||
apiServices.register();
|
||||
|
||||
enableSystems(
|
||||
processing,
|
||||
|
@ -193,7 +157,7 @@ public class PlanSystem implements SubSystem {
|
|||
));
|
||||
}
|
||||
|
||||
extensionService.registerExtensions();
|
||||
apiServices.registerExtensions();
|
||||
enabled = true;
|
||||
|
||||
String javaVersion = System.getProperty("java.specification.version");
|
||||
|
@ -223,7 +187,7 @@ public class PlanSystem implements SubSystem {
|
|||
enabled = false;
|
||||
Formatters.clearSingleton();
|
||||
|
||||
extensionService.disableUpdates();
|
||||
apiServices.disableExtensionDataUpdates();
|
||||
|
||||
disableSystems(
|
||||
taskSystem,
|
||||
|
@ -316,12 +280,8 @@ public class PlanSystem implements SubSystem {
|
|||
return enabled;
|
||||
}
|
||||
|
||||
public ExtensionSvc getExtensionService() {
|
||||
return extensionService;
|
||||
}
|
||||
|
||||
public ComponentSvc getComponentService() {
|
||||
return componentService;
|
||||
public ApiServices getApiServices() {
|
||||
return apiServices;
|
||||
}
|
||||
|
||||
public static long getServerEnableTime() {
|
||||
|
|
|
@ -201,7 +201,7 @@ class AccessControlTest {
|
|||
address,
|
||||
TestConstants.VERSION)));
|
||||
|
||||
Caller caller = system.getExtensionService().register(new ExtensionsDatabaseTest.PlayerExtension())
|
||||
Caller caller = system.getApiServices().getExtensionService().register(new ExtensionsDatabaseTest.PlayerExtension())
|
||||
.orElseThrow(AssertionError::new);
|
||||
caller.updatePlayerData(TestConstants.PLAYER_ONE_UUID, TestConstants.PLAYER_ONE_NAME);
|
||||
|
||||
|
|
|
@ -70,7 +70,7 @@ class HttpAccessControlTest {
|
|||
ADDRESS,
|
||||
TestConstants.VERSION)));
|
||||
|
||||
Caller caller = system.getExtensionService().register(new ExtensionsDatabaseTest.PlayerExtension())
|
||||
Caller caller = system.getApiServices().getExtensionService().register(new ExtensionsDatabaseTest.PlayerExtension())
|
||||
.orElseThrow(AssertionError::new);
|
||||
caller.updatePlayerData(TestConstants.PLAYER_ONE_UUID, TestConstants.PLAYER_ONE_NAME);
|
||||
|
||||
|
|
|
@ -64,9 +64,9 @@ public interface DatabaseTestPreparer {
|
|||
return system().getDeliveryUtilities();
|
||||
}
|
||||
|
||||
default ExtensionSvc extensionService() {return system().getExtensionService();}
|
||||
default ExtensionSvc extensionService() {return system().getApiServices().getExtensionService();}
|
||||
|
||||
default ComponentSvc componentService() {return system().getComponentService();}
|
||||
default ComponentSvc componentService() {return system().getApiServices().getComponentService();}
|
||||
|
||||
QueryFilters queryFilters();
|
||||
|
||||
|
|
Loading…
Reference in New Issue