How to create an annotation for a service property?

36 views
Skip to first unread message

Christian Schneider

unread,
Nov 7, 2016, 6:32:37 AM11/7/16
to bndtool...@googlegroups.com
If I remember correctly then bnd or DS allow to use annotations to
define service properties. I was not able to find an example for it though.

Can anyone point me to how to do something like this:

@RestPath("/task")
@Component
public class TaskResourceImpl {

}

Where my annotation above would add a service property:

org.apache.cxf.rs.address="/task"

Christian

--
Christian Schneider
http://www.liquid-reality.de

Open Source Architect
http://www.talend.com

Benson Margulies

unread,
Nov 7, 2016, 6:41:22 AM11/7/16
to bndtool...@googlegroups.com
@Component(property="org.apache.cxf.rs.assert="/task")
> --
> 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.
> For more options, visit https://groups.google.com/d/optout.

Christian Schneider

unread,
Nov 7, 2016, 6:50:35 AM11/7/16
to bndtool...@googlegroups.com
This is what I use now. The question was if I can use a custom
annotation that creates this service property.

I remember that Peter used something like this for enroute but could not
find the code anymore.

Christian

Simon Chemouil

unread,
Nov 7, 2016, 8:39:06 AM11/7/16
to bndtools-users
Hi Christian,

Last time I checked bnd did not support custom property annotations. There is a solution in the upcoming DS R7 draft that was presented at OSGi CE by Carsten Ziegeler. I believe bnd support will come then.

If you're like me and can't wait, unless there's now first class support, you can use my bnd plugin: http://lambdacube.github.io/bnd-dsap-plugin/

Right now it is not tested with bnd's latest version (and bnd does not provide any guarantee of API compatibility) but it worked on recent versions (3.1 being the latest I tried) and it is trivial to fix it there is a problem.

It has a few gotchas (notably because of some limitations in bnd 3.0 annotation support) but it will do exactly what you want.

It is very easy to get started and you can smoothly move to future DS R7 annotation if you name your property keys in the same way DS does with annotation configuration objects.

Hope this helps,

Simon

BJ Hargrave

unread,
Nov 7, 2016, 11:29:37 AM11/7/16
to bndtool...@googlegroups.com
RFC 222 is adding a ComponentPropertyType meta-annotation to DS for the next spec release. This integrates with the existing component property type support in DS 1.3 to provide a type-safe way to specify component property values on the component declaration.

Bnd does not currently support this design proposal however. See section 5.10 in the latest RFC 222 at https://github.com/osgi/design/blob/master/rfcs/rfc0222/rfc-0222-DeclarativeServicesUpdates.pdf.

--
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.
For more options, visit https://groups.google.com/d/optout.
--
BJ
Reply all
Reply to author
Forward
0 new messages