Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OSGi: Use declarative service registration instead of programmatic for #4371 #4372

Closed
denis-anisimov opened this issue Jul 9, 2018 · 5 comments
Assignees
Milestone

Comments

@denis-anisimov
Copy link
Contributor

I've been trying to register a service using OSGi @Component annotation instead of using bundle activator and programmatic registration. But I'm failed: the service for some reason doesn't appear as a registered in the flow-client bundle.

It would be nice (though not necessary) to use declarative OSGi service registration instead of programmatic.
This is just an enhancement and is not a top priority. We may live without this.

@Sandared
Copy link

Hi Denis,

does your service not appear at all or is it registered but just not activated?

Kind regards,
Thomas

@denis-anisimov
Copy link
Contributor Author

Hi,
no service reference available : it's null when I ask for it.

@Sandared
Copy link

Did you check if your service throws any Exceptions within its @Activate method? Those are often silently swallowed by OSGi and then the service just doesn't start.

If you are using felix-scr at runtime for your declarative services then in the gogo shell you could use the scr commands to get more information about the bundles and services they provide and if your service is not found at all or registered but not activated.

@denis-anisimov
Copy link
Contributor Author

I don't have any @Activate method.
The service just makes possible to get resources from the bundle via API method.
So there is no need in any specific activation.

I think I missed something trying @Component annotation since I'm quite new in this area.
So we will return back to this at some point. It's not very important and now there is no time for this.

But thank you for helping with this anyway!

@pleku pleku added this to the Not Planned milestone Jul 16, 2018
@denis-anisimov
Copy link
Contributor Author

Just for the reference:
to be able to make declarative registration works you should deploy implementation AND DON'T deploy the API (like compendium jar: it's only compile time dependency).

If you don't have implementation bundles in your OSGi container then this declarative registration won't work.

In our felix tests currently no implementation is deployed so that's the reason why it doesn't work.
There will be a PR which deploys this implementation bundles and with this setup it will work.
For Felix this is org.apache.felix.scr.* bundles.
Once this PR is merged we may use fix this issue and use declarative service registration.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants