resourceProperty.addChangeListener(relationshipCapability);//add for management events
RelationshipDocument relationshipDocument = RelationshipDocument.Factory.newInstance();
//add new type
RelationshipType relationshipType = null;
try
{
relationshipType = relationshipDocument.addNewRelationship();
RelationshipTypeType relationshipTypeType = relationshipType.addNewType();
XmlObject relationType = XmlObject.Factory.parse("<" + RELATIONSHIP_RELATION.getPrefix() + ":" + RELATIONSHIP_RELATION.getLocalPart() + " xmlns:" + RELATIONSHIP_RELATION.getPrefix() + "=" + "\"" + RELATIONSHIP_RELATION.getNamespaceURI() + "\" />");
XmlBeanUtils.addChildElement(relationshipTypeType, relationType);
}
catch (XmlException e)
{
e.printStackTrace();
}
QName qName = QName.valueOf("{" + WeatherstationPropertyQNames.FCCID.getNamespaceURI() + "}ResourceID");
//add a participant
RelationshipParticipantType relationshipParticipantType = relationshipType.addNewParticipant();
relationshipParticipantType.setResourceId("urn:" + InteropConstants.WEATHERSTATION_KEY1);
relationshipParticipantType.setRole("urn://parent");//uri
EndpointReferenceType manageabilityEndpointReferenceType = relationshipParticipantType.addNewManageabilityEndpointReference();
manageabilityEndpointReferenceType.addNewAddress().setStringValue(InteropConstants.SERVICES_URL + "/" + InteropConstants.WEATHERSTATION_SERVICE_NAME);
ReferencePropertiesType referencePropertiesType = manageabilityEndpointReferenceType.addNewReferenceProperties();
XmlObject key1 = XmlBeanUtils.addChildElement(referencePropertiesType, qName);
XmlBeanUtils.setValue(key1, InteropConstants.WEATHERSTATION_KEY1);
RelationshipParticipantType relationshipParticipantType2 = relationshipType.addNewParticipant();
relationshipParticipantType2.setResourceId("urn:" + InteropConstants.WEATHERSTATION_KEY2);//spec optional
relationshipParticipantType2.setRole("urn://child1");//uri
EndpointReferenceType manageabilityEndpointReferenceType2 = relationshipParticipantType.addNewManageabilityEndpointReference();
manageabilityEndpointReferenceType2.addNewAddress().setStringValue(InteropConstants.SERVICES_URL + "/" + InteropConstants.WEATHERSTATION_SERVICE_NAME);
ReferencePropertiesType referencePropertiesType2 = manageabilityEndpointReferenceType2.addNewReferenceProperties();