-
1. Re: org.jboss.byteman.agent.submit.Submit a script from the classpath?
adinn Nov 22, 2012 8:28 AM (in response to paul.robinson)Bela Ban has already implemented this feature. It was discussed in this forum some months ago and Bela raised a BYTEMAN-185 and submitted a patch which wenrt into the 2.0.1 release.
If you look at the patch you will see that the lookup follows the same conventions for constructiing potential filenames from the info provided in the annotation, the test and the script name. However, for each potential name if it fails to find a file in the file system using no extension or .btm/.txt extension it then sees if the name can be resolved to a loadable resource file using those 3 altternative extensions.
-
2. Re: org.jboss.byteman.agent.submit.Submit a script from the classpath?
paul.robinson Nov 22, 2012 10:11 AM (in response to adinn)Thanks Andrew,
Unfortunately I can't use BMUnit as I'm using Arquillian. However, the code I needed was in there. I didn't realise you could do the following to get the file location of a resource on the classpath:
URL resource=Thread.currentThread().getContextClassLoader().getResource(fname); resource.getFile();
Cheers,
Paul.
-
3. Re: org.jboss.byteman.agent.submit.Submit a script from the classpath?
paul.robinson Nov 27, 2012 11:23 AM (in response to paul.robinson)Andrew,
Unfortunatly resource.getFile() doesn't work if the rules file is locted in some other jar (on the classpath). I'm trying to create a shared library of Byteman rules, so they really need to live in a seperate jar.
If Submit could take a list of URLs as well as a List of files, it would solve my problem. I've updated Submit.java to support this and it does work for my test:
https://github.com/bytemanproject/byteman/pull/16
Can you take a look and consider it for contribution?
Paul.
-
4. Re: org.jboss.byteman.agent.submit.Submit a script from the classpath?
paul.robinson Dec 4, 2012 10:13 AM (in response to paul.robinson)Andrew,
I've updated the pull request to use InputStreams rather than URLs (as we discussed offline).
Paul.