CB-422 AWS common service and EC2 metadata discovery

This commit is contained in:
Serge Rider
2020-10-17 16:46:49 +03:00
parent ab30320544
commit 0ad610e854
2 changed files with 43 additions and 1 deletions
@@ -23,7 +23,9 @@ import com.google.gson.stream.JsonWriter;
import io.cloudbeaver.DBWConnectionGrant;
import io.cloudbeaver.DBWSecurityController;
import io.cloudbeaver.WebServiceUtils;
import io.cloudbeaver.registry.WebServiceRegistry;
import io.cloudbeaver.server.jetty.CBJettyServer;
import io.cloudbeaver.service.DBWServiceInitializer;
import org.eclipse.core.runtime.Platform;
import org.eclipse.equinox.app.IApplicationContext;
import org.eclipse.osgi.service.datalocation.Location;
@@ -242,6 +244,17 @@ public class CBApplication extends BaseApplicationImpl {
log.debug("\t\t" + ia.getHostAddress() + " (" + ia.getCanonicalHostName() + ")");
}
}
{
// Perform services initialization
for (DBWServiceInitializer wsi : WebServiceRegistry.getInstance().getWebServices(DBWServiceInitializer.class)) {
try {
wsi.initializeService(this);
} catch (Exception e) {
log.warn("Error initializing web service " + wsi.getClass().getName(), e);
}
}
}
{
try {
@@ -278,7 +291,7 @@ public class CBApplication extends BaseApplicationImpl {
try {
InetAddress dockerAddress = InetAddress.getByName(CBConstants.VAR_HOST_DOCKER_INTERNAL);
localInetAddresses.add(dockerAddress);
log.debug("\tRun in Docker container (" + dockerAddress + ")");
log.debug("\tRun in Docker container (" + dockerAddress + ")?");
} catch (UnknownHostException e) {
// Ignore - not a docker env
}
@@ -0,0 +1,29 @@
/*
* DBeaver - Universal Database Manager
* Copyright (C) 2010-2020 DBeaver Corp and others
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.cloudbeaver.service;
import org.jkiss.dbeaver.DBException;
import org.jkiss.dbeaver.model.app.DBPApplication;
/**
* Web service implementation
*/
public interface DBWServiceInitializer extends DBWServiceBinding {
void initializeService(DBPApplication application) throws DBException;
}