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

Adjust and clean-up/simplify sisu-OSGi-connect #1361

Merged
merged 2 commits into from
Sep 20, 2022

Conversation

HannesWell
Copy link
Member

This PR is split in two commits.

  1. A few minor clean-ups/simplifications for the code of sisu-osgi-connect that I noticed while working on Add PDE API Tools Mojo for Tycho #1328.

  2. The path for the connect.bundles file is fixed in the release-notes and the path of the connect.properties is changed from META-INF/sisu-connect.properties to META-INF/sisu/connect.properties, to correspond to META-INF/sisu/connect.bundles.
    @laeubi I assume that was the actual intention, wasn't it?

@HannesWell HannesWell requested a review from laeubi September 18, 2022 19:20
@HannesWell HannesWell changed the title Clean Adjust and clean-up/simplify sisu-OSGi-connect Sep 18, 2022
@github-actions
Copy link

github-actions bot commented Sep 18, 2022

Test Results

328 files  328 suites   2h 13m 49s ⏱️
292 tests 288 ✔️ 4 💤 0
584 runs  575 ✔️ 9 💤 0

Results for commit 34712da.

♻️ This comment has been updated with latest results.

@laeubi
Copy link
Member

laeubi commented Sep 19, 2022

Yeah the path part was changed at the development phase a bit, an I'm not completely happy with the way to configure this but I think we need to get some experience with that :-)

@HannesWell
Copy link
Member Author

Yeah the path part was changed at the development phase a bit, an I'm not completely happy with the way to configure this but I think we need to get some experience with that :-)

No problem, its a new thing and it is really hard to know from the beginning how to use it/configure it in all cases. :)

Two other things I noticed (that maybe should be addressed separately if we know we need it):

  • A EquinoxServiceFactory with hint="connect" cannot be injected into Mojo but into a Plexus-Component, but a factory with hint "tycho-core" can be injected into a Mojo. I have no clue why, but at least I was not able to do that in Add PDE API Tools Mojo for Tycho #1328 and therefore created a separated component.
  • EquinoxServiceFactory only launches a framework when querying a service, but in some cases one only wants to launch the framework without querying a service, because the desired class is not available as OSGi-Service and has to be instantiated directly. At least that is the case in Add PDE API Tools Mojo for Tycho #1328 (given that it uses/works with osgi-connect finally).
    But we can discuss that in Add PDE API Tools Mojo for Tycho #1328.

@laeubi
Copy link
Member

laeubi commented Sep 19, 2022

  • A EquinoxServiceFactory with hint="connect" cannot be injected into Mojo but into a Plexus-Component, but a factory with hint "tycho-core" can be injected into a Mojo.

Please be carefull that Mojo + Plexus Component use different annotations (@Component versus @Requirement) and one can't mix both!

  • EquinoxServiceFactory only launches a framework when querying a service, but in some cases one only wants to launch the framework without querying a service, because the desired class is not available as OSGi-Service and has to be instantiated directly.

Yes, OSGi is all about services, so you should use them. Anyways you can query any service if you think you can do better without it even getService(Object.class)

@HannesWell
Copy link
Member Author

  • A EquinoxServiceFactory with hint="connect" cannot be injected into Mojo but into a Plexus-Component, but a factory with hint "tycho-core" can be injected into a Mojo.

Please be carefull that Mojo + Plexus Component use different annotations (@Component versus @Requirement) and one can't mix both!

🤦🏽‍♂️ looks like I indeed blindly copied it and didn't notice @Component versus @Requirement. Thanks for the hint! That should be it.

  • EquinoxServiceFactory only launches a framework when querying a service, but in some cases one only wants to launch the framework without querying a service, because the desired class is not available as OSGi-Service and has to be instantiated directly.

Yes, OSGi is all about services, so you should use them. Anyways you can query any service if you think you can do better without it even getService(Object.class)

In the mentioned case there was simply no useful service that I could query, but yes I just queried some unused service to launch the osgi-instance. But using Object probably indicates the intend of not using it better.

@laeubi
Copy link
Member

laeubi commented Sep 19, 2022

In the mentioned case there was simply no useful service that I could query

Then probably there should be one!

Just keep in mind that the whole purpose of connect is to interact with the OSGi framework (otherwise you might better instantiate the classes directly without any OSGi), so you can ave you a lot of trouble if there is a service you can call and that do the dirty bits without you knowing. I also used something similar anyways but more as a legacy way, so you should be able to directly use any class up to a point where one service will be required. And yes Eclipse is nasty in its usage of static activator access... a good opportunity to fix that and using real service/ds instead :-)

@HannesWell
Copy link
Member Author

In the mentioned case there was simply no useful service that I could query

Then probably there should be one!

Just keep in mind that the whole purpose of connect is to interact with the OSGi framework (otherwise you might better instantiate the classes directly without any OSGi), so you can ave you a lot of trouble if there is a service you can call and that do the dirty bits without you knowing. I also used something similar anyways but more as a legacy way, so you should be able to directly use any class up to a point where one service will be required. And yes Eclipse is nasty in its usage of static activator access... a good opportunity to fix that and using real service/ds instead :-)

Fully agree, but that is a huge task since that pattern is used very often in the Eclipse eco-system.

@HannesWell HannesWell added this to the 3.0 milestone Sep 19, 2022
@laeubi
Copy link
Member

laeubi commented Sep 20, 2022

Fully agree, but that is a huge task since that pattern is used very often in the Eclipse eco-system.

Every little piece counts :-) As DS now days even require less setup I don't see a reason to not use it ...

@HannesWell
Copy link
Member Author

Fully agree, but that is a huge task since that pattern is used very often in the Eclipse eco-system.

Every little piece counts :-) As DS now days even require less setup I don't see a reason to not use it ...

That's right. I just meant it is too much to wait for it now. :)

Besides that, do you have any more remarks? If not I think this is ready.

@HannesWell HannesWell requested a review from laeubi September 20, 2022 07:45
Copy link
Member

@laeubi laeubi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds reasonable!

@laeubi laeubi merged commit fe99a12 into eclipse-tycho:master Sep 20, 2022
@HannesWell HannesWell deleted the osgiConnect branch September 20, 2022 13:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants