diff --git a/API/pom.xml b/API/pom.xml index cb6d68f..aa451d1 100644 --- a/API/pom.xml +++ b/API/pom.xml @@ -19,7 +19,7 @@ asys api - 0.1 + 0.2 bundle diff --git a/API/src/main/java/asys/api/BankObject.java b/API/src/main/java/asys/api/BankObject.java new file mode 100644 index 0000000..65ef46f --- /dev/null +++ b/API/src/main/java/asys/api/BankObject.java @@ -0,0 +1,10 @@ +/* + * DmitriyMX + * 2016-08-15 + */ +package asys.api; + +public interface BankObject { + Object get(String name); + void set(String name, Object object); +} diff --git a/Commons/pom.xml b/Commons/pom.xml new file mode 100644 index 0000000..3a24ba3 --- /dev/null +++ b/Commons/pom.xml @@ -0,0 +1,67 @@ + + + 4.0.0 + ASys Commons + + + + DmitriyMX + mail@dmiriymx.ru + + + + + UTF-8 + 1.8 + + + asys + commons + 0.1.2 + bundle + + + + asys + api + 0.2 + + + org.osgi + org.osgi.core + 6.0.0 + + + + + ${project.groupId}.${project.artifactId}-${project.version} + + + org.apache.maven.plugins + maven-compiler-plugin + 3.5.1 + + ${java.version} + ${java.version} + ${project.build.sourceEncoding} + + + + org.apache.felix + maven-bundle-plugin + 3.0.1 + true + + + ${project.name} + ${project.groupId}.${project.artifactId} + asys.commons.Activator + asys.api, * + + + + + + \ No newline at end of file diff --git a/Commons/src/main/java/asys/commons/Activator.java b/Commons/src/main/java/asys/commons/Activator.java new file mode 100644 index 0000000..3b320f6 --- /dev/null +++ b/Commons/src/main/java/asys/commons/Activator.java @@ -0,0 +1,24 @@ +/* + * DmitriyMX + * 2016-08-15 + */ +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 service; + + @Override + public void start(BundleContext bundleContext) throws Exception { + service = bundleContext.registerService(BankObject.class.getName(), new SimpleBankObject(), null); + } + + @Override + public void stop(BundleContext bundleContext) throws Exception { + service.unregister(); + } +} diff --git a/Commons/src/main/java/asys/commons/SimpleBankObject.java b/Commons/src/main/java/asys/commons/SimpleBankObject.java new file mode 100644 index 0000000..bed10ab --- /dev/null +++ b/Commons/src/main/java/asys/commons/SimpleBankObject.java @@ -0,0 +1,22 @@ +/* + * DmitriyMX + * 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 bank = new HashMap<>(); + + public Object get(String name) { + return bank.remove(name); + } + + public void set(String name, Object object) { + bank.put(name, object); + } +}