On Oct 13, 2010, at 5:33 PM, Kevan Miller wrote:

> 
> On Oct 12, 2010, at 10:08 PM, [email protected] wrote:
> 
>> Author: dblevins
>> Date: Wed Oct 13 02:08:04 2010
>> New Revision: 1021975
>> 
>> URL: http://svn.apache.org/viewvc?rev=1021975&view=rev
>> Log:
>> OPENEJB-1370: Broadcast InetAddress.getLocalHost() when ejbd is bound to 
>> 0.0.0.0
>> 
>> Modified:
>>   
>> openejb/branches/openejb-3.1.x/server/openejb-server/src/main/java/org/apache/openejb/server/ServiceDaemon.java
>> 
>> Modified: 
>> openejb/branches/openejb-3.1.x/server/openejb-server/src/main/java/org/apache/openejb/server/ServiceDaemon.java
>> URL: 
>> http://svn.apache.org/viewvc/openejb/branches/openejb-3.1.x/server/openejb-server/src/main/java/org/apache/openejb/server/ServiceDaemon.java?rev=1021975&r1=1021974&r2=1021975&view=diff
>> ==============================================================================
>> --- 
>> openejb/branches/openejb-3.1.x/server/openejb-server/src/main/java/org/apache/openejb/server/ServiceDaemon.java
>>  (original)
>> +++ 
>> openejb/branches/openejb-3.1.x/server/openejb-server/src/main/java/org/apache/openejb/server/ServiceDaemon.java
>>  Wed Oct 13 02:08:04 2010
>> @@ -70,6 +70,7 @@ public class ServiceDaemon implements Se
>>    private boolean secure;
>>    private StringTemplate discoveryUriFormat;
>>    private URI uri;
>> +    private Properties props;
>> 
>>    public ServiceDaemon(ServerService next) {
>>        this.next = next;
>> @@ -112,6 +113,8 @@ public class ServiceDaemon implements Se
>> 
>>    public void init(Properties props) throws Exception {
>> 
>> +        this.props = props;
>> +        
>>        String formatString = props.getProperty("discovery");
>>        if (formatString != null){
>>            discoveryUriFormat = new StringTemplate(formatString);
>> @@ -171,9 +174,26 @@ public class ServiceDaemon implements Se
>>            DiscoveryAgent agent = 
>> SystemInstance.get().getComponent(DiscoveryAgent.class);
>>            if (agent != null && discoveryUriFormat != null) {
>>                Map<String,String> map = new HashMap<String,String>();
>> +
>> +                // add all the properties that were used to construct this 
>> service
>> +                for (Map.Entry<Object, Object> entry : props.entrySet()) {
>> +                    map.put(entry.getKey().toString(), 
>> entry.getValue().toString());
>> +                }
>> +
>>                map.put("port", Integer.toString(port));
>> -                map.put("host", ip);
>> -                map.put("bind", ip);
>> +
>> +                String address = ip;
>> +
>> +                if ("0.0.0.0".equals(address)) {
> 
> Pretty sure that this approach will not work on IP v6 system. Anybody have a 
> better way of detecting this?

Yeah, not sure.  At the very least an IP v6 address won't show up as 0.0.0.0 so 
will remain unaltered.  But it would be nice to get something there.

-David

Reply via email to