Please log a bug for this.  I will probably come upon this issue
sometime, too.
 

-----Original Message-----
From: Bogdan Solomon [mailto:[EMAIL PROTECTED] 
Sent: Thursday, August 16, 2007 12:04 PM
To: [email protected]
Subject: RE: Array serialization problem in notifications


Well I have discovered what the problem is. I am unsure however if this
is because of the way I construct the XML or if this is a bug in Muse.

The SimpleNotificationProducer publish array method does the following:

NotificationMessage message = createNotificationMessage();
        
for (int n = 0; n < content.length; ++n)
     message.addMessageContent(content[n]); 

and in SimpleNotificationMessage

the addMessageContent does the following:

if (content == null)
     throw new
NullPointerException(_MESSAGES.get("NullMessageContent"));

QName name = XmlUtils.getElementQName(content);
_messageContent.put(name, content); 

but _messageContent is a LinkedHashMap, and from what the Java
specification says adding multiple instances with the same key
overwrites the values. So only the last one will be preserved.

I have solved the issue for the moment by wrapping the Elements that
represent the array in another top level element that gets published.


Vinh Nguyen (vinguye2) wrote:
> 
> Try explicitly converting your XmlSerializable[] to an Element[], and 
> then call producer.publish(QName,Element[]).  See if that makes a 
> difference?
> 
> 
> -----Original Message-----
> From: Bogdan Solomon [mailto:[EMAIL PROTECTED]
> Sent: Thursday, August 16, 2007 7:23 AM
> To: [email protected]
> Subject: Array serialization problem in notifications
> 
> 
> I think the problem is in my serialization code but I just can't 
> figured out what it is.
> 
> I am trying to send via notifications an array of custom objects which

> implement XmlSerializable. I logged some messages and I see that all 
> the objects in the array get serialized (the toXml() method is called 
> for each of them), but the final notification only contains the last 
> element in the array.
> 
> Here is the notification code (the data structure is an ArrayList):
> 
> QName messageName = new
> QName("http://autonomic.ibm.com/muse/sensor/execution/Topics";,
> "MeasuredDataTopic", "topics1");
> wsn.publish(messageName, data.toArray(new DataInterface[0]));
> 
> and here is the serialization code:
> 
> public Element toXML() {
>               System.out.println("Serializing:"+name);
>               
>               Element root =
> XmlUtils.createElement(XmlUtils.EMPTY_DOC,rootQName);
>               
>               //Element root = XmlUtils.createElement(rootQName);
>               
>               Element name = XmlUtils.createElement(nameQName,
getName());
>               
>               Element dataValue =
> XmlUtils.createElement(dataValueQName,getDataValue());
>               
>               Element desc =
> XmlUtils.createElement(descQName,getDescription());
>               
>               Element valueType =
> XmlUtils.createElement(valueTypeQName,getDataType());
>               
>               root.appendChild(name);
>               root.appendChild(dataValue);
>               root.appendChild(desc);
>               root.appendChild(valueType);
>               
>               return root;
>       }
> 
> The resulting Notification looks as follows:
> 
> <soap:Body>
>         <wsnt:Notify xmlns:wsnt="http://docs.oasis-open.org/wsn/b-2";>
>             <wsnt:NotificationMessage
>                 xmlns:muse-wsa="http://ws.apache.org/muse/addressing";
>                
> xmlns:sensor="http://autonomic.ibm.com/muse/filter/execution";
>                 xmlns:wsa="http://www.w3.org/2005/08/addressing";
> xmlns:wsnt="http://docs.oasis-open.org/wsn/b-2";>
>                 <wsnt:SubscriptionReference>
>                     <wsa:Address
> xmlns:wsa="http://www.w3.org/2005/08/addressing";>http://192.168.32.23:
> 90 81/AutonomicSensor/services/SubscriptionManager</wsa:Address>
>                     <wsa:ReferenceParameters 
> xmlns:wsa="http://www.w3.org/2005/08/addressing";>
>                         <muse-wsa:ResourceId 
> xmlns:muse-wsa="http://ws.apache.org/muse/addressing";>MuseResource-1</
> mu
> se-wsa:ResourceId>
>                     </wsa:ReferenceParameters>
>                 </wsnt:SubscriptionReference>
>                 <wsnt:Topic
>                    
> Dialect="http://docs.oasis-open.org/wsn/t-1/TopicExpression/Concrete";
> xmlns:topics1="http://autonomic.ibm.com/muse/sensor/execution/Topics";>
> to
> pics1:MeasuredDataTopic</wsnt:Topic>
>                 <wsnt:ProducerReference>
>                     <wsa:Address
> xmlns:wsa="http://www.w3.org/2005/08/addressing";>http://192.168.32.23:
> 90 81/AutonomicSensor/services/sensor</wsa:Address>
>                     <wsa:ReferenceParameters 
> xmlns:wsa="http://www.w3.org/2005/08/addressing";>
>                         <muse-wsa:ResourceId 
> xmlns:muse-wsa="http://ws.apache.org/muse/addressing";>MuseResource-13<
> /m
> use-wsa:ResourceId>
>                     </wsa:ReferenceParameters>
>                 </wsnt:ProducerReference>
>                 <wsnt:Message>
>                     <sensor:FilteredData 
> xmlns:sensor="http://autonomic.ibm.com/muse/filter/execution";>
>                        
> <sensor:name>TradeScenarioServlet-ServiceTime-TotalTime</sensor:name>
>                         <sensor:dataValue>0</sensor:dataValue>
>                         <sensor:description/>
>                         <sensor:valueType>Long</sensor:valueType>
>                     </sensor:FilteredData>
>                 </wsnt:Message>
>             </wsnt:NotificationMessage>
>         </wsnt:Notify>
>     </soap:Body>
> 
> But my message should contain 7 FilteredData structures as I have 7 
> DataInterface objects.
> --
> View this message in context:
> http://www.nabble.com/Array-serialization-problem-in-notifications-tf4
> 27
> 9966.html#a12182356
> Sent from the Muse User mailing list archive at Nabble.com.
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 
> 
> 

--
View this message in context:
http://www.nabble.com/Array-serialization-problem-in-notifications-tf427
9966.html#a12187485
Sent from the Muse User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to