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

Enhance wizard-based creation of OSGi services #5632

Closed
scottslewis opened this issue Apr 10, 2023 · 30 comments
Closed

Enhance wizard-based creation of OSGi services #5632

scottslewis opened this issue Apr 10, 2023 · 30 comments
Assignees

Comments

@scottslewis
Copy link
Contributor

As per discussion here

https://bnd.discourse.group/t/osgi-services-creation-wizards/218/12

It would be useful to for bndtools to support wizard-based creation of OSGi services.

As an initial contribution, I've created a new package/API: org.bndtools.core.ui.wizards.service for building wizards for creating OSGi services with (by default) three projects: a service-api project, a service-impl project, and service-consumer project. These wizard classes allow the use of named bndtools templates for creating the service-api, service-impl, and service-consumer projects via a single wizard.

Further, I've created a Java OSGi Service wizard in new package: org.bndtools.core.ui.wizards.service.java and referenced in _plugin.xml. This uses the new package/API above and 3 built-in templates (in new bundtools.core/resources/unprocessed/serviceTemplates) in bndtools.core.

@scottslewis
Copy link
Contributor Author

Please see draft pull request #5633

@scottslewis
Copy link
Contributor Author

Please see new pull request #5643 for simplification of new service wizard support

@scottslewis
Copy link
Contributor Author

@kriegfrj I would appreciate your merging of the pr in bndtools.workspace repo here

bndtools/workspace#18

All it does is add the bundle annotation bundle to the workspace template...so that the java wizard contribution (associated with this issue) will work as expected by users when using the bndtools.workspace workspace template.

@scottslewis
Copy link
Contributor Author

@kriegfrj @pkriens

I've completed the technical work to close this issue except for two things:

  1. The modification of the bndtools workspace to include the org.osgi.annotation.bundle (so that if the new java osgi service wizard is used, the wizard-create classes will all compile...since the @Version annotation is used by the wizard-created code). The pull request for this is change is here Added org.osgi.annotation.bundle to maven repo as described by workspace#18 (in the bndtools/workspace repo).

  2. I think it would be useful to add this same org.osgi.annotation.bundle (from maven central) to the workspace.minimal workspace template. However, currently this minimal template has absolutely nothing in it...meaning that I would have to add maven central repo and the inclusion of the org.osgi.annotation.bundle (as with the above workspace). This seems still pretty minimal (I don't see how anyone could actually use the current minimal workspace template for any real project)....but I leave this to the committers to decide. If you will approve a pull request for the minimal workspace template to add the necessary annotation classes then please let me know and I'll submit one.

  3. Any further textual/wizard name changes desired, and/or code generalizations or refactoring to make extension easier/more useful for other osgi service wizard use cases.

BTW: I have another Eclipse plugin that adds 5 additional Remote Service wizards to create gRPC, sync, asyn, jaxrs distribution-based remote services. These are based upon the classes added to bndtools (no new java code, just plugin.xml). Currently this Eclipse plugin is in https://github.com/ECF/grpc-RemoteServicesProvider repo (p2 repo in build sub-directory). I may move it elsewhere but obviously it has to wait on bndtools 7 next release. When is that next bndtools 7 release expected?

Thanks.

@pkriens
Copy link
Member

pkriens commented May 26, 2023

@scottslewis the bndtools/workspace#18 PR fails, can you fix?

About 2, I agree, please also add it to minimum

About 3, do you take action here? not sure I get it?

Next, release, I am going to work on it soon. July is likely

@scottslewis
Copy link
Contributor Author

scottslewis commented May 27, 2023 via email

@pkriens
Copy link
Member

pkriens commented Jul 21, 2023

We're discussing release process. Do we want that in here?

@scottslewis
Copy link
Contributor Author

Yes.

@scottslewis
Copy link
Contributor Author

One comment: To have the java service tutorial work 'out of the box' in bndtools 7.x, it requires updates to the two default workspace templates (i.e. bndtools.workspace and bndtools.workspace.minimal). That's why I opened the issues on those workspace template repos. I stated on one of them (can't remember which one now) what the needs/requirements are for the workspace templates (i.e. so that they include the annotations currently used in the tutorial [compile] as well as the runtime-required bundles...e.g. scr, framework, console, etc). Depending on what happens wrt those two templates (e.g. versions) I may need to make some small modifications to the tutorial...which includes generated bndrun files. I will be responsive on doing that work (and contributing to the workspace template changes if needed) to make the necessary and timely adjustments to the java service wizard.

@pkriens pkriens self-assigned this Sep 1, 2023
@pkriens
Copy link
Member

pkriens commented Sep 5, 2023

I feel a bit daft but I cannot really figure out what I need to do to progress this. Can you give me an instruction list for an IQ 85? :-)

I am publishing RC1 end of the week and I'd like to get this in.

@scottslewis
Copy link
Contributor Author

What remains to be done to have this work properly is to enhance the bndtools and bndtools.minimal workspace template projects so that they both

  1. Reference OSGi R8 repos/bundles
  2. Include references to the dependencies in the wizard-created code as per Enhance wizard-based creation of OSGi services #5632 (comment)

Here are is the OSGi R8 issue for bndtools.workspace

bndtools/workspace#23

and bndtools.workspace.min

bndtools/bndtools.workspace.min#7

In the workspace.min issue is the dependencies that the wizard-generated require:

he requirements of the generated projects are currently: Use of R8 org.osgi.annotation.bundle.Export and org.osgi.annotation.versioning.Version("1.0.0") annotations. Use of org.osgi.service.component.annotations.Component, org.osgi.service.component.annotations.Reference, org.osgi.service.component.annotations.Activate scr annotations. Use of R8 framework impl. Use of R8 SCR impl, Use of gogo (shell, command, runtime bundles).

I would request that the wizard's R8 dependencies as above be present for both min and the bndtools.workspace templates (annotations, scr, framework, gogo console). That way the new Java wizard (this issue) output will compile and run for either of the bndtools.workspace and bndtools.workspace.min templates.

@chrisrueger
Copy link
Contributor

I feel a bit daft but I cannot really figure out what I need to do to progress this.

I would interpret that

https://github.com/bndtools/workspace/blob/master/cnf/build.bnd

currenty points OSGi R7 (7.0.0) (org.osgi.enroute:osgi-api:7.0.0)

image

What I think @scottslewis is asking, is to increase that to R8?

Maybe https://mvnrepository.com/artifact/org.osgi/osgi.core/8.0.0 ?

Maybe @scottslewis could clarify more.

@scottslewis
Copy link
Contributor Author

> > What I think @scottslewis is asking, is to increase that to R8?

Yes, that's correct. I've got open issues for both the minimal workspace template repo and the regular workspace template repo to use R8...and to include in both workspace templates the org.osgi.* dependencies required for the Java service wizard-created projects to resolve (e.g. scr impl, as well as some OSGi annotations. See

https://github.com/bndtools/bndtools.workspace.min/issues

and

https://github.com/bndtools/workspace/issues

I think a complicating factor here is may be that the location and organization of bundles (enroute?) changed from R7 to R8...and so it isn't a tiny change of the version number in the pom that's necessary. I could be wrong about that, but don't know enough about the shape of things in R7 vs. R8.

@chrisrueger
Copy link
Contributor

chrisrueger commented Nov 17, 2023

I think @pkriens started something here:
bndtools/bndtools.workspace.min#9

Is this related? Sorry for asking, but I get lost a bit with all the links to Issues and PRs :)

I can help testing, but I try to find out "what".

@chrisrueger
Copy link
Contributor

Maybe helpful:

  • org.osgi.enroute:osgi-api:7.0.0 in the Repository definition seems to be a POM bundling all single deps into one big thing and provide it as a repo (BndPomRepository)
  • for R8 I couldn't find such a thing
  • thus: I search libs manually
  • I tried that for our app
  • I search and handpicked all GAVs to go from R7 to R8 for our app and these are the changes I made until the app started again.
  • I guess a minimum like that is what is needed in the template as well (maybe not the HTTP stuff, if you do not need it)
image
org.osgi:osgi.core:8.0.0
#org.osgi:osgi.cmpn:8.0.0
org.osgi:osgi.annotation:8.0.0
org.osgi:org.osgi.service.component.annotations:1.5.1
org.osgi:org.osgi.service.component:1.5.1
org.osgi:org.osgi.util.promise:1.3.0
org.osgi:org.osgi.service.http:1.2.2
org.apache.felix:org.apache.felix.scr:2.2.6

Sidenode (for people coming from google):
During it took me a while to figure out this error during startup:
Unresolved requirement: Require-Capability: osgi.extender; filter:="(&(osgi.extender=osgi.component)(version>=1.5.0)(!(version>=2.0.0)))"

Solution: upgrade from org.apache.felix:org.apache.felix.scr:2.1.28 to org.apache.felix:org.apache.felix.scr:2.2.6
because only org.apache.felix:org.apache.felix.scr:2.2.6 provides the Capability osgi.extender=osgi.component in v 1.5.0. org.apache.felix:org.apache.felix.scr:2.1.28 just had 1.4.0

image

Slowly I am getting (used to) the Resolution View :)

@pkriens pkriens assigned chrisrueger and unassigned pkriens Nov 24, 2023
@chrisrueger
Copy link
Contributor

@scottslewis I talked to @pkriens today and I started this PR.
bndtools/bndtools.workspace.min#11

I would need your help to verify if this solves what you are asking for. The PR contains steps to test this.
Maybe this is similar to how you could test it with your new wizard.

Let me know in the PR if you want changes.

@scottslewis
Copy link
Contributor Author

@chrisrueger I will give it a try now

@pkriens
Copy link
Member

pkriens commented Dec 8, 2023

I just merged the bndtools.workspace.min ...

Can we work from this because I understand that @chrisrueger has more confidence in this one than the workspace one.

I am also inclined to have only one from now on.

@scottslewis can you look and give back a list of things to do?

@scottslewis
Copy link
Contributor Author

I just merged the bndtools.workspace.min ...

Can we work from this because I understand that @chrisrueger has more confidence in this one than the workspace one.

I am also inclined to have only one from now on.

@scottslewis can you look and give back a list of things to do?

@pkriens @chrisrueger

Yes. Today, I've tested using the Java OSGi service wizard using the min repo contents from main with bndtools snapshot (12/8).

Short story: The Java OSGi Service wizard now (R8 min workspace template) works as desired. Thanks @chrisrueger and @pkriens!

There is one small nit fixed by pr #5932. Without this fix, the after the 3 projects are created by the wizard the workspace is not refreshed and has errors because of dependencies between projects. With pr #5932 the workspace is refreshed and so everything is green once the wizard is finished.

I am also inclined to have only one from now on.

It's your call, but haven't there been two around for a while? Won't this be a bit of a surprise for bndtools users that have been using two for a while?

So if pr #5932 can be merged then I will close this issue. When is the next expected release of bndtools?

I would suggest some promotion of the existence of the Java OSGi Service Wizard in the next release...I'm not sure how/who does that, but if a couple of screenshots are desired I can easily create them now.

One other thing to make public: It's possible with the current code to create custom service wizards just by using the eclipse wizard extension point and providing a bndtools service template. For example, this markup creates a new Grpc Remote Service Wizard

<wizard
            category="bndtools.serviceWizardCategory/org.eclipse.ecf.remoteservices.category"
            finalPerspective="bndtools.perspective"
            class="org.bndtools.core.ui.wizards.service.NewBndTemplateBasedServiceWizard:grpc"
            icon="icons/grpc16x16.gif"
            id="org.eclipse.ecf.bndtools.grpc.ui.grpc"
            name="gRPC Remote Service (generated api, impl, consumer)"
            preferredPerspectives="bndtools.perspective"
            project="true">
      </wizard>

I intend to use this so that I (or anyone) can introduce new OSGi service wizards for (e.g.) the wizard-based creation of Remote Services (like with the ECF grpc provider-based wizard as above).

I can/will produce more documentation for this, but can't right at the moment. But it is something that's already in the existing service wizard code.

@chrisrueger
Copy link
Contributor

couple of screenshots are desired I can easily create them now.

Oh yes please. Maybe just paste them here with a few bullet points of notes.

@scottslewis
Copy link
Contributor Author

scottslewis commented Dec 12, 2023

Once this pr is merged: #5932

Then with bndtools snapshot or newer here are screenshots of the projects creation of the Java OSGi Service Wizard

Requirements: It's assumed that bndtools snapshot or better has been installed, and a new workspace has been created with the new bndtools.workspace.min (R8) template.

To open wizard, select File->New->Other...

image

Then select OSGi Services -> Java OSGi Service (api, impl, consumer) and Next>

image

Fill in desired values for the Project Name and the Service Name fields, and make any other desired changes to the execution environment or project set usage on the wizard page

image

Click Finish

image

There are three projects created org.myorg.test.hello (api), org.myorg.test.hello.impl, and org.myorg.test.hello.consumer.

The three Java classes created (in each of the projects) are shown in the edit window (HelloService, HelloServiceImpl, HelloServiceConsumer).

If desired, the user can use Eclipse refactoring to rename the default service method (named methodName) to (e.g.) hello, resulting in:

image

Included in the generated org.myorg.test.hello project is a Hello.bndrun file that can be used to launch a framework. register the HelloServiceImpl, inject (via SCR) into the HelloServiceConsumer and have the HelloServiceConsumer call the service.

To Run/Debug

image

Opening the bndrun file results in:

image

Then clicking Resolve and Update

image

Then clicking on Run OSGi (or Debug OSGi). Results in the service method being called and the console output

image

@chrisrueger
Copy link
Contributor

Thanks a lot @scottslewis for the screnshots and notes.
I will create a PR for this.

Question:
My initial suggestion would be to put it here on the bndtools website in a new UI-Section "Templates".

image

Thoughts? Or you know a better place? @pkriens

@chrisrueger
Copy link
Contributor

@scottslewis @pkriens I have created bndtools/bndtools.github.io#146 for my website / documentation relevant additions for the next release. Feel free to provide feedback, additions and corrections there.

@chrisrueger
Copy link
Contributor

chrisrueger commented Dec 12, 2023

@scottslewis

One other thing to make public: It's possible with the current code to create custom service wizards just by using the eclipse wizard extension point and providing a bndtools service template. For example, this markup creates a new Grpc Remote Service Wizard

I have added a section "Creating custom OSGi service wizards" to the Developer Guide here

@scottslewis
Copy link
Contributor Author

I've just tested the Java OSGi Service wizard in bndtools snapshot: 7.1.0.DEV-202312261441-gd759351. It's working as designed/expected, so I'm closing this issue. Please reopen if issues remain open until actually released.

@scottslewis
Copy link
Contributor Author

scottslewis commented Nov 28, 2024

@chrisrueger I see that you are the author of the recently released 7.1 changes...i.e.

https://github.com/bndtools/bnd/wiki/Changes-in-7.1.0

A couple of small nits about the OSGi Services Wizard finally released in 7.1.0:

First, there is this in the text about the OSGi Services Wizard currently:

new Wizard for creating a Java OSGi Service (api, impl, consumer) on the new Project Templates section on the bndtools website.

I should point out that technically this isn't just another project template, but rather a whole new type of template...i.e. an OSGi service template. Also included is both the infrastructure classes for this new type of template and the wizard/UI classes for using this new type of template to create api, impl, consumer bundles from 3 project templates. So yes, there is just a single Java OSGi Service template right now, but my intention is to introduce a number of OSGi Remote Service templates after refactoring ECF workspace template.

Also, I think the screenshots that you/ @chrisrueger have already put together should have a higher profile on the top-level page....just because it is a big (new) user-visible change for encouraging/enabling the creation of OSGi services. As far as I've seen, it's the first UI-visible tooling support for OSGi services specifically in the Eclipse ecosystem. My $0.03.

@chrisrueger
Copy link
Contributor

Thanks for the remarks @scottslewis . I am totally fine to weave this in, whatever you think is best. I mean you could write it yourself if you want and I put it there exactly as you write it (in case you don't see the Edit button on the wiki page.

Also, I think the screenshots that you/ @chrisrueger have already put together should have a higher profile on the top-level page.

Do you mean the homepage (bndtools.org) like the other existing sections?
image

@chrisrueger
Copy link
Contributor

@scottslewis I added a separate section: https://github.com/bndtools/bnd/wiki/Changes-in-7.1.0#osgi-service-template

If you like to have wording changes, please post the exact sentences and I'll add / copy paste them :)

@scottslewis
Copy link
Contributor Author

@scottslewis I added a separate section: https://github.com/bndtools/bnd/wiki/Changes-in-7.1.0#osgi-service-template

If you like to have wording changes, please post the exact sentences and I'll add / copy paste them :)

Hi @chrisrueger. This looks fine to me. Thanks. I don't need/want to write doc sat the moment as I'm taking some time off...so your willingness to do this is most appreciated. I trust your judgment/decisions about best places to make visible.

For everyone's info: It's my intention/desire to contribute additional service creation wizards for ECF remote services...e.g. async remote services using various distribution providers (e.g. grpc). I may try to contribute also a tutorial and/or docs on introducing one's own OSGi service template using the new classes introduced in 7.1 so that others can contribute OSGi service creation wizards also.

BTW, congrats on the 7.1 release.

@chrisrueger
Copy link
Contributor

@scottslewis ok thanks for the feedback.
Regarding the highlighting the Wizzard on the bndtools.org website I will have a look in the next days.

BTW, congrats on the 7.1 release.

Thanks, but kudos goes to @pkriens and @peterkir for tweaking and doing the release process.

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

No branches or pull requests

3 participants