Return-Path: Delivered-To: apmail-activemq-commits-archive@www.apache.org Received: (qmail 22920 invoked from network); 9 Mar 2009 12:03:47 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 9 Mar 2009 12:03:47 -0000 Received: (qmail 15236 invoked by uid 500); 9 Mar 2009 12:03:47 -0000 Delivered-To: apmail-activemq-commits-archive@activemq.apache.org Received: (qmail 15209 invoked by uid 500); 9 Mar 2009 12:03:47 -0000 Mailing-List: contact commits-help@activemq.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@activemq.apache.org Delivered-To: mailing list commits@activemq.apache.org Received: (qmail 15200 invoked by uid 99); 9 Mar 2009 12:03:47 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 09 Mar 2009 05:03:47 -0700 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 09 Mar 2009 12:03:39 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id A6E8323888F1; Mon, 9 Mar 2009 12:03:18 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r751656 - in /activemq/trunk: activemq-web-console/src/main/resources/ activemq-web-console/src/main/webapp/ activemq-web-console/src/main/webapp/WEB-INF/ activemq-web-console/src/main/webapp/WEB-INF/tags/jms/ activemq-web-console/src/main/... Date: Mon, 09 Mar 2009 12:03:16 -0000 To: commits@activemq.apache.org From: dejanb@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20090309120318.A6E8323888F1@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: dejanb Date: Mon Mar 9 12:03:14 2009 New Revision: 751656 URL: http://svn.apache.org/viewvc?rev=751656&view=rev Log: fix for https://issues.apache.org/activemq/browse/AMQ-1324 Added: activemq/trunk/activemq-web-console/src/main/webapp/WEB-INF/tags/jms/forEachConnection.tag activemq/trunk/activemq-web-console/src/main/webapp/connection.jsp activemq/trunk/activemq-web-console/src/main/webapp/connections.jsp activemq/trunk/activemq-web-console/src/main/webapp/queueConsumers.jsp activemq/trunk/activemq-web/src/main/java/org/apache/activemq/web/ConnectionQuery.java activemq/trunk/activemq-web/src/main/java/org/apache/activemq/web/QueueConsumerQuery.java activemq/trunk/activemq-web/src/main/java/org/apache/activemq/web/config/ activemq/trunk/activemq-web/src/main/java/org/apache/activemq/web/config/AbstractConfiguration.java activemq/trunk/activemq-web/src/main/java/org/apache/activemq/web/config/JNDIConfiguration.java activemq/trunk/activemq-web/src/main/java/org/apache/activemq/web/config/SystemPropertiesConfiguration.java activemq/trunk/activemq-web/src/main/java/org/apache/activemq/web/config/WebConsoleConfiguration.java Modified: activemq/trunk/activemq-web-console/src/main/resources/log4j.properties activemq/trunk/activemq-web-console/src/main/webapp/WEB-INF/webconsole-embedded.xml activemq/trunk/activemq-web-console/src/main/webapp/WEB-INF/webconsole-invm.xml activemq/trunk/activemq-web-console/src/main/webapp/WEB-INF/webconsole-jndi.xml activemq/trunk/activemq-web-console/src/main/webapp/WEB-INF/webconsole-properties.xml activemq/trunk/activemq-web-console/src/main/webapp/browse.jsp activemq/trunk/activemq-web-console/src/main/webapp/decorators/main.jsp activemq/trunk/activemq-web-console/src/main/webapp/index.jsp activemq/trunk/activemq-web-console/src/main/webapp/queues.jsp activemq/trunk/activemq-web/src/main/java/org/apache/activemq/web/BrokerFacade.java activemq/trunk/activemq-web/src/main/java/org/apache/activemq/web/BrokerFacadeSupport.java activemq/trunk/activemq-web/src/main/java/org/apache/activemq/web/LocalBrokerFacade.java activemq/trunk/activemq-web/src/main/java/org/apache/activemq/web/RemoteJMXBrokerFacade.java activemq/trunk/activemq-web/src/main/java/org/apache/activemq/web/WebClient.java activemq/trunk/assembly/src/release/webapps/admin/WEB-INF/webconsole-embedded.xml Modified: activemq/trunk/activemq-web-console/src/main/resources/log4j.properties URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-web-console/src/main/resources/log4j.properties?rev=751656&r1=751655&r2=751656&view=diff ============================================================================== --- activemq/trunk/activemq-web-console/src/main/resources/log4j.properties (original) +++ activemq/trunk/activemq-web-console/src/main/resources/log4j.properties Mon Mar 9 12:03:14 2009 @@ -18,8 +18,9 @@ # # The logging properties used during tests.. # -log4j.rootLogger=DEBUG, stdout +log4j.rootLogger=INFO, stdout +log4j.logger.org.apache.activemq=INFO log4j.logger.org.apache.activemq.spring=WARN log4j.logger.org.springframework=warn Added: activemq/trunk/activemq-web-console/src/main/webapp/WEB-INF/tags/jms/forEachConnection.tag URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-web-console/src/main/webapp/WEB-INF/tags/jms/forEachConnection.tag?rev=751656&view=auto ============================================================================== --- activemq/trunk/activemq-web-console/src/main/webapp/WEB-INF/tags/jms/forEachConnection.tag (added) +++ activemq/trunk/activemq-web-console/src/main/webapp/WEB-INF/tags/jms/forEachConnection.tag Mon Mar 9 12:03:14 2009 @@ -0,0 +1,35 @@ +<%-- + 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. +--%> +<%@ attribute name="connection" type="java.lang.String" required="true" %> +<%@ attribute name="connectionName" type="java.lang.String" required="true" %> +<%@ attribute name="broker" type="org.apache.activemq.web.BrokerFacade" required="true" %> +<%@ attribute name="connectorName" type="java.lang.String" required="true" %> +<%@ tag import="java.util.Iterator" %> +<%@ tag import="org.apache.activemq.broker.jmx.ConnectionViewMBean" %> +<% + Iterator it = broker.getConnections(connectorName).iterator(); + while (it.hasNext()) { + String conName = (String) it.next(); + ConnectionViewMBean con = broker.getConnection(conName); + request.setAttribute(connectionName, conName); + request.setAttribute(connection, con); +%> + +<% + } +%> + Modified: activemq/trunk/activemq-web-console/src/main/webapp/WEB-INF/webconsole-embedded.xml URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-web-console/src/main/webapp/WEB-INF/webconsole-embedded.xml?rev=751656&r1=751655&r2=751656&view=diff ============================================================================== --- activemq/trunk/activemq-web-console/src/main/webapp/WEB-INF/webconsole-embedded.xml (original) +++ activemq/trunk/activemq-web-console/src/main/webapp/WEB-INF/webconsole-embedded.xml Mon Mar 9 12:03:14 2009 @@ -40,5 +40,7 @@ + + Modified: activemq/trunk/activemq-web-console/src/main/webapp/WEB-INF/webconsole-invm.xml URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-web-console/src/main/webapp/WEB-INF/webconsole-invm.xml?rev=751656&r1=751655&r2=751656&view=diff ============================================================================== --- activemq/trunk/activemq-web-console/src/main/webapp/WEB-INF/webconsole-invm.xml (original) +++ activemq/trunk/activemq-web-console/src/main/webapp/WEB-INF/webconsole-invm.xml Mon Mar 9 12:03:14 2009 @@ -39,5 +39,7 @@ + + Modified: activemq/trunk/activemq-web-console/src/main/webapp/WEB-INF/webconsole-jndi.xml URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-web-console/src/main/webapp/WEB-INF/webconsole-jndi.xml?rev=751656&r1=751655&r2=751656&view=diff ============================================================================== --- activemq/trunk/activemq-web-console/src/main/webapp/WEB-INF/webconsole-jndi.xml (original) +++ activemq/trunk/activemq-web-console/src/main/webapp/WEB-INF/webconsole-jndi.xml Mon Mar 9 12:03:14 2009 @@ -27,20 +27,17 @@ + + - + - - - - - - - + - + + Modified: activemq/trunk/activemq-web-console/src/main/webapp/WEB-INF/webconsole-properties.xml URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-web-console/src/main/webapp/WEB-INF/webconsole-properties.xml?rev=751656&r1=751655&r2=751656&view=diff ============================================================================== --- activemq/trunk/activemq-web-console/src/main/webapp/WEB-INF/webconsole-properties.xml (original) +++ activemq/trunk/activemq-web-console/src/main/webapp/WEB-INF/webconsole-properties.xml Mon Mar 9 12:03:14 2009 @@ -26,20 +26,19 @@ + + - - - + - - - - + + + Modified: activemq/trunk/activemq-web-console/src/main/webapp/browse.jsp URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-web-console/src/main/webapp/browse.jsp?rev=751656&r1=751655&r2=751656&view=diff ============================================================================== --- activemq/trunk/activemq-web-console/src/main/webapp/browse.jsp (original) +++ activemq/trunk/activemq-web-console/src/main/webapp/browse.jsp Mon Mar 9 12:03:14 2009 @@ -37,9 +37,6 @@ -<%-- - ----%> -<%-- - ---%> - + Added: activemq/trunk/activemq-web-console/src/main/webapp/connection.jsp URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-web-console/src/main/webapp/connection.jsp?rev=751656&view=auto ============================================================================== --- activemq/trunk/activemq-web-console/src/main/webapp/connection.jsp (added) +++ activemq/trunk/activemq-web-console/src/main/webapp/connection.jsp Mon Mar 9 12:03:14 2009 @@ -0,0 +1,150 @@ +<%-- + 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. +--%> + + + +Connection ${requestContext.connectionQuery.connectionID} + + + + + + + +
+No connection could be found for ID ${requestContext.connectionQuery.connectionID} +
+ +
+ + + +

Connection ${requestContext.connectionQuery.connectionID}

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

Consumers

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
DestinationSessionIdSelectorEnqueuesDequeuesDispatchedDispatched Queue + Prefetch +
+ Max pending +
+ Exclusive +
+ Retroactive +
+ + + Queue ${consumer.destinationName} + + + Topic ${consumer.destinationName} + + + ${consumer.destinationName} + + + ${consumer.sessionId}${consumer.selector}${consumer.enqueueCounter}${consumer.dequeueCounter}${consumer.dispachedCounter}${consumer.dispatchedQueueSize} + ${consumer.prefetchSize}
+ ${consumer.maximumPendingMessageLimit} +
+ ${consumer.exclusive}
+ ${consumer.retroactive} +
+ + +
+
+ + + + + + + + \ No newline at end of file Added: activemq/trunk/activemq-web-console/src/main/webapp/connections.jsp URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-web-console/src/main/webapp/connections.jsp?rev=751656&view=auto ============================================================================== --- activemq/trunk/activemq-web-console/src/main/webapp/connections.jsp (added) +++ activemq/trunk/activemq-web-console/src/main/webapp/connections.jsp Mon Mar 9 12:03:14 2009 @@ -0,0 +1,91 @@ +<%-- + 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. +--%> + + +Connections + + + +

Connections

+ + +

Connector ${connectorName}

+ + + + + + + + + + + + + + + + + + + + + + + + + + +
NameRemote AddressEnqueue CountDequeue CountDispatch Queue SizeActiveSlow
${conName}${con.remoteAddress}${con.enqueueCount}${con.dequeueCount}${con.dispatchQueueSize}${con.active}${con.slow}
+ +
+ +
+

Network Connectors

+ + + + + + + + + + + + + + + + + + + + + + + + + + +
NameNetwork TTLDynamic OnlyConduit SubscriptionsBridge TempsDecrease PrioritiesDispatch Async
${nc.name}${nc.networkTTL}${nc.dynamicOnly}${nc.conduitSubscriptions}${nc.bridgeTempDestinations}${nc.decreaseNetworkConsumerPriority}${nc.dispatchAsync}
+
+ + + + Modified: activemq/trunk/activemq-web-console/src/main/webapp/decorators/main.jsp URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-web-console/src/main/webapp/decorators/main.jsp?rev=751656&r1=751655&r2=751656&view=diff ============================================================================== --- activemq/trunk/activemq-web-console/src/main/webapp/decorators/main.jsp (original) +++ activemq/trunk/activemq-web-console/src/main/webapp/decorators/main.jsp Mon Mar 9 12:03:14 2009 @@ -72,6 +72,8 @@ | Subscribers | + Connections + | Send Modified: activemq/trunk/activemq-web-console/src/main/webapp/index.jsp URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-web-console/src/main/webapp/index.jsp?rev=751656&r1=751655&r2=751656&view=diff ============================================================================== --- activemq/trunk/activemq-web-console/src/main/webapp/index.jsp (original) +++ activemq/trunk/activemq-web-console/src/main/webapp/index.jsp Mon Mar 9 12:03:14 2009 @@ -23,7 +23,7 @@

Welcome!

-Welcome to the ActiveMQ Console +Welcome to the ActiveMQ Console of ${requestContext.brokerQuery.brokerName} (${requestContext.brokerQuery.brokerAdmin.brokerId})

Added: activemq/trunk/activemq-web-console/src/main/webapp/queueConsumers.jsp URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-web-console/src/main/webapp/queueConsumers.jsp?rev=751656&view=auto ============================================================================== --- activemq/trunk/activemq-web-console/src/main/webapp/queueConsumers.jsp (added) +++ activemq/trunk/activemq-web-console/src/main/webapp/queueConsumers.jsp Mon Mar 9 12:03:14 2009 @@ -0,0 +1,79 @@ +<%-- + 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. +--%> + + +Consumers for ${requestContext.queueConsumerQuery.JMSDestination} + + + +

Active Consumers for ${requestContext.queueConsumerQuery.JMSDestination}

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ Client ID +
+ Connection ID +
SessionIdSelectorEnqueuesDequeuesDispatchedDispatched Queue + Prefetch +
+ Max pending +
+ Exclusive +
+ Retroactive +
+ ${row.clientId}
+ ${row.connectionId} +
${row.sessionId}${row.selector}${row.enqueueCounter}${row.dequeueCounter}${row.dispachedCounter}${row.dispatchedQueueSize} + ${row.prefetchSize}
+ ${row.maximumPendingMessageLimit} +
+ ${row.exclusive}
+ ${row.retroactive} +
+ + + + \ No newline at end of file Modified: activemq/trunk/activemq-web-console/src/main/webapp/queues.jsp URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-web-console/src/main/webapp/queues.jsp?rev=751656&r1=751655&r2=751656&view=diff ============================================================================== --- activemq/trunk/activemq-web-console/src/main/webapp/queues.jsp (original) +++ activemq/trunk/activemq-web-console/src/main/webapp/queues.jsp Mon Mar 9 12:03:14 2009 @@ -56,9 +56,7 @@ ${row.dequeueCount} Browse -<%-- - Graph ---%> + Active Consumers
Modified: activemq/trunk/activemq-web/src/main/java/org/apache/activemq/web/BrokerFacade.java URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-web/src/main/java/org/apache/activemq/web/BrokerFacade.java?rev=751656&r1=751655&r2=751656&view=diff ============================================================================== --- activemq/trunk/activemq-web/src/main/java/org/apache/activemq/web/BrokerFacade.java (original) +++ activemq/trunk/activemq-web/src/main/java/org/apache/activemq/web/BrokerFacade.java Mon Mar 9 12:03:14 2009 @@ -19,33 +19,163 @@ import java.util.Collection; import org.apache.activemq.broker.jmx.BrokerViewMBean; +import org.apache.activemq.broker.jmx.ConnectionViewMBean; +import org.apache.activemq.broker.jmx.ConnectorViewMBean; +import org.apache.activemq.broker.jmx.DurableSubscriptionViewMBean; +import org.apache.activemq.broker.jmx.NetworkConnectorViewMBean; import org.apache.activemq.broker.jmx.QueueViewMBean; +import org.apache.activemq.broker.jmx.SubscriptionViewMBean; import org.apache.activemq.broker.jmx.TopicViewMBean; import org.apache.activemq.command.ActiveMQDestination; /** * A facade for either a local in JVM broker or a remote broker over JMX * + * * @version $Revision$ */ public interface BrokerFacade { - BrokerViewMBean getBrokerAdmin() throws Exception; - - Collection getQueues() throws Exception; - - Collection getTopics() throws Exception; - - Collection getDurableTopicSubscribers() throws Exception; - - /** - * Purges the given destination - * @param destination - * @throws Exception - */ - void purgeQueue(ActiveMQDestination destination) throws Exception; - - QueueViewMBean getQueue(String name) throws Exception; - - TopicViewMBean getTopic(String name) throws Exception; -} + /** + * The name of the active broker (f.e. 'localhost' or 'my broker'). + * + * @return not null + * @throws Exception + */ + String getBrokerName() throws Exception; + + /** + * Admin view of the broker. + * + * @return not null + * @throws Exception + */ + BrokerViewMBean getBrokerAdmin() throws Exception; + + /** + * All queues known to the broker. + * + * @return not null + * @throws Exception + */ + Collection getQueues() throws Exception; + + /** + * All topics known to the broker. + * + * @return not null + * @throws Exception + */ + Collection getTopics() throws Exception; + + /** + * All active consumers of a queue. + * + * @param queueName + * the name of the queue, not null + * @return not null + * @throws Exception + */ + Collection getQueueConsumers(String queueName) + throws Exception; + + /** + * All durable subscribers to topics of the broker. + * + * @return not null + * @throws Exception + */ + Collection getDurableTopicSubscribers() + throws Exception; + + /** + * The names of all transport connectors of the broker (f.e. openwire, ssl) + * + * @return not null + * @throws Exception + */ + Collection getConnectors() throws Exception; + + /** + * A transport connectors. + * + * @param name + * name of the connector (f.e. openwire) + * @return null if not found + * @throws Exception + */ + ConnectorViewMBean getConnector(String name) throws Exception; + + /** + * All connections to all transport connectors of the broker. + * + * @return not null + * @throws Exception + */ + Collection getConnections() throws Exception; + + /** + * The names of all connections to a specific transport connectors of the + * broker. + * + * @see #getConnection(String) + * @param connectorName + * not null + * @return not null + * @throws Exception + */ + Collection getConnections(String connectorName) throws Exception; + + /** + * A specific connection to the broker. + * + * @param connectionName + * the name of the connection, not null + * @return not null + * @throws Exception + */ + ConnectionViewMBean getConnection(String connectionName) throws Exception; + /** + * Returns all consumers of a connection. + * + * @param connectionName + * the name of the connection, not null + * @return not null + * @throws Exception + */ + Collection getConsumersOnConnection( + String connectionName) throws Exception; + /** + * The brokers network connectors. + * + * @return not null + * @throws Exception + */ + Collection getNetworkConnectors() + throws Exception; + /** + * Purges the given destination + * + * @param destination + * @throws Exception + */ + void purgeQueue(ActiveMQDestination destination) throws Exception; + /** + * Get the view of the queue with the specified name. + * + * @param name + * not null + * @return null if no queue with this name exists + * @throws Exception + */ + QueueViewMBean getQueue(String name) throws Exception; + /** + * Get the view of the topic with the specified name. + * + * @param name + * not null + * @return null if no topic with this name exists + * @throws Exception + */ + TopicViewMBean getTopic(String name) throws Exception; +} \ No newline at end of file Modified: activemq/trunk/activemq-web/src/main/java/org/apache/activemq/web/BrokerFacadeSupport.java URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-web/src/main/java/org/apache/activemq/web/BrokerFacadeSupport.java?rev=751656&r1=751655&r2=751656&view=diff ============================================================================== --- activemq/trunk/activemq-web/src/main/java/org/apache/activemq/web/BrokerFacadeSupport.java (original) +++ activemq/trunk/activemq-web/src/main/java/org/apache/activemq/web/BrokerFacadeSupport.java Mon Mar 9 12:03:14 2009 @@ -21,17 +21,24 @@ import java.util.Collections; import java.util.Iterator; import java.util.List; +import java.util.Set; import javax.management.MBeanServer; +import javax.management.MBeanServerConnection; import javax.management.MBeanServerInvocationHandler; import javax.management.ObjectName; import org.apache.activemq.broker.jmx.BrokerViewMBean; +import org.apache.activemq.broker.jmx.ConnectionViewMBean; +import org.apache.activemq.broker.jmx.ConnectorViewMBean; import org.apache.activemq.broker.jmx.DestinationViewMBean; import org.apache.activemq.broker.jmx.DurableSubscriptionViewMBean; import org.apache.activemq.broker.jmx.ManagementContext; +import org.apache.activemq.broker.jmx.NetworkConnectorViewMBean; import org.apache.activemq.broker.jmx.QueueViewMBean; +import org.apache.activemq.broker.jmx.SubscriptionViewMBean; import org.apache.activemq.broker.jmx.TopicViewMBean; +import org.springframework.util.StringUtils; /** * A useful base class for an implementation of {@link BrokerFacade} @@ -41,7 +48,7 @@ public abstract class BrokerFacadeSupport implements BrokerFacade { public abstract ManagementContext getManagementContext(); - public Collection getQueues() throws Exception { + public Collection getQueues() throws Exception { BrokerViewMBean broker = getBrokerAdmin(); if (broker == null) { return Collections.EMPTY_LIST; @@ -50,7 +57,7 @@ return getManagedObjects(queues, QueueViewMBean.class); } - public Collection getTopics() throws Exception { + public Collection getTopics() throws Exception { BrokerViewMBean broker = getBrokerAdmin(); if (broker == null) { return Collections.EMPTY_LIST; @@ -59,7 +66,7 @@ return getManagedObjects(queues, TopicViewMBean.class); } - public Collection getDurableTopicSubscribers() throws Exception { + public Collection getDurableTopicSubscribers() throws Exception { BrokerViewMBean broker = getBrokerAdmin(); if (broker == null) { return Collections.EMPTY_LIST; @@ -76,29 +83,162 @@ return (TopicViewMBean) getDestinationByName(getTopics(), name); } - protected DestinationViewMBean getDestinationByName(Collection collection, String name) { - Iterator iter = collection.iterator(); - while (iter.hasNext()) { - DestinationViewMBean destinationViewMBean = (DestinationViewMBean) iter.next(); - if (name.equals(destinationViewMBean.getName())) { - return destinationViewMBean; - } - } - return null; - } + protected DestinationViewMBean getDestinationByName( + Collection collection, String name) { + Iterator iter = collection.iterator(); + while (iter.hasNext()) { + DestinationViewMBean destinationViewMBean = iter.next(); + if (name.equals(destinationViewMBean.getName())) { + return destinationViewMBean; + } + } + return null; + } + + @SuppressWarnings("unchecked") + protected Collection getManagedObjects(ObjectName[] names, + Class type) { + List answer = new ArrayList(); + MBeanServer mbeanServer = getManagementContext().getMBeanServer(); + if (mbeanServer != null) { + for (int i = 0; i < names.length; i++) { + ObjectName name = names[i]; + T value = (T) MBeanServerInvocationHandler.newProxyInstance( + mbeanServer, name, type, true); + if (value != null) { + answer.add(value); + } + } + } + return answer; + } + + + /** + * Get the MBeanServer connection. + * + * @return not null + * @throws Exception + */ + protected MBeanServerConnection getMBeanServerConnection() throws Exception { + return getManagementContext().getMBeanServer(); + } + + @SuppressWarnings("unchecked") + public Collection getConnections() throws Exception { + MBeanServerConnection connection = getMBeanServerConnection(); + String brokerName = getBrokerName(); + ObjectName query = new ObjectName("org.apache.activemq:BrokerName=" + + brokerName + ",Type=Connection,*"); + System.out.println(query); + Set queryResult = connection.queryNames(query, null); + return getManagedObjects(queryResult.toArray(new ObjectName[queryResult + .size()]), ConnectionViewMBean.class); + } + + @SuppressWarnings("unchecked") + public Collection getConnections(String connectorName) + throws Exception { + MBeanServerConnection connection = getMBeanServerConnection(); + String brokerName = getBrokerName(); + ObjectName query = new ObjectName("org.apache.activemq:BrokerName=" + + brokerName + ",Type=Connection,ConnectorName=" + + connectorName + ",*"); + Set queryResult = connection.queryNames(query, null); + + Collection result = new ArrayList(queryResult.size()); + for (ObjectName on : queryResult) { + String name = StringUtils.replace(on.getKeyProperty("Connection"), + "_", ":"); + result.add(name); + } + return result; + } + + @SuppressWarnings("unchecked") + public ConnectionViewMBean getConnection(String connectionName) + throws Exception { + connectionName = StringUtils.replace(connectionName, ":", "_"); + + MBeanServerConnection connection = getMBeanServerConnection(); + String brokerName = getBrokerName(); + ObjectName query = new ObjectName("org.apache.activemq:BrokerName=" + + brokerName + ",Type=Connection,*,Connection=" + + connectionName); + Set queryResult = connection.queryNames(query, null); + if (queryResult.size() == 0) + return null; + ObjectName objectName = queryResult.iterator().next(); + return (ConnectionViewMBean) MBeanServerInvocationHandler + .newProxyInstance(connection, objectName, + ConnectionViewMBean.class, true); + } + + @SuppressWarnings("unchecked") + public Collection getConnectors() throws Exception { + MBeanServerConnection connection = getMBeanServerConnection(); + String brokerName = getBrokerName(); + ObjectName query = new ObjectName("org.apache.activemq:BrokerName=" + + brokerName + ",Type=Connector,*"); + Set queryResult = connection.queryNames(query, null); + + Collection result = new ArrayList(queryResult.size()); + for (ObjectName on : queryResult) + result.add(on.getKeyProperty("ConnectorName")); + return result; + } + + public ConnectorViewMBean getConnector(String name) throws Exception { + MBeanServerConnection connection = getMBeanServerConnection(); + String brokerName = getBrokerName(); + ObjectName objectName = new ObjectName( + "org.apache.activemq:BrokerName=" + brokerName + + ",Type=Connector,ConnectorName=" + name); + return (ConnectorViewMBean) MBeanServerInvocationHandler + .newProxyInstance(connection, objectName, + ConnectorViewMBean.class, true); + } + + @SuppressWarnings("unchecked") + public Collection getNetworkConnectors() + throws Exception { + MBeanServerConnection connection = getMBeanServerConnection(); + String brokerName = getBrokerName(); + ObjectName query = new ObjectName("org.apache.activemq:BrokerName=" + + brokerName + ",Type=NetworkConnector,*"); + Set queryResult = connection.queryNames(query, null); + return getManagedObjects(queryResult.toArray(new ObjectName[queryResult + .size()]), NetworkConnectorViewMBean.class); + } + + @SuppressWarnings("unchecked") + public Collection getQueueConsumers(String queueName) + throws Exception { + MBeanServerConnection connection = getMBeanServerConnection(); + String brokerName = getBrokerName(); + ObjectName query = new ObjectName("org.apache.activemq:BrokerName=" + + brokerName + + ",Type=Subscription,destinationType=Queue,destinationName=" + + queueName + ",*"); + Set queryResult = connection.queryNames(query, null); + return getManagedObjects(queryResult.toArray(new ObjectName[queryResult + .size()]), SubscriptionViewMBean.class); + } + + @SuppressWarnings("unchecked") + public Collection getConsumersOnConnection( + String connectionName) throws Exception { + connectionName = StringUtils.replace(connectionName, ":", "_"); + + MBeanServerConnection connection = getMBeanServerConnection(); + String brokerName = getBrokerName(); + ObjectName query = new ObjectName("org.apache.activemq:BrokerName=" + + brokerName + ",Type=Subscription,clientId=" + connectionName + + ",*"); + Set queryResult = connection.queryNames(query, null); + return getManagedObjects(queryResult.toArray(new ObjectName[queryResult + .size()]), SubscriptionViewMBean.class); + } + - protected Collection getManagedObjects(ObjectName[] names, Class type) { - List answer = new ArrayList(); - MBeanServer mbeanServer = getManagementContext().getMBeanServer(); - if (mbeanServer != null) { - for (int i = 0; i < names.length; i++) { - ObjectName name = names[i]; - Object value = MBeanServerInvocationHandler.newProxyInstance(mbeanServer, name, type, true); - if (value != null) { - answer.add(value); - } - } - } - return answer; - } } Added: activemq/trunk/activemq-web/src/main/java/org/apache/activemq/web/ConnectionQuery.java URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-web/src/main/java/org/apache/activemq/web/ConnectionQuery.java?rev=751656&view=auto ============================================================================== --- activemq/trunk/activemq-web/src/main/java/org/apache/activemq/web/ConnectionQuery.java (added) +++ activemq/trunk/activemq-web/src/main/java/org/apache/activemq/web/ConnectionQuery.java Mon Mar 9 12:03:14 2009 @@ -0,0 +1,49 @@ +package org.apache.activemq.web; + +import java.util.Collection; +import java.util.Collections; + +import org.apache.activemq.broker.jmx.ConnectionViewMBean; +import org.apache.activemq.broker.jmx.SubscriptionViewMBean; + +/** + * Query for a single connection. + * + * @author ms + */ +public class ConnectionQuery { + + private final BrokerFacade mBrokerFacade; + private String mConnectionID; + + public ConnectionQuery(BrokerFacade brokerFacade) { + mBrokerFacade = brokerFacade; + } + + public void destroy() { + // empty + } + + public void setConnectionID(String connectionID) { + mConnectionID = connectionID; + } + + public String getConnectionID() { + return mConnectionID; + } + + public ConnectionViewMBean getConnection() throws Exception { + String connectionID = getConnectionID(); + if (connectionID == null) + return null; + return mBrokerFacade.getConnection(connectionID); + } + + public Collection getConsumers() throws Exception { + String connectionID = getConnectionID(); + if (connectionID == null) + return Collections.emptyList(); + return mBrokerFacade.getConsumersOnConnection(connectionID); + } + +} \ No newline at end of file Modified: activemq/trunk/activemq-web/src/main/java/org/apache/activemq/web/LocalBrokerFacade.java URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-web/src/main/java/org/apache/activemq/web/LocalBrokerFacade.java?rev=751656&r1=751655&r2=751656&view=diff ============================================================================== --- activemq/trunk/activemq-web/src/main/java/org/apache/activemq/web/LocalBrokerFacade.java (original) +++ activemq/trunk/activemq-web/src/main/java/org/apache/activemq/web/LocalBrokerFacade.java Mon Mar 9 12:03:14 2009 @@ -34,36 +34,34 @@ * @version $Revision$ */ public class LocalBrokerFacade extends BrokerFacadeSupport { - private BrokerService brokerService; + private BrokerService brokerService; - public LocalBrokerFacade(BrokerService brokerService) { - this.brokerService = brokerService; - } - - public BrokerService getBrokerService() { - return brokerService; - } - - public Broker getBroker() throws Exception { - return brokerService.getBroker(); - } - - public ManagementContext getManagementContext() { - return brokerService.getManagementContext(); - } - - public BrokerViewMBean getBrokerAdmin() throws Exception { - // TODO could use JMX to look this up - return brokerService.getAdminView(); - } - - public ManagedRegionBroker getManagedBroker() throws Exception { - BrokerView adminView = brokerService.getAdminView(); - if (adminView == null) { - return null; - } - return adminView.getBroker(); - } + public LocalBrokerFacade(BrokerService brokerService) { + this.brokerService = brokerService; + } + + public BrokerService getBrokerService() { + return brokerService; + } + public String getBrokerName() throws Exception { + return brokerService.getBrokerName(); + } + public Broker getBroker() throws Exception { + return brokerService.getBroker(); + } + public ManagementContext getManagementContext() { + return brokerService.getManagementContext(); + } + public BrokerViewMBean getBrokerAdmin() throws Exception { + return brokerService.getAdminView(); + } + public ManagedRegionBroker getManagedBroker() throws Exception { + BrokerView adminView = brokerService.getAdminView(); + if (adminView == null) { + return null; + } + return adminView.getBroker(); + } public void purgeQueue(ActiveMQDestination destination) throws Exception { Set destinations = getManagedBroker().getQueueRegion().getDestinations(destination); @@ -72,4 +70,5 @@ regionQueue.purge(); } } + } Added: activemq/trunk/activemq-web/src/main/java/org/apache/activemq/web/QueueConsumerQuery.java URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-web/src/main/java/org/apache/activemq/web/QueueConsumerQuery.java?rev=751656&view=auto ============================================================================== --- activemq/trunk/activemq-web/src/main/java/org/apache/activemq/web/QueueConsumerQuery.java (added) +++ activemq/trunk/activemq-web/src/main/java/org/apache/activemq/web/QueueConsumerQuery.java Mon Mar 9 12:03:14 2009 @@ -0,0 +1,45 @@ +/* + * 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 java.util.Collection; + +import javax.jms.JMSException; + +import org.apache.activemq.broker.jmx.SubscriptionViewMBean; + +/** + * Query for Queue consumers. + * + * @version $Revision: 504235 $ + */ +public class QueueConsumerQuery extends DestinationFacade { + + public QueueConsumerQuery(BrokerFacade brokerFacade) throws JMSException { + super(brokerFacade); + setJMSDestinationType("queue"); + } + + public Collection getConsumers() throws Exception { + return getBrokerFacade().getQueueConsumers(getJMSDestination()); + } + + public void destroy() { + // empty + } + +} \ No newline at end of file Modified: activemq/trunk/activemq-web/src/main/java/org/apache/activemq/web/RemoteJMXBrokerFacade.java URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-web/src/main/java/org/apache/activemq/web/RemoteJMXBrokerFacade.java?rev=751656&r1=751655&r2=751656&view=diff ============================================================================== --- activemq/trunk/activemq-web/src/main/java/org/apache/activemq/web/RemoteJMXBrokerFacade.java (original) +++ activemq/trunk/activemq-web/src/main/java/org/apache/activemq/web/RemoteJMXBrokerFacade.java Mon Mar 9 12:03:14 2009 @@ -21,6 +21,7 @@ import java.util.Collection; import java.util.HashMap; import java.util.List; +import java.util.Map; import java.util.Set; import javax.management.MBeanServerConnection; @@ -35,6 +36,7 @@ import org.apache.activemq.broker.jmx.ManagementContext; import org.apache.activemq.broker.jmx.QueueViewMBean; import org.apache.activemq.command.ActiveMQDestination; +import org.apache.activemq.web.config.WebConsoleConfiguration; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; @@ -48,34 +50,30 @@ private static final transient Log LOG = LogFactory.getLog(RemoteJMXBrokerFacade.class); - private String jmxUrl; - private String jmxRole; - private String jmxPassword; private String brokerName; private JMXConnector connector; + private WebConsoleConfiguration configuration; public void setBrokerName(String brokerName) { this.brokerName = brokerName; } - public void setJmxUrl(String url) { - this.jmxUrl = url; - } - - public void setJmxRole(String role) { - this.jmxRole = role; - } - - public void setJmxPassword(String password) { - this.jmxPassword = password; - } - /** * Shutdown this facade aka close any open connection. */ public void shutdown() { closeConnection(); } + + private ObjectName getBrokerObjectName(MBeanServerConnection connection) + throws IOException, MalformedObjectNameException { + Set brokers = findBrokers(connection); + if (brokers.size() == 0) { + throw new IOException("No broker could be found in the JMX."); + } + ObjectName name = brokers.iterator().next(); + return name; + } public BrokerViewMBean getBrokerAdmin() throws Exception { MBeanServerConnection connection = getConnection(); @@ -89,6 +87,14 @@ return mbean; } + public String getBrokerName() throws Exception, + MalformedObjectNameException { + MBeanServerConnection connection = getMBeanServerConnection(); + ObjectName brokerObjectName = getBrokerObjectName(connection); + String brokerName = brokerObjectName.getKeyProperty("BrokerName"); + return brokerName; + } + protected MBeanServerConnection getConnection() throws IOException { JMXConnector connector = this.connector; if (isConnectionActive(connector)) { @@ -119,44 +125,43 @@ } protected JMXConnector createConnection() { - String[] urls = this.jmxUrl.split(","); - HashMap env = new HashMap(); - env.put("jmx.remote.credentials", new String[] { - this.jmxRole, this.jmxPassword - }); - - if (urls == null || urls.length == 0) { - urls = new String[] { - this.jmxUrl - }; - } + + Map env = new HashMap(); + if (this.configuration.getJmxUser() != null) { + env.put("jmx.remote.credentials", new String[] { + this.configuration.getJmxUser(), + this.configuration.getJmxPassword() }); + } + Collection jmxUrls = this.configuration.getJmxUrls(); Exception exception = null; - for (int i = 0; i < urls.length; i++) { - try { - JMXConnector connector = JMXConnectorFactory.connect(new JMXServiceURL(urls[i]), env); - 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); - } + for (JMXServiceURL url : jmxUrls) { + try { + JMXConnector connector = JMXConnectorFactory.connect(url, env); + connector.connect(); + MBeanServerConnection connection = connector + .getMBeanServerConnection(); + + Set brokers = findBrokers(connection); + if (brokers.size() > 0) { + LOG.info("Connected via JMX to the broker at " + url); + 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 " + + jmxUrls.size() + " configured urls"); + } protected synchronized void closeConnection() { if (connector != null) { @@ -171,55 +176,61 @@ } } - /** - * 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 null - * @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; + /** + * 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 null + * @return Set with ObjectName-elements + * @throws IOException + * @throws MalformedObjectNameException + */ + @SuppressWarnings("unchecked") + 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"); + } + + + @SuppressWarnings("unchecked") + protected Collection getManagedObjects(ObjectName[] names, + Class type) { + MBeanServerConnection connection; + try { + connection = getMBeanServerConnection(); + } catch (Exception e) { + throw new RuntimeException(e); + } + + List answer = new ArrayList(); + if (connection != null) { + for (int i = 0; i < names.length; i++) { + ObjectName name = names[i]; + T value = (T) MBeanServerInvocationHandler.newProxyInstance( + connection, name, type, true); + if (value != null) { + answer.add(value); + } + } + } + return answer; } } Modified: activemq/trunk/activemq-web/src/main/java/org/apache/activemq/web/WebClient.java URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-web/src/main/java/org/apache/activemq/web/WebClient.java?rev=751656&r1=751655&r2=751656&view=diff ============================================================================== --- activemq/trunk/activemq-web/src/main/java/org/apache/activemq/web/WebClient.java (original) +++ activemq/trunk/activemq-web/src/main/java/org/apache/activemq/web/WebClient.java Mon Mar 9 12:03:14 2009 @@ -56,8 +56,6 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import sun.util.logging.resources.logging; - /** * Represents a messaging client used from inside a web container typically * stored inside a HttpSession TODO controls to prevent DOS attacks with users Added: activemq/trunk/activemq-web/src/main/java/org/apache/activemq/web/config/AbstractConfiguration.java URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-web/src/main/java/org/apache/activemq/web/config/AbstractConfiguration.java?rev=751656&view=auto ============================================================================== --- activemq/trunk/activemq-web/src/main/java/org/apache/activemq/web/config/AbstractConfiguration.java (added) +++ activemq/trunk/activemq-web/src/main/java/org/apache/activemq/web/config/AbstractConfiguration.java Mon Mar 9 12:03:14 2009 @@ -0,0 +1,95 @@ +/* + * 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.config; + +import java.net.MalformedURLException; +import java.util.ArrayList; +import java.util.Collection; + +import javax.jms.ConnectionFactory; +import javax.management.remote.JMXServiceURL; + +import org.apache.activemq.ActiveMQConnectionFactory; + +/** + * Base class for configurations. + * + * @version $Revision: $ + */ +public abstract class AbstractConfiguration implements WebConsoleConfiguration { + + public ConnectionFactory getConnectionFactory() { + return null; + } + + public String getJmxPassword() { + return null; + } + + public Collection getJmxUrls() { + return null; + } + + public String getJmxUser() { + return null; + } + + /** + * Creates the ActiveMQ-ConnectionFactory. + * + * @param jmsUrl + * not null + * @param jmsUser + * null if no authentication + * @param jmsPassword + * null is ok + * @return not null + */ + protected ConnectionFactory makeConnectionFactory(String jmsUrl, String jmsUser, + String jmsPassword) { + if (jmsUser != null && jmsUser.length() > 0) + return new ActiveMQConnectionFactory(jmsUser, jmsPassword, jmsUrl); + else + return new ActiveMQConnectionFactory(jmsUrl); + } + + /** + * Splits the JMX-Url string into a series of JMSServiceURLs. + * + * @param jmxUrls + * the JMX-url, multiple URLs are separated by commas. + * @return not null, contains at least one element. + */ + protected Collection makeJmxUrls(String jmxUrls) { + String[] urls = jmxUrls.split(","); + if (urls == null || urls.length == 0) { + urls = new String[] { jmxUrls }; + } + + try { + Collection result = new ArrayList( + jmxUrls.length()); + for (String url : urls) { + result.add(new JMXServiceURL(url)); + } + return result; + } catch (MalformedURLException e) { + throw new IllegalArgumentException("Invalid JMX-url", e); + } + } + +} \ No newline at end of file Added: activemq/trunk/activemq-web/src/main/java/org/apache/activemq/web/config/JNDIConfiguration.java URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-web/src/main/java/org/apache/activemq/web/config/JNDIConfiguration.java?rev=751656&view=auto ============================================================================== --- activemq/trunk/activemq-web/src/main/java/org/apache/activemq/web/config/JNDIConfiguration.java (added) +++ activemq/trunk/activemq-web/src/main/java/org/apache/activemq/web/config/JNDIConfiguration.java Mon Mar 9 12:03:14 2009 @@ -0,0 +1,104 @@ +/* + * 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.config; + +import java.util.Collection; + +import javax.jms.ConnectionFactory; +import javax.management.remote.JMXServiceURL; +import javax.naming.InitialContext; +import javax.naming.NameNotFoundException; +import javax.naming.NamingException; + +/** + * Configuration based on JNDI values. + * + * @version $Revision: $ + */ +public class JNDIConfiguration extends AbstractConfiguration { + + private static final String JNDI_JMS_CONNECTION_FACTORY = "java:comp/env/jms/connectionFactory"; + private static final String JNDI_JMS_URL = "java:comp/env/jms/url"; + private static final String JNDI_JMS_USER = "java:comp/env/jms/user"; + private static final String JNDI_JMS_PASSWORD = "java:comp/env/jms/password"; + + private static final String JNDI_JMX_URL = "java:comp/env/jmx/url"; + private static final String JNDI_JMX_USER = "java:comp/env/jmx/user"; + private static final String JNDI_JMX_PASSWORD = "java:comp/env/jmx/password"; + + private InitialContext context; + + public JNDIConfiguration() throws NamingException { + this.context = new InitialContext(); + } + + public JNDIConfiguration(InitialContext context) { + this.context = context; + } + + public ConnectionFactory getConnectionFactory() { + try { + ConnectionFactory connectionFactory = (ConnectionFactory) this.context + .lookup(JNDI_JMS_CONNECTION_FACTORY); + return connectionFactory; + } catch (NameNotFoundException e) { + // try to find an url + } catch (NamingException e) { + throw new RuntimeException(e); + } + + try { + String jmsUrl = (String) this.context.lookup(JNDI_JMS_URL); + if (jmsUrl == null) { + throw new IllegalArgumentException( + "A JMS-url must be specified (system property " + + JNDI_JMS_URL); + } + + String jmsUser = getJndiString(JNDI_JMS_USER); + String jmsPassword = getJndiString(JNDI_JMS_PASSWORD); + return makeConnectionFactory(jmsUrl, jmsUser, jmsPassword); + } catch (NameNotFoundException e) { + throw new IllegalArgumentException( + "Neither a ConnectionFactory nor a JMS-url were specified"); + } catch (NamingException e) { + throw new RuntimeException(e); + } + } + + protected String getJndiString(String name) { + try { + return (String) this.context.lookup(name); + } catch (NamingException e) { + return null; + } + } + + public Collection getJmxUrls() { + String jmxUrls = getJndiString(JNDI_JMX_URL); + return makeJmxUrls(jmxUrls); + } + + public String getJmxPassword() { + return getJndiString(JNDI_JMX_USER); + } + + public String getJmxUser() { + return getJndiString(JNDI_JMX_PASSWORD); + } + +} \ No newline at end of file Added: activemq/trunk/activemq-web/src/main/java/org/apache/activemq/web/config/SystemPropertiesConfiguration.java URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-web/src/main/java/org/apache/activemq/web/config/SystemPropertiesConfiguration.java?rev=751656&view=auto ============================================================================== --- activemq/trunk/activemq-web/src/main/java/org/apache/activemq/web/config/SystemPropertiesConfiguration.java (added) +++ activemq/trunk/activemq-web/src/main/java/org/apache/activemq/web/config/SystemPropertiesConfiguration.java Mon Mar 9 12:03:14 2009 @@ -0,0 +1,65 @@ +/* + * 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.config; + +import java.util.Collection; + +import javax.jms.ConnectionFactory; +import javax.management.remote.JMXServiceURL; + + +/** + * Configuration based on system-properties. + * + * @version $Revision: $ + */ +public class SystemPropertiesConfiguration extends AbstractConfiguration { + + private static final String PROPERTY_JMS_URL = "webconsole.jms.url"; + private static final String PROPERTY_JMS_USER = "webconsole.jms.user"; + private static final String PROPERTY_JMS_PASSWORD = "webconsole.jms.password"; + + private static final String PROPERTY_JMX_URL = "webconsole.jmx.url"; + private static final String PROPERTY_JMX_USER = "webconsole.jmx.user"; + private static final String PROPERTY_JMX_PASSWORD = "webconsole.jmx.password"; + + public ConnectionFactory getConnectionFactory() { + String jmsUrl = System.getProperty(PROPERTY_JMS_URL); + if (jmsUrl == null) + throw new IllegalArgumentException( + "A JMS-url must be specified (system property " + + PROPERTY_JMS_URL); + + String jmsUser = System.getProperty(PROPERTY_JMS_USER); + String jmsPassword = System.getProperty(PROPERTY_JMS_PASSWORD); + return makeConnectionFactory(jmsUrl, jmsUser, jmsPassword); + } + + public Collection getJmxUrls() { + String jmxUrls = System.getProperty(PROPERTY_JMX_URL); + return makeJmxUrls(jmxUrls); + } + + public String getJmxPassword() { + return System.getProperty(PROPERTY_JMX_USER); + } + + public String getJmxUser() { + return System.getProperty(PROPERTY_JMX_PASSWORD); + } + +} \ No newline at end of file Added: activemq/trunk/activemq-web/src/main/java/org/apache/activemq/web/config/WebConsoleConfiguration.java URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-web/src/main/java/org/apache/activemq/web/config/WebConsoleConfiguration.java?rev=751656&view=auto ============================================================================== --- activemq/trunk/activemq-web/src/main/java/org/apache/activemq/web/config/WebConsoleConfiguration.java (added) +++ activemq/trunk/activemq-web/src/main/java/org/apache/activemq/web/config/WebConsoleConfiguration.java Mon Mar 9 12:03:14 2009 @@ -0,0 +1,62 @@ +/* + * 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.config; + +import java.util.Collection; + +import javax.jms.ConnectionFactory; +import javax.management.remote.JMXServiceURL; + +/** + * The configuration used for the web console. + * + * @version $Revision: $ + */ +public interface WebConsoleConfiguration { + + /** + * The connection factory to use for sending/receiving messages. + * + * @return not null + */ + ConnectionFactory getConnectionFactory(); + + /** + * The URL to the JMX connectors of the broker. The names of any failover + * (master-slave configuration) must also be specified. + * + * @return not null, must contain at least one entry + */ + Collection getJmxUrls(); + + /** + * The user that is used in case of authenticated JMX connections. The user + * must be the same for all the brokers. + * + * @return null if no authentication should be used. + */ + String getJmxUser(); + + /** + * Password for the JMX-user. + * + * @see #getJmxUser() + * @return null if no authentication + */ + String getJmxPassword(); + +} Modified: activemq/trunk/assembly/src/release/webapps/admin/WEB-INF/webconsole-embedded.xml URL: http://svn.apache.org/viewvc/activemq/trunk/assembly/src/release/webapps/admin/WEB-INF/webconsole-embedded.xml?rev=751656&r1=751655&r2=751656&view=diff ============================================================================== --- activemq/trunk/assembly/src/release/webapps/admin/WEB-INF/webconsole-embedded.xml (original) +++ activemq/trunk/assembly/src/release/webapps/admin/WEB-INF/webconsole-embedded.xml Mon Mar 9 12:03:14 2009 @@ -40,5 +40,7 @@ + +