commit caceed005d2b827be0ce3f0cb71b0ef7dba87c04 Author: Bas van den Brink Date: Tue Oct 5 16:08:29 2021 +0200 First working version diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..5cacb94 --- /dev/null +++ b/.gitignore @@ -0,0 +1,5 @@ +generated/ +bin/ +*.iml +.idea/ +cnf/cache/ diff --git a/cnf/build.bnd b/cnf/build.bnd new file mode 100644 index 0000000..159e419 --- /dev/null +++ b/cnf/build.bnd @@ -0,0 +1,10 @@ +-plugin.projectDeps: \ + aQute.bnd.repository.maven.provider.MavenBndRepository; \ + releaseUrl=https://repo.maven.apache.org/maven2/; \ + index=${build}/dependencies.maven; \ + name=Maven dependencies + +-plugin.amdatuRemoteREp:\ + aQute.bnd.repository.osgi.OSGiRepository; \ + name=Amdatu remote; \ + locations=${fileuri;cnf/localrepo/index.xml} \ No newline at end of file diff --git a/cnf/dependencies.maven b/cnf/dependencies.maven new file mode 100644 index 0000000..5096986 --- /dev/null +++ b/cnf/dependencies.maven @@ -0,0 +1,29 @@ +org.osgi:osgi.core:8.0.0 +org.osgi:org.osgi.annotation:6.0.0 +org.osgi:org.osgi.service.component:1.4.0 +org.osgi:org.osgi.service.component.annotations:1.4.0 +org.osgi:org.osgi.util.promise:1.1.1 +org.osgi:org.osgi.util.function:1.1.0 + +org.apache.felix:org.apache.felix.framework:7.0.1 + +org.apache.felix:org.apache.felix.gogo.command:1.1.2 +org.apache.felix:org.apache.felix.gogo.runtime:1.1.4 +org.apache.felix:org.apache.felix.gogo.shell:1.1.4 + +org.apache.felix:org.apache.felix.scr:2.1.28 + +org.apache.felix:org.apache.felix.configadmin:1.9.22 +org.apache.felix:org.apache.felix.configurator:1.0.14 +org.apache.felix:org.apache.felix.cm.json:1.0.6 +org.apache.sling:org.apache.sling.commons.johnzon:1.2.6 +org.apache.felix:org.apache.felix.converter:1.0.18 + +org.apache.felix:org.apache.felix.log:1.2.4 + +org.apache.felix:org.apache.felix.eventadmin:1.6.2 +org.apache.felix:org.apache.felix.metatype:1.2.4 +org.apache.felix:org.apache.felix.dependencymanager:3.2.0 +org.apache.felix:org.apache.felix.http.servlet-api:1.1.2 +org.apache.felix:org.apache.felix.http.jetty:4.1.12 +org.osgi:org.osgi.service.remoteserviceadmin:1.1.0 diff --git a/cnf/localrepo/index.xml b/cnf/localrepo/index.xml new file mode 100644 index 0000000..e75a884 --- /dev/null +++ b/cnf/localrepo/index.xml @@ -0,0 +1,238 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/cnf/localrepo/org.amdatu.remote.admin.http-0.1.3.jar b/cnf/localrepo/org.amdatu.remote.admin.http-0.1.3.jar new file mode 100644 index 0000000..2a5fdde Binary files /dev/null and b/cnf/localrepo/org.amdatu.remote.admin.http-0.1.3.jar differ diff --git a/cnf/localrepo/org.amdatu.remote.discovery.configured-0.1.3.jar b/cnf/localrepo/org.amdatu.remote.discovery.configured-0.1.3.jar new file mode 100644 index 0000000..52971de Binary files /dev/null and b/cnf/localrepo/org.amdatu.remote.discovery.configured-0.1.3.jar differ diff --git a/cnf/localrepo/org.amdatu.remote.topology.promiscuous-0.1.3.jar b/cnf/localrepo/org.amdatu.remote.topology.promiscuous-0.1.3.jar new file mode 100644 index 0000000..c184bf5 Binary files /dev/null and b/cnf/localrepo/org.amdatu.remote.topology.promiscuous-0.1.3.jar differ diff --git a/com.thalesgroup.nl.chat.api/bnd.bnd b/com.thalesgroup.nl.chat.api/bnd.bnd new file mode 100644 index 0000000..4e99128 --- /dev/null +++ b/com.thalesgroup.nl.chat.api/bnd.bnd @@ -0,0 +1,5 @@ +Bundle-Version: 1.0.0 +Export-Package: com.thalesgroup.nl.chat.api + +-buildpath: \ + osgi.annotation \ No newline at end of file diff --git a/com.thalesgroup.nl.chat.api/src/com/thalesgroup/nl/chat/api/Chat.java b/com.thalesgroup.nl.chat.api/src/com/thalesgroup/nl/chat/api/Chat.java new file mode 100644 index 0000000..d1e08f4 --- /dev/null +++ b/com.thalesgroup.nl.chat.api/src/com/thalesgroup/nl/chat/api/Chat.java @@ -0,0 +1,5 @@ +package com.thalesgroup.nl.chat.api; + +public interface Chat { + void sendMessage(String author, String message); +} diff --git a/com.thalesgroup.nl.chat.api/src/com/thalesgroup/nl/chat/api/package-info.java b/com.thalesgroup.nl.chat.api/src/com/thalesgroup/nl/chat/api/package-info.java new file mode 100644 index 0000000..05d585d --- /dev/null +++ b/com.thalesgroup.nl.chat.api/src/com/thalesgroup/nl/chat/api/package-info.java @@ -0,0 +1,4 @@ +@Version("1.0.0") +package com.thalesgroup.nl.chat.api; + +import org.osgi.annotation.versioning.Version; \ No newline at end of file diff --git a/com.thalesgroup.nl.chat.impl/bnd.bnd b/com.thalesgroup.nl.chat.impl/bnd.bnd new file mode 100644 index 0000000..49b2e0a --- /dev/null +++ b/com.thalesgroup.nl.chat.impl/bnd.bnd @@ -0,0 +1,9 @@ +Bundle-Version: 1.0.0 +Private-Package: com.thalesgroup.nl.chat.impl + +-buildpath: \ + osgi.core,\ + org.osgi.service.component,\ + org.osgi.service.component.annotations,\ + org.osgi.service.remoteserviceadmin,\ + com.thalesgroup.nl.chat.api;version=latest \ No newline at end of file diff --git a/com.thalesgroup.nl.chat.impl/run.bndrun b/com.thalesgroup.nl.chat.impl/run.bndrun new file mode 100644 index 0000000..4f956b0 --- /dev/null +++ b/com.thalesgroup.nl.chat.impl/run.bndrun @@ -0,0 +1,35 @@ +-runfw: org.apache.felix.framework + +-runproperties: \ + org.amdatu.remote.discovery.configured.endpoints='http://172.24.12.36:8080/org.amdatu.remote.discovery.configured,http://172.24.15.19:8080/org.amdatu.remote.discovery.configured,http://172.24.12.66:8080/org.amdatu.remote.discovery.configured,http://172.24.12.236:8080/org.amdatu.remote.discovery.configured,http://172.24.11.212:8080/org.amdatu.remote.discovery.configured,http://172.24.18.97:8080/org.amdatu.remote.discovery.configured,http://172.24.11.177:8080/org.amdatu.remote.discovery.configured,http://172.24.13.242:8080/org.amdatu.remote.discovery.configured,http://172.24.14.222:8080/org.amdatu.remote.discovery.configured,http://172.24.14.202:8080/org.amdatu.remote.discovery.configured',\ + org.amdatu.remote.discovery.configured.host=172.24.11.212,\ + org.amdatu.remote.admin.http.host=172.24.11.212,\ + org.amdatu.remote.admin.http.port=8080,\ + org.osgi.service.http.port=8080 + +-runfeatures: shell + +-runbundles: \ + org.apache.felix.gogo.command,\ + org.apache.felix.gogo.runtime,\ + org.apache.felix.gogo.shell,\ + org.apache.felix.scr,\ + org.osgi.util.promise,\ + org.osgi.util.function,\ + org.apache.felix.configadmin,\ + org.apache.felix.configurator,\ + org.apache.felix.cm.json,\ + org.apache.sling.commons.johnzon,\ + org.apache.felix.converter,\ + org.amdatu.remote.admin.http,\ + org.amdatu.remote.discovery.configured,\ + org.amdatu.remote.topology.promiscuous,\ + org.apache.felix.metatype,\ + org.apache.felix.eventadmin,\ + org.apache.felix.log,\ + org.apache.felix.dependencymanager,\ + org.apache.felix.http.servlet-api,\ + org.apache.felix.http.jetty,\ + org.osgi.service.remoteserviceadmin,\ + com.thalesgroup.nl.chat.api;version=latest,\ + com.thalesgroup.nl.chat.impl;version=latest \ No newline at end of file diff --git a/com.thalesgroup.nl.chat.impl/src/com/thalesgroup/nl/chat/impl/ChatImpl.java b/com.thalesgroup.nl.chat.impl/src/com/thalesgroup/nl/chat/impl/ChatImpl.java new file mode 100644 index 0000000..4cbc649 --- /dev/null +++ b/com.thalesgroup.nl.chat.impl/src/com/thalesgroup/nl/chat/impl/ChatImpl.java @@ -0,0 +1,17 @@ +package com.thalesgroup.nl.chat.impl; + +import com.thalesgroup.nl.chat.api.Chat; +import org.osgi.service.component.annotations.Component; +import org.osgi.service.remoteserviceadmin.RemoteConstants; + +@Component( + property = {RemoteConstants.SERVICE_EXPORTED_INTERFACES + "=com.thalesgroup.nl.chat.api.Chat", + "participant.name=Bas"} +) +public class ChatImpl implements Chat { + + @Override + public void sendMessage(String author, String message){ + System.out.printf("%s: %s%n", author, message); + } +} diff --git a/com.thalesgroup.nl.chat.impl/src/com/thalesgroup/nl/chat/impl/ChatServer.java b/com.thalesgroup.nl.chat.impl/src/com/thalesgroup/nl/chat/impl/ChatServer.java new file mode 100644 index 0000000..7e8655b --- /dev/null +++ b/com.thalesgroup.nl.chat.impl/src/com/thalesgroup/nl/chat/impl/ChatServer.java @@ -0,0 +1,50 @@ +package com.thalesgroup.nl.chat.impl; + +import com.thalesgroup.nl.chat.api.Chat; +import org.osgi.service.component.annotations.*; + +import java.util.HashMap; +import java.util.Map; + +@Component( + property = { + "osgi.command.scope=chat", + "osgi.command.function=send" + }, + immediate = true, + service = Object.class +) +public class ChatServer { + public static final String NAME = "Bas"; + private Map chatters = new HashMap<>(); + @Activate + public ChatServer() { + + } + + @Reference(policy = ReferencePolicy.DYNAMIC, cardinality = ReferenceCardinality.MULTIPLE) + public void addChatter(Chat chat, Map props){ + String name = (String) props.get("participant.name"); + System.out.printf("Adding %s%n", name); + chatters.put(name, chat); + chat.sendMessage(NAME, String.format("Hoi %s!", name)); + } + + public void removeChatter(Chat chat){ + chatters.remove(chat); + } + + public void send(String name, String message){ + Chat chat = chatters.get(name); + if(chat == null){ + System.out.printf("Error: %s not found%n", name); + } else { + chat.sendMessage(NAME, message); + } + } + + @Deactivate + public void deactivate(){ + + } +}