How do I make an (abstract) superclass for factories?

27 views
Skip to first unread message

Arvid

unread,
Nov 16, 2020, 2:56:17 AM11/16/20
to bndtools-users
Hello OSGI enthusiasts,

I have a question (again): I have several factories whose configuration is provided by JSON files. 
Now, to make it more modular, I have split the factories over a few different projects. 
Apart from their project and configuration, the factories are the same. So that I don't get a boiler plate code, I would like to write an abstract super class for the factories. 
But unfortunately I have no success with it, because then the factories can no longer be found. 
Even if I keep the @References in every derivation. The abstract super class would then have to be in the API.

How can I do that, or even do it better in a different way? 
Does anyone have an example?

Best regards 
Arvid


Jürgen Albert

unread,
Nov 16, 2020, 3:04:46 AM11/16/20
to bndtool...@googlegroups.com

Hi Arvid,

I had the same Problem at a certain point.

-dsannotations-options: inherit

This Should solve your issue.

see: https://bnd.bndtools.org/instructions/dsannotations-options.html

Hope this helps,

Jürgen.

--
You received this message because you are subscribed to the Google Groups "bndtools-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to bndtools-user...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/bndtools-users/fc52b854-8ed5-43e9-9839-731b61ae08ban%40googlegroups.com.
-- 
Jürgen Albert
Geschäftsführer

Data In Motion Consulting GmbH

Kahlaische Str. 4
07745 Jena

Mobil:  0157-72521634
E-Mail: j.al...@datainmotion.de
Web: www.datainmotion.de

XING:   https://www.xing.com/profile/Juergen_Albert5

Rechtliches

Jena HBR 513025

Stefan Feilmeier

unread,
Nov 16, 2020, 3:08:32 AM11/16/20
to bndtools-users
Hi Arvid,

this is how I usually solve similar problems in OpenEMS (https://openems.io):

(The example is a "driver" component for Modbus connections - either via serial RS485 line or Ethernet):


I had not know about Jürgens tip. Sounds interesting and will have a look.

Regars,
Stefan

Jürgen Albert

unread,
Nov 16, 2020, 3:16:28 AM11/16/20
to bndtool...@googlegroups.com

@Stefan:

Speaking of tips: Did you know that you can use the EventTopics Annotation to get rid of the error prone properties. See -> https://docs.osgi.org/specification/osgi.cmpn/7.0.0/service.event.html#org.osgi.service.event.propertytypes.EventTopics

Regards,

Jürgen.

--
You received this message because you are subscribed to the Google Groups "bndtools-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to bndtools-user...@googlegroups.com.

David Jencks

unread,
Nov 16, 2020, 4:34:13 AM11/16/20
to 'Clément Delgrange' via bndtools-users
When I argued for and implemented this option, BJ and Peter pointed out that it tends to make your bundle dramatically more fragile, as it depends on a superclass that by default isn’t in the bundle, and may change incompatibly.  I advise using bnd to pull the superclass (in a private package) into each of the bundles extending it.

David Jencks

BJ Hargrave

unread,
Nov 16, 2020, 9:18:18 AM11/16/20
to bndtool...@googlegroups.com
See also https://stackoverflow.com/questions/37681829/why-arent-osgi-declarative-services-ds-annotations-inherited-from-super-class for more information behind the reason component inheritance is not supported by the DS spec.



--

BJ
Reply all
Reply to author
Forward
0 new messages