mirror of https://github.com/apache/activemq.git
applied patch for AMQ-1241 to allow the web console to be run against an embedded, invm, properties or remote broker. Many thanks to Mario Siegenthaler for the patch!
git-svn-id: https://svn.apache.org/repos/asf/activemq/trunk@541306 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
a92fb28d75
commit
87f75b2de7
|
@ -52,6 +52,20 @@
|
|||
<name>com.sun.management.jmxremote</name>
|
||||
<value></value>
|
||||
</systemProperty>
|
||||
<!--
|
||||
<systemProperty>
|
||||
<name>webconsole.type</name>
|
||||
<value>properties</value>
|
||||
</systemProperty>
|
||||
<systemProperty>
|
||||
<name>webconsole.jms.url</name>
|
||||
<value>tcp://localhost:61616</value>
|
||||
</systemProperty>
|
||||
<systemProperty>
|
||||
<name>webconsole.jmx.url</name>
|
||||
<value>service:jmx:rmi:///jndi/rmi://localhost:1099/jmxrmi</value>
|
||||
</systemProperty>
|
||||
-->
|
||||
</systemProperties>
|
||||
<scanIntervalSeconds>10</scanIntervalSeconds>
|
||||
</configuration>
|
||||
|
|
|
@ -1,73 +0,0 @@
|
|||
/**
|
||||
*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You 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.activemq.web;
|
||||
|
||||
import org.apache.activemq.broker.jmx.BrokerViewMBean;
|
||||
import org.apache.activemq.broker.jmx.ManagementContext;
|
||||
import org.apache.activemq.command.ActiveMQDestination;
|
||||
|
||||
import javax.management.MBeanServerConnection;
|
||||
import javax.management.MBeanServerInvocationHandler;
|
||||
import javax.management.MalformedObjectNameException;
|
||||
import javax.management.ObjectName;
|
||||
|
||||
/**
|
||||
* A {@link BrokerFacade} which uses JMX to communicate with a remote broker
|
||||
*
|
||||
* @version $Revision$
|
||||
*/
|
||||
public class JMXBrokerFacade extends BrokerFacadeSupport {
|
||||
private ManagementContext managementContext;
|
||||
private ObjectName brokerName;
|
||||
|
||||
public BrokerViewMBean getBrokerAdmin() throws Exception {
|
||||
MBeanServerConnection mbeanServer = getManagementContext().getMBeanServer();
|
||||
return (BrokerViewMBean) MBeanServerInvocationHandler.newProxyInstance(mbeanServer, getBrokerName(), BrokerViewMBean.class, true);
|
||||
}
|
||||
|
||||
public void purgeQueue(ActiveMQDestination destination) throws Exception {
|
||||
/** TODO */
|
||||
}
|
||||
|
||||
public ManagementContext getManagementContext() {
|
||||
if (managementContext == null) {
|
||||
managementContext = new ManagementContext();
|
||||
managementContext.setCreateConnector(true);
|
||||
}
|
||||
return managementContext;
|
||||
}
|
||||
|
||||
public void setManagementContext(ManagementContext managementContext) {
|
||||
this.managementContext = managementContext;
|
||||
}
|
||||
|
||||
public ObjectName getBrokerName() throws MalformedObjectNameException {
|
||||
if (brokerName == null) {
|
||||
brokerName = createBrokerName();
|
||||
}
|
||||
return brokerName;
|
||||
}
|
||||
|
||||
public void setBrokerName(ObjectName brokerName) {
|
||||
this.brokerName = brokerName;
|
||||
}
|
||||
|
||||
protected ObjectName createBrokerName() throws MalformedObjectNameException {
|
||||
return new ObjectName(getManagementContext().getJmxDomainName() + ":Type=Broker");
|
||||
}
|
||||
}
|
|
@ -0,0 +1,222 @@
|
|||
/**
|
||||
*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You 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.activemq.web;
|
||||
|
||||
import org.apache.activemq.broker.jmx.BrokerViewMBean;
|
||||
import org.apache.activemq.broker.jmx.ManagementContext;
|
||||
import org.apache.activemq.broker.jmx.QueueViewMBean;
|
||||
import org.apache.activemq.command.ActiveMQDestination;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
import javax.management.MBeanServerConnection;
|
||||
import javax.management.MBeanServerInvocationHandler;
|
||||
import javax.management.MalformedObjectNameException;
|
||||
import javax.management.ObjectName;
|
||||
import javax.management.remote.JMXConnector;
|
||||
import javax.management.remote.JMXConnectorFactory;
|
||||
import javax.management.remote.JMXServiceURL;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* A {@link BrokerFacade} which uses a JMX-Connection to communicate with a
|
||||
* broker
|
||||
*
|
||||
* @version $Revision: 1.1 $
|
||||
*/
|
||||
public class RemoteJMXBrokerFacade extends BrokerFacadeSupport {
|
||||
private static final transient Log log = LogFactory.getLog(RemoteJMXBrokerFacade.class);
|
||||
private String jmxUrl;
|
||||
private String brokerName;
|
||||
private JMXConnector connector;
|
||||
|
||||
public void setBrokerName(String brokerName) {
|
||||
this.brokerName = brokerName;
|
||||
}
|
||||
|
||||
public void setJmxUrl(String url) {
|
||||
this.jmxUrl = url;
|
||||
}
|
||||
|
||||
/**
|
||||
* Shutdown this facade aka close any open connection.
|
||||
*/
|
||||
public void shutdown() {
|
||||
closeConnection();
|
||||
}
|
||||
|
||||
public BrokerViewMBean getBrokerAdmin() throws Exception {
|
||||
MBeanServerConnection connection = getConnection();
|
||||
|
||||
Set brokers = findBrokers(connection);
|
||||
if (brokers.size() == 0) {
|
||||
throw new IOException("No broker could be found in the JMX.");
|
||||
}
|
||||
ObjectName name = (ObjectName) brokers.iterator().next();
|
||||
BrokerViewMBean mbean = (BrokerViewMBean) MBeanServerInvocationHandler
|
||||
.newProxyInstance(connection, name, BrokerViewMBean.class, true);
|
||||
return mbean;
|
||||
}
|
||||
|
||||
protected MBeanServerConnection getConnection() throws IOException {
|
||||
JMXConnector connector = this.connector;
|
||||
if (isConnectionActive(connector)) {
|
||||
return connector.getMBeanServerConnection();
|
||||
}
|
||||
|
||||
synchronized (this) {
|
||||
closeConnection();
|
||||
|
||||
log.debug("Creating a new JMX-Connection to the broker");
|
||||
this.connector = createConnection();
|
||||
return this.connector.getMBeanServerConnection();
|
||||
}
|
||||
}
|
||||
|
||||
protected boolean isConnectionActive(JMXConnector connector) {
|
||||
if (connector == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
try {
|
||||
MBeanServerConnection connection = connector
|
||||
.getMBeanServerConnection();
|
||||
int brokerCount = findBrokers(connection).size();
|
||||
return brokerCount > 0;
|
||||
}
|
||||
catch (Exception e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
protected JMXConnector createConnection() {
|
||||
String[] urls = this.jmxUrl.split(",");
|
||||
if (urls == null || urls.length == 0) {
|
||||
urls = new String[]{this.jmxUrl};
|
||||
}
|
||||
|
||||
Exception exception = null;
|
||||
for (int i = 0; i < urls.length; i++) {
|
||||
try {
|
||||
JMXConnector connector = JMXConnectorFactory
|
||||
.connect(new JMXServiceURL(urls[i]));
|
||||
connector.connect();
|
||||
MBeanServerConnection connection = connector
|
||||
.getMBeanServerConnection();
|
||||
|
||||
Set brokers = findBrokers(connection);
|
||||
if (brokers.size() > 0) {
|
||||
log
|
||||
.info("Connected via JMX to the broker at "
|
||||
+ urls[i]);
|
||||
return connector;
|
||||
}
|
||||
}
|
||||
catch (Exception e) {
|
||||
// Keep the exception for later
|
||||
exception = e;
|
||||
}
|
||||
}
|
||||
if (exception != null) {
|
||||
if (exception instanceof RuntimeException) {
|
||||
throw (RuntimeException) exception;
|
||||
}
|
||||
else {
|
||||
throw new RuntimeException(exception);
|
||||
}
|
||||
}
|
||||
throw new IllegalStateException(
|
||||
"No broker is found at any of the urls " + this.jmxUrl);
|
||||
}
|
||||
|
||||
protected synchronized void closeConnection() {
|
||||
if (connector != null) {
|
||||
try {
|
||||
log.debug("Closing a connection to a broker ("
|
||||
+ connector.getConnectionId() + ")");
|
||||
|
||||
connector.close();
|
||||
}
|
||||
catch (IOException e) {
|
||||
// Ignore the exception, since it most likly won't matter
|
||||
// anymore
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Finds all ActiveMQ-Brokers registered on a certain JMX-Server or, if a
|
||||
* JMX-BrokerName has been set, the broker with that name.
|
||||
*
|
||||
* @param connection not <code>null</code>
|
||||
* @return Set with ObjectName-elements
|
||||
* @throws IOException
|
||||
* @throws MalformedObjectNameException
|
||||
*/
|
||||
protected Set findBrokers(MBeanServerConnection connection)
|
||||
throws IOException, MalformedObjectNameException {
|
||||
ObjectName name;
|
||||
if (this.brokerName == null) {
|
||||
name = new ObjectName("org.apache.activemq:Type=Broker,*");
|
||||
}
|
||||
else {
|
||||
name = new ObjectName("org.apache.activemq:BrokerName="
|
||||
+ this.brokerName + ",Type=Broker");
|
||||
}
|
||||
|
||||
Set brokers = connection.queryNames(name, null);
|
||||
return brokers;
|
||||
}
|
||||
|
||||
public void purgeQueue(ActiveMQDestination destination) throws Exception {
|
||||
QueueViewMBean queue = getQueue(destination.getPhysicalName());
|
||||
queue.purge();
|
||||
}
|
||||
|
||||
public ManagementContext getManagementContext() {
|
||||
throw new IllegalStateException("not supported");
|
||||
}
|
||||
|
||||
protected Collection getManagedObjects(ObjectName[] names, Class type) {
|
||||
MBeanServerConnection connection;
|
||||
try {
|
||||
connection = getConnection();
|
||||
}
|
||||
catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
|
||||
List answer = new ArrayList();
|
||||
if (connection != null) {
|
||||
for (int i = 0; i < names.length; i++) {
|
||||
ObjectName name = names[i];
|
||||
Object value = MBeanServerInvocationHandler.newProxyInstance(
|
||||
connection, name, type, true);
|
||||
if (value != null) {
|
||||
answer.add(value);
|
||||
}
|
||||
}
|
||||
}
|
||||
return answer;
|
||||
}
|
||||
|
||||
}
|
|
@ -16,13 +16,12 @@
|
|||
*/
|
||||
package org.apache.activemq.web;
|
||||
|
||||
import org.apache.activemq.ActiveMQConnectionFactory;
|
||||
import java.util.LinkedList;
|
||||
|
||||
import javax.jms.Connection;
|
||||
import javax.jms.ConnectionFactory;
|
||||
import javax.jms.JMSException;
|
||||
import javax.jms.Session;
|
||||
import java.util.LinkedList;
|
||||
|
||||
/**
|
||||
* A simple pool of JMS Session objects intended for use by Queue browsers.
|
||||
|
@ -31,58 +30,71 @@ import java.util.LinkedList;
|
|||
*/
|
||||
public class SessionPool {
|
||||
|
||||
private ConnectionFactory connectionFactory;
|
||||
private Connection connection;
|
||||
private LinkedList sessions = new LinkedList();
|
||||
private ConnectionFactory connectionFactory;
|
||||
private Connection connection;
|
||||
private LinkedList sessions = new LinkedList();
|
||||
|
||||
public Connection getConnection() throws JMSException {
|
||||
if (connection == null) {
|
||||
connection = getConnectionFactory().createConnection();
|
||||
connection.start();
|
||||
}
|
||||
return connection;
|
||||
}
|
||||
public Connection getConnection() throws JMSException {
|
||||
if (checkConnection())
|
||||
return connection;
|
||||
|
||||
public void setConnection(Connection connection) {
|
||||
this.connection = connection;
|
||||
}
|
||||
synchronized (this) {
|
||||
connection = getConnectionFactory().createConnection();
|
||||
connection.start();
|
||||
return connection;
|
||||
}
|
||||
}
|
||||
|
||||
public ConnectionFactory getConnectionFactory() {
|
||||
if (connectionFactory == null) {
|
||||
// TODO support remote brokers too
|
||||
connectionFactory = new ActiveMQConnectionFactory("vm://localhost");
|
||||
}
|
||||
return connectionFactory;
|
||||
}
|
||||
private boolean checkConnection() {
|
||||
if (connection == null)
|
||||
return false;
|
||||
|
||||
public void setConnectionFactory(ConnectionFactory connectionFactory) {
|
||||
this.connectionFactory = connectionFactory;
|
||||
}
|
||||
try {
|
||||
connection.getMetaData();
|
||||
return true;
|
||||
} catch (JMSException e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public void setConnection(Connection connection) {
|
||||
this.connection = connection;
|
||||
}
|
||||
|
||||
public Session borrowSession() throws JMSException {
|
||||
Session answer = null;
|
||||
synchronized (sessions) {
|
||||
if (sessions.isEmpty()) {
|
||||
answer = createSession();
|
||||
}
|
||||
else {
|
||||
answer = (Session) sessions.removeLast();
|
||||
}
|
||||
}
|
||||
return answer;
|
||||
}
|
||||
public ConnectionFactory getConnectionFactory() {
|
||||
if (connectionFactory == null) {
|
||||
throw new IllegalStateException(
|
||||
"No ConnectionFactory has been set for the session pool");
|
||||
}
|
||||
return connectionFactory;
|
||||
}
|
||||
|
||||
protected void returnSession(Session session) {
|
||||
if (session != null) {
|
||||
synchronized (sessions) {
|
||||
sessions.add(session);
|
||||
}
|
||||
}
|
||||
}
|
||||
public void setConnectionFactory(ConnectionFactory connectionFactory) {
|
||||
this.connectionFactory = connectionFactory;
|
||||
}
|
||||
|
||||
protected Session createSession() throws JMSException {
|
||||
return getConnection().createSession(false, Session.AUTO_ACKNOWLEDGE);
|
||||
}
|
||||
public Session borrowSession() throws JMSException {
|
||||
Session answer = null;
|
||||
synchronized (sessions) {
|
||||
if (sessions.isEmpty()) {
|
||||
answer = createSession();
|
||||
} else {
|
||||
answer = (Session) sessions.removeLast();
|
||||
}
|
||||
}
|
||||
return answer;
|
||||
}
|
||||
|
||||
public void returnSession(Session session) {
|
||||
if (session != null) {
|
||||
synchronized (sessions) {
|
||||
sessions.add(session);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected Session createSession() throws JMSException {
|
||||
return getConnection().createSession(false, Session.AUTO_ACKNOWLEDGE);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,83 @@
|
|||
/**
|
||||
*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You 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.activemq.web;
|
||||
|
||||
import javax.jms.ConnectionFactory;
|
||||
import javax.servlet.ServletContext;
|
||||
import javax.servlet.ServletContextEvent;
|
||||
import javax.servlet.ServletContextListener;
|
||||
|
||||
import org.springframework.web.context.WebApplicationContext;
|
||||
import org.springframework.web.context.support.WebApplicationContextUtils;
|
||||
import org.springframework.web.context.support.XmlWebApplicationContext;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
/**
|
||||
* Starts the WebConsole.
|
||||
*
|
||||
* @version $Revision: 1.1 $
|
||||
*/
|
||||
public class WebConsoleStarter implements ServletContextListener {
|
||||
private static final transient Log log = LogFactory.getLog(WebConsoleStarter.class);
|
||||
|
||||
public void contextInitialized(ServletContextEvent event) {
|
||||
log.debug("Initializing ActiveMQ WebConsole...");
|
||||
|
||||
ServletContext servletContext = event.getServletContext();
|
||||
WebApplicationContext context = createWebapplicationContext(servletContext);
|
||||
|
||||
initializeWebClient(servletContext, context);
|
||||
|
||||
log.info("ActiveMQ WebConsole initialized.");
|
||||
}
|
||||
|
||||
private WebApplicationContext createWebapplicationContext(ServletContext servletContext) {
|
||||
String webconsoleType = System.getProperty("webconsole.type", "embedded");
|
||||
String configuration = "/WEB-INF/webconsole-" + webconsoleType + ".xml";
|
||||
|
||||
XmlWebApplicationContext context = new XmlWebApplicationContext();
|
||||
context.setServletContext(servletContext);
|
||||
context.setConfigLocations(new String[] { configuration });
|
||||
context.refresh();
|
||||
context.start();
|
||||
|
||||
servletContext.setAttribute(WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE, context);
|
||||
|
||||
return context;
|
||||
}
|
||||
|
||||
private void initializeWebClient(ServletContext servletContext, WebApplicationContext context) {
|
||||
ConnectionFactory connectionFactory = (ConnectionFactory) context
|
||||
.getBean("connectionFactory");
|
||||
servletContext.setAttribute(WebClient.connectionFactoryAttribute,
|
||||
connectionFactory);
|
||||
}
|
||||
|
||||
public void contextDestroyed(ServletContextEvent event) {
|
||||
XmlWebApplicationContext context = (XmlWebApplicationContext) WebApplicationContextUtils
|
||||
.getWebApplicationContext(event.getServletContext());
|
||||
if (context != null)
|
||||
{
|
||||
context.stop();
|
||||
context.destroy();
|
||||
}
|
||||
// do nothing, since the context is destoyed anyway
|
||||
}
|
||||
|
||||
}
|
|
@ -78,8 +78,6 @@ public class SendMessage extends DestinationFacade implements Controller {
|
|||
}
|
||||
|
||||
client.send(dest, message, JMSPersistent, JMSPriority, JMSTimeToLive);
|
||||
|
||||
System.out.println("Sent message: " + message);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -22,117 +22,141 @@
|
|||
http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"
|
||||
version="2.4">
|
||||
|
||||
<description>
|
||||
Apache ActiveMQ Web Console
|
||||
</description>
|
||||
<display-name>ActiveMQ Console</display-name>
|
||||
<description>
|
||||
Apache ActiveMQ Web Console
|
||||
</description>
|
||||
<display-name>ActiveMQ Console</display-name>
|
||||
|
||||
<!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
|
||||
<!-- Configuration of the SiteMesh Filter. -->
|
||||
<!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
|
||||
<filter>
|
||||
<filter-name>sitemesh</filter-name>
|
||||
<filter-class>com.opensymphony.module.sitemesh.filter.PageFilter</filter-class>
|
||||
</filter>
|
||||
<!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
|
||||
<!-- Configuration of the SiteMesh Filter. -->
|
||||
<!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
|
||||
<filter>
|
||||
<filter-name>sitemesh</filter-name>
|
||||
<filter-class>com.opensymphony.module.sitemesh.filter.PageFilter</filter-class>
|
||||
</filter>
|
||||
|
||||
<filter-mapping>
|
||||
<filter-name>sitemesh</filter-name>
|
||||
<url-pattern>/*</url-pattern>
|
||||
</filter-mapping>
|
||||
|
||||
<!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
|
||||
<!-- Expose Spring POJOs to JSP . -->
|
||||
<!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
|
||||
<filter>
|
||||
<filter-name>spring</filter-name>
|
||||
<filter-class>org.apache.activemq.web.filter.ApplicationContextFilter</filter-class>
|
||||
</filter>
|
||||
<filter-mapping>
|
||||
<filter-name>sitemesh</filter-name>
|
||||
<url-pattern>/*</url-pattern>
|
||||
</filter-mapping>
|
||||
|
||||
<filter-mapping>
|
||||
<filter-name>spring</filter-name>
|
||||
<url-pattern>/*</url-pattern>
|
||||
</filter-mapping>
|
||||
<!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
|
||||
<!-- Expose Spring POJOs to JSP . -->
|
||||
<!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
|
||||
<filter>
|
||||
<filter-name>spring</filter-name>
|
||||
<filter-class>org.apache.activemq.web.filter.ApplicationContextFilter</filter-class>
|
||||
</filter>
|
||||
|
||||
<!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
|
||||
<!-- ActiveMQ servlets -->
|
||||
<!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
|
||||
|
||||
<!-- the subscription REST servlet -->
|
||||
<servlet>
|
||||
<servlet-name>AjaxServlet</servlet-name>
|
||||
<servlet-class>org.apache.activemq.web.AjaxServlet</servlet-class>
|
||||
<load-on-startup>1</load-on-startup>
|
||||
</servlet>
|
||||
<servlet-mapping>
|
||||
<servlet-name>AjaxServlet</servlet-name>
|
||||
<url-pattern>/ajax/*</url-pattern>
|
||||
</servlet-mapping>
|
||||
<filter-mapping>
|
||||
<filter-name>spring</filter-name>
|
||||
<url-pattern>/*</url-pattern>
|
||||
</filter-mapping>
|
||||
|
||||
<servlet>
|
||||
<servlet-name>SendServlet</servlet-name>
|
||||
<servlet-class>org.apache.activemq.web.MessageServlet</servlet-class>
|
||||
<load-on-startup>1</load-on-startup>
|
||||
</servlet>
|
||||
<servlet-mapping>
|
||||
<servlet-name>SendServlet</servlet-name>
|
||||
<url-pattern>/send/*</url-pattern>
|
||||
</servlet-mapping>
|
||||
<!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
|
||||
<!-- ActiveMQ servlets -->
|
||||
<!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
|
||||
|
||||
<!-- the queue browse servlet -->
|
||||
<servlet>
|
||||
<servlet-name>QueueBrowseServlet</servlet-name>
|
||||
<servlet-class>org.apache.activemq.web.QueueBrowseServlet</servlet-class>
|
||||
</servlet>
|
||||
<servlet-mapping>
|
||||
<servlet-name>QueueBrowseServlet</servlet-name>
|
||||
<url-pattern>/queueBrowse/*</url-pattern>
|
||||
</servlet-mapping>
|
||||
<!-- the subscription REST servlet -->
|
||||
<servlet>
|
||||
<servlet-name>AjaxServlet</servlet-name>
|
||||
<servlet-class>org.apache.activemq.web.AjaxServlet</servlet-class>
|
||||
<load-on-startup>1</load-on-startup>
|
||||
</servlet>
|
||||
<servlet-mapping>
|
||||
<servlet-name>AjaxServlet</servlet-name>
|
||||
<url-pattern>/ajax/*</url-pattern>
|
||||
</servlet-mapping>
|
||||
|
||||
<!-- track the session usage for web JMS clients -->
|
||||
<filter>
|
||||
<filter-name>session</filter-name>
|
||||
<filter-class>org.apache.activemq.web.SessionFilter</filter-class>
|
||||
</filter>
|
||||
|
||||
<filter-mapping>
|
||||
<filter-name>session</filter-name>
|
||||
<url-pattern>/*</url-pattern>
|
||||
</filter-mapping>
|
||||
<servlet>
|
||||
<servlet-name>SendServlet</servlet-name>
|
||||
<servlet-class>org.apache.activemq.web.MessageServlet</servlet-class>
|
||||
<load-on-startup>1</load-on-startup>
|
||||
</servlet>
|
||||
<servlet-mapping>
|
||||
<servlet-name>SendServlet</servlet-name>
|
||||
<url-pattern>/send/*</url-pattern>
|
||||
</servlet-mapping>
|
||||
|
||||
|
||||
<!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
|
||||
<!-- Spring listener. -->
|
||||
<!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
|
||||
<listener>
|
||||
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
|
||||
</listener>
|
||||
<!-- the queue browse servlet -->
|
||||
<servlet>
|
||||
<servlet-name>QueueBrowseServlet</servlet-name>
|
||||
<servlet-class>org.apache.activemq.web.QueueBrowseServlet</servlet-class>
|
||||
</servlet>
|
||||
<servlet-mapping>
|
||||
<servlet-name>QueueBrowseServlet</servlet-name>
|
||||
<url-pattern>/queueBrowse/*</url-pattern>
|
||||
</servlet-mapping>
|
||||
|
||||
<!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
|
||||
<!-- Configuration of the Spring MVC dispatcher -->
|
||||
<!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
|
||||
<servlet>
|
||||
<servlet-name>dispatcher</servlet-name>
|
||||
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
|
||||
<load-on-startup>2</load-on-startup>
|
||||
</servlet>
|
||||
<!-- track the session usage for web JMS clients -->
|
||||
<filter>
|
||||
<filter-name>session</filter-name>
|
||||
<filter-class>org.apache.activemq.web.SessionFilter</filter-class>
|
||||
</filter>
|
||||
|
||||
<servlet-mapping>
|
||||
<servlet-name>dispatcher</servlet-name>
|
||||
<url-pattern>*.action</url-pattern>
|
||||
</servlet-mapping>
|
||||
<filter>
|
||||
<filter-name>spring-rq</filter-name>
|
||||
<filter-class>org.springframework.web.filter.RequestContextFilter</filter-class>
|
||||
</filter>
|
||||
|
||||
<welcome-file-list>
|
||||
<welcome-file>index.html</welcome-file>
|
||||
<welcome-file>index.jsp</welcome-file>
|
||||
</welcome-file-list>
|
||||
<filter-mapping>
|
||||
<filter-name>session</filter-name>
|
||||
<url-pattern>/*</url-pattern>
|
||||
</filter-mapping>
|
||||
<filter-mapping>
|
||||
<filter-name>spring-rq</filter-name>
|
||||
<url-pattern>/*</url-pattern>
|
||||
</filter-mapping>
|
||||
|
||||
<!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
|
||||
<!-- Factor out common headers in JSP pages -->
|
||||
<!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
|
||||
<jsp-config>
|
||||
<jsp-property-group>
|
||||
<url-pattern>*.jsp</url-pattern>
|
||||
<include-prelude>/WEB-INF/jspf/headertags.jspf</include-prelude>
|
||||
</jsp-property-group>
|
||||
</jsp-config>
|
||||
|
||||
<!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
|
||||
<!-- Spring listener. -->
|
||||
<!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
|
||||
<listener>
|
||||
<listener-class>org.apache.activemq.web.WebConsoleStarter</listener-class>
|
||||
</listener>
|
||||
|
||||
|
||||
<!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
|
||||
<!-- Configuration of the Spring MVC dispatcher -->
|
||||
<!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
|
||||
<servlet>
|
||||
<servlet-name>dispatcher</servlet-name>
|
||||
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
|
||||
<load-on-startup>2</load-on-startup>
|
||||
</servlet>
|
||||
|
||||
<servlet-mapping>
|
||||
<servlet-name>dispatcher</servlet-name>
|
||||
<url-pattern>*.action</url-pattern>
|
||||
</servlet-mapping>
|
||||
|
||||
<welcome-file-list>
|
||||
<welcome-file>index.html</welcome-file>
|
||||
<welcome-file>index.jsp</welcome-file>
|
||||
</welcome-file-list>
|
||||
|
||||
|
||||
<!-- JNDI Stuff
|
||||
<resource-ref>
|
||||
<res-ref-name>jms/connectionFactory</res-ref-name>
|
||||
<res-type>javax.jms.ConnectionFactory</res-type>
|
||||
<res-auth>Container</res-auth>
|
||||
</resource-ref>
|
||||
<resource-ref>
|
||||
<res-ref-name>jmx/url</res-ref-name>
|
||||
<res-type>java.lang.String</res-type>
|
||||
</resource-ref>
|
||||
-->
|
||||
|
||||
|
||||
<!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
|
||||
<!-- Factor out common headers in JSP pages -->
|
||||
<!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
|
||||
<jsp-config>
|
||||
<jsp-property-group>
|
||||
<url-pattern>*.jsp</url-pattern>
|
||||
<include-prelude>/WEB-INF/jspf/headertags.jspf</include-prelude>
|
||||
</jsp-property-group>
|
||||
</jsp-config>
|
||||
</web-app>
|
||||
|
|
|
@ -20,20 +20,23 @@
|
|||
|
||||
<bean id="placeholderConfig" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer" />
|
||||
|
||||
|
||||
<bean id="sessionPool" class="org.apache.activemq.web.SessionPool"/>
|
||||
|
||||
<!-- use the following bean for a local in-JVM broker -->
|
||||
|
||||
<bean id="brokerQuery" class="org.apache.activemq.web.LocalBrokerFacade" autowire='constructor' singleton="false"/>
|
||||
|
||||
<!-- use the following for a remote JMX based broker -->
|
||||
<!--<bean id="brokerQuery" class="org.apache.activemq.web.JMXBrokerFacade" autowire='constructor' singleton="false"/>-->
|
||||
|
||||
<bean id="brokerService" class="org.apache.activemq.xbean.BrokerFactoryBean">
|
||||
<property name="config" value="/WEB-INF/activemq.xml"/>
|
||||
</bean>
|
||||
|
||||
<!-- use the following for a remote JMX based broker -->
|
||||
<!--<bean id="brokerQuery" class="org.apache.activemq.web.JMXBrokerFacade" autowire='constructor' singleton="false"/>-->
|
||||
<bean id="sessionPool" class="org.apache.activemq.web.SessionPool">
|
||||
<property name="connectionFactory" ref="connectionFactory"/>
|
||||
</bean>
|
||||
|
||||
<bean id="connectionFactory" class="org.apache.activemq.ActiveMQConnectionFactory" depends-on="brokerService">
|
||||
<property name="brokerURL" value="vm://localhost"/>
|
||||
</bean>
|
||||
|
||||
<bean id="queueBrowser" class="org.apache.activemq.web.QueueBrowseQuery" autowire='constructor' singleton="false"/>
|
||||
<bean id="messageQuery" class="org.apache.activemq.web.MessageQuery" autowire='constructor' singleton="false"/>
|
|
@ -0,0 +1,43 @@
|
|||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<!--
|
||||
Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
contributor license agreements. See the NOTICE file distributed with
|
||||
this work for additional information regarding copyright ownership.
|
||||
The ASF licenses this file to You 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.
|
||||
-->
|
||||
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns:aop="http://www.springframework.org/schema/aop"
|
||||
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
|
||||
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.0.xsd">
|
||||
|
||||
<bean id="placeholderConfig" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer" />
|
||||
|
||||
|
||||
<bean id="sessionPool" class="org.apache.activemq.web.SessionPool">
|
||||
<property name="connectionFactory" ref="connectionFactory"/>
|
||||
</bean>
|
||||
|
||||
<bean id="brokerRegistry" class="org.apache.activemq.broker.BrokerRegistry" factory-method="getInstance"/>
|
||||
<bean id="brokerService" factory-bean="brokerRegistry" factory-method="findFirst"/>
|
||||
<bean id="brokerURL" factory-bean="brokerService" factory-method="getVmConnectorURI"/>
|
||||
|
||||
<bean id="connectionFactory" class="org.apache.activemq.ActiveMQConnectionFactory">
|
||||
<constructor-arg ref="brokerURL"/>
|
||||
</bean>
|
||||
|
||||
<bean id="brokerQuery" class="org.apache.activemq.web.LocalBrokerFacade" autowire="constructor" scope="prototype"/>
|
||||
|
||||
<bean id="queueBrowser" class="org.apache.activemq.web.QueueBrowseQuery" autowire="constructor" destroy-method="destroy" scope="request"/>
|
||||
<bean id="messageQuery" class="org.apache.activemq.web.MessageQuery" autowire="constructor" destroy-method="destroy" scope="request"/>
|
||||
|
||||
</beans>
|
|
@ -0,0 +1,46 @@
|
|||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<!--
|
||||
Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
contributor license agreements. See the NOTICE file distributed with
|
||||
this work for additional information regarding copyright ownership.
|
||||
The ASF licenses this file to You 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.
|
||||
-->
|
||||
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns:aop="http://www.springframework.org/schema/aop"
|
||||
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
|
||||
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.0.xsd">
|
||||
|
||||
<bean id="placeholderConfig" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer" />
|
||||
|
||||
|
||||
<bean id="sessionPool" class="org.apache.activemq.web.SessionPool">
|
||||
<property name="connectionFactory" ref="connectionFactory"/>
|
||||
</bean>
|
||||
|
||||
<bean id="brokerQuery" class="org.apache.activemq.web.RemoteJMXBrokerFacade" autowire="constructor" destroy-method="shutdown">
|
||||
<property name="jmxUrl" ref="jmxUrl"/>
|
||||
<property name="brokerName"><null/></property>
|
||||
</bean>
|
||||
|
||||
<bean id="jmxUrl" class="org.springframework.jndi.JndiObjectFactoryBean">
|
||||
<property name="jndiName" value="java:comp/env/jmx/url" />
|
||||
</bean>
|
||||
<bean id="connectionFactory" class="org.springframework.jndi.JndiObjectFactoryBean">
|
||||
<property name="jndiName" value="java:comp/env/jms/connectionFactory" />
|
||||
</bean>
|
||||
|
||||
|
||||
<bean id="queueBrowser" class="org.apache.activemq.web.QueueBrowseQuery" autowire="constructor" destroy-method="destroy" scope="request"/>
|
||||
<bean id="messageQuery" class="org.apache.activemq.web.MessageQuery" autowire="constructor" destroy-method="destroy" scope="request"/>
|
||||
|
||||
</beans>
|
|
@ -0,0 +1,43 @@
|
|||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<!--
|
||||
Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
contributor license agreements. See the NOTICE file distributed with
|
||||
this work for additional information regarding copyright ownership.
|
||||
The ASF licenses this file to You 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.
|
||||
-->
|
||||
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns:aop="http://www.springframework.org/schema/aop"
|
||||
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
|
||||
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.0.xsd">
|
||||
|
||||
<bean id="placeholderConfig" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer" />
|
||||
|
||||
|
||||
<bean id="sessionPool" class="org.apache.activemq.web.SessionPool">
|
||||
<property name="connectionFactory" ref="connectionFactory"/>
|
||||
</bean>
|
||||
|
||||
<bean id="brokerQuery" class="org.apache.activemq.web.RemoteJMXBrokerFacade" autowire="constructor" destroy-method="shutdown">
|
||||
<property name="jmxUrl" value="${webconsole.jmx.url}"/>
|
||||
<property name="brokerName"><null/></property>
|
||||
</bean>
|
||||
|
||||
<bean id="connectionFactory" class="org.apache.activemq.ActiveMQConnectionFactory">
|
||||
<property name="brokerURL" value="${webconsole.jms.url}"/>
|
||||
</bean>
|
||||
|
||||
|
||||
<bean id="queueBrowser" class="org.apache.activemq.web.QueueBrowseQuery" autowire="constructor" destroy-method="destroy" scope="request"/>
|
||||
<bean id="messageQuery" class="org.apache.activemq.web.MessageQuery" autowire="constructor" destroy-method="destroy" scope="request"/>
|
||||
|
||||
</beans>
|
|
@ -16,10 +16,11 @@
|
|||
*/
|
||||
package org.apache.activemq.web;
|
||||
|
||||
import org.apache.activemq.ActiveMQConnectionFactory;
|
||||
import org.apache.activemq.util.FactoryFinder;
|
||||
import org.apache.activemq.util.IntrospectionSupport;
|
||||
import org.apache.activemq.web.view.MessageRenderer;
|
||||
import java.io.IOException;
|
||||
import java.util.Enumeration;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedList;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.jms.Connection;
|
||||
import javax.jms.ConnectionFactory;
|
||||
|
@ -32,11 +33,9 @@ import javax.servlet.http.HttpServlet;
|
|||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Enumeration;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedList;
|
||||
import java.util.Map;
|
||||
import org.apache.activemq.util.FactoryFinder;
|
||||
import org.apache.activemq.util.IntrospectionSupport;
|
||||
import org.apache.activemq.web.view.MessageRenderer;
|
||||
|
||||
/**
|
||||
* Renders the contents of a queue using some kind of view. The URI is assumed
|
||||
|
@ -49,6 +48,8 @@ import java.util.Map;
|
|||
*
|
||||
* @version $Revision: $
|
||||
*/
|
||||
//TODO Why do we implement our own session pool?
|
||||
//TODO This doesn't work, since nobody will be setting the connection factory (because nobody is able to). Just use the WebClient?
|
||||
public class QueueBrowseServlet extends HttpServlet {
|
||||
|
||||
private static FactoryFinder factoryFinder = new FactoryFinder("META-INF/services/org/apache/activemq/web/view/");
|
||||
|
@ -71,8 +72,7 @@ public class QueueBrowseServlet extends HttpServlet {
|
|||
|
||||
public ConnectionFactory getConnectionFactory() {
|
||||
if (connectionFactory == null) {
|
||||
// TODO support remote brokers too
|
||||
connectionFactory = new ActiveMQConnectionFactory("vm://localhost");
|
||||
throw new IllegalStateException("missing ConnectionFactory in QueueBrowserServlet");
|
||||
}
|
||||
return connectionFactory;
|
||||
}
|
||||
|
|
|
@ -28,6 +28,7 @@ import java.util.Iterator;
|
|||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.jms.Connection;
|
||||
import javax.jms.ConnectionFactory;
|
||||
import javax.jms.DeliveryMode;
|
||||
import javax.jms.Destination;
|
||||
|
@ -44,9 +45,7 @@ import javax.servlet.http.HttpSessionBindingEvent;
|
|||
import javax.servlet.http.HttpSessionBindingListener;
|
||||
import javax.servlet.http.HttpSessionEvent;
|
||||
|
||||
import org.apache.activemq.ActiveMQConnection;
|
||||
import org.apache.activemq.ActiveMQConnectionFactory;
|
||||
import org.apache.activemq.ActiveMQSession;
|
||||
import org.apache.activemq.MessageAvailableConsumer;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
@ -75,8 +74,8 @@ public class WebClient implements HttpSessionActivationListener, HttpSessionBind
|
|||
private static transient ConnectionFactory factory;
|
||||
|
||||
private transient Map consumers = new HashMap();
|
||||
private transient ActiveMQConnection connection;
|
||||
private transient ActiveMQSession session;
|
||||
private transient Connection connection;
|
||||
private transient Session session;
|
||||
private transient MessageProducer producer;
|
||||
private int deliveryMode = DeliveryMode.NON_PERSISTENT;
|
||||
|
||||
|
@ -221,15 +220,15 @@ public class WebClient implements HttpSessionActivationListener, HttpSessionBind
|
|||
return session;
|
||||
}
|
||||
|
||||
public ActiveMQConnection getConnection() throws JMSException {
|
||||
public Connection getConnection() throws JMSException {
|
||||
if (connection == null) {
|
||||
connection = (ActiveMQConnection) factory.createConnection();
|
||||
connection = factory.createConnection();
|
||||
connection.start();
|
||||
}
|
||||
return connection;
|
||||
}
|
||||
|
||||
public static synchronized void initConnectionFactory(ServletContext servletContext) {
|
||||
protected static synchronized void initConnectionFactory(ServletContext servletContext) {
|
||||
if (factory == null)
|
||||
factory = (ConnectionFactory) servletContext.getAttribute(connectionFactoryAttribute);
|
||||
if (factory == null) {
|
||||
|
@ -239,7 +238,7 @@ public class WebClient implements HttpSessionActivationListener, HttpSessionBind
|
|||
log.debug("Value of: " + brokerUrlInitParam + " is: " + brokerURL);
|
||||
|
||||
if (brokerURL == null) {
|
||||
brokerURL = "vm://localhost";
|
||||
throw new IllegalStateException("missing brokerURL (specified via "+brokerUrlInitParam+" init-Param");
|
||||
}
|
||||
|
||||
ActiveMQConnectionFactory amqfactory = new ActiveMQConnectionFactory(brokerURL);
|
||||
|
@ -302,8 +301,8 @@ public class WebClient implements HttpSessionActivationListener, HttpSessionBind
|
|||
return new ArrayList(consumers.values());
|
||||
}
|
||||
|
||||
protected ActiveMQSession createSession() throws JMSException {
|
||||
return (ActiveMQSession) getConnection().createSession(false, Session.AUTO_ACKNOWLEDGE);
|
||||
protected Session createSession() throws JMSException {
|
||||
return getConnection().createSession(false, Session.AUTO_ACKNOWLEDGE);
|
||||
}
|
||||
|
||||
public Semaphore getSemaphore() {
|
||||
|
|
|
@ -208,6 +208,10 @@
|
|||
|
||||
<!-- copied dependencies from activemq-web-console -->
|
||||
<!-- enable commons-logging when inside jetty6:run -->
|
||||
<dependency>
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>slf4j-api</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>slf4j-jcl</artifactId>
|
||||
|
|
|
@ -105,7 +105,7 @@
|
|||
<outputDirectory>/webapps/admin</outputDirectory>
|
||||
<excludes>
|
||||
<exclude>**/activemq.xml</exclude>
|
||||
<exclude>**/applicationContext.xml</exclude>
|
||||
<exclude>**/webconsole-embedded.xml</exclude>
|
||||
</excludes>
|
||||
</fileSet>
|
||||
<fileSet>
|
||||
|
@ -122,7 +122,7 @@
|
|||
<outputDirectory>/webapps/demo</outputDirectory>
|
||||
<excludes>
|
||||
<exclude>**/activemq.xml</exclude>
|
||||
<exclude>**/applicationContext.xml</exclude>
|
||||
<exclude>**/webconsole-embedded.xml</exclude>
|
||||
</excludes>
|
||||
</fileSet>
|
||||
|
||||
|
@ -188,6 +188,7 @@
|
|||
<include>org.mortbay.jetty:jetty-util</include>
|
||||
<include>org.mortbay.jetty:jetty-xbean</include>
|
||||
<include>org.mortbay.jetty:servlet-api-2.5</include>
|
||||
<include>org.slf4j:slf4j-api</include>
|
||||
<include>org.slf4j:slf4j-jcl</include>
|
||||
|
||||
<!-- JSP support -->
|
||||
|
|
|
@ -109,7 +109,7 @@
|
|||
<outputDirectory>/webapps/admin</outputDirectory>
|
||||
<excludes>
|
||||
<exclude>**/activemq.xml</exclude>
|
||||
<exclude>**/applicationContext.xml</exclude>
|
||||
<exclude>**/webconsole-embedded.xml</exclude>
|
||||
</excludes>
|
||||
</fileSet>
|
||||
<fileSet>
|
||||
|
@ -127,7 +127,7 @@
|
|||
<outputDirectory>/webapps/demo</outputDirectory>
|
||||
<excludes>
|
||||
<exclude>**/activemq.xml</exclude>
|
||||
<exclude>**/applicationContext.xml</exclude>
|
||||
<exclude>**/webconsole-embedded.xml</exclude>
|
||||
</excludes>
|
||||
</fileSet>
|
||||
|
||||
|
@ -196,6 +196,7 @@
|
|||
<include>org.mortbay.jetty:jetty-util</include>
|
||||
<include>org.mortbay.jetty:jetty-xbean</include>
|
||||
<include>org.mortbay.jetty:servlet-api-2.5</include>
|
||||
<include>org.slf4j:slf4j-api</include>
|
||||
<include>org.slf4j:slf4j-jcl</include>
|
||||
|
||||
<!-- JSP support -->
|
||||
|
|
|
@ -20,12 +20,18 @@
|
|||
|
||||
<bean id="placeholderConfig" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer" />
|
||||
|
||||
|
||||
<bean id="sessionPool" class="org.apache.activemq.web.SessionPool"/>
|
||||
|
||||
<!-- use the following bean for a local in-JVM broker -->
|
||||
<bean id="brokerQuery" class="org.apache.activemq.web.SingletonBrokerFacade" autowire='constructor' singleton="false"/>
|
||||
|
||||
|
||||
<bean id="sessionPool" class="org.apache.activemq.web.SessionPool">
|
||||
<property name="connectionFactory" ref="connectionFactory"/>
|
||||
</bean>
|
||||
|
||||
<bean id="connectionFactory" class="org.apache.activemq.ActiveMQConnectionFactory">
|
||||
<property name="brokerURL" value="vm://localhost"/>
|
||||
</bean>
|
||||
|
||||
<bean id="queueBrowser" class="org.apache.activemq.web.QueueBrowseQuery" autowire='constructor' singleton="false"/>
|
||||
<bean id="messageQuery" class="org.apache.activemq.web.MessageQuery" autowire='constructor' singleton="false"/>
|
||||
|
9
pom.xml
9
pom.xml
|
@ -64,6 +64,8 @@
|
|||
<p2psockets-version>1.1.2</p2psockets-version>
|
||||
<regexp-version>1.3</regexp-version>
|
||||
<rome-version>0.8</rome-version>
|
||||
<slf4j-version>1.4.0</slf4j-version>
|
||||
<!--<slf4j-version>1.0-rc5</slf4j-version>-->
|
||||
<stax-version>1.1.1-dev</stax-version>
|
||||
<xalan-version>2.6.0</xalan-version>
|
||||
<xmlbeans-version>2.0.0-beta1</xmlbeans-version>
|
||||
|
@ -794,10 +796,15 @@
|
|||
<version>${jxta-version}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>slf4j-api</artifactId>
|
||||
<version>${slf4j-version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>slf4j-jcl</artifactId>
|
||||
<version>1.0-rc5</version>
|
||||
<version>${slf4j-version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>opensymphony</groupId>
|
||||
|
|
Loading…
Reference in New Issue