Return-Path: X-Original-To: apmail-activemq-commits-archive@www.apache.org Delivered-To: apmail-activemq-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 2AD7AC0A4 for ; Thu, 19 Jul 2012 12:55:39 +0000 (UTC) Received: (qmail 65956 invoked by uid 500); 19 Jul 2012 12:55:38 -0000 Delivered-To: apmail-activemq-commits-archive@activemq.apache.org Received: (qmail 65865 invoked by uid 500); 19 Jul 2012 12:55:37 -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 65853 invoked by uid 99); 19 Jul 2012 12:55:37 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 19 Jul 2012 12:55:37 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.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; Thu, 19 Jul 2012 12:55:35 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id 4BD102388A6E for ; Thu, 19 Jul 2012 12:55:15 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1363319 - in /activemq/trunk: activemq-core/src/main/java/org/apache/activemq/broker/ activemq-web-console/src/main/java/org/apache/activemq/web/filter/ activemq-web-console/src/main/webapp/ activemq-web-console/src/main/webapp/WEB-INF/ ac... Date: Thu, 19 Jul 2012 12:55:14 -0000 To: commits@activemq.apache.org From: dejanb@apache.org X-Mailer: svnmailer-1.0.8-patched Message-Id: <20120719125515.4BD102388A6E@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: dejanb Date: Thu Jul 19 12:55:14 2012 New Revision: 1363319 URL: http://svn.apache.org/viewvc?rev=1363319&view=rev Log: https://issues.apache.org/jira/browse/AMQ-3696 - fix web console to show special page for slave brokers Added: activemq/trunk/activemq-web-console/src/main/webapp/slave.jsp - copied, changed from r1363003, activemq/trunk/activemq-web-console/src/main/webapp/404.html Modified: activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/BrokerService.java activemq/trunk/activemq-web-console/src/main/java/org/apache/activemq/web/filter/ApplicationContextFilter.java activemq/trunk/activemq-web-console/src/main/webapp/404.html activemq/trunk/activemq-web-console/src/main/webapp/500.html activemq/trunk/activemq-web-console/src/main/webapp/WEB-INF/decorators.xml 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 Modified: activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/BrokerService.java URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/BrokerService.java?rev=1363319&r1=1363318&r2=1363319&view=diff ============================================================================== --- activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/BrokerService.java (original) +++ activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/BrokerService.java Thu Jul 19 12:55:14 2012 @@ -520,7 +520,7 @@ public class BrokerService implements Se if (isUseJmx()) { startManagementContext(); } - + BrokerRegistry.getInstance().bind(getBrokerName(), BrokerService.this); startPersistenceAdapter(startAsync); startBroker(startAsync); } catch (Exception e) { @@ -608,7 +608,6 @@ public class BrokerService implements Se managedBroker.setContextBroker(broker); adminView.setBroker(managedBroker); } - BrokerRegistry.getInstance().bind(getBrokerName(), BrokerService.this); // see if there is a MasterBroker service and if so, configure // it and start it. for (Service service : services) { Modified: activemq/trunk/activemq-web-console/src/main/java/org/apache/activemq/web/filter/ApplicationContextFilter.java URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-web-console/src/main/java/org/apache/activemq/web/filter/ApplicationContextFilter.java?rev=1363319&r1=1363318&r2=1363319&view=diff ============================================================================== --- activemq/trunk/activemq-web-console/src/main/java/org/apache/activemq/web/filter/ApplicationContextFilter.java (original) +++ activemq/trunk/activemq-web-console/src/main/java/org/apache/activemq/web/filter/ApplicationContextFilter.java Thu Jul 19 12:55:14 2012 @@ -29,7 +29,10 @@ import javax.servlet.ServletContext; import javax.servlet.ServletException; import javax.servlet.ServletRequest; import javax.servlet.ServletResponse; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import org.apache.activemq.web.BrokerFacade; import org.springframework.web.bind.ServletRequestDataBinder; import org.springframework.web.context.WebApplicationContext; import org.springframework.web.context.support.WebApplicationContextUtils; @@ -60,6 +63,7 @@ public class ApplicationContextFilter im private String applicationContextName = "applicationContext"; private String requestContextName = "requestContext"; private String requestName = "request"; + private final String slavePage = "slave.jsp"; public void init(FilterConfig config) throws ServletException { this.servletContext = config.getServletContext(); @@ -76,6 +80,17 @@ public class ApplicationContextFilter im public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException { // lets register a requestContext in the requestScope Map requestContextWrapper = createRequestContextWrapper(request); + String path = ((HttpServletRequest)request).getRequestURI(); + // handle slave brokers + try { + if (((BrokerFacade)requestContextWrapper.get("brokerQuery")).isSlave() + && (!(path.endsWith("css") || path.endsWith("png")) && !path.endsWith(slavePage))) { + ((HttpServletResponse)response).sendRedirect(slavePage); + return; + } + } catch (Exception e) { + throw new IOException(e); + } request.setAttribute(requestContextName, requestContextWrapper); request.setAttribute(requestName, request); chain.doFilter(request, response); Modified: activemq/trunk/activemq-web-console/src/main/webapp/404.html URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-web-console/src/main/webapp/404.html?rev=1363319&r1=1363318&r2=1363319&view=diff ============================================================================== --- activemq/trunk/activemq-web-console/src/main/webapp/404.html (original) +++ activemq/trunk/activemq-web-console/src/main/webapp/404.html Thu Jul 19 12:55:14 2012 @@ -27,8 +27,8 @@ Apache ActiveMQ Modified: activemq/trunk/activemq-web-console/src/main/webapp/500.html URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-web-console/src/main/webapp/500.html?rev=1363319&r1=1363318&r2=1363319&view=diff ============================================================================== --- activemq/trunk/activemq-web-console/src/main/webapp/500.html (original) +++ activemq/trunk/activemq-web-console/src/main/webapp/500.html Thu Jul 19 12:55:14 2012 @@ -27,8 +27,8 @@ Apache ActiveMQ Modified: activemq/trunk/activemq-web-console/src/main/webapp/WEB-INF/decorators.xml URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-web-console/src/main/webapp/WEB-INF/decorators.xml?rev=1363319&r1=1363318&r2=1363319&view=diff ============================================================================== --- activemq/trunk/activemq-web-console/src/main/webapp/WEB-INF/decorators.xml (original) +++ activemq/trunk/activemq-web-console/src/main/webapp/WEB-INF/decorators.xml Thu Jul 19 12:55:14 2012 @@ -19,6 +19,7 @@ /xml/* + /slave.jsp Copied: activemq/trunk/activemq-web-console/src/main/webapp/slave.jsp (from r1363003, activemq/trunk/activemq-web-console/src/main/webapp/404.html) URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-web-console/src/main/webapp/slave.jsp?p2=activemq/trunk/activemq-web-console/src/main/webapp/slave.jsp&p1=activemq/trunk/activemq-web-console/src/main/webapp/404.html&r1=1363003&r2=1363319&rev=1363319&view=diff ============================================================================== --- activemq/trunk/activemq-web-console/src/main/webapp/404.html (original) +++ activemq/trunk/activemq-web-console/src/main/webapp/slave.jsp Thu Jul 19 12:55:14 2012 @@ -27,8 +27,8 @@ Apache ActiveMQ @@ -77,13 +77,7 @@
-

Page Not Found!

- -

What do you want to do next?

- +

Broker is currently in slave mode!

@@ -133,4 +127,4 @@ - + \ No newline at end of file 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=1363319&r1=1363318&r2=1363319&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 Thu Jul 19 12:55:14 2012 @@ -209,4 +209,6 @@ public interface BrokerFacade { boolean isJobSchedulerStarted(); + boolean isSlave() 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=1363319&r1=1363318&r2=1363319&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 Thu Jul 19 12:55:14 2012 @@ -226,4 +226,8 @@ public abstract class BrokerFacadeSuppor return false; } } + + public boolean isSlave() throws Exception { + return getBrokerAdmin().isSlave(); + } }