* com.thoughtworks.xstream.converters.MarshallingContext)
*/
@Override
public void marshal(Object source, HierarchicalStreamWriter writer,
MarshallingContext context) {
InstanceInfo info = (InstanceInfo) source;
writer.startNode(ELEM_HOST);
writer.setValue(info.getHostName());
writer.endNode();
writer.startNode(ELEM_APP);
writer.setValue(info.getAppName());
writer.endNode();
writer.startNode(ELEM_IP);
writer.setValue(info.getIPAddr());
writer.endNode();
if (!("unknown".equals(info.getSID()) || "na".equals(info.getSID()))) {
writer.startNode(ELEM_SID);
writer.setValue(info.getSID());
writer.endNode();
}
writer.startNode(ELEM_STATUS);
writer.setValue(getStatus(info));
writer.endNode();
writer.startNode(ELEM_OVERRIDDEN_STATUS);
writer.setValue(info.getOverriddenStatus().name());
writer.endNode();
writer.startNode(ELEM_PORT);
writer.addAttribute(ATTR_ENABLED,
String.valueOf(info.isPortEnabled(PortType.UNSECURE)));
writer.setValue(String.valueOf(info.getPort()));
writer.endNode();
writer.startNode(ELEM_SECURE_PORT);
writer.addAttribute(ATTR_ENABLED,
String.valueOf(info.isPortEnabled(PortType.SECURE)));
writer.setValue(String.valueOf(info.getSecurePort()));
writer.endNode();
writer.startNode(ELEM_COUNTRY_ID);
writer.setValue(String.valueOf(info.getCountryId()));
writer.endNode();
if (info.getDataCenterInfo() != null) {
writer.startNode(NODE_DATACENTER);
// This is needed for backward compat. for now.
if (info.getDataCenterInfo().getName() == Name.Amazon) {
writer.addAttribute("class",
"com.netflix.appinfo.AmazonInfo");
} else {
writer.addAttribute("class",
"com.netflix.appinfo.InstanceInfo$DefaultDataCenterInfo");
}
context.convertAnother(info.getDataCenterInfo());
writer.endNode();
}
if (info.getLeaseInfo() != null) {
writer.startNode(NODE_LEASE);
context.convertAnother(info.getLeaseInfo());
writer.endNode();
}
if (info.getMetadata() != null) {
writer.startNode(NODE_METADATA);
// for backward compat. for now
if (info.getMetadata().size() == 0) {
writer.addAttribute("class",
"java.util.Collections$EmptyMap");
}
context.convertAnother(info.getMetadata());
writer.endNode();
}
autoMarshalEligible(source, writer);
}