mirror of https://github.com/apache/activemq.git
AMQ-6908 allow use of ActiveMQ console login credential (for authorization) when browsing messages through the console
This commit is contained in:
parent
2ca46c561b
commit
822cf62034
|
@ -16,9 +16,6 @@
|
||||||
*/
|
*/
|
||||||
package org.apache.activemq.web;
|
package org.apache.activemq.web;
|
||||||
|
|
||||||
import java.util.Enumeration;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Map;
|
|
||||||
import javax.jms.BytesMessage;
|
import javax.jms.BytesMessage;
|
||||||
import javax.jms.JMSException;
|
import javax.jms.JMSException;
|
||||||
import javax.jms.MapMessage;
|
import javax.jms.MapMessage;
|
||||||
|
@ -27,19 +24,22 @@ import javax.jms.ObjectMessage;
|
||||||
import javax.jms.QueueBrowser;
|
import javax.jms.QueueBrowser;
|
||||||
import javax.jms.StreamMessage;
|
import javax.jms.StreamMessage;
|
||||||
import javax.jms.TextMessage;
|
import javax.jms.TextMessage;
|
||||||
|
import java.util.Enumeration;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Allow the user to browse a message on a queue by its ID
|
* Allow the user to browse a message on a queue by its ID
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class MessageQuery extends QueueBrowseQuery {
|
public class MessageQuery extends QueueBrowseQuery {
|
||||||
|
|
||||||
private String id;
|
private String id;
|
||||||
private Message message;
|
private Message message;
|
||||||
|
|
||||||
public MessageQuery(BrokerFacade brokerFacade, SessionPool sessionPool) throws JMSException {
|
public MessageQuery(BrokerFacade brokerFacade) throws JMSException {
|
||||||
super(brokerFacade, sessionPool);
|
super(brokerFacade);
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getId() {
|
public String getId() {
|
||||||
|
@ -111,7 +111,7 @@ public class MessageQuery extends QueueBrowseQuery {
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isDLQ() throws Exception {
|
public boolean isDLQ() throws Exception {
|
||||||
return getQueueView().isDLQ();
|
return getQueueView().isDLQ();
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,28 +16,26 @@
|
||||||
*/
|
*/
|
||||||
package org.apache.activemq.web;
|
package org.apache.activemq.web;
|
||||||
|
|
||||||
|
import org.springframework.beans.factory.DisposableBean;
|
||||||
|
import org.springframework.web.context.request.RequestContextHolder;
|
||||||
|
import org.springframework.web.context.request.ServletRequestAttributes;
|
||||||
|
|
||||||
import javax.jms.JMSException;
|
import javax.jms.JMSException;
|
||||||
import javax.jms.Queue;
|
import javax.jms.Queue;
|
||||||
import javax.jms.QueueBrowser;
|
import javax.jms.QueueBrowser;
|
||||||
import javax.jms.Session;
|
import javax.jms.Session;
|
||||||
|
|
||||||
import org.springframework.beans.factory.DisposableBean;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class QueueBrowseQuery extends DestinationFacade implements DisposableBean {
|
public class QueueBrowseQuery extends DestinationFacade implements DisposableBean {
|
||||||
private SessionPool sessionPool;
|
|
||||||
private String selector;
|
private String selector;
|
||||||
private Session session;
|
|
||||||
private Queue queue;
|
private Queue queue;
|
||||||
private QueueBrowser browser;
|
private QueueBrowser browser;
|
||||||
|
|
||||||
public QueueBrowseQuery(BrokerFacade brokerFacade, SessionPool sessionPool) throws JMSException {
|
public QueueBrowseQuery(BrokerFacade brokerFacade) throws JMSException {
|
||||||
super(brokerFacade);
|
super(brokerFacade);
|
||||||
this.sessionPool = sessionPool;
|
|
||||||
this.session = sessionPool.borrowSession();
|
|
||||||
setJMSDestinationType("query");
|
setJMSDestinationType("query");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -45,8 +43,6 @@ public class QueueBrowseQuery extends DestinationFacade implements DisposableBea
|
||||||
if (browser != null) {
|
if (browser != null) {
|
||||||
browser.close();
|
browser.close();
|
||||||
}
|
}
|
||||||
sessionPool.returnSession(session);
|
|
||||||
session = null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public QueueBrowser getBrowser() throws JMSException {
|
public QueueBrowser getBrowser() throws JMSException {
|
||||||
|
@ -62,7 +58,7 @@ public class QueueBrowseQuery extends DestinationFacade implements DisposableBea
|
||||||
|
|
||||||
public Queue getQueue() throws JMSException {
|
public Queue getQueue() throws JMSException {
|
||||||
if (queue == null) {
|
if (queue == null) {
|
||||||
queue = session.createQueue(getValidDestination());
|
queue = getSession().createQueue(getValidDestination());
|
||||||
}
|
}
|
||||||
return queue;
|
return queue;
|
||||||
}
|
}
|
||||||
|
@ -79,10 +75,13 @@ public class QueueBrowseQuery extends DestinationFacade implements DisposableBea
|
||||||
this.selector = selector;
|
this.selector = selector;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Session getSession() {
|
public Session getSession() throws JMSException {
|
||||||
return session;
|
ServletRequestAttributes servletRequestAttributes = (ServletRequestAttributes) RequestContextHolder.currentRequestAttributes();
|
||||||
|
|
||||||
|
return WebClient.getWebClient(servletRequestAttributes.getRequest()).getSession();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public boolean isQueue() {
|
public boolean isQueue() {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -91,5 +90,4 @@ public class QueueBrowseQuery extends DestinationFacade implements DisposableBea
|
||||||
return getSession().createBrowser(getQueue(), getSelector());
|
return getSession().createBrowser(getQueue(), getSelector());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue