By using javax.xml.transform.TransformerFactory'newIstance() method in my code I'm launching a file system search. The documentation says that by setting the javax.xml.transform.TransformerFactory system property I avoid this search, which has a big impact on the performance. I think that I have set it correctly, but I would really like to monitor the calls to the file system that my java program makes. I'm working on WindowsXP, with Java 1.4 Do you know how can I see the calls my Java program makes to the file system? Any tool? Any ideea? Thank you in advance.
Best regards, Felix Use www.jaaava.com - A Google CSE for Java
Felix: By using javax.xml.transform.TransformerFactory'newIstance() method in my code I'm launching a file system search.
No, it does not do a file system search. This is what the javadocs says:
This method uses the following ordered lookup procedure to determine the TransformerFactory implementation class to load:
* Use the javax.xml.transform.TransformerFactory system property. * Use the properties file "lib/jaxp.properties" in the JRE directory. This configuration file is in standard java.util.Properties format and contains the fully qualified name of the implementation class with the key being the system property defined above. The jaxp.properties file is read only once by the JAXP implementation and it's values are then cached for future use. If the file does not exist when the first attempt is made to read from it, no further attempts are made to check for its existence. It is not possible to change the value of any property in jaxp.properties after it has been read for the first time. * Use the Services API (as detailed in the JAR specification), if available, to determine the classname. The Services API will look for a classname in the file META-INF/services/javax.xml.transform.TransformerFactory in jars available to the runtime. * Platform default TransformerFactory instance.
So, the maximum that this method will do is to search the META-INF directories of all the jar files present in the classpath. If you just want to confirm whether the program is using the property you are setting, either set it to a bogus value(I assume the method will throw an exception) or just implement your own factory that prints something in the constructor. Otherwise an easier way, attach a remote debug session for the process and check whether the implementation received from the newInstance() method is the one you have set.
Thank you for you response, but a file system is launched if the property is not set.
1. * Use the properties file "lib/jaxp.properties" in the JRE directory* - this file is in the file system and not in classpath so it must be loaded, but first it must be found
2. * So, the maximum that this method will do is to search the META-INF directories of all the jar files present in the classpath.* ^^^^^^ This is exactly what i want to avoid In my code this search was launched thousands of time, with a negative impact on the performace. Under Unix my system administrator showed me all the stat64 calls, but I don't know how to see them in Windows
Felix: but a file system is launched if the property is not set.
I understand that you are saying a native call is made to query the file system. Yeah a file system call will be made to get any file. What I meant was that the *entire* file system is not searched. Only the jar files present in the classpath are searched. There is a lot of difference between these two.
Felix: * Use the properties file "lib/jaxp.properties" in the JRE directory* - this file is in the file system and not in classpath so it must be loaded, but first it must be found.
Classpath is just a collection of file paths(urls) that refer to the files on the file system. There is no search required to find the above file. The JRE directory if fixed and hence the location of lib/jaxp.properties.
Felix:Under Unix my system administrator showed me all the stat64 calls, but I don't know how to see them in Windows
I dont know the command to find this out in Windows, but I dont think that you need to be so cautious about it. If you want to make sure that you have set the property correctly, then you can follow some steps that I mentioned in my previous post. If the property is properly set then only that class will be searched in the classpath which will result in the file system calls I guess.