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/03/18 15:35:17 UTC

svn commit: r519619 - in /webservices/muse/trunk/modules/muse-wsn-impl/src/org/apache/muse/ws/notification/impl: NotifyHandler.java SimpleNotificationConsumer.java SubscribeHandler.java

Author: danj
Date: Sun Mar 18 07:35:15 2007
New Revision: 519619

URL: http://svn.apache.org/viewvc?view=rev&rev=519619
Log:
When removing the ArraySerializer hack that allowed for arrays that didn't have a wrapper element, 
I forgot to add an explicit message handler for WSN Notify, which fits that scenario with its 
list of NotificationMessages.

Added:
    webservices/muse/trunk/modules/muse-wsn-impl/src/org/apache/muse/ws/notification/impl/NotifyHandler.java
Modified:
    webservices/muse/trunk/modules/muse-wsn-impl/src/org/apache/muse/ws/notification/impl/SimpleNotificationConsumer.java
    webservices/muse/trunk/modules/muse-wsn-impl/src/org/apache/muse/ws/notification/impl/SubscribeHandler.java

Added: webservices/muse/trunk/modules/muse-wsn-impl/src/org/apache/muse/ws/notification/impl/NotifyHandler.java
URL: http://svn.apache.org/viewvc/webservices/muse/trunk/modules/muse-wsn-impl/src/org/apache/muse/ws/notification/impl/NotifyHandler.java?view=auto&rev=519619
==============================================================================
--- webservices/muse/trunk/modules/muse-wsn-impl/src/org/apache/muse/ws/notification/impl/NotifyHandler.java (added)
+++ webservices/muse/trunk/modules/muse-wsn-impl/src/org/apache/muse/ws/notification/impl/NotifyHandler.java Sun Mar 18 07:35:15 2007
@@ -0,0 +1,66 @@
+/*=============================================================================*
+ *  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.core.serializer.Serializer;
+import org.apache.muse.core.serializer.SerializerRegistry;
+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;
+
+/**
+ *
+ * NotifyHandler is the parser for the WS-Notification Notify operation.
+ *
+ * @author Dan Jemiolo (danj)
+ *
+ */
+
+public class NotifyHandler extends AbstractMessageHandler
+{
+    //
+    // Response message never changes, so we use a static value
+    //
+    private static final Element _NOTIFY_RESPONSE = XmlUtils.createElement(WsnConstants.NOTIFY_RESPONSE_QNAME);
+    
+    public NotifyHandler()
+    {
+        super(WsnConstants.NOTIFY_URI, WsnConstants.NOTIFY_QNAME);
+    }
+    
+    public Object[] fromXML(Element xml) 
+        throws SoapFault
+    {
+        //
+        // use the Muse serializer framework to convert <Notify/> into 
+        // an array of NotificationMessage objects
+        //
+        SerializerRegistry registry = SerializerRegistry.getInstance();
+        Serializer ser = registry.getSerializer(NotificationMessage[].class);
+        Object messageArray = ser.fromXML(xml);
+        return new Object[]{ messageArray };
+    }
+    
+    public Element toXML(Object result)
+    {
+        return _NOTIFY_RESPONSE;
+    }
+}

Modified: webservices/muse/trunk/modules/muse-wsn-impl/src/org/apache/muse/ws/notification/impl/SimpleNotificationConsumer.java
URL: http://svn.apache.org/viewvc/webservices/muse/trunk/modules/muse-wsn-impl/src/org/apache/muse/ws/notification/impl/SimpleNotificationConsumer.java?view=diff&rev=519619&r1=519618&r2=519619
==============================================================================
--- webservices/muse/trunk/modules/muse-wsn-impl/src/org/apache/muse/ws/notification/impl/SimpleNotificationConsumer.java (original)
+++ webservices/muse/trunk/modules/muse-wsn-impl/src/org/apache/muse/ws/notification/impl/SimpleNotificationConsumer.java Sun Mar 18 07:35:15 2007
@@ -16,6 +16,7 @@
 
 package org.apache.muse.ws.notification.impl;
 
+import java.lang.reflect.Method;
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.Collections;
@@ -25,6 +26,7 @@
 import javax.xml.namespace.QName;
 
 import org.apache.muse.core.AbstractCapability;
+import org.apache.muse.core.routing.MessageHandler;
 import org.apache.muse.core.serializer.SerializerRegistry;
 import org.apache.muse.util.LoggingUtils;
 import org.apache.muse.util.MultiMap;
@@ -67,6 +69,29 @@
         _topicListeners.put(listener.getTopic(), listener);
     }
     
+    protected MessageHandler createNotifyHandler()
+    {
+        MessageHandler handler = new NotifyHandler();
+        Method method = null;
+        
+        try
+        {
+            //
+            // can't use ReflectUtils.getFirstMethod() because it might 
+            // return Object.notify()
+            //
+            method = getClass().getMethod("notify", new Class[]{ NotificationMessage[].class });
+        }
+        
+        catch (Throwable error)
+        {
+            throw new RuntimeException(error.getMessage(), error);
+        }
+        
+        handler.setMethod(method);
+        return handler;
+    }
+    
     public Collection getMessageListeners()
     {
         return Collections.unmodifiableCollection(_messageListeners);
@@ -93,6 +118,12 @@
         //
         SerializerRegistry registry = SerializerRegistry.getInstance();
         registry.registerSerializer(NotificationMessage.class, new NotificationMessageSerializer());
+        
+        //
+        // add message handler for <Notify/>, which has array parameters 
+        // that are outside our WSDL conventions
+        //
+        setMessageHandler(createNotifyHandler());
     }
     
     /**

Modified: webservices/muse/trunk/modules/muse-wsn-impl/src/org/apache/muse/ws/notification/impl/SubscribeHandler.java
URL: http://svn.apache.org/viewvc/webservices/muse/trunk/modules/muse-wsn-impl/src/org/apache/muse/ws/notification/impl/SubscribeHandler.java?view=diff&rev=519619&r1=519618&r2=519619
==============================================================================
--- webservices/muse/trunk/modules/muse-wsn-impl/src/org/apache/muse/ws/notification/impl/SubscribeHandler.java (original)
+++ webservices/muse/trunk/modules/muse-wsn-impl/src/org/apache/muse/ws/notification/impl/SubscribeHandler.java Sun Mar 18 07:35:15 2007
@@ -28,6 +28,7 @@
 import org.apache.muse.ws.resource.lifetime.WsrlConstants;
 
 /**
+ * 
  * SubscribeHandler is the parser for the WS-Notification Subscribe operation.
  * 
  * @author Dan Jemiolo (danj)



---------------------------------------------------------------------
To unsubscribe, e-mail: muse-commits-unsubscribe@ws.apache.org
For additional commands, e-mail: muse-commits-help@ws.apache.org