activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jstrac...@apache.org
Subject svn commit: r389021 - in /incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/view: DestinationDotFileInterceptor.java DotFileInterceptorSupport.java
Date Mon, 27 Mar 2006 04:53:54 GMT
Author: jstrachan
Date: Sun Mar 26 20:53:51 2006
New Revision: 389021

URL: http://svn.apache.org/viewcvs?rev=389021&view=rev
Log:
minor refactor to share code

Added:
    incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/view/DotFileInterceptorSupport.java
  (with props)
Modified:
    incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/view/DestinationDotFileInterceptor.java

Modified: incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/view/DestinationDotFileInterceptor.java
URL: http://svn.apache.org/viewcvs/incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/view/DestinationDotFileInterceptor.java?rev=389021&r1=389020&r2=389021&view=diff
==============================================================================
--- incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/view/DestinationDotFileInterceptor.java
(original)
+++ incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/view/DestinationDotFileInterceptor.java
Sun Mar 26 20:53:51 2006
@@ -36,43 +36,30 @@
  * 
  * @version $Revision: $
  */
-public class DestinationDotFileInterceptor extends BrokerFilter {
+public class DestinationDotFileInterceptor extends DotFileInterceptorSupport {
 
-    private static final Log log = LogFactory.getLog(DestinationDotFileInterceptor.class);
     protected static final String ID_SEPARATOR = "_";
     
-    private String file;
 
     public DestinationDotFileInterceptor(Broker next, String file) {
-        super(next);
+        super(next, file);
+        
     }
 
     public Destination addDestination(ConnectionContext context, ActiveMQDestination destination)
throws Exception {
         Destination answer = super.addDestination(context, destination);
-        generateDestinationGraph();
+        generateFile();
         return answer;
     }
 
     public void removeDestination(ConnectionContext context, ActiveMQDestination destination,
long timeout)
             throws Exception {
         super.removeDestination(context, destination, timeout);
-        generateDestinationGraph();
+        generateFile();
     }
 
-    protected void generateDestinationGraph() throws Exception {
-        if (log.isDebugEnabled()) {
-            log.debug("Creating destination DOT file at: " + file);
-        }
-        PrintWriter writer = new PrintWriter(new FileWriter(file));
-        try {
-            generateDestinationGraph(writer);
-        }
-        finally {
-            writer.close();
-        }
-    }
 
-    protected void generateDestinationGraph(PrintWriter writer) throws Exception {
+    protected void generateFile(PrintWriter writer) throws Exception {
         ActiveMQDestination[] destinations = getDestinations();
 
         // lets split into a tree

Added: incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/view/DotFileInterceptorSupport.java
URL: http://svn.apache.org/viewcvs/incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/view/DotFileInterceptorSupport.java?rev=389021&view=auto
==============================================================================
--- incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/view/DotFileInterceptorSupport.java
(added)
+++ incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/view/DotFileInterceptorSupport.java
Sun Mar 26 20:53:51 2006
@@ -0,0 +1,55 @@
+/*
+ * Copyright 2005-2006 The Apache Software Foundation.
+ *
+ * Licensed 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.broker.view;
+
+import org.apache.activemq.broker.Broker;
+import org.apache.activemq.broker.BrokerFilter;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import java.io.FileWriter;
+import java.io.PrintWriter;
+
+/**
+ * Useful base class
+ * 
+ * @version $Revision: $
+ */
+public abstract class DotFileInterceptorSupport extends BrokerFilter {
+    private final Log log = LogFactory.getLog(DotFileInterceptorSupport.class);
+
+    private String file;
+
+    public DotFileInterceptorSupport(Broker next, String file) {
+        super(next);
+        this.file = file;
+    }
+
+    protected void generateFile() throws Exception {
+        if (log.isDebugEnabled()) {
+            log.debug("Creating DOT file at: " + file);
+        }
+        PrintWriter writer = new PrintWriter(new FileWriter(file));
+        try {
+            generateFile(writer);
+        }
+        finally {
+            writer.close();
+        }
+    }
+
+    protected abstract void generateFile(PrintWriter writer) throws Exception;
+}

Propchange: incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/view/DotFileInterceptorSupport.java
------------------------------------------------------------------------------
    svn:eol-style = native



Mime
View raw message