DS Annotations with BND

38 views
Skip to first unread message

Jens Kübler

unread,
Apr 15, 2017, 10:41:20 AM4/15/17
to bndtools-users
I'm trying to create the most simple example with ds annotations.
I have a component with annotations and I am writing to sysout "Hello World"

@Component(name="test")
public class DockerIdentification implements ContainerIdentification {
@Activate
public void activate() {
System.out.println("Hello World");
}
}

I managed the run configuration and checked that the xml file is generated correctly in the jar.
Everthing is fine but I simply don't see "Hello World" when running with felix

What could I possible do wrong ?

I figured that in the component's bundle bnd.bnd there is a drop down box for annotations that always resets itself to Manually.
As the bundle looks fine I suspect this is just a UI bug.

list+bndt...@io7m.com

unread,
Apr 15, 2017, 10:59:15 AM4/15/17
to 'Jens Kübler' via bndtools-users
On 2017-04-15T07:41:20 -0700
'Jens Kübler' via bndtools-users <bndtool...@googlegroups.com>
wrote:

> I'm trying to create the most simple example with ds annotations.
> I have a component with annotations and I am writing to sysout "Hello World"
>
> @Component(name="test")
> public class DockerIdentification implements ContainerIdentification {
> @Activate
> public void activate() {
> System.out.println("Hello World");
> }
> }
>
> I managed the run configuration and checked that the xml file is generated
> correctly in the jar.
> Everthing is fine but I simply don't see "Hello World" when running with
> felix
>
> What could I possible do wrong ?

Couple of things spring to mind:

1. Is anything actually triggering that component to be instantiated?
It's not marked as @Component(immediate=true).

2. Do you have the right SCR bundles installed? You need at least
org.apache.felix.scr installed before any DS components will do
anything.

M

Jens Kübler

unread,
Apr 15, 2017, 12:11:03 PM4/15/17
to bndtools-users, list+bndt...@io7m.com
Here is the console output. Added immediate = true

g! lb
START LEVEL 1
   ID|State      |Level|Name
    0|Active     |    0|System Bundle (5.4.0)|5.4.0
    1|Active     |    1|Apache Felix Log Service (1.0.1)|1.0.1
    2|Active     |    1|com.kuebler.uservices.id.api (1.0.0.201704151330)|1.0.0.201704151330
    3|Active     |    1|Docker Identifaction (1.0.0.201704151425)|1.0.0.201704151425
    4|Active     |    1|Apache Felix Gogo Command (1.0.2)|1.0.2
    5|Active     |    1|Apache Felix Gogo Runtime (1.0.0)|1.0.0
    6|Active     |    1|Apache Felix Gogo Shell (1.0.0)|1.0.0
    7|Active     |    1|Apache Felix Metatype Service (1.1.2)|1.1.2
    8|Active     |    1|Apache Felix Declarative Services (2.0.8)|2.0.8
    9|Active     |    1|Apache Felix EventAdmin (1.4.6)|1.4.6
   10|Active     |    1|Apache Felix Configuration Admin Service (1.8.8)|1.8.8
g! list
 BundleId Component Name Default State
    Component Id State      PIDs (Factory PID)
 [   3]   test  enabled
    [   0] [satisfied   ] 
g! 

Jens Kübler

unread,
Apr 15, 2017, 12:17:09 PM4/15/17
to bndtools-users, list+bndt...@io7m.com
Oh and one more thing. Launching it in debug mode and setting breakpoints eclipse never enters these breakpoints
In the launch I have

-runrequires.debug:  ${debug-bundles}
-runtrace: true

BJ Hargrave

unread,
Apr 15, 2017, 12:27:33 PM4/15/17
to bndtool...@googlegroups.com
What triggers the component to be activated? Since it is not immediate, does some other bundle get its service? 

--
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

Jens Kübler

unread,
Apr 15, 2017, 1:27:35 PM4/15/17
to bndtools-users
D'oh. I could not see the forrest through the trees.
It does work now.
Thanks for the help.
Reply all
Reply to author
Forward
0 new messages