mirror of
https://github.com/dbeaver/cloudbeaver.git
synced 2026-09-24 16:04:36 +08:00
dbeaver/pro#5915 Delete legacy name service API usage + code style (#3510)
This commit is contained in:
+1
-1
@@ -55,9 +55,9 @@ public abstract class BaseServerConfigurationController<T extends ServletServerC
|
||||
@NotNull
|
||||
protected abstract GsonBuilder getGsonBuilder();
|
||||
|
||||
@NotNull
|
||||
public abstract T getServerConfiguration();
|
||||
|
||||
|
||||
@NotNull
|
||||
protected synchronized Path initWorkspacePath() {
|
||||
Path defaultWorkspaceLocation = homeDirectory.resolve("workspace");
|
||||
|
||||
+7
-35
@@ -26,7 +26,6 @@ import io.cloudbeaver.model.app.ServletAuthConfiguration;
|
||||
import io.cloudbeaver.model.app.ServletSystemInformationCollector;
|
||||
import io.cloudbeaver.model.config.CBAppConfig;
|
||||
import io.cloudbeaver.model.config.CBServerConfig;
|
||||
import io.cloudbeaver.model.config.SMControllerConfiguration;
|
||||
import io.cloudbeaver.registry.WebDriverRegistry;
|
||||
import io.cloudbeaver.registry.WebServiceRegistry;
|
||||
import io.cloudbeaver.server.jetty.CBJettyServer;
|
||||
@@ -76,8 +75,9 @@ import java.util.concurrent.ConcurrentHashMap;
|
||||
/**
|
||||
* This class controls all aspects of the application's execution
|
||||
*/
|
||||
public abstract class CBApplication<T extends CBServerConfig> extends
|
||||
BaseServletApplication implements ServletAuthApplication, WebApplication {
|
||||
public abstract class CBApplication<T extends CBServerConfig>
|
||||
extends BaseServletApplication
|
||||
implements ServletAuthApplication, WebApplication {
|
||||
|
||||
private static final Log log = Log.getLog(CBApplication.class);
|
||||
|
||||
@@ -93,8 +93,8 @@ public abstract class CBApplication<T extends CBServerConfig> extends
|
||||
}
|
||||
|
||||
|
||||
public static CBApplication getInstance() {
|
||||
return (CBApplication) BaseApplicationImpl.getInstance();
|
||||
public static CBApplication<?> getInstance() {
|
||||
return (CBApplication<?>) BaseApplicationImpl.getInstance();
|
||||
}
|
||||
|
||||
private final File homeDirectory;
|
||||
@@ -111,7 +111,7 @@ public abstract class CBApplication<T extends CBServerConfig> extends
|
||||
private CBSessionManager sessionManager;
|
||||
|
||||
private final Map<String, String> initActions = new ConcurrentHashMap<>();
|
||||
private ServletSystemInformationCollector systemInformationCollector;
|
||||
private ServletSystemInformationCollector<?> systemInformationCollector;
|
||||
|
||||
private CBJettyServer jettyServer;
|
||||
|
||||
@@ -188,14 +188,11 @@ public abstract class CBApplication<T extends CBServerConfig> extends
|
||||
return getServerConfigurationController().getAuthServiceURL();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public Map<String, Object> getProductConfiguration() {
|
||||
return getServerConfigurationController().getProductConfiguration();
|
||||
}
|
||||
|
||||
public SMControllerConfiguration getSecurityManagerConfiguration() {
|
||||
return getServerConfiguration().getSecurityManagerConfiguration();
|
||||
}
|
||||
|
||||
public SMAdminController getSecurityController() {
|
||||
return securityController;
|
||||
}
|
||||
@@ -231,9 +228,6 @@ public abstract class CBApplication<T extends CBServerConfig> extends
|
||||
localHostAddress = CBConstants.HOST_LOCALHOST;
|
||||
}
|
||||
|
||||
final Runtime runtime = Runtime.getRuntime();
|
||||
initializeAdditionalConfiguration();
|
||||
|
||||
Location instanceLoc = Platform.getInstanceLocation();
|
||||
try {
|
||||
if (!instanceLoc.isSet()) { // always false?
|
||||
@@ -335,23 +329,15 @@ public abstract class CBApplication<T extends CBServerConfig> extends
|
||||
runWebServer();
|
||||
|
||||
log.debug("Shutdown");
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
protected ServletSystemInformationCollector<?> createSystemInformationCollector() {
|
||||
return new ServletSystemInformationCollector<>(this);
|
||||
}
|
||||
|
||||
protected void initializeAdditionalConfiguration() {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Configures server automatically.
|
||||
* Called on startup
|
||||
*
|
||||
* @param configPath
|
||||
*/
|
||||
protected void performAutoConfiguration(Path configPath) {
|
||||
String autoServerName = System.getenv(CBConstants.VAR_AUTO_CB_SERVER_NAME);
|
||||
@@ -417,11 +403,6 @@ public abstract class CBApplication<T extends CBServerConfig> extends
|
||||
|
||||
private void determineLocalAddresses() {
|
||||
try {
|
||||
// InetAddress localHost = InetAddress.getLocalHost();
|
||||
// InetAddress[] allMyIps = InetAddress.getAllByName(localHost.getCanonicalHostName());
|
||||
// for (InetAddress addr : allMyIps) {
|
||||
// System.out.println("Local addr: " + addr);
|
||||
// }
|
||||
try {
|
||||
InetAddress dockerAddress = InetAddress.getByName(CBConstants.VAR_HOST_DOCKER_INTERNAL);
|
||||
localInetAddresses.add(dockerAddress);
|
||||
@@ -524,15 +505,6 @@ public abstract class CBApplication<T extends CBServerConfig> extends
|
||||
return localHostAddress;
|
||||
}
|
||||
|
||||
public boolean isLocalInetAddress(String hostName) {
|
||||
for (InetAddress addr : localInetAddresses) {
|
||||
if (addr.getHostAddress().equals(hostName)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public List<InetAddress> getLocalInetAddresses() {
|
||||
return localInetAddresses;
|
||||
}
|
||||
|
||||
+7
-12
@@ -355,7 +355,7 @@ public abstract class CBServerConfigurationController<T extends CBServerConfig>
|
||||
protected synchronized void saveRuntimeConfig(
|
||||
@NotNull CBServerConfig serverConfig,
|
||||
@NotNull CBAppConfig appConfig,
|
||||
SMCredentialsProvider credentialsProvider
|
||||
@Nullable SMCredentialsProvider credentialsProvider
|
||||
) throws DBException {
|
||||
if (serverConfig.getServerName() == null) {
|
||||
throw new DBException("Invalid server configuration, server name cannot be empty");
|
||||
@@ -493,18 +493,12 @@ public abstract class CBServerConfigurationController<T extends CBServerConfig>
|
||||
navigatorProperties.put("hideVirtualModel", navSettings.isHideVirtualModel());
|
||||
}
|
||||
}
|
||||
if (appConfig.getEnabledFeatures() != null) {
|
||||
appConfigProperties.put("enabledFeatures", Arrays.asList(appConfig.getEnabledFeatures()));
|
||||
}
|
||||
appConfigProperties.put("enabledFeatures", Arrays.asList(appConfig.getEnabledFeatures()));
|
||||
if (appConfig.getEnabledAuthProviders() != null) {
|
||||
appConfigProperties.put("enabledAuthProviders", Arrays.asList(appConfig.getEnabledAuthProviders()));
|
||||
}
|
||||
if (appConfig.getEnabledDrivers() != null) {
|
||||
appConfigProperties.put("enabledDrivers", Arrays.asList(appConfig.getEnabledDrivers()));
|
||||
}
|
||||
if (appConfig.getDisabledDrivers() != null) {
|
||||
appConfigProperties.put("disabledDrivers", Arrays.asList(appConfig.getDisabledDrivers()));
|
||||
}
|
||||
appConfigProperties.put("enabledDrivers", Arrays.asList(appConfig.getEnabledDrivers()));
|
||||
appConfigProperties.put("disabledDrivers", Arrays.asList(appConfig.getDisabledDrivers()));
|
||||
|
||||
if (!CommonUtils.isEmpty(appConfig.getPlugins())) {
|
||||
appConfigProperties.put("plugins", appConfig.getPlugins());
|
||||
@@ -586,7 +580,7 @@ public abstract class CBServerConfigurationController<T extends CBServerConfig>
|
||||
Map<String, Object> subValue = new LinkedHashMap<>();
|
||||
Map<String, Object> oldConfigValue = JSONUtils.getObject(oldConfig, key);
|
||||
for (Map.Entry<String, Object> entry : oldConfigValue.entrySet()) {
|
||||
copyConfigValue(oldConfigValue, subValue, entry.getKey(), ((Map) defaultValue).get(entry.getKey()));
|
||||
copyConfigValue(oldConfigValue, subValue, entry.getKey(), ((Map<?,?>) defaultValue).get(entry.getKey()));
|
||||
}
|
||||
newConfig.put(key, subValue);
|
||||
} else {
|
||||
@@ -618,13 +612,14 @@ public abstract class CBServerConfigurationController<T extends CBServerConfig>
|
||||
return dataDir;
|
||||
}
|
||||
|
||||
public void saveProductConfiguration(Map<String, Object> productConfiguration) throws DBException {
|
||||
public void saveProductConfiguration(Map<String, Object> productConfiguration) {
|
||||
Map<String, Object> productSettings = getServerConfiguration().getProductSettings();
|
||||
Map<String, Object> mergedConfig = ServletAppUtils.mergeConfigurations(productSettings, productConfiguration);
|
||||
productSettings.clear();
|
||||
productSettings.putAll(ServletAppUtils.flattenMap(mergedConfig));
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public T getServerConfiguration() {
|
||||
return serverConfiguration;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user