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

Extension storage based on Java Service Provider (META-INf/services) #85

Merged
merged 9 commits into from Jan 13, 2016

Conversation

decebals
Copy link
Member

@decebals decebals commented Jan 4, 2016

This pull request comes with some improvements related to how we store metadata related to @Extension in files.
Until now we stored the metadata for extensions in a META-INF/extensions.idx (one file per plugin, the format is one text line with extension class name for each @Extension). I propose you a more standard location and format, META-INF/services/<extension-point>, used by Java Service Provider (see java.util.ServiceLoader).

The old format (META-INF/extensions.idx):

ro.fortsoft.pf4j.demo.HowdyGreeting
ro.fortsoft.pf4j.demo.WhazzupGreeting

The new format (META-INF/services/ro.fortsoft.pf4j.demo.api.Greeting):

# Generated by PF4J
ro.fortsoft.pf4j.demo.HowdyGreeting
ro.fortsoft.pf4j.demo.WhazzupGreeting # pf4j extension

More, I introduced with this PR a new abstraction ExtensionStorage so you can write and use your own storage.

My goal with this PR is to improve the adoption of PF4J, to allow other people to jump ease from ServiceLoader to PF4J.

The new versions of PF4J can work OK with the old format, extensions.idx (the DefaultExtensionFinder is a compound between ServiceProviderExtensionFinder and LegacyExtensionFinder).

@decebals decebals closed this Jan 4, 2016
@decebals decebals deleted the service_provider branch January 4, 2016 19:51
@decebals decebals restored the service_provider branch January 4, 2016 19:53
@decebals decebals reopened this Jan 4, 2016
@decebals
Copy link
Member Author

decebals commented Jan 5, 2016

I think that I finished the work at this branch.

So, in few words, this branch add:

  • the possibility to change the ExtensionStorage in ExtensionAnnotationProcessor(for now we will use yet the old format with META-INF/extensions.idx)
  • read META-INF/services (Java Service Provider mechanism) as extensions; if you have a modular application based on ServiceLoader class you can replace entirely ServiceLoader.load()call with PluginManager.getExtensions() and migrate smooth from ServiceLoader to PF4J

decebals added a commit that referenced this pull request Jan 13, 2016
Extension storage based on Java Service Provider (META-INf/services)
@decebals decebals merged commit 96a649f into master Jan 13, 2016
@decebals decebals deleted the service_provider branch March 3, 2017 16:36
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.

None yet

1 participant