Frank,
I had been wanting to respond to this in detail. But got a chance only now.
A hidden gem (not the Ruby gem ;)) in GlassFish configuration is called the token support. This is
also known as variable substitution. Thus, at any place in the configuration, you can define a token and then its value will be replaced at all places where the token is referenced. The way the
token is defined is rather counter-intuitive. It's called "system-property" for some unknown reason.
Thus, you define a <system property name="foo" value="bar"> in the domain.xml using
[b] asadmin create-system-properties[/b] command. Then you reference it as "$foo" elsewhere and "bar" will be substituted.
But have I really answered your question? Not yet.
For some excellent reasons, we have a precedence order set to resolve the value of a token.
Thus, if the token can be defined at 4 [b] target[/b] levels:
- domain
- config
- cluster
- server
in the order of increasing precedence. Thus, if a token is defined on the config level, it can be
overridden at server level (just as an example). And this is the key to your problem. What
you need to do in this case is to define the token representing the address at server level and
then reference it from the <http-listener> element inside the config. As you know, a server
inherits a cluster's config, when it is part of that cluster. And because of this, this "overriding"
effect is nicely achieved. Thus, when you are done configuring, this is how it should look in
domain.xml:
<domain>
...
<configs>
<config name="c1-config" ...>
<http-service ...>
<http-listener name="http-listener-1" address="${NIC_ADDRESS}" ...> .. </http-listener>
</http-service>
</configs>
<clusters>
<cluster name="c1 cofig-ref="c1-config"> ...
<server-ref> s1 <server-ref>
<server-ref> s1 <server-ref>
...
</cluster>
<servers>
<server name="s1" config-ref="c1-config" ...>
...
<system-property name="NIC_ADDRESS" value="10.22.223.233"/>
</server>
<server name="s2" config-ref="c1-config" ...>
...
<system-property name="NIC_ADDRESS" value="10.22.223.235"/>
</server>
</servers>
</domain>
Now you can see that these values can be overridden at the server level (the most specific).
Interesting configuration options emerge here. If you see the default configuration, we actually change the ports and keep the addresses the same. Your requirement is exact opposite in that
you want the same port (not necessary, but desirable) and different addresses.
Hope this explains.
Regards,
Kedar
[Message sent by forum member 'km' (km)]
http://forums.java.net/jive/thread.jspa?messageID=262831