Работающий прототип расширения веб интерфейса
This commit is contained in:
@@ -16,9 +16,13 @@ import org.slf4j.LoggerFactory;
|
||||
public class Activator implements BundleActivator, ServiceListener {
|
||||
private final Logger logger = LoggerFactory.getLogger(Activator.class);
|
||||
private ServiceTracker<?, Webinterface> serviceTracker;
|
||||
private MCSM_WebModule module;
|
||||
private Webinterface webinterface;
|
||||
|
||||
@Override
|
||||
public void start(BundleContext context) throws Exception {
|
||||
module = new MCSM_WebModule();
|
||||
|
||||
logger.debug("Register service listener");
|
||||
context.addServiceListener(this);
|
||||
|
||||
@@ -28,6 +32,9 @@ public class Activator implements BundleActivator, ServiceListener {
|
||||
|
||||
@Override
|
||||
public void stop(BundleContext context) throws Exception {
|
||||
if (webinterface != null) {
|
||||
webinterface.removeModule(module.getName());
|
||||
}
|
||||
serviceTracker.close();
|
||||
context.removeServiceListener(this);
|
||||
}
|
||||
@@ -40,11 +47,9 @@ public class Activator implements BundleActivator, ServiceListener {
|
||||
if (classStr.equals(Webinterface.class.getCanonicalName())) {
|
||||
try {
|
||||
serviceTracker.open();
|
||||
Webinterface webinterface = serviceTracker.waitForService(5000);
|
||||
webinterface = serviceTracker.waitForService(5000);
|
||||
if (webinterface != null) {
|
||||
webinterface.addMainMenuItem("mcsmanager",
|
||||
"Серверы", "/modules/mcsmanager");
|
||||
return;
|
||||
webinterface.addModule(module);
|
||||
} else {
|
||||
logger.debug("service not found =(");
|
||||
}
|
||||
|
||||
@@ -0,0 +1,44 @@
|
||||
/*
|
||||
* DmitriyMX <mail@dmitriymx.ru>
|
||||
* 2017-03-15
|
||||
*/
|
||||
package asys.mcsmanager;
|
||||
|
||||
import asys.webinterface.api.HttpReqResp;
|
||||
import asys.webinterface.api.WebModule;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class MCSM_WebModule implements WebModule {
|
||||
private final String MODULE_NAME = "mcsmanager";
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return MODULE_NAME;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getStylesheetsLinks() {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getJavaScriptLinks() {
|
||||
return Collections.singletonList("/module/"+MODULE_NAME+"/module.js");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, String> getMainMenuItems() {
|
||||
return new HashMap<String, String>(){{
|
||||
this.put("Серверы", "/module/"+MODULE_NAME);
|
||||
}};
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handle(HttpReqResp httpReqResp) {
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user