I have my custom tomcat Valve extending FormAuthenticator, and same is defined in context.xml of each webapp. I need to read some property files in 'initInternal' of Valve, based on webapp name. i.e. for each webapp different property file. Since Valve is common, I need a way to find out the context in which my Valve is loaded. Is there any way to get the context in Valve class.
I tried to set system property in 'ServletContextListener' but Valve class is loaded before the ServletContextListener is initialised.
Here is how my context.xml look.
<Context className="org.apache.catalina.core.StandardContext" debug="0" allowLinking="true" docBase="auth" path="/auth" privileged="true" reloadable="false">
<Realm className="org.apache.catalina.realm.LockOutRealm" failureCount="5" lockOutTime="300" >
<Realm className="com.foo.realm.FooRealm" /></Realm>
<Valve className="com.foo.valves.FooRESTValve" />
</Context>
Only 'docbase' and 'path' is different for each webapp.