Commit b2412358 authored by Guillaume Surrel's avatar Guillaume Surrel
Browse files

Replace ClientMessages Vector and Enumeration with collection framework List and Iterator.

parent 4b991c71
/*
* JORAM: Java(TM) Open Reliable Asynchronous Messaging
* Copyright (C) 2001 - 2008 ScalAgent Distributed Technologies
* Copyright (C) 2001 - 2010 ScalAgent Distributed Technologies
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
......@@ -24,6 +24,7 @@ package com.scalagent.joram.mom.dest.ftp;
import java.util.Enumeration;
import java.util.Hashtable;
import java.util.Iterator;
import java.util.Properties;
import org.objectweb.joram.mom.dest.QueueImpl;
......@@ -158,9 +159,8 @@ public class FtpQueueImpl extends QueueImpl {
}
public ClientMessages preProcess(AgentId from, ClientMessages not) {
for (Enumeration msgs = not.getMessages().elements();
msgs.hasMoreElements();) {
Message msg = (Message) msgs.nextElement();
for (Iterator msgs = not.getMessages().iterator(); msgs.hasNext();) {
Message msg = (Message) msgs.next();
if (isFtpMsg(msg)) {
doProcessFtp(not,msg);
not.getMessages().remove(msg);
......
/*
* JORAM: Java(TM) Open Reliable Asynchronous Messaging
* Copyright (C) 2005 - 2009 ScalAgent Distributed Technologies
* Copyright (C) 2005 - 2010 ScalAgent Distributed Technologies
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
......@@ -23,7 +23,7 @@
package com.scalagent.joram.mom.dest.scheduler;
import java.util.Date;
import java.util.Enumeration;
import java.util.Iterator;
import java.util.Properties;
import org.objectweb.joram.mom.dest.QueueImpl;
......@@ -96,8 +96,8 @@ public class SchedulerQueueImpl extends QueueImpl {
org.objectweb.joram.shared.messages.Message msg;
long currentTimeMillis = System.currentTimeMillis();
for (Enumeration msgs = not.getMessages().elements(); msgs.hasMoreElements();) {
msg = (org.objectweb.joram.shared.messages.Message) msgs.nextElement();
for (Iterator msgs = not.getMessages().iterator(); msgs.hasNext();) {
msg = (org.objectweb.joram.shared.messages.Message) msgs.next();
long scheduleDate = getScheduleDate(msg);
// If there is no schedule date or if it is outdated do nothing.
if (scheduleDate < currentTimeMillis) return;
......
/*
* JORAM: Java(TM) Open Reliable Asynchronous Messaging
* Copyright (C) 2004 - 2008 ScalAgent Distributed Technologies
* Copyright (C) 2004 - 2010 ScalAgent Distributed Technologies
* Copyright (C) 2003 - 2004 Bull SA
*
* This library is free software; you can redistribute it and/or
......@@ -25,6 +25,7 @@ package org.objectweb.joram.mom.dest.jmsbridge;
import java.util.Enumeration;
import java.util.Hashtable;
import java.util.Iterator;
import java.util.Properties;
import java.util.Vector;
......@@ -241,9 +242,8 @@ public class JMSBridgeQueueImpl extends QueueImpl {
// Sending each message:
Message message;
for (Enumeration msgs = not.getMessages().elements();
msgs.hasMoreElements();) {
message = new Message((org.objectweb.joram.shared.messages.Message) msgs.nextElement());
for (Iterator msgs = not.getMessages().iterator(); msgs.hasNext();) {
message = new Message((org.objectweb.joram.shared.messages.Message) msgs.next());
message.order = arrivalsCounter++;
outTable.put(message.getIdentifier(), message);
......
/*
* JORAM: Java(TM) Open Reliable Asynchronous Messaging
* Copyright (C) 2004 - 2008 ScalAgent Distributed Technologies
* Copyright (C) 2004 - 2010 ScalAgent Distributed Technologies
* Copyright (C) 2003 - 2004 Bull SA
*
* This library is free software; you can redistribute it and/or
......@@ -25,6 +25,7 @@ package org.objectweb.joram.mom.dest.jmsbridge;
import java.util.Enumeration;
import java.util.Hashtable;
import java.util.Iterator;
import java.util.Properties;
import java.util.Vector;
......@@ -208,9 +209,9 @@ public class JMSBridgeTopicImpl extends TopicImpl {
// Sending the received messages to the foreign JMS destination:
Message message;
DMQManager dmqManager = null;
for (Enumeration msgs = not.messages.getMessages().elements(); msgs.hasMoreElements();) {
for (Iterator msgs = not.messages.getMessages().iterator(); msgs.hasNext();) {
// AF: TODO it seems not useful to transform the message !!
message = new Message((org.objectweb.joram.shared.messages.Message) msgs.nextElement());
message = new Message((org.objectweb.joram.shared.messages.Message) msgs.next());
message.order = arrivalsCounter++;
outTable.put(message.getIdentifier(), message);
......@@ -248,8 +249,8 @@ public class JMSBridgeTopicImpl extends TopicImpl {
// Sending the received messages to the foreign JMS destination:
Message message;
DMQManager dmqManager = null;
for (Enumeration msgs = not.getMessages().elements(); msgs.hasMoreElements();) {
message = new Message((org.objectweb.joram.shared.messages.Message) msgs.nextElement());
for (Iterator msgs = not.getMessages().iterator(); msgs.hasNext();) {
message = new Message((org.objectweb.joram.shared.messages.Message) msgs.next());
message.order = arrivalsCounter++;
outTable.put(message.getIdentifier(), message);
......
/*
* JORAM: Java(TM) Open Reliable Asynchronous Messaging
* Copyright (C) 2001 - 2006 ScalAgent Distributed Technologies
* Copyright (C) 2001 - 2010 ScalAgent Distributed Technologies
* Copyright (C) 1996 - 2000 Dyade
*
* This library is free software; you can redistribute it and/or
......@@ -23,8 +23,9 @@
*/
package org.objectweb.joram.mom.notifications;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.Vector;
import java.util.List;
import org.objectweb.joram.shared.messages.Message;
......@@ -41,7 +42,7 @@ public class ClientMessages extends AbstractRequest {
/** Message sent by the client. */
private Message message = null;
/** Messages sent by the client. */
private Vector messages = null;
private List messages = null;
private boolean asyncSend;
......@@ -76,7 +77,7 @@ public class ClientMessages extends AbstractRequest {
* @param requestId Request identifier.
* @param messages Vector of messages.
*/
public ClientMessages(int clientContext, int requestId, Vector messages) {
public ClientMessages(int clientContext, int requestId, List messages) {
super(clientContext, requestId);
if (messages.size() == 1) {
this.message = (Message) messages.get(0);
......@@ -114,7 +115,7 @@ public class ClientMessages extends AbstractRequest {
this.setPriority(message.priority);
} else {
if (messages == null) {
messages = new Vector();
messages = new ArrayList();
messages.add(this.message);
message = null;
}
......@@ -138,9 +139,9 @@ public class ClientMessages extends AbstractRequest {
/** Returns the messages. */
public Vector getMessages() {
public List getMessages() {
if (messages == null) {
messages = new Vector();
messages = new ArrayList();
if (message != null)
messages.add(message);
}
......@@ -155,6 +156,18 @@ public class ClientMessages extends AbstractRequest {
return asyncSend;
}
public int getMessageCount() {
if (messages == null) {
if (message == null) {
return 0;
} else {
return 1;
}
} else {
return messages.size();
}
}
/**
* Returns the identifier of the producer's dead message queue, if any.
* Basically, it simply calls {@link #getDeadNotificationAgentId()}
......
/*
* JORAM: Java(TM) Open Reliable Asynchronous Messaging
* Copyright (C) 2001 - 2006 ScalAgent Distributed Technologies
* Copyright (C) 2001 - 2010 ScalAgent Distributed Technologies
* Copyright (C) 1996 - 2000 Dyade
*
* This library is free software; you can redistribute it and/or
......@@ -24,7 +24,7 @@
package org.objectweb.joram.mom.notifications;
import java.util.Iterator;
import java.util.Vector;
import java.util.List;
import org.objectweb.joram.shared.messages.Message;
......@@ -39,15 +39,16 @@ public class TopicMsgsReply extends AbstractReply {
*
*/
private static final long serialVersionUID = 1L;
/** Vector of messages. */
private Vector messages;
private List messages;
/**
* Constructs a <code>TopicMsgsReply</code>.
*
* @param messages Vector of delivered messages.
* @param messages List of delivered messages.
*/
public TopicMsgsReply(Vector messages) {
public TopicMsgsReply(List messages) {
long newExpiration = -1L;
int newPriority = 0;
for (Iterator iterator = messages.iterator(); iterator.hasNext();) {
......@@ -66,7 +67,7 @@ public class TopicMsgsReply extends AbstractReply {
/** Returns the messages. */
public Vector getMessages() {
public List getMessages() {
return messages;
}
......
......@@ -26,8 +26,11 @@ import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Enumeration;
import java.util.Hashtable;
import java.util.Iterator;
import java.util.List;
import java.util.Vector;
import javax.management.openmbean.CompositeData;
......@@ -476,15 +479,15 @@ class ClientSubscription implements ClientSubscriptionMBean, Serializable {
*/
// AF: TODO we should parse each message for each subscription
// see ProxyImpl.doFwd
void browseNewMessages(Vector newMessages) {
void browseNewMessages(List newMessages) {
if (logger.isLoggable(BasicLevel.DEBUG))
logger.log(BasicLevel.DEBUG, this + ".browseNewMessages(" + newMessages + ')');
// Browsing the messages one by one.
Message message;
String msgId;
DMQManager dmqManager = null;
for (Enumeration e = newMessages.elements(); e.hasMoreElements();) {
message = (Message) e.nextElement();
for (Iterator e = newMessages.iterator(); e.hasNext();) {
message = (Message) e.next();
msgId = message.getIdentifier();
// test nbMaxMsg
......
......@@ -28,8 +28,11 @@ package org.objectweb.joram.mom.proxies;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.util.ArrayList;
import java.util.Enumeration;
import java.util.Hashtable;
import java.util.Iterator;
import java.util.List;
import java.util.Vector;
import org.objectweb.joram.mom.dest.AdminTopic;
......@@ -122,9 +125,7 @@ import org.objectweb.joram.shared.excepts.StateException;
import org.objectweb.util.monolog.api.BasicLevel;
import org.objectweb.util.monolog.api.Logger;
import fr.dyade.aaa.agent.Agent;
import fr.dyade.aaa.agent.AgentId;
import fr.dyade.aaa.agent.AgentServer;
import fr.dyade.aaa.agent.Channel;
import fr.dyade.aaa.agent.DeleteNot;
import fr.dyade.aaa.agent.Notification;
......@@ -1955,10 +1956,9 @@ public class ProxyImpl implements java.io.Serializable, ProxyImplMBean {
// AF: TODO we should parse each message for each subscription
// see ClientSubscription.browseNewMessages
Vector messages = new Vector();
for (Enumeration msgs = rep.getMessages().elements();
msgs.hasMoreElements();) {
Message message = new Message((org.objectweb.joram.shared.messages.Message) msgs.nextElement());
List messages = new ArrayList();
for (Iterator msgs = rep.getMessages().iterator(); msgs.hasNext();) {
Message message = new Message((org.objectweb.joram.shared.messages.Message) msgs.next());
// Setting the arrival order of the messages
message.order = arrivalsCounter++;
messages.add(message);
......@@ -1974,8 +1974,8 @@ public class ProxyImpl implements java.io.Serializable, ProxyImplMBean {
}
// Save message if it is delivered to a durable subscription.
for (Enumeration msgs = messages.elements(); msgs.hasMoreElements();) {
Message message = (Message) msgs.nextElement();
for (Iterator msgs = messages.iterator(); msgs.hasNext();) {
Message message = (Message) msgs.next();
if (message.durableAcksCounter > 0) {
if (logger.isLoggable(BasicLevel.DEBUG))
......@@ -2143,9 +2143,9 @@ public class ProxyImpl implements java.io.Serializable, ProxyImplMBean {
// Sending the messages again if not coming from the default DMQ:
if (QueueImpl.getDefaultDMQId() != null && !agId.equals(QueueImpl.getDefaultDMQId())) {
DMQManager dmqManager = new DMQManager(dmqId, null);
Enumeration msgs = ((ClientMessages) req).getMessages().elements();
while (msgs.hasMoreElements()) {
org.objectweb.joram.shared.messages.Message msg = (org.objectweb.joram.shared.messages.Message) msgs.nextElement();
Iterator msgs = ((ClientMessages) req).getMessages().iterator();
while (msgs.hasNext()) {
org.objectweb.joram.shared.messages.Message msg = (org.objectweb.joram.shared.messages.Message) msgs.next();
nbMsgsSentToDMQSinceCreation++;
dmqManager.addDeadMessage(msg, MessageErrorConstants.DELETED_DEST);
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment