summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--javae/test/IceE/common/ServerWrapper.java43
-rw-r--r--javae/test/IceE/common/TestApplication.java22
2 files changed, 36 insertions, 29 deletions
diff --git a/javae/test/IceE/common/ServerWrapper.java b/javae/test/IceE/common/ServerWrapper.java
index 417a2b76807..e0ba6170009 100644
--- a/javae/test/IceE/common/ServerWrapper.java
+++ b/javae/test/IceE/common/ServerWrapper.java
@@ -11,29 +11,29 @@ public class ServerWrapper
extends TestApplication
implements Runnable
{
- //
- // Find the IP address once we've connected to the network and display it.
- //
- class FindHostname
- extends Thread
+ protected void
+ initIce()
{
- public void
- run()
+ Ice.Properties properties = Ice.Util.createProperties();
+ java.io.InputStream is = getClass().getResourceAsStream("config");
+ if(is != null)
{
- String s = System.getProperty("microedition.hostname");
- while(s == null || s.length() == 0)
- {
- try
- {
- sleep(5000);
- }
- catch(InterruptedException ex)
- {
- }
- s = System.getProperty("microedition.hostname");
- }
- _out.println("Running with IP " + s);
+ properties.load(is);
+ }
+
+ try
+ {
+ _hostnameConnection =
+ (javax.microedition.io.ServerSocketConnection)javax.microedition.io.Connector.open("socket://");
+ properties.setProperty("Ice.Default.Host", _hostnameConnection.getLocalAddress());
+ _out.println("Running on " + _hostnameConnection.getLocalAddress());
+ }
+ catch(Exception ex)
+ {
+ _out.println("Unable to set default host");
}
+
+ _communicator = Ice.Util.initializeWithProperties(new String[0], properties);
}
protected void
@@ -42,7 +42,6 @@ public class ServerWrapper
{
super.startApp();
new Thread(this).start();
- new FindHostname().start();
}
public void
@@ -62,4 +61,6 @@ public class ServerWrapper
ex.printStackTrace();
}
}
+
+ protected javax.microedition.io.ServerSocketConnection _hostnameConnection;
}
diff --git a/javae/test/IceE/common/TestApplication.java b/javae/test/IceE/common/TestApplication.java
index 0df907c24fd..8611afa7c64 100644
--- a/javae/test/IceE/common/TestApplication.java
+++ b/javae/test/IceE/common/TestApplication.java
@@ -43,6 +43,19 @@ public class TestApplication
}
protected void
+ initIce()
+ {
+ Ice.Properties properties = Ice.Util.createProperties();
+ java.io.InputStream is = getClass().getResourceAsStream("config");
+ if(is != null)
+ {
+ properties.load(is);
+ }
+
+ _communicator = Ice.Util.initializeWithProperties(new String[0], properties);
+ }
+
+ protected void
startApp()
throws javax.microedition.midlet.MIDletStateChangeException
{
@@ -56,14 +69,7 @@ public class TestApplication
}
_out = new java.io.PrintStream(new Test.StreamListAdapter((javax.microedition.lcdui.List)_screen));
_display.setCurrent(_screen);
-
- Ice.Properties properties = Ice.Util.createProperties();
- java.io.InputStream is = getClass().getResourceAsStream("config");
- if(is != null)
- {
- properties.load(is);
- }
- _communicator = Ice.Util.initializeWithProperties(new String[0], properties);
+ initIce();
}
catch(Exception ex)
{