[jboss-cvs] JBossAS SVN: r91264 - in branches/JBPAPP_5_0/server/src: etc/conf/all/xmdesc and 4 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Tue Jul 14 18:12:53 EDT 2009
Author: bstansberry at jboss.com
Date: 2009-07-14 18:12:52 -0400 (Tue, 14 Jul 2009)
New Revision: 91264
Modified:
branches/JBPAPP_5_0/server/src/etc/conf/all/jboss-service-production.xml
branches/JBPAPP_5_0/server/src/etc/conf/all/jboss-service.xml
branches/JBPAPP_5_0/server/src/etc/conf/all/xmdesc/NamingProviderURLWriter-xmbean.xml
branches/JBPAPP_5_0/server/src/etc/conf/minimal/jboss-service.xml
branches/JBPAPP_5_0/server/src/etc/conf/standard/jboss-service.xml
branches/JBPAPP_5_0/server/src/etc/conf/web/jboss-service.xml
branches/JBPAPP_5_0/server/src/main/org/jboss/naming/NamingProviderURLWriter.java
Log:
[JBPAPP-2216] Don't write URL for host 0.0.0.0 in jnp-service.url
Modified: branches/JBPAPP_5_0/server/src/etc/conf/all/jboss-service-production.xml
===================================================================
--- branches/JBPAPP_5_0/server/src/etc/conf/all/jboss-service-production.xml 2009-07-14 21:43:27 UTC (rev 91263)
+++ branches/JBPAPP_5_0/server/src/etc/conf/all/jboss-service-production.xml 2009-07-14 22:12:52 UTC (rev 91264)
@@ -239,7 +239,7 @@
-->
<depends optional-attribute-name="Naming"
proxy-type="attribute">jboss:service=NamingBeanImpl</depends>
- </mbean>
+ </mbean>
<!-- Writes the bootstrap URL for the NamingService in a known location,
so tools (e.g. Jopr) can use it as a java.naming.provider.url.
@@ -249,8 +249,9 @@
xmbean-dd="resource:xmdesc/NamingProviderURLWriter-xmbean.xml">
<attribute name="Server"><inject bean="JBossServer"/></attribute>
- <attribute name="BootstrapURL"><inject bean="jboss:service=Naming" property="bootstrapURL"/></attribute>
- </mbean>
+ <attribute name="BootstrapAddress"><inject bean="jboss:service=Naming" property="bindAddress"/></attribute>
+ <attribute name="BootstrapPort"><inject bean="jboss:service=Naming" property="port"/></attribute>
+ </mbean>
<mbean code="org.jboss.naming.JNDIView"
name="jboss:service=JNDIView"
Modified: branches/JBPAPP_5_0/server/src/etc/conf/all/jboss-service.xml
===================================================================
--- branches/JBPAPP_5_0/server/src/etc/conf/all/jboss-service.xml 2009-07-14 21:43:27 UTC (rev 91263)
+++ branches/JBPAPP_5_0/server/src/etc/conf/all/jboss-service.xml 2009-07-14 22:12:52 UTC (rev 91264)
@@ -249,7 +249,8 @@
xmbean-dd="resource:xmdesc/NamingProviderURLWriter-xmbean.xml">
<attribute name="Server"><inject bean="JBossServer"/></attribute>
- <attribute name="BootstrapURL"><inject bean="jboss:service=Naming" property="bootstrapURL"/></attribute>
+ <attribute name="BootstrapAddress"><inject bean="jboss:service=Naming" property="bindAddress"/></attribute>
+ <attribute name="BootstrapPort"><inject bean="jboss:service=Naming" property="port"/></attribute>
</mbean>
<mbean code="org.jboss.naming.JNDIView"
Modified: branches/JBPAPP_5_0/server/src/etc/conf/all/xmdesc/NamingProviderURLWriter-xmbean.xml
===================================================================
--- branches/JBPAPP_5_0/server/src/etc/conf/all/xmdesc/NamingProviderURLWriter-xmbean.xml 2009-07-14 21:43:27 UTC (rev 91263)
+++ branches/JBPAPP_5_0/server/src/etc/conf/all/xmdesc/NamingProviderURLWriter-xmbean.xml 2009-07-14 22:12:52 UTC (rev 91264)
@@ -40,6 +40,18 @@
<type>java.lang.String</type>
</attribute>
+ <attribute access="read-write" getMethod="getBootstrapAddress" setMethod="setBootstrapAddress">
+ <description>Address to use to create the BootstrapURL if it isn't directly configured</description>
+ <name>BootstrapAddress</name>
+ <type>java.lang.String</type>
+ </attribute>
+
+ <attribute access="read-write" getMethod="getBootstrapPort" setMethod="setBootstrapPort">
+ <description>Port to use to create the BootstrapURL if it isn't directly configured</description>
+ <name>BootstrapPort</name>
+ <type>int</type>
+ </attribute>
+
<!-- Operations -->
<operation>
<description>The start lifecycle op</description>
Modified: branches/JBPAPP_5_0/server/src/etc/conf/minimal/jboss-service.xml
===================================================================
--- branches/JBPAPP_5_0/server/src/etc/conf/minimal/jboss-service.xml 2009-07-14 21:43:27 UTC (rev 91263)
+++ branches/JBPAPP_5_0/server/src/etc/conf/minimal/jboss-service.xml 2009-07-14 22:12:52 UTC (rev 91264)
@@ -103,7 +103,8 @@
xmbean-dd="resource:xmdesc/NamingProviderURLWriter-xmbean.xml">
<attribute name="Server"><inject bean="JBossServer"/></attribute>
- <attribute name="BootstrapURL"><inject bean="jboss:service=Naming" property="bootstrapURL"/></attribute>
+ <attribute name="BootstrapAddress"><inject bean="jboss:service=Naming" property="bindAddress"/></attribute>
+ <attribute name="BootstrapPort"><inject bean="jboss:service=Naming" property="port"/></attribute>
</mbean>
</server>
Modified: branches/JBPAPP_5_0/server/src/etc/conf/standard/jboss-service.xml
===================================================================
--- branches/JBPAPP_5_0/server/src/etc/conf/standard/jboss-service.xml 2009-07-14 21:43:27 UTC (rev 91263)
+++ branches/JBPAPP_5_0/server/src/etc/conf/standard/jboss-service.xml 2009-07-14 22:12:52 UTC (rev 91264)
@@ -223,7 +223,19 @@
-->
<depends optional-attribute-name="Naming"
proxy-type="attribute">jboss:service=NamingBeanImpl</depends>
- </mbean>
+ </mbean>
+
+ <!-- Writes the bootstrap URL for the NamingService in a known location,
+ so tools (e.g. Jopr) can use it as a java.naming.provider.url.
+ -->
+ <mbean code="org.jboss.naming.NamingProviderURLWriter"
+ name="jboss:service=NamingProviderURLWriter"
+ xmbean-dd="resource:xmdesc/NamingProviderURLWriter-xmbean.xml">
+
+ <attribute name="Server"><inject bean="JBossServer"/></attribute>
+ <attribute name="BootstrapAddress"><inject bean="jboss:service=Naming" property="bindAddress"/></attribute>
+ <attribute name="BootstrapPort"><inject bean="jboss:service=Naming" property="port"/></attribute>
+ </mbean>
<mbean code="org.jboss.naming.JNDIView"
name="jboss:service=JNDIView"
Modified: branches/JBPAPP_5_0/server/src/etc/conf/web/jboss-service.xml
===================================================================
--- branches/JBPAPP_5_0/server/src/etc/conf/web/jboss-service.xml 2009-07-14 21:43:27 UTC (rev 91263)
+++ branches/JBPAPP_5_0/server/src/etc/conf/web/jboss-service.xml 2009-07-14 22:12:52 UTC (rev 91264)
@@ -218,7 +218,19 @@
-->
<depends optional-attribute-name="Naming"
proxy-type="attribute">jboss:service=NamingBeanImpl</depends>
- </mbean>
+ </mbean>
+
+ <!-- Writes the bootstrap URL for the NamingService in a known location,
+ so tools (e.g. Jopr) can use it as a java.naming.provider.url.
+ -->
+ <mbean code="org.jboss.naming.NamingProviderURLWriter"
+ name="jboss:service=NamingProviderURLWriter"
+ xmbean-dd="resource:xmdesc/NamingProviderURLWriter-xmbean.xml">
+
+ <attribute name="Server"><inject bean="JBossServer"/></attribute>
+ <attribute name="BootstrapAddress"><inject bean="jboss:service=Naming" property="bindAddress"/></attribute>
+ <attribute name="BootstrapPort"><inject bean="jboss:service=Naming" property="port"/></attribute>
+ </mbean>
<mbean code="org.jboss.naming.JNDIView"
name="jboss:service=JNDIView"
Modified: branches/JBPAPP_5_0/server/src/main/org/jboss/naming/NamingProviderURLWriter.java
===================================================================
--- branches/JBPAPP_5_0/server/src/main/org/jboss/naming/NamingProviderURLWriter.java 2009-07-14 21:43:27 UTC (rev 91263)
+++ branches/JBPAPP_5_0/server/src/main/org/jboss/naming/NamingProviderURLWriter.java 2009-07-14 22:12:52 UTC (rev 91264)
@@ -23,8 +23,14 @@
package org.jboss.naming;
import java.io.File;
+import java.io.IOException;
import java.io.PrintWriter;
+import java.net.Inet6Address;
+import java.net.InetAddress;
+import java.net.NetworkInterface;
+import java.net.SocketException;
import java.net.URI;
+import java.util.Enumeration;
import org.jboss.bootstrap.spi.Server;
import org.jboss.logging.Logger;
@@ -43,6 +49,8 @@
private static final Logger log = Logger.getLogger(NamingProviderURLWriter.class);
private String bootstrapUrl;
+ private String bindAddress;
+ private int port;
private Server server;
private URI outputDir;
private String filename = DEFAULT_PERSIST_FILE_NAME;
@@ -83,8 +91,30 @@
this.bootstrapUrl = url;
}
+ public String getBootstrapAddress()
+ {
+ return bindAddress;
+ }
+
+ public void setBootstrapAddress(String bindAddress)
+ {
+ this.bindAddress = bindAddress;
+ }
+
+ public int getBootstrapPort()
+ {
+ return port;
+ }
+
+ public void setBootstrapPort(int port)
+ {
+ this.port = port;
+ }
+
public void start() throws Exception
{
+ establishBootStrapURL();
+
if (bootstrapUrl != null)
{
File base = null;
@@ -150,4 +180,55 @@
}
}
+ protected void establishBootStrapURL() throws IOException
+ {
+ if (getBootstrapURL() == null && getBootstrapAddress() != null)
+ {
+ InetAddress addr = InetAddress.getByName(getBootstrapAddress());
+ if (addr.isAnyLocalAddress())
+ {
+ addr = findLoopbackAddress();
+ if (addr == null)
+ {
+ addr = InetAddress.getLocalHost();
+ }
+ }
+
+ // Build the bootstrap URL
+ StringBuilder sb = new StringBuilder("jnp://");
+ if (addr instanceof Inet6Address)
+ {
+ sb.append('[');
+ sb.append(addr.getHostAddress());
+ sb.append(']');
+ }
+ else
+ {
+ sb.append(addr.getHostAddress());
+ }
+ sb.append(':');
+ sb.append(getBootstrapPort());
+ setBootstrapURL(sb.toString());
+ }
+ }
+
+ private static InetAddress findLoopbackAddress() throws SocketException
+ {
+ Enumeration<NetworkInterface> ifaces = NetworkInterface.getNetworkInterfaces();
+ while (ifaces.hasMoreElements())
+ {
+ NetworkInterface iface = ifaces.nextElement();
+ Enumeration<InetAddress> addrs = iface.getInetAddresses();
+ while (addrs.hasMoreElements())
+ {
+ InetAddress addr = addrs.nextElement();
+ if (addr.isLoopbackAddress())
+ {
+ return addr;
+ }
+ }
+ }
+ return null;
+ }
+
}
More information about the jboss-cvs-commits
mailing list