[jboss-cvs] JBossAS SVN: r96387 - in projects/naming/trunk/jnpserver: src/main/java/org/jnp/interfaces and 3 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Sun Nov 15 20:05:48 EST 2009
Author: scott.stark at jboss.org
Date: 2009-11-15 20:05:48 -0500 (Sun, 15 Nov 2009)
New Revision: 96387
Modified:
projects/naming/trunk/jnpserver/pom.xml
projects/naming/trunk/jnpserver/src/main/java/org/jnp/interfaces/NamingContext.java
projects/naming/trunk/jnpserver/src/main/java/org/jnp/server/NamingServerWrapper.java
projects/naming/trunk/jnpserver/src/test/java/org/jnp/test/IPv6UnitTest.java
projects/naming/trunk/jnpserver/src/test/java/org/jnp/test/NamingMCUnitTest.java
projects/naming/trunk/jnpserver/src/test/resources/org/jnp/test/NamingMCUnitTest#testMainBeanSFs.xml
Log:
JBNAME-39, JBPAPP-2941, simplify the handling of IPv6 addresses
Modified: projects/naming/trunk/jnpserver/pom.xml
===================================================================
--- projects/naming/trunk/jnpserver/pom.xml 2009-11-16 00:44:32 UTC (rev 96386)
+++ projects/naming/trunk/jnpserver/pom.xml 2009-11-16 01:05:48 UTC (rev 96387)
@@ -53,6 +53,7 @@
<!--testFailureIgnore>true</testFailureIgnore-->
<excludes>
<exclude>org/jnp/test/support/**</exclude>
+ <exclude>**/*$*</exclude>
</excludes>
</configuration>
</plugin>
Modified: projects/naming/trunk/jnpserver/src/main/java/org/jnp/interfaces/NamingContext.java
===================================================================
--- projects/naming/trunk/jnpserver/src/main/java/org/jnp/interfaces/NamingContext.java 2009-11-16 00:44:32 UTC (rev 96386)
+++ projects/naming/trunk/jnpserver/src/main/java/org/jnp/interfaces/NamingContext.java 2009-11-16 01:05:48 UTC (rev 96387)
@@ -1293,7 +1293,9 @@
{
if((naming instanceof NamingEvents) == false)
{
- throw new UnsupportedOperationException("Naming implementation (" + naming + ") does not implement NamingEvents");
+ Class<?> cls = naming.getClass();
+ String cs = cls.getName() + ", CS:"+ cls.getProtectionDomain().getCodeSource().toString();
+ throw new UnsupportedOperationException("Naming implementation does not support NamingExt, : "+cs);
}
NamingEvents next = (NamingEvents) naming;
try
@@ -1836,34 +1838,93 @@
static private int parseHostPort(String url, Object[] output, int defaultPort)
{
// First look for a @ separating the host and port
+
int colon = url.indexOf('@');
+ String host = null;
+ int port = defaultPort;
+
if(colon < 0)
{
- // If there are multiple ':' assume its an IPv6 address
+ // <IPv4>, <IPv4>:port, [<IPv6>] or [<IPv6>]:port
+ colon = url.indexOf(':');
+ int rightbracket = url.indexOf(']') ;
+ int lastcolon = url.lastIndexOf(':') ;
+
+ if (rightbracket < 0)
+ {
+ // If there are multiple ':' assume its an IPv6 address
+ int firstColon = url.indexOf(':');
+ if(lastcolon > firstColon)
+ colon = lastcolon;
+
+ // assume IPv4 host port combination
+ if (colon < 0)
+ {
+ host = url.trim();
+ }
+ else
+ {
+ host = url.substring(0, colon).trim();
+ try
+ {
+ port = Integer.parseInt(url.substring(colon + 1).trim());
+ }
+ catch (Exception ex)
+ {
+ // Use default;
+ }
+ }
+ }
+ else
+ {
+ // assume IPv6 host port combination
+ if (lastcolon < rightbracket)
+ {
+ host = url.substring(1,rightbracket).trim() ;
+ }
+ else
+ {
+ host = url.substring(1,rightbracket).trim() ;
+ try
+ {
+ port = Integer.parseInt(url.substring(lastcolon + 1).trim());
+ }
+ catch (Exception ex)
+ {
+ // Use default;
+ }
+ }
+ }
+ }
+ else
+ {
+ // <IPv6>@port, If there are multiple ':' assume its an IPv6 address
colon = url.lastIndexOf(':');
int firstColon = url.indexOf(':');
if(colon > firstColon)
colon = -1;
- }
-
- if(colon < 0)
- {
- output[HOST_INDEX] = url;
- output[PORT_INDEX] = new Integer(defaultPort);
- }
- else
- {
- output[HOST_INDEX] = url.substring(0, colon);
- try
+ if(colon < 0)
{
- output[PORT_INDEX] = Integer.parseInt(url.substring(colon+1).trim());
+ host = url;
+ port = defaultPort;
}
- catch (Exception ex)
+ else
{
- // Use default port
- output[PORT_INDEX] = new Integer(defaultPort);
- }
+ host = url.substring(0, colon);
+ try
+ {
+ port = Integer.parseInt(url.substring(colon+1).trim());
+ }
+ catch (Exception ex)
+ {
+ // Use default port
+ port = defaultPort;
+ }
+ }
}
+
+ output[HOST_INDEX] = host;
+ output[PORT_INDEX] = new Integer(port);
return colon;
}
Modified: projects/naming/trunk/jnpserver/src/main/java/org/jnp/server/NamingServerWrapper.java
===================================================================
--- projects/naming/trunk/jnpserver/src/main/java/org/jnp/server/NamingServerWrapper.java 2009-11-16 00:44:32 UTC (rev 96386)
+++ projects/naming/trunk/jnpserver/src/main/java/org/jnp/server/NamingServerWrapper.java 2009-11-16 01:05:48 UTC (rev 96387)
@@ -27,8 +27,11 @@
import javax.naming.Context;
import javax.naming.Name;
import javax.naming.NamingException;
+import javax.naming.event.EventContext;
+import javax.naming.event.NamingListener;
import org.jnp.interfaces.Naming;
+import org.jnp.interfaces.NamingEvents;
/**
* A delegating wrapper that can be used to create a unique rmi server endpoint
@@ -38,12 +41,16 @@
* @version $Revision:$
*/
public class NamingServerWrapper
- implements Naming
+ implements Naming, NamingEvents
{
Naming delegate;
+ NamingEvents edelegate;
+
NamingServerWrapper(Naming delegate)
{
this.delegate = delegate;
+ if(delegate instanceof NamingEvents)
+ edelegate = (NamingEvents) delegate;
}
public void bind(Name name, Object obj, String className)
@@ -81,4 +88,19 @@
{
delegate.unbind(name);
}
+
+ public void addNamingListener(EventContext context, Name target, int scope,
+ NamingListener l) throws NamingException, RemoteException
+ {
+ edelegate.addNamingListener(context, target, scope, l);
+ }
+ public void removeNamingListener(NamingListener l) throws NamingException,
+ RemoteException
+ {
+ edelegate.removeNamingListener(l);
+ }
+ public boolean targetMustExist() throws NamingException, RemoteException
+ {
+ return edelegate.targetMustExist();
+ }
}
Modified: projects/naming/trunk/jnpserver/src/test/java/org/jnp/test/IPv6UnitTest.java
===================================================================
--- projects/naming/trunk/jnpserver/src/test/java/org/jnp/test/IPv6UnitTest.java 2009-11-16 00:44:32 UTC (rev 96386)
+++ projects/naming/trunk/jnpserver/src/test/java/org/jnp/test/IPv6UnitTest.java 2009-11-16 01:05:48 UTC (rev 96387)
@@ -66,7 +66,7 @@
return;
InetAddress localhost = InetAddress.getByName("localhost");
- InetAddress localhostIPv6 = InetAddress.getByName("::ffff:127.0.0.1");
+ InetAddress localhostIPv6 = InetAddress.getByName("::1");
// Set the java.rmi.server.hostname to the bind address if not set
if(System.getProperty("java.rmi.server.hostname") == null)
@@ -101,7 +101,7 @@
{
Properties env = new Properties();
env.setProperty("java.naming.factory.initial", "org.jnp.interfaces.NamingContextFactory");
- env.setProperty("java.naming.provider.url", "localhost:"+serverPort);
+ env.setProperty("java.naming.provider.url", "::1:"+serverPort);
env.setProperty("java.naming.factory.url", "org.jboss.naming:org.jnp.interfaces");
Name baseName = null;
Naming server = null;
@@ -117,10 +117,10 @@
{
Properties env = new Properties();
InetAddress localhost = InetAddress.getByName("localhost");
- InetAddress localhostIPv6 = InetAddress.getByName("::ffff:"+localhost.getHostAddress());
+ InetAddress localhostIPv6 = InetAddress.getByName("::1");
env.setProperty("java.naming.factory.initial", "org.jnp.interfaces.NamingContextFactory");
- env.setProperty("java.naming.provider.url", localhostIPv6.getHostAddress()+"@"+serverPort);
+ env.setProperty("java.naming.provider.url", "::1:"+serverPort);
env.setProperty("java.naming.factory.url", "org.jboss.naming:org.jnp.interfaces");
Name baseName = null;
Naming server = null;
Modified: projects/naming/trunk/jnpserver/src/test/java/org/jnp/test/NamingMCUnitTest.java
===================================================================
--- projects/naming/trunk/jnpserver/src/test/java/org/jnp/test/NamingMCUnitTest.java 2009-11-16 00:44:32 UTC (rev 96386)
+++ projects/naming/trunk/jnpserver/src/test/java/org/jnp/test/NamingMCUnitTest.java 2009-11-16 01:05:48 UTC (rev 96387)
@@ -152,7 +152,8 @@
assertNull("main.getLookupListenerException", main.getLookupListenerException());
Properties env = new Properties();
env.setProperty("java.naming.factory.initial", "org.jnp.interfaces.NamingContextFactory");
- env.setProperty("java.naming.provider.url", "localhost:1099");
+ String providerURL = System.getProperty("java.naming.provider.url", "localhost:1099");
+ env.setProperty("java.naming.provider.url", providerURL);
env.setProperty("java.naming.factory.url", "org.jboss.naming:org.jnp.interfaces");
env.setProperty(TimedSocketFactory.JNP_TIMEOUT, "10000");
env.setProperty(TimedSocketFactory.JNP_SO_TIMEOUT, "10000");
@@ -172,7 +173,8 @@
getLog().debug("InetAddress.getLocalHost(): "+localAddr);
Properties env = new Properties();
env.setProperty("java.naming.factory.initial", "org.jnp.interfaces.NamingContextFactory");
- env.setProperty("java.naming.provider.url", "localhost:2099");
+ String providerURL = System.getProperty("java.naming.provider.url", "localhost:2099");
+ env.setProperty("java.naming.provider.url", providerURL);
env.setProperty("java.naming.factory.url", "org.jboss.naming:org.jnp.interfaces");
env.setProperty(TimedSocketFactory.JNP_TIMEOUT, "1000");
env.setProperty(TimedSocketFactory.JNP_SO_TIMEOUT, "1000");
Modified: projects/naming/trunk/jnpserver/src/test/resources/org/jnp/test/NamingMCUnitTest#testMainBeanSFs.xml
===================================================================
--- projects/naming/trunk/jnpserver/src/test/resources/org/jnp/test/NamingMCUnitTest#testMainBeanSFs.xml 2009-11-16 00:44:32 UTC (rev 96386)
+++ projects/naming/trunk/jnpserver/src/test/resources/org/jnp/test/NamingMCUnitTest#testMainBeanSFs.xml 2009-11-16 01:05:48 UTC (rev 96387)
@@ -69,7 +69,7 @@
<bean name="testLocaNamingBeanImpl" class="org.jnp.server.NamingBeanImpl">
<!-- Install this bean as the global JVM NamingServer -->
<property name="installGlobalService">true</property>
-
+ <property name="installJavaComp">false</property>
<property name="useGlobalService">false</property>
</bean>
<bean name="jboss:service=Naming" class="org.jnp.server.Main">
More information about the jboss-cvs-commits
mailing list