+ @Inject
+ @Activate
+ public KitchenServiceImpl(@Reference final RpcService rpcService,
+ @Reference final NotificationService notifService) {
+ super("KitchenService", "toaster-consumer", null);
+ makeToast = rpcService.getRpc(MakeToast.class);
+ reg = notifService.registerCompositeListener(new CompositeListener(Set.of(
+ new CompositeListener.Component<>(ToasterOutOfBread.class, notification -> {
+ LOG.info("ToasterOutOfBread notification");
+ toasterOutOfBread = true;
+ }),
+ new CompositeListener.Component<>(ToasterRestocked.class, notification -> {
+ LOG.info("ToasterRestocked notification - amountOfBread: {}", notification.getAmountOfBread());
+ toasterOutOfBread = false;
+ }))));
+ register();
+ }
+
+ @PreDestroy
+ @Deactivate
+ public void close() {
+ unregister();
+ reg.close();