use of com.sun.messaging.jmq.jmsserver.core.SelectorFilter in project openmq by eclipse-ee4j.
the class QBrowseHandler method getQBrowseList.
public ArrayList getQBrowseList(Destination d, String selectorstr) throws BrokerException, SelectorFormatException {
Collection msgs = null;
if (selectorstr == null) {
msgs = d.getAll((Filter) null).values();
} else {
SelectorFilter f = new SelectorFilter(selectorstr);
Map m = d.getAll(f);
msgs = m.values();
}
// sort the messages
ArrayList sorted = new ArrayList(msgs);
Collections.sort(sorted, new RefCompare());
TransactionList[] tls = DL.getTransactionList(d.getPartitionedStore());
TransactionList tlist = tls[0];
// remove any expired messages or messages in open txn
Iterator itr = sorted.iterator();
while (itr.hasNext()) {
PacketReference p = (PacketReference) itr.next();
if (p.isExpired()) {
itr.remove();
}
if (!p.isDeliveryDue()) {
itr.remove();
}
if (p.getTransactionID() != null) {
// look up txn
TransactionState ts = tlist.retrieveState(p.getTransactionID());
if (ts != null && ts.getState() != TransactionState.COMMITTED) {
// open txn, remove
itr.remove();
}
}
// check in takeover processing
if (p.checkLock(false) == null) {
itr.remove();
}
}
ArrayList returnmsgs = new ArrayList();
itr = sorted.iterator();
while (itr.hasNext()) {
PacketReference p = (PacketReference) itr.next();
if (p == null) {
continue;
}
returnmsgs.add(p.getSysMessageID());
}
return returnmsgs;
}
Aggregations