Обновление модуля Commons: стандартная команда exit
This commit is contained in:
@@ -19,20 +19,25 @@
|
|||||||
|
|
||||||
<groupId>asys</groupId>
|
<groupId>asys</groupId>
|
||||||
<artifactId>commons</artifactId>
|
<artifactId>commons</artifactId>
|
||||||
<version>0.1.3</version>
|
<version>0.2</version>
|
||||||
<packaging>bundle</packaging>
|
<packaging>bundle</packaging>
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>asys</groupId>
|
<groupId>asys</groupId>
|
||||||
<artifactId>api</artifactId>
|
<artifactId>api</artifactId>
|
||||||
<version>0.4</version>
|
<version>0.7</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.osgi</groupId>
|
<groupId>org.osgi</groupId>
|
||||||
<artifactId>org.osgi.core</artifactId>
|
<artifactId>org.osgi.core</artifactId>
|
||||||
<version>6.0.0</version>
|
<version>6.0.0</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.apache.felix</groupId>
|
||||||
|
<artifactId>org.apache.felix.gogo.runtime</artifactId>
|
||||||
|
<version>0.10.0</version>
|
||||||
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
<build>
|
<build>
|
||||||
|
|||||||
@@ -4,21 +4,24 @@
|
|||||||
*/
|
*/
|
||||||
package asys.commons;
|
package asys.commons;
|
||||||
|
|
||||||
|
import asys.api.ASysUtils;
|
||||||
import asys.api.BankObject;
|
import asys.api.BankObject;
|
||||||
import org.osgi.framework.BundleActivator;
|
import org.osgi.framework.BundleActivator;
|
||||||
import org.osgi.framework.BundleContext;
|
import org.osgi.framework.BundleContext;
|
||||||
import org.osgi.framework.ServiceRegistration;
|
import org.osgi.framework.ServiceRegistration;
|
||||||
|
|
||||||
public class Activator implements BundleActivator {
|
public class Activator implements BundleActivator {
|
||||||
private ServiceRegistration<?> service;
|
private ServiceRegistration<?> serviceBankObjects, serviceCmd;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void start(BundleContext bundleContext) throws Exception {
|
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
|
@Override
|
||||||
public void stop(BundleContext bundleContext) throws Exception {
|
public void stop(BundleContext bundleContext) throws Exception {
|
||||||
service.unregister();
|
serviceBankObjects.unregister();
|
||||||
|
serviceCmd.unregister();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
29
Commons/src/main/java/asys/commons/Commands.java
Normal file
29
Commons/src/main/java/asys/commons/Commands.java
Normal 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) {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user