Hi
I have a bunch of system properties that i need to be set before I can do any JSSE stuff. I wont rely on these being set with -D options on the command line (though they may be), so my bean - in this case a connection factory - which depends on these properties has a dependency like
and then my definition of one of these properties isCode:<bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"> <property name="location" value="classpath:jsse.properties"/> <property name="ignoreResourceNotFound" value="true"/> </bean> <bean id="connectionFactory" class="org.springframework.jndi.JndiObjectFactoryBean" depends-on="keyStoreProperty,keyStoreTypeProperty,keyStorePasswordProperty,trustStoreProperty,trustStoreTypeProperty,trustStorePasswordProperty"> ...
This works OK, because a user could invoke Java with a -Djavax.net.ssl.keyStore=whatever.jks option or put javax.net.ssl.keyStore=whatever.jks in jsse.properties (and they'd not be able to override it at the command line, which is potentially useful).Code:<bean id="setSystemProperty" abstract="true" class="org.springframework.beans.factory.config.MethodInvokingFactoryBean"> <property name="targetClass" value="java.lang.System"/> <property name="targetMethod" value="setProperty"/> </bean> <bean id="keyStoreProperty" parent="setSystemProperty"> <property name="arguments"> <list> <value>javax.net.ssl.keyStore</value> <value>${javax.net.ssl.keyStore}</value> </list> </property> </bean>
This is all a bit long-winded - can anyone think of a more consice way to do it?


Reply With Quote