Archived
0

Обновление модуля Commons: стандартная команда exit

This commit is contained in:
2016-08-15 22:47:21 +03:00
parent a8b2633f1c
commit cd84b915b3
3 changed files with 42 additions and 5 deletions

View File

@@ -19,20 +19,25 @@
<groupId>asys</groupId>
<artifactId>commons</artifactId>
<version>0.1.3</version>
<version>0.2</version>
<packaging>bundle</packaging>
<dependencies>
<dependency>
<groupId>asys</groupId>
<artifactId>api</artifactId>
<version>0.4</version>
<version>0.7</version>
</dependency>
<dependency>
<groupId>org.osgi</groupId>
<artifactId>org.osgi.core</artifactId>
<version>6.0.0</version>
</dependency>
<dependency>
<groupId>org.apache.felix</groupId>
<artifactId>org.apache.felix.gogo.runtime</artifactId>
<version>0.10.0</version>
</dependency>
</dependencies>
<build>

View File

@@ -4,21 +4,24 @@
*/
package asys.commons;
import asys.api.ASysUtils;
import asys.api.BankObject;
import org.osgi.framework.BundleActivator;
import org.osgi.framework.BundleContext;
import org.osgi.framework.ServiceRegistration;
public class Activator implements BundleActivator {
private ServiceRegistration<?> service;
private ServiceRegistration<?> serviceBankObjects, serviceCmd;
@Override
public void start(BundleContext bundleContext) throws Exception {
service = bundleContext.registerService(BankObject.class.getName(), new SimpleBankObject(), null);
serviceCmd = ASysUtils.RegisterCommands(bundleContext, new Commands(bundleContext.getBundle(0L)), "asys");
serviceBankObjects = bundleContext.registerService(BankObject.class.getName(), new SimpleBankObject(), null);
}
@Override
public void stop(BundleContext bundleContext) throws Exception {
service.unregister();
serviceBankObjects.unregister();
serviceCmd.unregister();
}
}

View File

@@ -0,0 +1,29 @@
/*
* DmitriyMX <mail@dmitriymx.ru>
* 2016-08-15
*/
package asys.commons;
import asys.api.ASysUtils;
import asys.api.Command;
import org.apache.felix.service.command.Descriptor;
import org.osgi.framework.Bundle;
import org.osgi.framework.BundleException;
public class Commands {
private Bundle systemBundle;
public Commands(Bundle systemBundle) {
this.systemBundle = systemBundle;
}
@Command
@Descriptor("Завершить работу платформы ASys")
public void exit() {
try {
ASysUtils.Log("ASys shutdown...");
systemBundle.stop();
} catch (BundleException ignore) {
}
}
}