I have a simple service called BuildNumberService which would be instantiated by spring.
I'm trying to find the cleanest code for the class to find out the MANIFEST.MF file from the jar file it has been packaged into.
The code has to run inside a servlet container.
@Service
public class BuildNumberService {
private static final String IMPLEMENTATION_BUILD = "Implementation-Build";
private String version = null;
public BuildNumberService() {
// find correct manifest.mf
// ?????
// then read IMPLEMENTATION_BUILD attributes and caches it.
Attributes mainAttributes = mf.getMainAttributes();
version = mainAttributes.getValue(IMPLEMENTATION_BUILD);
}
public String getVersion() {
return this.version;
}
}
How would you do that ?
Edit: Actually, what I'm trying to do, is, find a resource by name which sits in the same package as the actual class.