[jboss-cvs] JBossAS SVN: r91362 - in branches/Branch_5_x/server/src: etc/conf/all/xmdesc and 4 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Thu Jul 16 18:43:46 EDT 2009
Author: bstansberry at jboss.com
Date: 2009-07-16 18:43:46 -0400 (Thu, 16 Jul 2009)
New Revision: 91362
Modified:
branches/Branch_5_x/server/src/etc/conf/all/jboss-service.xml
branches/Branch_5_x/server/src/etc/conf/all/xmdesc/NamingProviderURLWriter-xmbean.xml
branches/Branch_5_x/server/src/etc/conf/minimal/jboss-service.xml
branches/Branch_5_x/server/src/etc/conf/standard/jboss-service.xml
branches/Branch_5_x/server/src/etc/conf/web/jboss-service.xml
branches/Branch_5_x/server/src/main/org/jboss/naming/NamingProviderURLWriter.java
Log:
[JBAS-7072] Don't write a URL for host 0.0.0.0 in jnp-service.url
Modified: branches/Branch_5_x/server/src/etc/conf/all/jboss-service.xml
===================================================================
--- branches/Branch_5_x/server/src/etc/conf/all/jboss-service.xml 2009-07-16 22:38:33 UTC (rev 91361)
+++ branches/Branch_5_x/server/src/etc/conf/all/jboss-service.xml 2009-07-16 22:43:46 UTC (rev 91362)
@@ -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/Branch_5_x/server/src/etc/conf/all/xmdesc/NamingProviderURLWriter-xmbean.xml
===================================================================
--- branches/Branch_5_x/server/src/etc/conf/all/xmdesc/NamingProviderURLWriter-xmbean.xml 2009-07-16 22:38:33 UTC (rev 91361)
+++ branches/Branch_5_x/server/src/etc/conf/all/xmdesc/NamingProviderURLWriter-xmbean.xml 2009-07-16 22:43:46 UTC (rev 91362)
@@ -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/Branch_5_x/server/src/etc/conf/minimal/jboss-service.xml
===================================================================
--- branches/Branch_5_x/server/src/etc/conf/minimal/jboss-service.xml 2009-07-16 22:38:33 UTC (rev 91361)
+++ branches/Branch_5_x/server/src/etc/conf/minimal/jboss-service.xml 2009-07-16 22:43:46 UTC (rev 91362)
@@ -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/Branch_5_x/server/src/etc/conf/standard/jboss-service.xml
===================================================================
--- branches/Branch_5_x/server/src/etc/conf/standard/jboss-service.xml 2009-07-16 22:38:33 UTC (rev 91361)
+++ branches/Branch_5_x/server/src/etc/conf/standard/jboss-service.xml 2009-07-16 22:43:46 UTC (rev 91362)
@@ -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/Branch_5_x/server/src/etc/conf/web/jboss-service.xml
===================================================================
--- branches/Branch_5_x/server/src/etc/conf/web/jboss-service.xml 2009-07-16 22:38:33 UTC (rev 91361)
+++ branches/Branch_5_x/server/src/etc/conf/web/jboss-service.xml 2009-07-16 22:43:46 UTC (rev 91362)
@@ -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/Branch_5_x/server/src/main/org/jboss/naming/NamingProviderURLWriter.java
===================================================================
--- branches/Branch_5_x/server/src/main/org/jboss/naming/NamingProviderURLWriter.java 2009-07-16 22:38:33 UTC (rev 91361)
+++ branches/Branch_5_x/server/src/main/org/jboss/naming/NamingProviderURLWriter.java 2009-07-16 22:43:46 UTC (rev 91362)
@@ -23,10 +23,17 @@
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.as.server.JBossASBasedServer;
+import org.jboss.bootstrap.spi.as.server.JBossASServer;
import org.jboss.logging.Logger;
/**
@@ -43,6 +50,8 @@
private static final Logger log = Logger.getLogger(NamingProviderURLWriter.class);
private String bootstrapUrl;
+ private String bindAddress;
+ private int port;
private JBossASBasedServer<?, ?> server;
private URI outputDir;
private String filename = DEFAULT_PERSIST_FILE_NAME;
@@ -83,8 +92,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 +181,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