Set<CompositeValue> tmp = new TreeSet<CompositeValue>(new FullyQualifiedNameComparator());
for (ServiceBinding b : mapEntry.getValue())
{
try
{
MapCompositeValueSupport cvs = new MapCompositeValueSupport(SERVICE_BINDING_TYPE);
cvs.put("serviceName", SimpleValueSupport.wrap(b.getServiceName()));
cvs.put("bindingName", SimpleValueSupport.wrap(b.getBindingName()));
cvs.put("fullyQualifiedName", SimpleValueSupport.wrap(b.getFullyQualifiedName()));
cvs.put("description", SimpleValueSupport.wrap(b.getDescription()));
cvs.put("hostName", SimpleValueSupport.wrap(b.getHostName()));
InetAddress inet = b.getBindAddress();
if (inet != null)
{
ArrayValueSupport avs = new ArrayValueSupport(ArrayMetaType.getPrimitiveArrayType(byte[].class));
avs.setValue(inet.getAddress());
cvs.put("bindAddress", avs);
}
else
{
cvs.put("bindAddress", null);
}
cvs.put("port", SimpleValueSupport.wrap(b.getPort()));
tmp.add(cvs);
}
catch(Exception e)
{
log.warn("Skipping binding: "+ b, e);
}
}
MetaValue[] elements = tmp.toArray(new MetaValue[tmp.size()]);
CollectionValueSupport bindingSet = new CollectionValueSupport(MAP_VALUE_TYPE, elements);
map.put(mapEntry.getKey(), bindingSet);
}
return new MapCompositeValueSupport(map, MAP_VALUE_TYPE);
}