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

Introduces test http server #9748

Merged
merged 27 commits into from
Sep 4, 2023
Merged

Introduces test http server #9748

merged 27 commits into from
Sep 4, 2023

Conversation

koppor
Copy link
Member

@koppor koppor commented Apr 8, 2023

As a present for 🥚🐇 - first working Word-JabRef integration. Come out as preparation for a http-based client/server sync, some "small" http server offering an endpoint to JabRef Word Add-In.


To get the Word Plugin run:



In IntelliJ Ultimate (not community), you can open rest-api.http and play around there. Start main in TestServer to get the server running.

You can go to LibraryResourceTest to execute some tests (server is started automatically)


Changes in the code:

  • Add resources
    • /libraries
    • /libraries/{id} (both (embedded) BibTeX as string and CSL data)
  • Documentation / code style
    • Refined BibEntry class (JavaDoc, builder)
    • Comments to InternalField
    • move StyleTester to "test" module - package ...testutils/interactive...
  • Makes use of Jersey, Grizzly
  • Makes use of HK2 as dependency injection framework
  • Introduces "application/x-bibtex-library-csl+json" mimetype
  • Preparation for client/server sync (BibEntryDTO)
  • Minor
    • Made class "JabRefItemDataProvider" more visible
    • Encoding of a .bib file can now be asked for externally
    • Resorts modle-info.java
    • Fixes typo in NetworkTabViewModel
  • Installs SLF4J logging router: If a tool uses java commons logging, tinylog now also handles these logs

Future work (in a follow-up PR)

In a next PR, I am going work on a minimal implementation for #9220.


Compulsory checks

- Resources
  - /libraries
  - /libraries/{id} (both (embedded) BibTeX as string and CSL data)
- Documentation / code style
  - Refined BibEntry class (JavaDoc, builder)
  - Comments to InternalField
  - move StyleTester to "test" module - package ...testutils/interactive...
- Makes use of Jersey, Grizzly
- Makes use of HK2 as dependency injection framework
- Introduces "application/x-bibtex-library-csl+json" mimetype
- Preparation for client/server sync (BibEntryDTO)
- Minor
  - Made class "JabRefItemDataProvider" more visible
  - Encoding of a .bib file can now be asked for externally
  - Resorts modle-info.java
  - Fixes typo in NetworkTabViewModel
- Installs SLF4J logging router: If a tool uses java commons logging, tinylog now also handles these logs
@HoussemNasri
Copy link
Member

Great! I didn't know about Word add-in; it is much better than exporting XML references. I wonder if #6904 is still relevant anymore? I was hoping I could get to it this summer but as the integration with the Word addin progresses, I think I'm going to select another project.

@Siedlerchr
Copy link
Member

Method too large

@koppor
Copy link
Member Author

koppor commented Apr 9, 2023

Method too large

I know. We made some progress in the jdk fix: openjdk/jdk#10704 (comment)

@koppor koppor added the status: depends-on-external A bug or issue that depends on an update of an external library label Apr 9, 2023
@@ -38,6 +41,7 @@

// Logging
requires org.slf4j;
requires jul.to.slf4j;
Copy link
Member

Choose a reason for hiding this comment

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

Do we really need this jul adapter?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes. The Grizzly http server uses java-util-logging. To be able to handle the log output with our logging framework tinylog, we need jul-slf4j-tinylog.

More detailed:

  • We opted for SLF4J as the JabRef logging framework. We decided against direct calls to tinylog.
  • For log output of an application, there should be one logging framework
  • When using the http server, JabRef internal methods are used. They might log. Thus, we have logs using of SLF4J
  • Grizzly uses Java-Util-Logging - and outputs are produced.

The alternative can be to disable logging of Grizzly completely and bring it back (with the bridge) if needed.

@koppor koppor mentioned this pull request Apr 13, 2023
# Conflicts:
#	src/main/java/module-info.java
@koppor
Copy link
Member Author

koppor commented Apr 20, 2023

Update: Test files can be passed to the server. Adds a default serving file (so that developers not familiar with JabRef can just start the server)

I started to enable starting the server using gradle:

./gradlew run -Papplication=httpserver

However, I have issues with ForkJoin (discussion at https://discuss.gradle.org/t/is-it-ok-to-use-collection-parallelstream-or-other-potentially-multi-threaded-code-within-gradle-plugin-code/28003)

Gradle output:

> Task :run
2023-04-20 11:30:59 [main] org.jabref.http.server.Server.main()
DEBUG: Libraries served: [C:\git-repositories\jabref-all\jabref\src\main\resources\org\jabref\http\server\http-server-demo.bib]
2023-04-20 11:30:59 [main] org.jabref.http.server.Server.startServer()
DEBUG: Starting server...
<============-> 92% EXECUTING [2m 27s]
> :run

IntelliJ output, if org.jabref.http.server.Server#main is executed:

DEBUG: Starting server...
2023-04-20 11:44:59 [ForkJoinPool.commonPool-worker-1] org.glassfish.grizzly.http.server.NetworkListener.start()
INFO: Started listener bound to [localhost:6051]
2023-04-20 11:44:59 [ForkJoinPool.commonPool-worker-1] org.glassfish.grizzly.http.server.HttpServer.start()
INFO: [HttpServer] Started.
2023-04-20 11:44:59 [ForkJoinPool.commonPool-worker-1] org.jabref.http.server.Server.lambda$startServer$4()
DEBUG: Server started.

@koppor
Copy link
Member Author

koppor commented May 8, 2023

The commit 1c50d78 should be "intelligently" reverted to keep things going here.

@koppor koppor removed the status: depends-on-external A bug or issue that depends on an update of an external library label Jun 29, 2023
@koppor koppor mentioned this pull request Aug 1, 2023
6 tasks
* upstream/main: (737 commits)
  Use OpenRewrite UseStringReplace (#10299)
  Add ReplaceStringBuilderWithString (#10302)
  Apply ShortenFullyQualifiedTypeReferences (#10301)
  Apply StaticMethodNotFinal (#10300)
  Apply exit early pattern (#10297)
  Avoid GH_TOKEN_UPDATE_GRADLE_WRAPPER at refresh-csl-subtrees
  Update snapcraft.yaml
  Fix exception when opening preferences (#10294)
  gnome-42-2204
  use gnome 4.2
  Use gnome
  Update base 22
  Add method for detecting journal abbrev delimiter (#10281)
  Update bug_report.yml
  Fix selection of table sort order (#10250)
  Fix mixup with YAML tags (#10287)
  More guards for upload (#10282)
  Reduced calls to Globals.prefs and Globals.entryTypesManager (#10177)
  Update jmh plugin (#10279)
  Add computer science to protected terms (#10222)
  ...

# Conflicts:
#	build.gradle
#	src/main/java/module-info.java
#	src/main/java/org/jabref/cli/Launcher.java
#	src/main/java/org/jabref/preferences/JabRefPreferences.java
#	src/main/resources/tinylog.properties
@github-actions
Copy link
Contributor

github-actions bot commented Sep 3, 2023

Your code currently does not meet JabRef's code guidelines. The tool reviewdog already placed comments on GitHub to indicate the places. See the tab "Files" in you PR. Please carefully follow the setup guide for the codestyle. Afterwards, please run checkstyle locally and fix the issues.

More information on code quality in JabRef is available at https://devdocs.jabref.org/getting-into-the-code/development-strategy.html.

Siedlerchr and others added 2 commits September 3, 2023 22:29
…-api

* 'min-http-api' of github.com:JabRef/jabref:
  Fix broken JavaDoc
Siedlerchr
Siedlerchr previously approved these changes Sep 3, 2023
@koppor koppor added this pull request to the merge queue Sep 4, 2023
@github-actions
Copy link
Contributor

github-actions bot commented Sep 4, 2023

The build for this PR is no longer available. Please visit https://builds.jabref.org/main/ for the latest build.

Merged via the queue into main with commit 2518f7b Sep 4, 2023
15 of 16 checks passed
@koppor koppor deleted the min-http-api branch September 4, 2023 01:01
Siedlerchr added a commit that referenced this pull request Sep 4, 2023
…ustStore

* upstream/main:
  Introduces test http server (#9748)
  Generate journal-list.mv on build (#10298)

# Conflicts:
#	src/main/java/org/jabref/logic/net/ssl/TrustStoreManager.java
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.

4 participants