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

Implement PluginClassLoader.getResources (#336) #337

Merged
merged 3 commits into from
Sep 4, 2019

Conversation

slovdahl
Copy link
Contributor

@slovdahl slovdahl commented Aug 14, 2019

The logic of the method is essentially a reversed copy & paste of the
ClassLoader::getResources(String) method.

See #336 for a more in-depth description of the problem this PR tries to resolve.

The logic of the method is essentially a reversed copy & paste of the
`ClassLoader::getResources(String)` method.
@slovdahl
Copy link
Contributor Author

I took the liberty to write some tests for the existing getResource(String) method as well, mainly to validate my assumptions about how it works.

I'd be happy to add more tests if I've missed some (edge-)cases.

@decebals
Copy link
Member

decebals commented Aug 14, 2019

The PR looks good.
I prefer to use PluginZip and PluginJar in tests and not to create the plugin storage (zip, jar) by hand (file by file). These classes (PluginZip and PluginJar) is not finished yet (missing support for add files - classes, jars, resources) but they can be improved relative easy.
If you have few time, please take a look to see if you can use one of these classes.
The PR is very good and it will be merged in the end in a form or other (actual form or using PluginZip/PluginJar). Thanks!

@slovdahl
Copy link
Contributor Author

slovdahl commented Aug 28, 2019

Thank you for the feedback, and sorry for the late response.

I'm trying to figure out how to utilize PluginZip in the test. I have added a PluginZip.Builder method for adding files to the archive, but it's not immediately clear to me how to e.g. unzip the archive. I see that LoadPluginsTest uses PluginManager::loadPluginFromPath for unzipping the archive a PluginZip created, but it feels like using PluginManager in PluginClassLoaderTest turns it more into an integration test than a unit test. What are your thoughts about it?

@slovdahl
Copy link
Contributor Author

Thanks for the rubberduck.. 🦆 😄 I think I found a solution that feels ok. I'll let the latest changes be a separate commit until you have reviewed them.

@decebals
Copy link
Member

decebals commented Sep 4, 2019

I missed the notification that you made some changes. Sorry.
Your PR is awesome. I like the improvements to PluginZip (the addFile methods).
In the context of your second commit, do you think that we need the files added by you in resources in the first commit?
I think that we can generate these files on the fly (this was the main idea when I started to implement PluginZip and PluginJar).

@slovdahl
Copy link
Contributor Author

slovdahl commented Sep 4, 2019

In the context of your second commit, do you think that we need the files added by you in resources in the first commit?

It could work yes, but I'm not sure if it makes sense to do it via the PluginZip and PluginJar classes? The point of the files is that they should explicitly come from the parent class loader and nothing else.

@slovdahl
Copy link
Contributor Author

slovdahl commented Sep 4, 2019

I removed the static files and use a static @BeforeAll method to create the files, please re-review.

@decebals decebals merged commit 628bc9d into pf4j:master Sep 4, 2019
@decebals
Copy link
Member

decebals commented Sep 4, 2019

Good job. Thanks!

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