InitialContext initialContext = new InitialContext();
WeatherstationHome home = (WeatherstationHome) initialContext.lookup(WeatherstationHome.HOME_LOCATION);
SimpleTypeResourceKey simpleTypeResourceKey = new SimpleTypeResourceKey(new QName(WeatherstationPropertyQNames.FCCID.getNamespaceURI(), "ResourceID"),
InteropConstants.WEATHERSTATION_KEY1);
WeatherstationResource resource = (WeatherstationResource) home.find(simpleTypeResourceKey);
Topic topic = resource.getTopicSpaceSet().getTopicSpace(MowsConstants.NSURI_MOWS_TOPICS).getTopic("RequestProcessingObservations");
Calendar currentTime = Calendar.getInstance();
//RequestProcessingNotification
RequestProcessingNotificationDocument notifDocument = RequestProcessingNotificationDocument.Factory.newInstance();
RequestProcessingNotificationDocument.RequestProcessingNotification notif = notifDocument.addNewRequestProcessingNotification();
//request message
MessageInformationType requestInformationType = notif.addNewRequest();
MessageContentType requestMessage = requestInformationType.addNewMessage();
AnyXmlContentsType requestAnyXmlContentsType = requestMessage.addNewXml();
XmlBeanUtils.addChildElement(requestAnyXmlContentsType, getCurrentTemperatureRequestDoc);
//reply message
MessageInformationType replyInformationType = notif.addNewReply();
MessageContentType replyMessage = replyInformationType.addNewMessage();
AnyXmlContentsType replyAnyXmlContentsType = replyMessage.addNewXml();
XmlBeanUtils.addChildElement(replyAnyXmlContentsType, getCurrentTemperatureResponseDocument);
//todo flesh out
//StateInformation
RequestProcessingStateInformationType requestProcessingStateInformationType = notif.addNewStateInformation();
StateTransitionType stateTransitionType = requestProcessingStateInformationType.addNewStateTransition();
XmlObject currentState = XmlObject.Factory.parse("<tns:temp xmlns:tns=\"http://tempcentral.com/temps\">Cool</tns:temp>");
StateType enteredState = stateTransitionType.addNewEnteredState();
XmlBeanUtils.addChildElement(enteredState, currentState);
StateType prevState = stateTransitionType.addNewPreviousState();
XmlBeanUtils.addChildElement(prevState, currentState);
stateTransitionType.setTransitionIdentifier("urn:NONE");
stateTransitionType.setTime(currentTime);
notif.setCurrentTime(currentTime);
Situation situation = new SituationImpl(new CategoryImpl(MuwsConstants.SITUATION_OTHER));
XmlBeansManagementEvent xme = new XmlBeansManagementEvent(situation);
ManagementEventDocument mgmtEvent = (ManagementEventDocument) ((XmlObjectWrapper) xme).getXmlObject();
org.oasisOpen.docs.wsdm.x2004.x12.muws.wsdmMuwsPart1.ManagementEventType managementEvent = mgmtEvent.getManagementEvent();
XmlBeanUtils.addChildElement(managementEvent, notifDocument);
topic.publish(mgmtEvent);
}
catch (Exception e)
{
e.printStackTrace();
}