DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Refcards Trend Reports Events Over 2 million developers have joined DZone. Join Today! Thanks for visiting DZone today,
Edit Profile Manage Email Subscriptions Moderation Admin Console How to Post to DZone Article Submission Guidelines
View Profile
Sign Out
Refcards
Trend Reports
Events
Zones
Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Partner Zones AWS Cloud
by AWS Developer Relations
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Partner Zones
AWS Cloud
by AWS Developer Relations
  1. DZone
  2. Data Engineering
  3. Databases
  4. On The Need of OSGi-compatible JSR API Class Libraries

On The Need of OSGi-compatible JSR API Class Libraries

Valery Abu-Eid user avatar by
Valery Abu-Eid
·
Sep. 04, 08 · Interview
Like (0)
Save
Tweet
Share
7.22K Views

Join the DZone community and get the full member experience.

Join For Free

Although JSR APIs are generally simple to use, they introduce a lot of difficulties when used from OSGi Environments. The main two problems they introduce are:

  1. Lack of OSGi metadata
    Many JSR API class libraries lack OSGi headers in their manifests as such they don't export packages of classes they should provide and don't import the needed ones.
  2. Class/Resource Loading problems
    This is mostly noted for JSR specifications whose implementations are provided separately (like StAX) and JSR specifications that need to load user's classes and resources (like JPA and JAXB2). The problem of these specifications that they are oblivious about OSGi so they mostly use thread's context class loader to load needed classes and resources, while this seemed to work fine in non-osgi environments, in OSGi Environments it was not the case since there is no guarantee that thread's context loader will be a one which loads needed resources from the OSGi Environment.

Overcoming the first problem was mostly done in one of two ways: Generating new JAR files with OSGi-headers from the original ones (either using a tool or manually) or keeping OSGi application launchers like DA-Launcher handle the task of bundle generation from OSGi-incompatible JAR files.

Overcoming the second was by setting thread's context class loader to a class loader which loads classes and resources from the OSGi Environment. This was not a very simple solution since developers had to find/develop such class loader and they had to set it each time they wanted to access the API. Another problem is that the mentioned solution is fair only when you have the source code of the bundle which accesses the API, if you don't then you have a very difficult case and there is a probability of the problem being unsolvable.

Tackling similar problems for more than a dozen of OSGi-based applications I reached a conclusion that the most elegant way to solve these problems is to develop OSGi-compatible versions of JSR API class libraries. OSGi-compatible versions of the class libraries differ not only in that they define the needed OSGi headers but also in that they have a Bundle Activator which sets the right class loader for the API to use, project "OSGi-Compatible JSR APIs" is dedicated for this task. Currently, StAX-API is the only supported JSR API, the work for supporting JPA and JAXB2 is in progress. Of course, the role of OSGi-compatible versions of the JSR API class libraries is not limited to define needed headers and set the class loader, but generally making the usage of JSR's API in OSGi Environments as simple as it should be.

All of the provided libraries at "OSGi-Compatible JSR APIs" are licensed under the Apache v2 license and any contributions or ideas to simplify the usage of JSR APIs from OSGi Environments are welcomed.

API Library

Opinions expressed by DZone contributors are their own.

Popular on DZone

  • Custom Validators in Quarkus
  • HTTP vs Messaging for Microservices Communications
  • Is DevOps Dead?
  • DevOps vs Agile: Which Approach Will Win the Battle for Efficiency?

Comments

Partner Resources

X

ABOUT US

  • About DZone
  • Send feedback
  • Careers
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 600 Park Offices Drive
  • Suite 300
  • Durham, NC 27709
  • support@dzone.com
  • +1 (919) 678-0300

Let's be friends: