Archived
0

WebInterface: задействование глобальных настроек ASys

This commit is contained in:
2017-04-29 14:51:42 +03:00
parent 50242ec11f
commit e7305f6371
2 changed files with 10 additions and 2 deletions

View File

@@ -1,5 +1,5 @@
group = 'asys'
version = '0.17-SNAPSHOT'
version = '0.18-SNAPSHOT'
buildscript {
repositories {

View File

@@ -4,10 +4,12 @@
*/
package asys.webinterface;
import asys.api.Config;
import asys.webinterface.api.Webinterface;
import org.osgi.framework.BundleActivator;
import org.osgi.framework.BundleContext;
import org.osgi.framework.ServiceRegistration;
import org.osgi.util.tracker.ServiceTracker;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -18,6 +20,11 @@ public class Activator implements BundleActivator {
@Override
public void start(BundleContext context) throws Exception {
ServiceTracker<?, Config> serviceConfigTracker = new ServiceTracker<>(context, Config.class, null);
serviceConfigTracker.open();
Config config = serviceConfigTracker.getService();
if (config == null) throw new RuntimeException("Service 'Config' is not avalable!");
WebinterfaceImpl webinterface = new WebinterfaceImpl();
webinterface.addModule(new Modules_WebModule(context));
@@ -25,7 +32,8 @@ public class Activator implements BundleActivator {
serviceMainMenu = context.registerService(Webinterface.class, webinterface, null);
webServer = new WebServer(context, webinterface);
webServer.start(8778);
webServer.start(config.getInt("asys.webinterface.port", 8778));
serviceConfigTracker.close();
}
@Override