eclipse-ee4j / glassfish-hk2

Dynamic dependency injection framework
https://eclipse-ee4j.github.io/glassfish-hk2
Other
84 stars 57 forks source link

Read and Load under "WEB-INF/classes/hk2-locator" Doesn't Work #178

Closed glassfishrobot closed 10 years ago

glassfishrobot commented 11 years ago

The bellow documentation says that HK2 will be able to find and load "application" inhabitant file under "WEB-INF/classes/hk2-locator." Looking at the class "org.glassfish.hk2.utilities.ClasspathDescriptorFileFinder" by default it seems to always look for a inhabitant file called "default" under the "META-INF/hk2-locator/" instead of looking for inhabitant files under both "META-INF/hk2-locator/" and "WEB-INF/classes/hk2-locator/" resource paths.

There seems to be a discrepancy between the documentation and what happens and shouldn't HK2 scan for and pickup all inhabitant files under those resource paths regardless of whether they are called application, default, or some arbitrary custom name?

https://hk2.java.net/integration.html

Environment

Linux 64bit JDK v.1.7.0_40 Tomcat v7.0.34 HK2 v2.2.0-b20

Affected Versions

[2.2.0]

glassfishrobot commented 6 years ago
glassfishrobot commented 11 years ago

@glassfishrobot Commented Reported by @saden1

glassfishrobot commented 11 years ago

@glassfishrobot Commented @jwells131313 said: There are tests in GlassFish under appserver/tests/hk2 that appear to say that hk2 files located in WEB-INF/classes/hk2-locator/application are in fact picked up and used in applications. I'll investigate this a little more, but I think this is working as designed. I do not believe that the ClassPathDescriptorFileFinder is used when discovering hk2 artifacts in Java EE applications.

glassfishrobot commented 11 years ago

@glassfishrobot Commented @jwells131313 said: The integration with GlassFish is done in GlassFish (using the generic population facility of hk2). The class that finds the hk2 files is org.glassfish.internal.data.ApplicationDescriptorFileFinder. The file that runs https://hk2.java.net/2.2.0-b21/apidocs/org/glassfish/hk2/api/Populator.html#populate%28org.glassfish.hk2.api.DescriptorFileFinder,%20org.glassfish.hk2.api.PopulatorPostProcessor...%29 is org.glassfish.internal.data.ApplicationInfo when an application is being deployed.

This looks correct to me and there are tests that verify that it works properly.

glassfishrobot commented 11 years ago

@glassfishrobot Commented @saden1 said: I am using Tomcat. Are you suppose to do anything specific if you're not using Glassfish?

glassfishrobot commented 11 years ago

@glassfishrobot Commented @jwells131313 said: You can use HK2 in Tomcat, but you will need to do your own bootstrapping and population. The best thing to do is use the https://hk2.java.net/2.2.0-b22/apidocs/org/glassfish/hk2/api/DynamicConfigurationService.html, get the https://hk2.java.net/2.2.0-b22/apidocs/org/glassfish/hk2/api/Populator.html and write your own https://hk2.java.net/2.2.0-b22/apidocs/org/glassfish/hk2/api/DescriptorFileFinder.html.

It might not be a bad idea for HK2 to provide an implementation of DescriptorFileFinder that would work OOTB in WebApps on platforms like Tomcat.

glassfishrobot commented 7 years ago

@glassfishrobot Commented This issue was imported from java.net JIRA HK2-133

glassfishrobot commented 10 years ago

@glassfishrobot Commented Marked as works as designed on Friday, December 6th 2013, 3:45:09 am