How to explicitely specify AJP port using binding manager
twenckebach Feb 2, 2006 10:44 AMHello,
I`d like to pass a parameter other than host or port to a stylesheet in my binding manager xml input file (JBoss4.0.3 SP1). In particular, I want to be able to specify the AJP port explicitely, rather then by computing a difference from HTTP port as in the standard example.
This should work using the the following syntax (quote from admin guide):
<delegate-config>
<xslt-config configName="ConfigurationElement"><![CDATA[
Any XSL document contents...
]]>
</xslt-config>
<xslt-param name="param-name">param-value</xslt-param>
<!-- ... -->
</delegate-config>
Some parameter name and value seems to be submitted to the transformer as can be seen in XSLTConfigDelegate.java:
// xslt-param are transform parameters for(int a = 0; a < attributes.getLength(); a ++) { Element attr = (Element) attributes.item(a); String name = attr.getAttribute("name"); if( name.length() == 0 ) throw new IllegalArgumentException("attribute element #" +a+" has no name attribute"); String attrExp = MetaData.getElementContent(attr); String attrValue = StringPropertyReplacer.replaceProperties(attrExp); transformer.setParameter(name, attrValue); log.debug("set "+name+" parameter to:"+attrValue); }
However, I found no way of getting the parameter passing to work. Interestingly, I can state that the parameters declared in the script are not totally ignored - this is verified by using a default value via
<xsl:param name="portAJP" select="9999"/>
This will always result in usage of port 9999, though, even if I actually pass a parameter. If I don`t use the default, like
<xsl:param name="portAJP"/>
the port is assigned to 8009 - my script is pointless.
My actual xml file looks as follows:
<service-config name="jboss.web:service=WebServer" delegateClass="org.jboss.services.binding.XSLTFileDelegate" > <delegate-config> <xslt-config configName="ConfigFile"><![CDATA[ <xsl:stylesheet xmlns:xsl='http://www.w3.org/1999/XSL/Transform' version='1.0'> <xsl:output method="xml" /> <xsl:param name="port"/> <xsl:param name="portAJP"/> <xsl:variable name="portHttps" select="$port + 363"/> <xsl:template match="/"> <xsl:apply-templates/> </xsl:template> <xsl:template match = "Connector"> <xsl:for-each select="@*"> <xsl:choose> <xsl:when test="(name() = 'port' and . = '8080')"> <xsl:attribute name="port"><xsl:value-of select="$port" /></xsl:attribute> </xsl:when> <xsl:when test="(name() = 'port' and . = '8009')"> <xsl:attribute name="port"><xsl:value-of select="$portAJP" /></xsl:attribute> </xsl:when> <xsl:when test="(name() = 'redirectPort')"> <xsl:attribute name="redirectPort"><xsl:value-of select="$portHttps" /></xsl:attribute> </xsl:when> <xsl:when test="(name() = 'port' and . = '8443')"> <xsl:attribute name="port"><xsl:value-of select="$portHttps" /></xsl:attribute> </xsl:when> <xsl:otherwise> <xsl:attribute name="{name()}"><xsl:value-of select="." /></xsl:attribute> </xsl:otherwise> </xsl:choose> </xsl:for-each> <xsl:apply-templates/> </xsl:template> <xsl:template match="*|@*"> <xsl:copy> <xsl:apply-templates select="@*|node()"/> </xsl:copy> </xsl:template> </xsl:stylesheet> ]]> </xslt-config> <xslt-param name="portAJP">9999</xslt-param> </delegate-config> </service-config>
Thank`s a lot,
Thomas