diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 9ab3712b..3d77a31f 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -9,18 +9,29 @@ env: GRADLE_OPTS: -Dorg.gradle.parallel=false jobs: - build: - name: build on OpenJDK Linux - runs-on: ubuntu-latest - steps: - - name: Git Checkout - uses: actions/checkout@v1 - - name: Gradle Wrapper Validation - uses: gradle/wrapper-validation-action@v1 - - name: Set up Java - uses: actions/setup-java@v1 - with: - java-version: 1.8 - - name: Build - shell: bash - run: ./gradlew build + Build_Matrix: + strategy: + matrix: + os: [ ubuntu-latest ] + java: [ 17 ] + runner: [ 'xvfb-run --auto-servernum {0}' ] + name: JDK${{ matrix.java }} ${{ matrix.os }} + runs-on: ${{ matrix.os }} + steps: + - name: Git Checkout + uses: actions/checkout@v3 + - name: Gradle Wrapper Validation + uses: gradle/wrapper-validation-action@v1 + - name: Set up Java ${{ matrix.java }} + uses: actions/setup-java@v3 + with: + distribution: "temurin" + cache: "gradle" + java-version: ${{ matrix.java }} + - name: Grant execute permission for gradlew + run: chmod +x ./gradlew + - name: Gradle version + run: ./gradlew --no-daemon --version + - name: Build with Gradle + run: ./gradlew clean build --info + diff --git a/cnf/ext/rsa.mvn b/cnf/ext/rsa.mvn index d7083827..922dca8e 100644 --- a/cnf/ext/rsa.mvn +++ b/cnf/ext/rsa.mvn @@ -48,7 +48,6 @@ org.apache.felix:org.apache.felix.http.servlet-api:1.1.2 org.apache.felix:org.apache.felix.inventory:1.0.6 org.apache.felix:org.apache.felix.cm.json:1.0.6 org.apache.felix:org.apache.felix.log.extension:1.0.0 -org.apache.felix:org.apache.felix.log:1.2.4 org.apache.felix:org.apache.felix.metatype:1.2.4 org.apache.felix:org.apache.felix.scr:2.1.30 org.apache.felix:org.apache.felix.shell.remote:1.2.0 @@ -139,3 +138,4 @@ org.bouncycastle:bcprov-jdk15on:1.70 org.bouncycastle:bctls-jdk15on:1.70 org.bouncycastle:bcutil-jdk15on:1.70 org.apache.felix:org.apache.felix.configurator:1.0.18 +org.apache.felix:org.apache.felix.log:1.3.0 diff --git a/org.gecko.playground.ds.config/README.md b/org.gecko.playground.ds.config/README.md new file mode 100644 index 00000000..b2cec4ed --- /dev/null +++ b/org.gecko.playground.ds.config/README.md @@ -0,0 +1,38 @@ +# `org.gecko.playground.ds.config` + +This is an example for configurable components. + +This project is a multi jar project and produces: + +* *org.gecko.playground.ds.config.configadmin* - components a programmatic way of configuration using the Configuration Admin +* *org.gecko.playground.ds.config.configurator* - declarative configured components using the Configurator + +It shows how programmatically and declarative component instances can be created. + +When running the application you will see this in the console: + +``` +Activate name-1 from 2001(album-10) from instance AlbumComponent@5398928f +Activate Funky from 1974(Funky, Funky) from instance AlbumComponent@165f68c5 +Activate Happy from 2010(I wanna be happy) from instance AlbumComponent@1cea869f +Activate name-2 from 2002(album-20) from instance AlbumComponent@2e10d72b +Activate name-3 from 2003(album-30) from instance AlbumComponent@54da9176 +Activate name-4 from 2004(album-40) from instance AlbumComponent@17d8d558 +Activate name-5 from 2005(album-50) from instance AlbumComponent@5f5f0ed4 +Modified name-1 from 2006(album-15) from instance AlbumComponent@5398928f +Modified name-2 from 2007(album-25) from instance AlbumComponent@2e10d72b +Modified name-3 from 2008(album-35) from instance AlbumComponent@54da9176 +Modified name-4 from 2009(album-45) from instance AlbumComponent@17d8d558 +Modified name-5 from 2010(album-55) from instance AlbumComponent@5f5f0ed4 +De-Activate name-1 from 2006(album-15) from instance AlbumComponent@5398928f +De-Activate name-2 from 2007(album-25) from instance AlbumComponent@2e10d72b +De-Activate name-3 from 2008(album-35) from instance AlbumComponent@54da9176 +De-Activate name-4 from 2009(album-45) from instance AlbumComponent@17d8d558 +De-Activate name-5 from 2010(album-55) from instance AlbumComponent@5f5f0ed4 +``` + +The albums *Funky* and *Happy* are created by configuration in *config/config.json*. This is published via the OSGi Configurator and the *org.gecko.playground.ds.config.configurator*. + +The *name-* Albums are created, then modified and after that removed using the Configuration Admin in the *AlbumCreator* component + +The *AlbumComponent* is the configuration factory. It creates a new instance for each new configuration. This can be recognized by the differnet instance id in the log entries. \ No newline at end of file diff --git a/org.gecko.playground.ds.dynamics/README.md b/org.gecko.playground.ds.dynamics/README.md new file mode 100644 index 00000000..83fed4cb --- /dev/null +++ b/org.gecko.playground.ds.dynamics/README.md @@ -0,0 +1,30 @@ +# `org.gecko.playground.ds.dynamics` + +This is an example for shows the *dynamic Reference Policy* in components. + +The *ExchangeComponent* has a dynamic reference to the exchange service. It will become active, even, if the exchange service is not available. + +Also, if the *ExchangeComponent* is active and the exchange service goes away, it still stays active: + +``` +g! Dynamic set exchange org.gecko.playground.exchange.impl.ExchangeImpl@10aa41f2 +Activate dynamic exchange component +There are 0 orders +g! stop 5 +Dynamic unset exchange org.gecko.playground.exchange.impl.ExchangeImpl@10aa41f2 +``` + +Now the exchange service is not there. And the component still exists. + +If we now deactivate *ExchangeComponent* an re-activate it, we will see a different log-out, because the exchange service is not available: + +``` +g! disable org.gecko.playground.ds.dynamics.ExchangeComponent +De-Activate dynamic exchange component +true +g! enable org.gecko.playground.ds.dynamics.ExchangeComponent +true +g! Activate dynamic exchange component +Exchange not available! +``` + diff --git a/org.gecko.playground.ds.factory/README.md b/org.gecko.playground.ds.factory/README.md index f10a6143..4b132b58 100644 --- a/org.gecko.playground.ds.factory/README.md +++ b/org.gecko.playground.ds.factory/README.md @@ -1,28 +1,44 @@ -# `org.gecko.playground.ds` +# `org.gecko.playground.ds.factory` -This tutorial shows how to work with OSGi *Declarative Service* and how many cool things you can do with them. +This tutorial shows how to work with OSGi *Declarative Service* as a factory. -## Configurable Services (`org.gecko.plaground.ds.config`) +For this we have two different factories: -First of all you can make your service *configurable*, meaning you can provide a set of properties that will customize the instance of your service, without having to repeat the common logic. +* *GardenDeviceFactory* - Creates smart device for your garden +* *HomeDeviceFactory* - Creates smart device for your home and rooms -As soon as the configuration is modified, or even removed, the service instance associated to it will be modified or removed accordingly. +Both are *Device* s -The configuration can be defined in a simple `.json` file, and can then be injected in the activate/modified/deactivate methods, so you have access to it. +The *DeviceHandlerService* injects these instance as *ComponentFactory*. These can create *ComponentInstance* s. Depending on the given type and properties now configured instance can be created using the right factory. +All instances can be disposed, when they are not needed any more +To test this you can use the *DeviceCommands*: -## Component Factory (`org.gecko.playground.ds.factory`) +* `device:createDevice ` - creates a new device of type and name +* `device:deleteDevice ` - removes the device with the given name +This can be tested: +``` +g! createDevice GARDEN Pool-Pump +Activate Instance GARDEN-DEVICE - Pool-Pump +Device created: GARDEN-DEVICE- Pool-Pump (org.gecko.playground.ds.factory.garden.GardenDeviceFactory@254b5fd4) +g! createDevice HOME Smart-TV +Activate Instance HOME-DEVICE - Smart-TV +Device created: HOME-DEVICE- Smart-TV (org.gecko.playground.ds.factory.home.HomeDeviceFactory@6147eaea) -## Greedy Policy (`org.gecko.playground.ds.greedy`) +g! deleteDevice HOME Smart-TV +Dispose device HOME - Smart-TV +Deactivate Instance HOME-DEVICE - Smart-TV +STOP HOME-DEVICE - Smart-TV +Device deleted: HOME- Smart-TV +g! deleteDevice GARDEN Pool-Pump +Dispose device GARDEN - Pool-Pump +Deactivate Instance GARDEN-DEVICE - Pool-Pump +STOP GARDEN-DEVICE - Pool-Pump +Device deleted: GARDEN- Pool-Pump +``` - - -## Prototype Services (`org.gecko.playground.ds.prototype`) - -By default, when you define a service, this will be a singleton, meaning, every time you want to reference to that service within the lifetime of an application, you will get the same instance. - -If instead you want to get a new instance every time, you can define your service as a *prototype*. +Now the instance are release using the corresponding factory. diff --git a/org.gecko.playground.ds.factory/config/config.json b/org.gecko.playground.ds.factory/config/config.json deleted file mode 100644 index f2b68e43..00000000 --- a/org.gecko.playground.ds.factory/config/config.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - ":configurator:resource-version": 1, - - "MyFancyConfig~test1": - { - "name": "Funky", - "year": 1974, - "description": "Funky, Funky" - }, - "MyFancyConfig~test2": - { - "name": "Happy", - "year": 2010, - "description": "I wanna be shappy" - } -} \ No newline at end of file diff --git a/org.gecko.playground.ds.factory/src/org/gecko/playground/ds/factory/cmd/WorkmodeCommands.java b/org.gecko.playground.ds.factory/src/org/gecko/playground/ds/factory/cmd/DeviceCommands.java similarity index 94% rename from org.gecko.playground.ds.factory/src/org/gecko/playground/ds/factory/cmd/WorkmodeCommands.java rename to org.gecko.playground.ds.factory/src/org/gecko/playground/ds/factory/cmd/DeviceCommands.java index f974a18b..631c2a37 100644 --- a/org.gecko.playground.ds.factory/src/org/gecko/playground/ds/factory/cmd/WorkmodeCommands.java +++ b/org.gecko.playground.ds.factory/src/org/gecko/playground/ds/factory/cmd/DeviceCommands.java @@ -16,12 +16,12 @@ import org.osgi.service.component.annotations.Component; import org.osgi.service.component.annotations.Reference; -@Component(service = WorkmodeCommands.class, property = { +@Component(service = DeviceCommands.class, property = { "osgi.command.scope=device", // "osgi.command.function=createDevice", "osgi.command.function=deleteDevice" }) -public class WorkmodeCommands { +public class DeviceCommands { @Reference private DeviceHandler deviceHandler; diff --git a/org.gecko.playground.ds.filter/README.md b/org.gecko.playground.ds.filter/README.md new file mode 100644 index 00000000..f0999e96 --- /dev/null +++ b/org.gecko.playground.ds.filter/README.md @@ -0,0 +1,29 @@ +# `org.gecko.playground.ds.filter` + +This tutorial shows how to work with OSGi *Declarative Service* references using filtering and selecting the right service. + +The *GreeterComponent* referenced to a *GreeterService*. But we have two implementations of it and only want tol select that one with the service propert< *lang=DE* + +The *ConfigurableGreeterComponent* uses the configuration in *config/config.json*. The reference for the *GreeterService* got a name *gs*. + +The configuration contains the filter, by extending the key with `.target`: + +```json +{ + ":configurator:resource-version": 1, + "CGS": + { + "gs.target": "(lang=EN)" + } +} +``` + +With this, it is possible to define filters in a declarative / configurable way. This can also be used when directly using the *ConfigurationAdmin*. + +When launching the application, you will see the result in the console: + +``` +Say greeting depending on the configuration: Greetz, Emil +Say greeting in german: Grüße dich, Emil +``` + diff --git a/org.gecko.playground.ds.filter/bnd.bnd b/org.gecko.playground.ds.filter/bnd.bnd index e69de29b..9a18814f 100644 --- a/org.gecko.playground.ds.filter/bnd.bnd +++ b/org.gecko.playground.ds.filter/bnd.bnd @@ -0,0 +1,5 @@ +-includeresource: \ + OSGI-INF/configurator/=config/ + +Require-Capability: osgi.extender;filter:='(osgi.extender=osgi.configurator)' +-privatepackage: org.gecko.playground.ds.filter \ No newline at end of file diff --git a/org.gecko.playground.ds.filter/config/config.json b/org.gecko.playground.ds.filter/config/config.json new file mode 100644 index 00000000..8395e30c --- /dev/null +++ b/org.gecko.playground.ds.filter/config/config.json @@ -0,0 +1,8 @@ +{ + ":configurator:resource-version": 1, + + "CGS": + { + "gs.target": "(lang=EN)" + } +} \ No newline at end of file diff --git a/org.gecko.playground.ds.filter/launch-filter.bndrun b/org.gecko.playground.ds.filter/launch-filter.bndrun index 5c579e0e..8efd37d6 100644 --- a/org.gecko.playground.ds.filter/launch-filter.bndrun +++ b/org.gecko.playground.ds.filter/launch-filter.bndrun @@ -3,13 +3,19 @@ -runrequires: \ bnd.identity;id='org.apache.felix.gogo.command',\ bnd.identity;id='org.apache.felix.gogo.shell',\ - bnd.identity;id='org.gecko.playground.ds.filter' + bnd.identity;id='org.gecko.playground.ds.filter',\ + bnd.identity;id='org.apache.felix.configadmin' -runbundles: \ org.apache.felix.gogo.command;version='[1.1.2,1.1.3)',\ org.apache.felix.gogo.runtime;version='[1.1.6,1.1.7)',\ org.apache.felix.gogo.shell;version='[1.1.4,1.1.5)',\ - org.apache.felix.scr;version='[2.2.6,2.2.7)',\ + org.apache.felix.cm.json;version='[2.0.0,2.0.1)',\ + org.apache.felix.configurator;version='[1.0.18,1.0.19)',\ + org.apache.felix.configadmin;version='[1.9.26,1.9.27)',\ + org.eclipse.parsson.jakarta.json;version='[1.1.2,1.1.3)',\ + org.osgi.util.function;version='[1.2.0,1.2.1)',\ + org.osgi.util.converter;version='[1.0.9,1.0.10)',\ org.gecko.playground.ds.filter;version=snapshot,\ + org.apache.felix.scr;version='[2.2.6,2.2.7)',\ org.osgi.service.component;version='[1.5.1,1.5.2)',\ - org.osgi.util.function;version='[1.2.0,1.2.1)',\ org.osgi.util.promise;version='[1.3.0,1.3.1)' \ No newline at end of file diff --git a/org.gecko.playground.ds.filter/src/org/gecko/playground/ds/filter/ConfigurableGreeterComponent.java b/org.gecko.playground.ds.filter/src/org/gecko/playground/ds/filter/ConfigurableGreeterComponent.java new file mode 100644 index 00000000..b1137087 --- /dev/null +++ b/org.gecko.playground.ds.filter/src/org/gecko/playground/ds/filter/ConfigurableGreeterComponent.java @@ -0,0 +1,28 @@ +package org.gecko.playground.ds.filter; + +import org.osgi.service.component.annotations.Activate; +import org.osgi.service.component.annotations.Component; +import org.osgi.service.component.annotations.ConfigurationPolicy; +import org.osgi.service.component.annotations.Reference; + +@Component(name="CGS", configurationPolicy = ConfigurationPolicy.REQUIRE) +public class ConfigurableGreeterComponent { + + private GreeterService greeter; + + @Activate + public void activate() { + System.out.println("Say greeting depending on the configuration: " + greeter.greet("Emil")); + } + + @Reference(name = "gs") + public void setGreeter(GreeterService greeter) { + this.greeter = greeter; + } + + public void unsetGreeter(GreeterService greeter) { + this.greeter = null; + } + + +} diff --git a/org.gecko.playground.ds.greedy/README.md b/org.gecko.playground.ds.greedy/README.md new file mode 100644 index 00000000..b046322e --- /dev/null +++ b/org.gecko.playground.ds.greedy/README.md @@ -0,0 +1,27 @@ +# `org.gecko.playground.ds.greedy` + +This tutorial shows how to work with OSGi *Declarative Service* references using greediness. + +The *GreedyConsumer* references to an *Important*-Service. We have the less important *ImportantService* implementation and the *VeryImportantService* implementation, that is disabled. + +So on start you see that the *ImportantService* was referenced: + +``` +Welcome to Apache Felix Gogo + +g! Activate Greedy Consumer +Set less important service: true, very: false from org.gecko.playground.ds.greedy.impl.ImportantService@d35dea7 +``` + + + +If you activate the *VeryImportantService* you see, that because of the defined service rank, this instance is more important. The greediness configuration should now take the better version: + +``` +g! enable VIS +true +g! Set VERY important service: true, very: true from org.gecko.playground.ds.greedy.very.VeryImportantService@4396e1f0 +Unset less important service: true, very: false from org.gecko.playground.ds.greedy.impl.ImportantService@d35dea7 +``` + +At first the new instance was set. Afterwards, the old instance has been unsetted. diff --git a/org.gecko.playground.ds.greedy/src/org/gecko/playground/ds/greedy/very/VeryImportantService.java b/org.gecko.playground.ds.greedy/src/org/gecko/playground/ds/greedy/very/VeryImportantService.java index 7057f402..c822b3fd 100644 --- a/org.gecko.playground.ds.greedy/src/org/gecko/playground/ds/greedy/very/VeryImportantService.java +++ b/org.gecko.playground.ds.greedy/src/org/gecko/playground/ds/greedy/very/VeryImportantService.java @@ -15,7 +15,7 @@ import org.osgi.framework.Constants; import org.osgi.service.component.annotations.Component; -@Component(name="VIS", property = Constants.SERVICE_RANKING + ":Integer=10") +@Component(name="VIS", enabled = false, property = Constants.SERVICE_RANKING + ":Integer=10") public class VeryImportantService implements Important{ /* diff --git a/org.gecko.playground.ds.scope/README.md b/org.gecko.playground.ds.scope/README.md new file mode 100644 index 00000000..5ffecb87 --- /dev/null +++ b/org.gecko.playground.ds.scope/README.md @@ -0,0 +1,26 @@ +# `org.gecko.playground.ds.proto` + +This tutorial shows how to work with OSGi *Declarative Service* using scoped services. + +As example there are two counter components for singleton services and two counter components for protoytpe services. + +Running the application prints something like this: + +``` +Counter 1: 1 with instance org.gecko.playground.ds.scope.CounterService@3be8df3 +Counter 1: 2 with instance org.gecko.playground.ds.scope.CounterService@3be8df3 +Counter 1: 3 with instance org.gecko.playground.ds.scope.CounterService@3be8df3 +Counter 2: 4 with instance org.gecko.playground.ds.scope.CounterService@3be8df3 +Counter 2: 5 with instance org.gecko.playground.ds.scope.CounterService@3be8df3 +Counter 2: 6 with instance org.gecko.playground.ds.scope.CounterService@3be8df3 +Proto Counter 1: 1 with instance CounterImpl@12933a4 +Proto Counter 1: 2 with instance CounterImpl@12933a4 +Proto Counter 1: 3 with instance CounterImpl@12933a4 +Proto Counter 2: 1 with instance CounterImpl@50bd50fd +Proto Counter 2: 2 with instance CounterImpl@50bd50fd +Proto Counter 2: 3 with instance CounterImpl@50bd50fd +``` + +The two singleton counter components 1 and 2 share the same counter service instance. + +The proto counter 1 and 2 getting an own instance of the *CounterImpl*, that is registered as prototype servicec factory in the *CounterPrototypeCreator*. diff --git a/org.gecko.playground.ds.scope/src/org/gecko/playground/ds/scope/prototype/CounterPrototypeCreator.java b/org.gecko.playground.ds.scope/src/org/gecko/playground/ds/scope/prototype/CounterPrototypeCreator.java index 79359a9b..acdb0b7a 100644 --- a/org.gecko.playground.ds.scope/src/org/gecko/playground/ds/scope/prototype/CounterPrototypeCreator.java +++ b/org.gecko.playground.ds.scope/src/org/gecko/playground/ds/scope/prototype/CounterPrototypeCreator.java @@ -5,14 +5,12 @@ import org.gecko.playground.ds.scope.Counter; import org.osgi.framework.BundleContext; import org.osgi.framework.FrameworkUtil; -import org.osgi.framework.ServiceObjects; -import org.osgi.framework.ServiceReference; import org.osgi.framework.ServiceRegistration; import org.osgi.service.component.annotations.Activate; import org.osgi.service.component.annotations.Component; import org.osgi.service.component.annotations.Deactivate; -//@Component +@Component public class CounterPrototypeCreator { private ServiceRegistration registration; diff --git a/org.gecko.playground.ds.simple/README.md b/org.gecko.playground.ds.simple/README.md new file mode 100644 index 00000000..a301b0ce --- /dev/null +++ b/org.gecko.playground.ds.simple/README.md @@ -0,0 +1,10 @@ +# `org.gecko.playground.ds.simple` + +This tutorial shows how to work with simple / basic OSGi *Declarative Services*. + +We show: + +* Simple components *HellpComponent* and component services *ConsoleLog* +* Property Annotations *MyServiceProp* and the usage in *AnotherLog* +* Composition of referenced services in *ReferencedComponent* +* Creation of a Gogo Shell command using declarative services diff --git a/org.gecko.playground.ds.simple/bnd.bnd b/org.gecko.playground.ds.simple/bnd.bnd index e69de29b..78ff917a 100644 --- a/org.gecko.playground.ds.simple/bnd.bnd +++ b/org.gecko.playground.ds.simple/bnd.bnd @@ -0,0 +1,2 @@ +-buildpath: \ + org.gecko.playground;version=project \ No newline at end of file diff --git a/org.gecko.playground.ds.simple/hello-component.bndrun b/org.gecko.playground.ds.simple/hello-component.bndrun index b01a35db..1c38c684 100644 --- a/org.gecko.playground.ds.simple/hello-component.bndrun +++ b/org.gecko.playground.ds.simple/hello-component.bndrun @@ -12,4 +12,5 @@ org.osgi.util.promise;version='[1.3.0,1.3.1)',\ org.apache.felix.gogo.command;version='[1.1.2,1.1.3)',\ org.apache.felix.gogo.runtime;version='[1.1.6,1.1.7)',\ - org.apache.felix.gogo.shell;version='[1.1.4,1.1.5)' \ No newline at end of file + org.apache.felix.gogo.shell;version='[1.1.4,1.1.5)',\ + org.gecko.playground;version=snapshot \ No newline at end of file diff --git a/org.gecko.playground.ds.simple/src/org/gecko/playground/ds/simple/ConsoleLog.java b/org.gecko.playground.ds.simple/src/org/gecko/playground/ds/simple/ConsoleLog.java index 85e86833..23dc5784 100644 --- a/org.gecko.playground.ds.simple/src/org/gecko/playground/ds/simple/ConsoleLog.java +++ b/org.gecko.playground.ds.simple/src/org/gecko/playground/ds/simple/ConsoleLog.java @@ -1,6 +1,6 @@ package org.gecko.playground.ds.simple; -import org.gecko.playground.ds.simple.logging.Log; +import org.gecko.playground.logging.Log; import org.osgi.service.component.annotations.Component; @Component diff --git a/org.gecko.playground.ds.simple/src/org/gecko/playground/ds/simple/properties/AnotherLog.java b/org.gecko.playground.ds.simple/src/org/gecko/playground/ds/simple/properties/AnotherLog.java index df38fab5..44669afb 100644 --- a/org.gecko.playground.ds.simple/src/org/gecko/playground/ds/simple/properties/AnotherLog.java +++ b/org.gecko.playground.ds.simple/src/org/gecko/playground/ds/simple/properties/AnotherLog.java @@ -1,9 +1,10 @@ package org.gecko.playground.ds.simple.properties; -import org.gecko.playground.ds.simple.logging.Log; +import org.gecko.playground.logging.Log; import org.osgi.service.component.annotations.Component; //@Component(property = "fizz=buzz") +@Component(property = "fizz=buzz") @MyServiceProp(foo = "bar") public class AnotherLog implements Log { diff --git a/org.gecko.playground.ds.simple/src/org/gecko/playground/ds/simple/references/ReferencedComponent.java b/org.gecko.playground.ds.simple/src/org/gecko/playground/ds/simple/references/ReferencedComponent.java index 496bd7c2..9ac8704d 100644 --- a/org.gecko.playground.ds.simple/src/org/gecko/playground/ds/simple/references/ReferencedComponent.java +++ b/org.gecko.playground.ds.simple/src/org/gecko/playground/ds/simple/references/ReferencedComponent.java @@ -1,10 +1,10 @@ package org.gecko.playground.ds.simple.references; -import org.gecko.playground.ds.simple.logging.Log; +import org.gecko.playground.logging.Log; import org.osgi.service.component.annotations.Component; import org.osgi.service.component.annotations.Reference; -//@Component +@Component public class ReferencedComponent { public ReferencedComponent () { diff --git a/org.gecko.playground.ds.simple/src/org/gecko/playground/ds/simple/services/MyServiceImpl.java b/org.gecko.playground.ds.simple/src/org/gecko/playground/ds/simple/services/MyServiceImpl.java index 191f2457..a90602c7 100644 --- a/org.gecko.playground.ds.simple/src/org/gecko/playground/ds/simple/services/MyServiceImpl.java +++ b/org.gecko.playground.ds.simple/src/org/gecko/playground/ds/simple/services/MyServiceImpl.java @@ -1,6 +1,6 @@ package org.gecko.playground.ds.simple.services; -import org.osgi.service.component.annotations.Component; +//import org.osgi.service.component.annotations.Component; //@Component(service = MyService.class) //@Component(service = {MyService1.class, MyService2.class}) diff --git a/org.gecko.playground.ds.simple/src/org/gecko/playground/ds/simple/shell/HelloCommand.java b/org.gecko.playground.ds.simple/src/org/gecko/playground/ds/simple/shell/HelloCommand.java index d4d7cd02..8a5d2e30 100644 --- a/org.gecko.playground.ds.simple/src/org/gecko/playground/ds/simple/shell/HelloCommand.java +++ b/org.gecko.playground.ds.simple/src/org/gecko/playground/ds/simple/shell/HelloCommand.java @@ -2,18 +2,18 @@ import org.osgi.service.component.annotations.Component; -//@Component (service = Object.class , -// property = { "osgi.command.scope=hello", -// "osgi.command.function=sagHallo", -// "osgi.command.function=sayHello"}) +@Component (service = Object.class , + property = { "osgi.command.scope=hello", + "osgi.command.function=sagHallo", + "osgi.command.function=sayHello"}) public class HelloCommand { public void sayHello () { System.out.println("I wanted to say Hello!"); } -// public void sagHallo () { -// System.out.println("Ich wollte nur Hallo sagen!"); -// } + public void sagHallo () { + System.out.println("Ich wollte nur Hallo sagen!"); + } } \ No newline at end of file diff --git a/org.gecko.playground.ds.statics/README.md b/org.gecko.playground.ds.statics/README.md new file mode 100644 index 00000000..24f833ac --- /dev/null +++ b/org.gecko.playground.ds.statics/README.md @@ -0,0 +1,139 @@ +# `org.gecko.playground.ds.statics` + +This tutorial shows how to work with OSGi *Declarative Services* and static references. + +The example is to play with the optional reference cardinality. + +We have two Components: + +* *ExchangeCommand* - Gogo Command **without optional** *Exchange*-service reference: `orders` +* *ExchangeComponent* - Component **with optional** cardinality + +When running the application, the console prints: + +``` +g! Set exchange org.gecko.playground.exchange.impl.ExchangeImpl@1f59a598 +Activate exchange component +There are 0 orders +``` + +If you now execute the `orders` command: + +``` +g! orders +Order Command: Set exchange org.gecko.playground.exchange.impl.ExchangeImpl@1f59a598 +Activate order command +There are 0 orders +De-Activate order command +Order Command: Unset exchange org.gecko.playground.exchange.impl.ExchangeImpl@1f59a598 +g! +``` + +If we now disable the exchange component service: + +``` +g! disable org.gecko.playground.exchange.impl.ExchangeImpl +true +g! De-Activate exchange component +Unset exchange org.gecko.playground.exchange.impl.ExchangeImpl@1f59a598 +Activate exchange component +Exchange not available! +g! list +org.gecko.playground.exchange.impl.ExchangeImpl in bundle 5 (org.gecko.playground.exchange.impl:1.0.0.202309021301-SNAPSHOT) enabled, 0 instances. +org.gecko.playground.ds.statics.ExchangeCommand in bundle 6 (org.gecko.playground.ds.statics:1.0.0.202309031406-SNAPSHOT) enabled, 1 instance. + Id: 1, State:UNSATISFIED REFERENCE +org.gecko.playground.ds.statics.ExchangeComponent in bundle 6 (org.gecko.playground.ds.statics:1.0.0.202309031406-SNAPSHOT) enabled, 1 instance. + Id: 2, State:ACTIVE +``` + +... we see, when executing the `list` , that the *ExchangeCommand* **without** optional cardinality the references to the *Exchange*-service are *unsatisfied*. + +Executing `orders`will not work anymore: + +``` +g! orders +gogo: CommandNotFoundException: Command not found: orders +``` + + + +The *ExchangeComponent* ***with** optional cardinality has been de-activated and activated again, but now without *Exchange*. Thats why it say exchange not available: + +``` +g! orders +Activate order command +Exchange not available! +De-Activate order command +``` + +Lets say, the *Exchange*-service comes back: + +``` +g! enable org.gecko.playground.exchange.impl.ExchangeImpl +true +g! list +org.gecko.playground.exchange.impl.ExchangeImpl in bundle 5 (org.gecko.playground.exchange.impl:1.0.0.202309021301-SNAPSHOT) enabled, 1 instance. + Id: 3, State:SATISFIED +org.gecko.playground.ds.statics.ExchangeCommand in bundle 6 (org.gecko.playground.ds.statics:1.0.0.202309031406-SNAPSHOT) enabled, 1 instance. + Id: 1, State:SATISFIED +org.gecko.playground.ds.statics.ExchangeComponent in bundle 6 (org.gecko.playground.ds.statics:1.0.0.202309031406-SNAPSHOT) enabled, 1 instance. + Id: 2, State:ACTIVE +``` + +Every references are satisfied again, so the `orders` command will work: + +``` +g! orders +Order Command: Set exchange org.gecko.playground.exchange.impl.ExchangeImpl@2a88c3ec +Activate order command +There are 0 orders +De-Activate order command +Order Command: Unset exchange org.gecko.playground.exchange.impl.ExchangeImpl@2a88c3ec +``` + +But we **do not** see, that the *ExchangeComponent* **with** optional cardinality is de-activated and activated again, with the *Exchange* reference, that came back. There is **no** printout like from the beginning + +``` +Set exchange org.gecko.playground.exchange.impl.ExchangeImpl@1f59a598 +Activate exchange component +There are 0 orders +``` + +Instead the *ExchangeComponent* stays active **without** re-injecting the *Exchange* service. + +An investigation leads to this: + +Before deactivating the *Exchange*, the `info` command for the *ExchangeComponent* provided one reference binding. After disabling the *Exchange* and enabling it again, the `info` command for the *ExchangeComponent* still says **no active binding** for *Exchange* reference binding: + +``` +g! info 2 +... +Component Configuration Id: 2 +----------------------------- +... +References: (total 2) + - Exchange: org.gecko.playground.exchange.api.Exchange SATISFIED 0..1 static + target=(*) scope=bundle (1 binding): + * Bound to [22] from bundle 5 (org.gecko.playground.exchange.impl:1.0.0.202309021301-SNAPSHOT) + - osgi.ds.satisfying.condition: ... + +g! disable org.gecko.playground.exchange.impl.ExchangeImpl +true +g! De-Activate exchange component +Unset exchange org.gecko.playground.exchange.impl.ExchangeImpl@2e377400 +Activate exchange component +Exchange not available! + +g! enable org.gecko.playground.exchange.impl.ExchangeImpl +true +g! info 2 +Component Configuration Id: 2 +----------------------------- +... +References: (total 2) + - Exchange: org.gecko.playground.exchange.api.Exchange SATISFIED 0..1 static + target=(*) scope=bundle (no active bindings) + - osgi.ds.satisfying.condition: ... +``` + +To get the *Exchange* back, you'd need the dynamic reference policy. diff --git a/org.gecko.playground.ds.statics/src/org/gecko/playground/ds/statics/ExchangeCommand.java b/org.gecko.playground.ds.statics/src/org/gecko/playground/ds/statics/ExchangeCommand.java index 888d637b..189cc159 100644 --- a/org.gecko.playground.ds.statics/src/org/gecko/playground/ds/statics/ExchangeCommand.java +++ b/org.gecko.playground.ds.statics/src/org/gecko/playground/ds/statics/ExchangeCommand.java @@ -7,7 +7,6 @@ import org.osgi.service.component.annotations.Component; import org.osgi.service.component.annotations.Deactivate; import org.osgi.service.component.annotations.Reference; -import org.osgi.service.component.annotations.ReferenceCardinality; @Component (service = Object.class , property = { "osgi.command.scope=exchange", @@ -26,8 +25,8 @@ private void deactivate() { System.out.println("De-Activate order command "); } -// @Reference - @Reference(cardinality = ReferenceCardinality.OPTIONAL) + @Reference +// @Reference(cardinality = ReferenceCardinality.OPTIONAL) public void setExchange(Exchange exchange) { System.out.println("Order Command: Set exchange " + exchange.toString()); this.exchange = exchange; diff --git a/org.gecko.playground.ds.whiteboard/README.md b/org.gecko.playground.ds.whiteboard/README.md new file mode 100644 index 00000000..0a89291a --- /dev/null +++ b/org.gecko.playground.ds.whiteboard/README.md @@ -0,0 +1,35 @@ +# `org.gecko.playground.whiteboard` + +This tutorial shows how to work withthe whiteboard pattern. + +This example uses the following other projects: + +* *org.gecko.playground.exchange.api* - To get the *ExchangeListener* API +* *org.gecko.playground.exchange.impl* - To run the application +* *org.gecko.playground.exchange.client* - To run the Gogo commands to ask for an order + +So, the client provides a command `askOrder `. + +When placing an order, they are forwarded to the *Exchange*. + +We register the *LoggingExchangeListener* and the *SysoutExchangeListener* as service. The *ExchangeImpl* injects all service of this abstract class *ExchangeListener*. Each time a new order is placed, all injected *ExchangeListener* are notified using the corresponding callback. + +When you run the application ans placing an order, the console printsout something like this: + +``` +g! ConsoleLog created + +g! askOrder TUT 123 222333 +Add listener to exchange: LoggingExchangeListener@360c2b09 +Add listener to exchange: SysoutExchangeListener@26f7f0a4 +Ask for order of 123 for TUT at the price of 222333 cent. +Order was submitted ... + +LOG : Log Exchange Listener: Order submittedOrder [id=08a3f8cb-5186-4d08-9916-ef30b3ab0978, customerId=0, symbol=TUT, side=Ask, quantity=123, initialQuantity=123, price=222333, expiry=0] + +Sysout: Order submittedOrder [id=08a3f8cb-5186-4d08-9916-ef30b3ab0978, customerId=0, symbol=TUT, side=Ask, quantity=123, initialQuantity=123, price=222333, expiry=0] + +``` + +As we see the two exchange listeners have been notified by the exchange. + diff --git a/org.gecko.playground.ds.whiteboard/bnd.bnd b/org.gecko.playground.ds.whiteboard/bnd.bnd index a2f90740..269993cf 100644 --- a/org.gecko.playground.ds.whiteboard/bnd.bnd +++ b/org.gecko.playground.ds.whiteboard/bnd.bnd @@ -1,4 +1,6 @@ -buildpath: \ org.gecko.playground.exchange.api;version=project,\ - org.gecko.playground.ds.simple;version=project --privatepackage: org.gecko.playground.ds.whiteboard.logger \ No newline at end of file + org.gecko.playground;version=project +-privatepackage: \ + org.gecko.playground.ds.whiteboard.logger,\ + org.gecko.playground.ds.whiteboard.sysout \ No newline at end of file diff --git a/org.gecko.playground.ds.whiteboard/launch-whiteboard.bndrun b/org.gecko.playground.ds.whiteboard/launch-whiteboard.bndrun index 7be6e94b..c3abfe0a 100644 --- a/org.gecko.playground.ds.whiteboard/launch-whiteboard.bndrun +++ b/org.gecko.playground.ds.whiteboard/launch-whiteboard.bndrun @@ -11,7 +11,6 @@ org.apache.felix.gogo.runtime;version='[1.1.6,1.1.7)',\ org.apache.felix.gogo.shell;version='[1.1.4,1.1.5)',\ org.apache.felix.scr;version='[2.2.6,2.2.7)',\ - org.gecko.playground.ds.simple;version=snapshot,\ org.gecko.playground.ds.whiteboard;version=snapshot,\ org.gecko.playground.exchange.api;version=snapshot,\ org.gecko.playground.exchange.impl;version=snapshot,\ @@ -19,4 +18,5 @@ org.osgi.service.log;version='[1.5.0,1.5.1)',\ org.osgi.util.function;version='[1.2.0,1.2.1)',\ org.osgi.util.promise;version='[1.3.0,1.3.1)',\ - org.gecko.playground.exchange.client;version=snapshot \ No newline at end of file + org.gecko.playground.exchange.client;version=snapshot,\ + org.gecko.playground;version=snapshot \ No newline at end of file diff --git a/org.gecko.playground.ds.whiteboard/src/org/gecko/playground/ds/whiteboard/logger/ConsoleLog.java b/org.gecko.playground.ds.whiteboard/src/org/gecko/playground/ds/whiteboard/logger/ConsoleLog.java new file mode 100644 index 00000000..9a58a124 --- /dev/null +++ b/org.gecko.playground.ds.whiteboard/src/org/gecko/playground/ds/whiteboard/logger/ConsoleLog.java @@ -0,0 +1,23 @@ +package org.gecko.playground.ds.whiteboard.logger; + +import org.gecko.playground.logging.Log; +import org.osgi.service.component.annotations.Component; + +@Component +public class ConsoleLog implements Log { + + public ConsoleLog () { + System.out.println("ConsoleLog created"); + } + + @Override + public void logMessage(String message) { + System.out.println("LOG : " + message); + } + + @Override + public String info(String message) { + return "INFO: " + message; + } + +} \ No newline at end of file diff --git a/org.gecko.playground.ds.whiteboard/src/org/gecko/playground/ds/whiteboard/logger/LoggingExchangeListener.java b/org.gecko.playground.ds.whiteboard/src/org/gecko/playground/ds/whiteboard/logger/LoggingExchangeListener.java index 270af824..41118bf8 100644 --- a/org.gecko.playground.ds.whiteboard/src/org/gecko/playground/ds/whiteboard/logger/LoggingExchangeListener.java +++ b/org.gecko.playground.ds.whiteboard/src/org/gecko/playground/ds/whiteboard/logger/LoggingExchangeListener.java @@ -1,12 +1,12 @@ package org.gecko.playground.ds.whiteboard.logger; -import org.gecko.playground.ds.simple.logging.Log; +import org.gecko.playground.logging.Log; import org.gecko.playground.exchange.api.ExchangeListener; import org.gecko.playground.model.orders.Order; import org.osgi.service.component.annotations.Component; import org.osgi.service.component.annotations.Reference; -@Component(service = ExchangeListener.class) +@Component(service = ExchangeListener.class,immediate = true) public class LoggingExchangeListener extends ExchangeListener { private Log log; @@ -22,17 +22,17 @@ public void setLog(Log log) { @Override public void orderSubmitted(String exchangeId, Order order) { - log.logMessage("LEL: Order submitted" + order.toString()); + log.logMessage("Log Exchange Listener: Order submitted" + order.toString()); } @Override public void orderCancelled(String exchangeId, Order order) { - log.logMessage("LEL: order cancelled: " + order.toString()); + log.logMessage("Log Exchange Listener: order cancelled: " + order.toString()); } @Override public void orderExpired(String exchangeId, Order order) { - log.logMessage("LEL: order expired: " + order.toString()); + log.logMessage("Log Exchange Listener: order expired: " + order.toString()); } } diff --git a/org.gecko.playground.ds.whiteboard/src/org/gecko/playground/ds/whiteboard/package-info.java b/org.gecko.playground.ds.whiteboard/src/org/gecko/playground/ds/whiteboard/package-info.java deleted file mode 100644 index f5ccb804..00000000 --- a/org.gecko.playground.ds.whiteboard/src/org/gecko/playground/ds/whiteboard/package-info.java +++ /dev/null @@ -1 +0,0 @@ -package org.gecko.playground.ds.whiteboard; \ No newline at end of file diff --git a/org.gecko.playground.ds.whiteboard/src/org/gecko/playground/ds/whiteboard/sysout/SysoutExchangeListener.java b/org.gecko.playground.ds.whiteboard/src/org/gecko/playground/ds/whiteboard/sysout/SysoutExchangeListener.java new file mode 100644 index 00000000..aa778653 --- /dev/null +++ b/org.gecko.playground.ds.whiteboard/src/org/gecko/playground/ds/whiteboard/sysout/SysoutExchangeListener.java @@ -0,0 +1,25 @@ +package org.gecko.playground.ds.whiteboard.sysout; + +import org.gecko.playground.exchange.api.ExchangeListener; +import org.gecko.playground.model.orders.Order; +import org.osgi.service.component.annotations.Component; + +@Component(service = ExchangeListener.class,immediate = true) +public class SysoutExchangeListener extends ExchangeListener { + + @Override + public void orderSubmitted(String exchangeId, Order order) { + System.out.println("Sysout: Order submitted" + order.toString()); + } + + @Override + public void orderCancelled(String exchangeId, Order order) { + System.out.println("Sysout: order cancelled: " + order.toString()); + } + + @Override + public void orderExpired(String exchangeId, Order order) { + System.out.println("Sysout: order expired: " + order.toString()); + } + +} diff --git a/org.gecko.playground.ds.whiteboard/src/org/gecko/playground/ds/whiteboard/sysout/package-info.java b/org.gecko.playground.ds.whiteboard/src/org/gecko/playground/ds/whiteboard/sysout/package-info.java new file mode 100644 index 00000000..e9ae3451 --- /dev/null +++ b/org.gecko.playground.ds.whiteboard/src/org/gecko/playground/ds/whiteboard/sysout/package-info.java @@ -0,0 +1 @@ +package org.gecko.playground.ds.whiteboard.sysout; \ No newline at end of file diff --git a/org.gecko.playground.eventadmin/README.md b/org.gecko.playground.eventadmin/README.md new file mode 100644 index 00000000..f79e626a --- /dev/null +++ b/org.gecko.playground.eventadmin/README.md @@ -0,0 +1,11 @@ +# `org.gecko.playground.eventadmin` + +This tutorial shows how the Event Admin service works. + +The *RandomPriceFeed* component gets the *EventAdmin* injected and posts events of stock information. + +The *OrderEventHandler* subscribes to that topic, using the component service property `event.topics` and prints-out the order and submits it to the *Exchange*. + +* Once you add the *org.gecko.playground.exchange.client* bundle to the run-configuration, you can verify the amount of order using the `orders` command. +* It is also possible to add the *org.gecko.playground.ds.whiteboard* bundle to add some *ExchangeListener* to the *Exchange* ;-) + diff --git a/org.gecko.playground.exchange.api/README.md b/org.gecko.playground.exchange.api/README.md new file mode 100644 index 00000000..d3a2f50d --- /dev/null +++ b/org.gecko.playground.exchange.api/README.md @@ -0,0 +1,4 @@ +# `org.gecko.playground.exchange.api` + +Simple API for the exchange example + diff --git a/org.gecko.playground.exchange.client/README.md b/org.gecko.playground.exchange.client/README.md new file mode 100644 index 00000000..d3e1947b --- /dev/null +++ b/org.gecko.playground.exchange.client/README.md @@ -0,0 +1,7 @@ +# `org.gecko.playground.exchange.client` + +Some gogo commands to deal with orders: + +* `askOrder ` - Placing an order at the *Exchange* +* `orders` - Show the numbers of orders in the queue + diff --git a/org.gecko.playground.exchange.client/src/org/gecko/playground/exchange/shell/ExchangeCommand.java b/org.gecko.playground.exchange.client/src/org/gecko/playground/exchange/shell/ExchangeCommand.java index 2cfd9052..63f24cd3 100644 --- a/org.gecko.playground.exchange.client/src/org/gecko/playground/exchange/shell/ExchangeCommand.java +++ b/org.gecko.playground.exchange.client/src/org/gecko/playground/exchange/shell/ExchangeCommand.java @@ -7,7 +7,6 @@ import org.gecko.playground.model.orders.Side; import org.osgi.service.component.annotations.Component; import org.osgi.service.component.annotations.Reference; -import org.osgi.service.component.annotations.ReferenceCardinality; @Component (service = Object.class , property = { "osgi.command.scope=exchange", diff --git a/org.gecko.playground.exchange.impl/README.md b/org.gecko.playground.exchange.impl/README.md new file mode 100644 index 00000000..3edb8b56 --- /dev/null +++ b/org.gecko.playground.exchange.impl/README.md @@ -0,0 +1,5 @@ +# `org.gecko.playground.exchange.impl` + +Simple *Exchange* implementation. + +The *ExchangeImpl* injects all *ExchangeListeners* in therefor acts as a whiteboard. All listeners are notified, when a new order arrives or was removed. diff --git a/org.gecko.playground.exchange.impl/bin_test/org/gecko/playground/exchange/impl/OrderEventHandlerTest.class b/org.gecko.playground.exchange.impl/bin_test/org/gecko/playground/exchange/impl/OrderEventHandlerTest.class index bfed1ff9..d5e7d4cd 100644 Binary files a/org.gecko.playground.exchange.impl/bin_test/org/gecko/playground/exchange/impl/OrderEventHandlerTest.class and b/org.gecko.playground.exchange.impl/bin_test/org/gecko/playground/exchange/impl/OrderEventHandlerTest.class differ diff --git a/org.gecko.playground.exchange.impl/src/org/gecko/playground/exchange/impl/ExchangeImpl.java b/org.gecko.playground.exchange.impl/src/org/gecko/playground/exchange/impl/ExchangeImpl.java index ee3d4b71..0fe2a6d4 100644 --- a/org.gecko.playground.exchange.impl/src/org/gecko/playground/exchange/impl/ExchangeImpl.java +++ b/org.gecko.playground.exchange.impl/src/org/gecko/playground/exchange/impl/ExchangeImpl.java @@ -41,7 +41,7 @@ public class ExchangeImpl implements Exchange { private static final AtomicLong instanceCounter = new AtomicLong(0L); - @Reference (cardinality = ReferenceCardinality.MULTIPLE, policy = ReferencePolicy.DYNAMIC) +// @Reference (cardinality = ReferenceCardinality.MULTIPLE, policy = ReferencePolicy.DYNAMIC) private final List listeners = new CopyOnWriteArrayList<>(); private final ConcurrentMap orders = new ConcurrentHashMap(); private final BlockingDeque orderQueue = new LinkedBlockingDeque(128); @@ -102,7 +102,7 @@ public Collection getAllOrders() { return orders.values(); } -// @Reference (cardinality = ReferenceCardinality.MULTIPLE , policy = ReferencePolicy.DYNAMIC) + @Reference (cardinality = ReferenceCardinality.MULTIPLE , policy = ReferencePolicy.DYNAMIC) public void addExchangeListener(ExchangeListener listener) { System.out.println("Add listener to exchange: " + listener); listeners.add(listener); diff --git a/org.gecko.playground.exchange.impl/test/org/gecko/playground/exchange/impl/OrderEventHandlerTest.java b/org.gecko.playground.exchange.impl/test/org/gecko/playground/exchange/impl/OrderEventHandlerTest.java index 761bbea9..c6c74ebf 100644 --- a/org.gecko.playground.exchange.impl/test/org/gecko/playground/exchange/impl/OrderEventHandlerTest.java +++ b/org.gecko.playground.exchange.impl/test/org/gecko/playground/exchange/impl/OrderEventHandlerTest.java @@ -1,7 +1,6 @@ package org.gecko.playground.exchange.impl; import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.mockito.Mockito.mock; import java.util.UUID; import java.util.concurrent.BlockingDeque; @@ -15,7 +14,6 @@ import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; import org.mockito.junit.jupiter.MockitoExtension; -import org.osgi.service.log.Logger; @ExtendWith(MockitoExtension.class) public class OrderEventHandlerTest { @@ -23,12 +21,12 @@ public class OrderEventHandlerTest { private final ExchangeImpl exchange = new ExchangeImpl(); private BlockingDeque fillQueue; - private Logger log; +// private Logger log; @BeforeEach protected void setUp() throws Exception { fillQueue = new LinkedBlockingDeque(); - log = mock(Logger.class); +// log = mock(Logger.class); } @AfterEach diff --git a/org.gecko.playground.rsa.api/README.md b/org.gecko.playground.rsa.api/README.md new file mode 100644 index 00000000..9c0770da --- /dev/null +++ b/org.gecko.playground.rsa.api/README.md @@ -0,0 +1,4 @@ +# `org.gecko.playground.rsa.api` + +This project contains some basic interface to be used in the remote service example. + diff --git a/org.gecko.playground.rsa.config/README.md b/org.gecko.playground.rsa.config/README.md new file mode 100644 index 00000000..0531150a --- /dev/null +++ b/org.gecko.playground.rsa.config/README.md @@ -0,0 +1,4 @@ +# `org.gecko.playground.rsa.config` + +This project is a multi bundle project and contains the configuration for provider and consumer. Each configuration ends up in an own JAR. + diff --git a/org.gecko.playground.rsa.consumer/README.md b/org.gecko.playground.rsa.consumer/README.md new file mode 100644 index 00000000..68b89932 --- /dev/null +++ b/org.gecko.playground.rsa.consumer/README.md @@ -0,0 +1,8 @@ +# `org.gecko.playground.rsa.consumer` + +This project is a consumer example for our remote service. + +It just contains the *Example* component, that gets wants the *HelloWorld* service, provided by the API. + +So as soon as the service discovery recognizes this service, it creates a local proxy for the *HelloWorld* service and injects it. + diff --git a/org.gecko.playground.rsa.consumer/consumer.bndrun b/org.gecko.playground.rsa.consumer/consumer.bndrun index 169fc6f7..4ff7a9f7 100644 --- a/org.gecko.playground.rsa.consumer/consumer.bndrun +++ b/org.gecko.playground.rsa.consumer/consumer.bndrun @@ -45,7 +45,7 @@ org.paremus.netty.tls;version='[1.0.0,1.0.1)',\ slf4j.api;version='[1.7.36,1.7.37)',\ slf4j.simple;version='[1.7.30,1.7.31)',\ - org.eclipse.parsson.jakarta.json;version='[1.1.1,1.1.2)' + org.eclipse.parsson.jakarta.json;version='[1.1.2,1.1.3)' -runrequires: \ osgi.identity;filter:='(osgi.identity=org.apache.felix.gogo.shell)',\ diff --git a/org.gecko.playground.rsa.provider/README.md b/org.gecko.playground.rsa.provider/README.md new file mode 100644 index 00000000..f5553714 --- /dev/null +++ b/org.gecko.playground.rsa.provider/README.md @@ -0,0 +1,8 @@ +# `org.gecko.playground.rsa.provider` + +This project is a provider example for our remote service. + +It just contains the *ExampleHello* component, that implement the *HelloWorld* API. It marks the service as remote service using the component properties: `service.exported.interfaces=*` + +The implementation tracks these services and creates a service description out of it. This is submitted over the service discovery mechanism + diff --git a/org.gecko.playground.rsa.provider/provider.bndrun b/org.gecko.playground.rsa.provider/provider.bndrun index a26d7e96..1d084918 100644 --- a/org.gecko.playground.rsa.provider/provider.bndrun +++ b/org.gecko.playground.rsa.provider/provider.bndrun @@ -45,7 +45,7 @@ org.paremus.netty.tls;version='[1.0.0,1.0.1)',\ slf4j.api;version='[1.7.36,1.7.37)',\ slf4j.simple;version='[1.7.30,1.7.31)',\ - org.eclipse.parsson.jakarta.json;version='[1.1.1,1.1.2)' + org.eclipse.parsson.jakarta.json;version='[1.1.2,1.1.3)' -runrequires: \ osgi.identity;filter:='(osgi.identity=org.apache.felix.gogo.shell)',\ diff --git a/org.gecko.playground.test/bnd.bnd b/org.gecko.playground.test/bnd.bnd index 8fb285f5..544145f4 100644 --- a/org.gecko.playground.test/bnd.bnd +++ b/org.gecko.playground.test/bnd.bnd @@ -7,7 +7,7 @@ Test-Cases: ${classes;HIERARCHY_INDIRECTLY_ANNOTATED;org.junit.platform.commons. org.osgi.framework;version=latest,\ org.osgi.test.junit5.cm;version=latest,\ org.gecko.playground.ds.config.configadmin;version=snapshot,\ - org.gecko.playground.ds.simple;version=snapshot + org.gecko.playground;version=snapshot Private-Package: org.gecko.playground.test diff --git a/org.gecko.playground.test/src/org/gecko/playground/test/ExampleTest.java b/org.gecko.playground.test/src/org/gecko/playground/test/ExampleTest.java index 7d83a63f..0b84bd1e 100644 --- a/org.gecko.playground.test/src/org/gecko/playground/test/ExampleTest.java +++ b/org.gecko.playground.test/src/org/gecko/playground/test/ExampleTest.java @@ -21,7 +21,7 @@ import static org.mockito.Mockito.mock; import org.gecko.playground.ds.config.api.Album; -import org.gecko.playground.ds.simple.logging.Log; +import org.gecko.playground.logging.Log; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; @@ -56,11 +56,11 @@ public class ExampleTest { @Mock Bar mockBar; - private BundleContext ctx; +// private BundleContext ctx; @BeforeEach public void before(@InjectBundleContext BundleContext ctx) { - this.ctx = ctx; +// this.ctx = ctx; } @Test diff --git a/org.gecko.playground.test/test.bndrun b/org.gecko.playground.test/test.bndrun index 66fe27a2..a2ed324a 100644 --- a/org.gecko.playground.test/test.bndrun +++ b/org.gecko.playground.test/test.bndrun @@ -1,7 +1,8 @@ -library: enableOSGi-Test -runrequires: \ - bnd.identity;id='org.gecko.playground.test' + bnd.identity;id='org.gecko.playground.test',\ + bnd.identity;id='org.gecko.playground.ds.simple' -runbundles.test: \ org.gecko.playground.test;version=snapshot @@ -17,6 +18,7 @@ net.bytebuddy.byte-buddy;version='[1.12.21,1.12.22)',\ net.bytebuddy.byte-buddy-agent;version='[1.12.21,1.12.22)',\ org.apache.felix.scr;version='[2.2.6,2.2.7)',\ + org.gecko.playground;version=snapshot,\ org.gecko.playground.ds.simple;version=snapshot,\ org.gecko.playground.test;version=snapshot,\ org.mockito.junit-jupiter;version='[4.11.0,4.11.1)',\ diff --git a/org.gecko.playground/README.md b/org.gecko.playground/README.md new file mode 100644 index 00000000..707e9e31 --- /dev/null +++ b/org.gecko.playground/README.md @@ -0,0 +1,8 @@ +# `org.gecko.playground` + +This project comtains some basic classes. + +The launchers are for running the task/workmode example within different frameoworks: + +* Eclipse Equinox +* Apache Felix diff --git a/org.gecko.playground/bnd.bnd b/org.gecko.playground/bnd.bnd index 45928dd0..98264b04 100644 --- a/org.gecko.playground/bnd.bnd +++ b/org.gecko.playground/bnd.bnd @@ -1,7 +1,3 @@ -buildpath: \ jakarta.json-api,\ - osgi.annotation - -Export-Package: \ - org.gecko.playground.configuration,\ - org.gecko.playground + osgi.annotation \ No newline at end of file diff --git a/org.gecko.playground/launch_felix.bndrun b/org.gecko.playground/launch_felix.bndrun index 24a0761d..bf4ce679 100644 --- a/org.gecko.playground/launch_felix.bndrun +++ b/org.gecko.playground/launch_felix.bndrun @@ -11,25 +11,30 @@ -runbundles: \ org.gecko.playground.logging.config;version=snapshot,\ org.gecko.playground.logging.log4j;version=snapshot,\ + org.gecko.playground;version=snapshot,\ + org.gecko.playground.workmode;version=snapshot,\ org.gecko.playground.config;version=snapshot,\ - org.osgi.util.function;version='[1.1.0,1.1.1)',\ + org.gecko.playground.tasks;version=snapshot,\ org.apache.felix.gogo.command;version='[1.1.2,1.1.3)',\ org.apache.felix.gogo.shell;version='[1.1.4,1.1.5)',\ - org.gecko.playground;version=snapshot,\ - org.gecko.playground.tasks;version=snapshot,\ org.gecko.playground.tasks.demo;version=snapshot,\ - org.gecko.playground.workmode;version=snapshot,\ - org.apache.felix.configurator;version='[1.0.8,1.0.9)',\ - org.apache.logging.log4j.slf4j-impl;version='[2.17.1,2.17.2)',\ - org.apache.felix.configadmin;version='[1.9.22,1.9.23)',\ org.apache.felix.gogo.runtime;version='[1.1.6,1.1.7)',\ - org.apache.felix.log;version='[1.2.6,1.2.7)',\ - org.apache.felix.scr;version='[2.2.0,2.2.1)',\ - org.apache.logging.log4j.api;version='[2.17.1,2.17.2)',\ - org.apache.logging.log4j.core;version='[2.17.1,2.17.2)',\ - org.osgi.util.promise;version='[1.1.1,1.1.2)',\ - slf4j.api;version='[1.7.30,1.7.31)',\ - slf4j.osgi;version='[1.7.0,1.7.1)' + org.apache.felix.cm.json;version='[2.0.0,2.0.1)',\ + org.apache.felix.configurator;version='[1.0.18,1.0.19)',\ + org.apache.felix.scr;version='[2.2.6,2.2.7)',\ + org.apache.logging.log4j.api;version='[2.19.0,2.19.1)',\ + org.apache.logging.log4j.core;version='[2.19.0,2.19.1)',\ + org.apache.logging.log4j.slf4j-impl;version='[2.19.0,2.19.1)',\ + org.osgi.service.cm;version='[1.6.1,1.6.2)',\ + org.osgi.service.component;version='[1.5.1,1.5.2)',\ + org.osgi.util.converter;version='[1.0.9,1.0.10)',\ + org.osgi.util.function;version='[1.2.0,1.2.1)',\ + org.osgi.util.promise;version='[1.3.0,1.3.1)',\ + slf4j.api;version='[1.7.36,1.7.37)',\ + org.apache.felix.log;version='[1.3.0,1.3.1)',\ + org.eclipse.equinox.cm;version='[1.5.100,1.5.101)',\ + org.eclipse.parsson.jakarta.json;version='[1.1.2,1.1.3)',\ + org.osgi.service.log;version='[1.5.0,1.5.1)' -runbundles+: \ org.apache.logging.log4j.api;startlevel=1,\ @@ -46,8 +51,7 @@ bnd.identity;id='org.gecko.playground.config',\ bnd.identity;id='org.gecko.playground.tasks.demo' --runvm: -DlogFolderPath=${build} +-runvm: -DlogFolderPath=${build}/logs -runblacklist: \ bnd.identity;id='org.apache.aries.jax.rs.whiteboard';version:Version='1.0.1',\ - bnd.identity;id='org.osgi.service.log';version:Version='1.4.0.201802012107',\ - bnd.identity;id='slf4j.simple';version:Version='1.6.0' \ No newline at end of file + bnd.identity;id='slf4j.simple' \ No newline at end of file diff --git a/org.gecko.playground/src/org/gecko/playground/configuration/package-info.java b/org.gecko.playground/src/org/gecko/playground/configuration/package-info.java index ed47087e..4b4a3122 100644 --- a/org.gecko.playground/src/org/gecko/playground/configuration/package-info.java +++ b/org.gecko.playground/src/org/gecko/playground/configuration/package-info.java @@ -1,2 +1,3 @@ @org.osgi.annotation.versioning.Version("1.0.0") +@org.osgi.annotation.bundle.Export package org.gecko.playground.configuration; diff --git a/org.gecko.playground.ds.simple/src/org/gecko/playground/ds/simple/logging/Log.java b/org.gecko.playground/src/org/gecko/playground/logging/Log.java similarity index 65% rename from org.gecko.playground.ds.simple/src/org/gecko/playground/ds/simple/logging/Log.java rename to org.gecko.playground/src/org/gecko/playground/logging/Log.java index 89c9a64f..7dd2960a 100644 --- a/org.gecko.playground.ds.simple/src/org/gecko/playground/ds/simple/logging/Log.java +++ b/org.gecko.playground/src/org/gecko/playground/logging/Log.java @@ -1,4 +1,4 @@ -package org.gecko.playground.ds.simple.logging; +package org.gecko.playground.logging; public interface Log { diff --git a/org.gecko.playground/src/org/gecko/playground/logging/package-info.java b/org.gecko.playground/src/org/gecko/playground/logging/package-info.java new file mode 100644 index 00000000..0a9325b3 --- /dev/null +++ b/org.gecko.playground/src/org/gecko/playground/logging/package-info.java @@ -0,0 +1,3 @@ +@org.osgi.annotation.versioning.Version("1.0.0") +@org.osgi.annotation.bundle.Export +package org.gecko.playground.logging;