Commons module
This commit is contained in:
15
commons/build.gradle
Normal file
15
commons/build.gradle
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
group = 'asys'
|
||||||
|
version = '0.0-SNAPSHOT'
|
||||||
|
|
||||||
|
apply plugin: 'osgi'
|
||||||
|
|
||||||
|
jar {
|
||||||
|
manifest {
|
||||||
|
name = 'ASys Commons'
|
||||||
|
instruction 'Bundle-Activator', 'asys.commons.Activator'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
dependencies {
|
||||||
|
compile project(':core')
|
||||||
|
}
|
||||||
24
commons/src/main/java/asys/commons/Activator.java
Normal file
24
commons/src/main/java/asys/commons/Activator.java
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
/*
|
||||||
|
* DmitriyMX <mail@dmitriymx.ru>
|
||||||
|
* 2016-12-05
|
||||||
|
*/
|
||||||
|
package asys.commons;
|
||||||
|
|
||||||
|
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<?> serviceBankObjects;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void start(BundleContext context) throws Exception {
|
||||||
|
serviceBankObjects = context.registerService(BankObject.class.getName(), new SimpleBankObject(), null);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void stop(BundleContext context) throws Exception {
|
||||||
|
serviceBankObjects.unregister();
|
||||||
|
}
|
||||||
|
}
|
||||||
22
commons/src/main/java/asys/commons/SimpleBankObject.java
Normal file
22
commons/src/main/java/asys/commons/SimpleBankObject.java
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
/*
|
||||||
|
* DmitriyMX <mail@dmitriymx.ru>
|
||||||
|
* 2016-08-15
|
||||||
|
*/
|
||||||
|
package asys.commons;
|
||||||
|
|
||||||
|
import asys.api.BankObject;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
public class SimpleBankObject implements BankObject {
|
||||||
|
private Map<String, Object> bank = new HashMap<>();
|
||||||
|
|
||||||
|
public Object get(String name) {
|
||||||
|
return bank.remove(name);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void save(String name, Object object) {
|
||||||
|
bank.put(name, object);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,2 +1,3 @@
|
|||||||
rootProject.name = 'asys'
|
rootProject.name = 'asys'
|
||||||
include 'core'
|
include 'core'
|
||||||
|
include 'commons'
|
||||||
Reference in New Issue
Block a user