[jboss-cvs] JBossAS SVN: r77504 - trunk/aspects/src/test50/org/jboss/test/asynch.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Tue Aug 26 15:26:38 EDT 2008


Author: kabir.khan at jboss.com
Date: 2008-08-26 15:26:38 -0400 (Tue, 26 Aug 2008)
New Revision: 77504

Modified:
   trunk/aspects/src/test50/org/jboss/test/asynch/Service.java
Log:
[JBAS-5846] Get the IP address to bind the proxy to from jboss.bind.address

Modified: trunk/aspects/src/test50/org/jboss/test/asynch/Service.java
===================================================================
--- trunk/aspects/src/test50/org/jboss/test/asynch/Service.java	2008-08-26 19:10:30 UTC (rev 77503)
+++ trunk/aspects/src/test50/org/jboss/test/asynch/Service.java	2008-08-26 19:26:38 UTC (rev 77504)
@@ -21,6 +21,9 @@
 */
 package org.jboss.test.asynch;
 
+import java.security.AccessController;
+import java.security.PrivilegedAction;
+
 import org.jboss.aop.Dispatcher;
 import org.jboss.aspects.asynch.AsynchRemoting;
 import org.jboss.aspects.jmx.MBean;
@@ -37,6 +40,8 @@
 @MBean
 public class Service
 {
+   private static final String BIND_ADDRESS = "jboss.bind.address";
+   
    public void start() throws Exception
    {
       InitialContext ctx = new InitialContext();
@@ -44,7 +49,7 @@
       Dispatcher.singleton.registerTarget("pojo", pojo);
       System.out.println("*** hello ***");
 
-      ctx.rebind("pojo", AsynchRemoting.createRemoteProxy("pojo", POJO.class, new InvokerLocator("socket://localhost:5150")));
+      ctx.rebind("pojo", AsynchRemoting.createRemoteProxy("pojo", POJO.class, new InvokerLocator("socket://" + getIpAddress() + ":5150")));
    }
 
    public void stop()
@@ -52,4 +57,23 @@
       System.out.println("**** STOP ***");
       Dispatcher.singleton.unregisterTarget("pojo");
    }
+   
+   private String getIpAddress()
+   {
+      
+      try
+      {
+         String address = AccessController.doPrivileged(new PrivilegedAction<String>() {
+
+            public String run()
+            {
+               return System.getProperty(BIND_ADDRESS);
+            }});
+         return address;
+      }
+      catch (Exception e)
+      {
+         throw new RuntimeException(e);
+      }
+   }
 }




More information about the jboss-cvs-commits mailing list