You are viewing a plain text version of this content. The canonical link for it is here.
Posted to muse-commits@ws.apache.org by da...@apache.org on 2007/01/04 19:24:09 UTC
svn commit: r492669 - in
/webservices/muse/trunk/modules/muse-wsn-impl/src/org/apache/muse/ws/notification:
impl/ remote/
Author: danj
Date: Thu Jan 4 10:24:08 2007
New Revision: 492669
URL: http://svn.apache.org/viewvc?view=rev&rev=492669
Log:
Fix for MUSE-165 - because the standard WSN WSDL does not include any type/naming
info for the contents of a GetCurrentMessageResponse (and we don't want to change
the standard message definitions in the WSDL), I had to write a custom handler for
this operation. We had this originally but removed it because I thought we could
rely on the reflection-based handler to do this. Without the name of the return
type, though, we lose the NotificationMessage wrapper element.
I also had to update NotificationProducerClient to use the new serialization class
so that it sends out proper requests.
Added:
webservices/muse/trunk/modules/muse-wsn-impl/src/org/apache/muse/ws/notification/impl/GetCurrentMessage.java
webservices/muse/trunk/modules/muse-wsn-impl/src/org/apache/muse/ws/notification/impl/GetCurrentMessageHandler.java
webservices/muse/trunk/modules/muse-wsn-impl/src/org/apache/muse/ws/notification/impl/GetCurrentMessageResponse.java
Modified:
webservices/muse/trunk/modules/muse-wsn-impl/src/org/apache/muse/ws/notification/impl/SimpleNotificationProducer.java
webservices/muse/trunk/modules/muse-wsn-impl/src/org/apache/muse/ws/notification/remote/NotificationProducerClient.java
Added: webservices/muse/trunk/modules/muse-wsn-impl/src/org/apache/muse/ws/notification/impl/GetCurrentMessage.java
URL: http://svn.apache.org/viewvc/webservices/muse/trunk/modules/muse-wsn-impl/src/org/apache/muse/ws/notification/impl/GetCurrentMessage.java?view=auto&rev=492669
==============================================================================
--- webservices/muse/trunk/modules/muse-wsn-impl/src/org/apache/muse/ws/notification/impl/GetCurrentMessage.java (added)
+++ webservices/muse/trunk/modules/muse-wsn-impl/src/org/apache/muse/ws/notification/impl/GetCurrentMessage.java Thu Jan 4 10:24:08 2007
@@ -0,0 +1,85 @@
+/*=============================================================================*
+ * Copyright 2007 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *=============================================================================*/
+
+package org.apache.muse.ws.notification.impl;
+
+import javax.xml.namespace.QName;
+
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+
+import org.apache.muse.util.messages.Messages;
+import org.apache.muse.util.messages.MessagesFactory;
+import org.apache.muse.util.xml.XmlSerializable;
+import org.apache.muse.util.xml.XmlUtils;
+import org.apache.muse.ws.notification.WsnConstants;
+import org.apache.muse.ws.notification.topics.WstConstants;
+
+/**
+ *
+ * GetCurrentMessage is a serializer/deserializer for the WS-Notification
+ * GetCurrentMessage operation's request content.
+ *
+ * @author Dan Jemiolo (danj)
+ *
+ */
+
+public class GetCurrentMessage implements XmlSerializable
+{
+ private static Messages _MESSAGES = MessagesFactory.get(GetCurrentMessage.class);
+
+ private QName _topicPath = null;
+
+ public GetCurrentMessage(Element xml)
+ {
+ _topicPath = XmlUtils.getQNameFromChild(xml, WsnConstants.TOPIC_QNAME);
+ }
+
+ public GetCurrentMessage(QName topicPath)
+ {
+ _topicPath = topicPath;
+ }
+
+ protected String getDialect(String name)
+ {
+ return name.indexOf('/') >= 0 ? WstConstants.CONCRETE_TOPIC_URI : WstConstants.SIMPLE_TOPIC_URI;
+ }
+
+ public QName getTopicPath()
+ {
+ return _topicPath;
+ }
+
+ public Element toXML()
+ {
+ return toXML(XmlUtils.EMPTY_DOC);
+ }
+
+ public Element toXML(Document doc)
+ {
+ if (doc == null)
+ throw new NullPointerException(_MESSAGES.get("NullDocument"));
+
+ Element root = XmlUtils.createElement(doc, WsnConstants.GET_CURRENT_QNAME);
+ Element topic = XmlUtils.createElement(doc, WsnConstants.TOPIC_QNAME, getTopicPath());
+
+ String dialect = getDialect(_topicPath.getLocalPart());
+ topic.setAttribute(WsnConstants.DIALECT, dialect);
+
+ root.appendChild(topic);
+ return root;
+ }
+}
Added: webservices/muse/trunk/modules/muse-wsn-impl/src/org/apache/muse/ws/notification/impl/GetCurrentMessageHandler.java
URL: http://svn.apache.org/viewvc/webservices/muse/trunk/modules/muse-wsn-impl/src/org/apache/muse/ws/notification/impl/GetCurrentMessageHandler.java?view=auto&rev=492669
==============================================================================
--- webservices/muse/trunk/modules/muse-wsn-impl/src/org/apache/muse/ws/notification/impl/GetCurrentMessageHandler.java (added)
+++ webservices/muse/trunk/modules/muse-wsn-impl/src/org/apache/muse/ws/notification/impl/GetCurrentMessageHandler.java Thu Jan 4 10:24:08 2007
@@ -0,0 +1,52 @@
+/*=============================================================================*
+ * Copyright 2007 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *=============================================================================*/
+
+package org.apache.muse.ws.notification.impl;
+
+import org.w3c.dom.Element;
+
+import org.apache.muse.core.routing.AbstractMessageHandler;
+import org.apache.muse.ws.notification.NotificationMessage;
+import org.apache.muse.ws.notification.WsnConstants;
+
+/**
+*
+* GetCurrentHandler is the parser for the WS-Notification GetCurrentMessage operation.
+*
+* @author Dan Jemiolo (danj)
+*
+*/
+
+public class GetCurrentMessageHandler extends AbstractMessageHandler
+{
+ public GetCurrentMessageHandler()
+ {
+ super(WsnConstants.GET_CURRENT_URI, WsnConstants.GET_CURRENT_QNAME);
+ }
+
+ public Object[] fromXML(Element xml)
+ {
+ GetCurrentMessage get = new GetCurrentMessage(xml);
+ return new Object[]{ get.getTopicPath() };
+ }
+
+ public Element toXML(Object result)
+ {
+ NotificationMessage message = (NotificationMessage)result;
+ GetCurrentMessageResponse response = new GetCurrentMessageResponse(message);
+ return response.toXML();
+ }
+}
Added: webservices/muse/trunk/modules/muse-wsn-impl/src/org/apache/muse/ws/notification/impl/GetCurrentMessageResponse.java
URL: http://svn.apache.org/viewvc/webservices/muse/trunk/modules/muse-wsn-impl/src/org/apache/muse/ws/notification/impl/GetCurrentMessageResponse.java?view=auto&rev=492669
==============================================================================
--- webservices/muse/trunk/modules/muse-wsn-impl/src/org/apache/muse/ws/notification/impl/GetCurrentMessageResponse.java (added)
+++ webservices/muse/trunk/modules/muse-wsn-impl/src/org/apache/muse/ws/notification/impl/GetCurrentMessageResponse.java Thu Jan 4 10:24:08 2007
@@ -0,0 +1,84 @@
+/*=============================================================================*
+ * Copyright 2007 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *=============================================================================*/
+
+package org.apache.muse.ws.notification.impl;
+
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+
+import org.apache.muse.util.messages.Messages;
+import org.apache.muse.util.messages.MessagesFactory;
+import org.apache.muse.util.xml.XmlSerializable;
+import org.apache.muse.util.xml.XmlUtils;
+import org.apache.muse.ws.addressing.soap.SoapFault;
+import org.apache.muse.ws.notification.NotificationMessage;
+import org.apache.muse.ws.notification.WsnConstants;
+
+/**
+ *
+ * GetCurrentMessageResponse is a serializer/deserializer for the WS-Notification
+ * GetCurrentMessage operation's response content.
+ *
+ * @author Dan Jemiolo (danj)
+ *
+ */
+
+public class GetCurrentMessageResponse implements XmlSerializable
+{
+ private static Messages _MESSAGES = MessagesFactory.get(GetCurrentMessageResponse.class);
+
+ private NotificationMessage _message = null;
+
+ public GetCurrentMessageResponse(Element xml)
+ throws SoapFault
+ {
+ Element messageXML = XmlUtils.getFirstElement(xml);
+
+ if (messageXML != null)
+ _message = new SimpleNotificationMessage(messageXML);
+ }
+
+ public GetCurrentMessageResponse(NotificationMessage message)
+ {
+ _message = message;
+ }
+
+ public NotificationMessage getMessage()
+ {
+ return _message;
+ }
+
+ public Element toXML()
+ {
+ return toXML(XmlUtils.EMPTY_DOC);
+ }
+
+ public Element toXML(Document doc)
+ {
+ if (doc == null)
+ throw new NullPointerException(_MESSAGES.get("NullDocument"));
+
+ Element root = XmlUtils.createElement(doc, WsnConstants.GET_CURRENT_RESPONSE_QNAME);
+
+ if (_message != null)
+ {
+ Element messageXML = _message.toXML(doc);
+ root.appendChild(messageXML);
+ }
+
+ return root;
+ }
+}
Modified: webservices/muse/trunk/modules/muse-wsn-impl/src/org/apache/muse/ws/notification/impl/SimpleNotificationProducer.java
URL: http://svn.apache.org/viewvc/webservices/muse/trunk/modules/muse-wsn-impl/src/org/apache/muse/ws/notification/impl/SimpleNotificationProducer.java?view=diff&rev=492669&r1=492668&r2=492669
==============================================================================
--- webservices/muse/trunk/modules/muse-wsn-impl/src/org/apache/muse/ws/notification/impl/SimpleNotificationProducer.java (original)
+++ webservices/muse/trunk/modules/muse-wsn-impl/src/org/apache/muse/ws/notification/impl/SimpleNotificationProducer.java Thu Jan 4 10:24:08 2007
@@ -167,6 +167,16 @@
addTopics(children[n], namespace, prefix);
}
+ protected MessageHandler createGetCurrentMessageHandler()
+ {
+ MessageHandler handler = new GetCurrentMessageHandler();
+
+ Method method = ReflectUtils.getFirstMethod(getClass(), "getCurrentMessage");
+ handler.setMethod(method);
+
+ return handler;
+ }
+
/**
*
* Users can override this method to provide an alternative implementation
@@ -311,6 +321,7 @@
_listenerFactory = createNotificationListenerFactory();
setMessageHandler(createSubscribeHandler());
+ setMessageHandler(createGetCurrentMessageHandler());
//
// make sure we're exposing the subscription endpoint so that
Modified: webservices/muse/trunk/modules/muse-wsn-impl/src/org/apache/muse/ws/notification/remote/NotificationProducerClient.java
URL: http://svn.apache.org/viewvc/webservices/muse/trunk/modules/muse-wsn-impl/src/org/apache/muse/ws/notification/remote/NotificationProducerClient.java?view=diff&rev=492669&r1=492668&r2=492669
==============================================================================
--- webservices/muse/trunk/modules/muse-wsn-impl/src/org/apache/muse/ws/notification/remote/NotificationProducerClient.java (original)
+++ webservices/muse/trunk/modules/muse-wsn-impl/src/org/apache/muse/ws/notification/remote/NotificationProducerClient.java Thu Jan 4 10:24:08 2007
@@ -23,12 +23,12 @@
import org.w3c.dom.Element;
import org.apache.muse.core.Environment;
-import org.apache.muse.util.xml.XmlUtils;
import org.apache.muse.ws.addressing.EndpointReference;
import org.apache.muse.ws.notification.Filter;
import org.apache.muse.ws.notification.NotificationMessage;
import org.apache.muse.ws.notification.WsnConstants;
-import org.apache.muse.ws.notification.impl.SimpleNotificationMessage;
+import org.apache.muse.ws.notification.impl.GetCurrentMessage;
+import org.apache.muse.ws.notification.impl.GetCurrentMessageResponse;
import org.apache.muse.ws.notification.impl.Subscribe;
import org.apache.muse.ws.notification.impl.SubscribeResponse;
import org.apache.muse.ws.resource.remote.WsResourceClient;
@@ -75,15 +75,12 @@
public NotificationMessage getCurrentMessage(QName topicPath)
throws SoapFault
{
- Element getXML = XmlUtils.createElement(WsnConstants.GET_CURRENT_QNAME, topicPath);
+ GetCurrentMessage get = new GetCurrentMessage(topicPath);
- Element responseXML = invoke(WsnConstants.GET_CURRENT_URI, getXML);
- Element messageXML = XmlUtils.getFirstElement(responseXML);
+ Element responseXML = invoke(WsnConstants.GET_CURRENT_URI, get.toXML());
- if (messageXML == null)
- return null;
-
- return new SimpleNotificationMessage(messageXML);
+ GetCurrentMessageResponse response = new GetCurrentMessageResponse(responseXML);
+ return response.getMessage();
}
public SubscriptionClient subscribe(EndpointReference consumer,
---------------------------------------------------------------------
To unsubscribe, e-mail: muse-commits-unsubscribe@ws.apache.org
For additional commands, e-mail: muse-commits-help@ws.apache.org