|
[
Permlink
| « Hide
]
Jean-Baptiste Onofré added a comment - 20/Jan/09 06:41 AM
For information, the <classpath/> management class is in servicemix-common. It's the ClassLoaderXmlPreprocessor.
Not sure how feasible it is to use regexp on non file based urls.
Well, I have seen the <location/> usage in the getClassLoader(SpringApplicationContext applicationContext, XmlBeanDefinitionReader reader, Document document) method.
For the <location/>, a classpath List is created and populated with location element. After that, this classpath List is transformed into a URLs array. URI uri = root.toURI().resolve(location); // where root is a File provided in the constructor I'm going to patch the getResource(String location) method to detect if the location is a JarUrlConnection or a File and return a URL. I have seen that getResource(String location) method is used to load a classpath.xml file (in the SU root) too.
This classpath.xml must be remain a File. So, I will make a little patch of the preprocess() method to let the classpath.xml as a File. Step 1 : add the support of jar: and file: classpath entries.
The path contains the getResource() changes in the ClassLoaderXmlPreprocessor and a small unit test for different kind of provided URLs. The patch root is servicemix-core. I resume to better support (and try the regexp support as made in Commons VFS). A new patch that use ZipFile/ZipEntry to use regexp and generate the matching URL.
Warning : this patch is work in progress (unit test fails). I need to work on it and so it's not intended for inclusion. Correct the issue. Now parse the URI using StringBuffer/String. Get the ZipFile and looking into entries.
Add unit test with a ear file. Need to complete with new unit tests. This is the first real patch release.
It includes the support of :
Guillaume, could make a quick review on the patch and give me some feedback ? Thanks, After dealing with Guillaume, the getResource() method should now return a list of URL.
Currently the getJarResource() supports regexp but returns only the first occurence that match. A more efficient way is to return the list of all URLs matching the regexp. This patch now supports multi URLs.
I'm going to extend the patch to be able to use system properties.
Has we have the servicemix.home argument in the SMX startup (provided using -Dservicemix.home=), it can be interesting to use this property in the <location/> definition. With it, we will be able to use notation like : This patch contains :
To avoid unit test failure after applying the patch (as the test.ear file shouldn't be created using the patch file), I have commented the unit test assert around the ear exploring.
This patch should be the final one. I build a complete SMX3 distribution and make "real" tests. The last patch contains only the change on the unit test. We need to apply both
Here is the complete patch with the commented part of the unit test.
I build SMX3 using this to perform "real" tests. Thanks for your comment Guillaume, I will submit a new patch including this.
Patch containing the last Guillaume's comment.
Another tip from Guillaume, the replaceString method can be replaced by :
for (Enumeration e = properties.propertyNames(); e.hasMoreElements() Patch commited. It will be included in the next SMX3 release.
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||