In my application context I want to be able to do
<property name="serviceUrl" value="${webappContextUrl}/myservice.service">
But ${webappContextUrl} is determined at runtime initialization and it's not in a *.properties file.
Instead a bean called JnlpWebappContextUrlLocator determines it.
How do I make my JnlpWebappContextUrlLocator.getWebAppContextUrl() bind to ${webappContextUrl} in the application context?
PS: I 'll submit it as a patch to spring richCode:/** * @author Geoffrey De Smet */ public class JnlpWebappContextUrlLocator { private String fallBackWebAppContextUrl; public String getFallBackWebAppContextUrl() { return fallBackWebAppContextUrl; } public void setFallBackWebAppContextUrl(String fallBackWebAppContextUrl) { this.fallBackWebAppContextUrl = fallBackWebAppContextUrl; } /** * Uses the webstart API to determine the webapp context. * If used outside of webstart, <code>fallBackWebAppContextUrl</code> is returned. * @return the url to the webapp ending with a slash */ public String getWebAppContextUrl() { String webAppContextUrl; try { BasicService basicService = (BasicService) ServiceManager.lookup("javax.jnlp.BasicService"); String codeBase = basicService.getCodeBase().toExternalForm(); // Remove "jnlp/" or "jnlp" int webAppContextUrlLength = codeBase.lastIndexOf("jnlp"); // TODO better solution required webAppContextUrl = codeBase.substring(0, webAppContextUrlLength); } catch (UnavailableServiceException e) { // TODO logging webAppContextUrl = fallBackWebAppContextUrl; } return webAppContextUrl; } }


Reply With Quote
.
