activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From chir...@apache.org
Subject svn commit: r379619 [19/30] - in /incubator/activemq/trunk: ./ activecluster/ activecluster/src/java/org/apache/activecluster/ activecluster/src/java/org/apache/activecluster/election/ activecluster/src/java/org/apache/activecluster/election/impl/ acti...
Date Tue, 21 Feb 2006 23:14:17 GMT
Modified: incubator/activemq/trunk/activemq-console/src/main/java/org/apache/activemq/console/filter/MBeansAttributeQueryFilter.java
URL: http://svn.apache.org/viewcvs/incubator/activemq/trunk/activemq-console/src/main/java/org/apache/activemq/console/filter/MBeansAttributeQueryFilter.java?rev=379619&r1=379618&r2=379619&view=diff
==============================================================================
--- incubator/activemq/trunk/activemq-console/src/main/java/org/apache/activemq/console/filter/MBeansAttributeQueryFilter.java (original)
+++ incubator/activemq/trunk/activemq-console/src/main/java/org/apache/activemq/console/filter/MBeansAttributeQueryFilter.java Tue Feb 21 15:12:56 2006
@@ -1,148 +1,148 @@
-/**
- *
- * 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.console.filter;
-
-import javax.management.remote.JMXServiceURL;
-import javax.management.remote.JMXConnectorFactory;
-import javax.management.remote.JMXConnector;
-import javax.management.ObjectInstance;
-import javax.management.ObjectName;
-import javax.management.MBeanServerConnection;
-import javax.management.ReflectionException;
-import javax.management.InstanceNotFoundException;
-import javax.management.AttributeList;
-import javax.management.Attribute;
-import javax.management.MBeanAttributeInfo;
-import javax.management.IntrospectionException;
-import java.util.Set;
-import java.util.Collection;
-import java.util.Iterator;
-import java.util.ArrayList;
-import java.util.List;
-import java.io.IOException;
-
-public class MBeansAttributeQueryFilter extends AbstractQueryFilter {
-    public static final String KEY_OBJECT_NAME_ATTRIBUTE = "Attribute:ObjectName:";
-
-    private JMXServiceURL jmxServiceUrl;
-    private Set           attribView;
-
-    /**
-     * Create an mbean attributes query filter that is able to select specific mbean attributes based on the object name to get.
-     * @param jmxServiceUrl - JMX service url to connect to.
-     * @param attribView - the attributes to extract
-     * @param next - the next query filter
-     */
-    public MBeansAttributeQueryFilter(JMXServiceURL jmxServiceUrl, Set attribView, MBeansObjectNameQueryFilter next) {
-        super(next);
-        this.jmxServiceUrl = jmxServiceUrl;
-        this.attribView    = attribView;
-    }
-
-    /**
-     * Filter the query by retrieving the attributes specified, this will modify the collection to a list of AttributeList
-     * @param queries - query list
-     * @return List of AttributeList, which includes the ObjectName, which has a key of MBeansAttributeQueryFilter.KEY_OBJECT_NAME_ATTRIBUTE
-     * @throws Exception
-     */
-    public List query(List queries) throws Exception {
-        return getMBeanAttributesCollection(next.query(queries));
-    }
-
-    /**
-     * Retrieve the specified attributes of the mbean
-     * @param result - collection of ObjectInstances and/or ObjectNames
-     * @return List of AttributeList
-     * @throws IOException
-     * @throws ReflectionException
-     * @throws InstanceNotFoundException
-     * @throws NoSuchMethodException
-     */
-    protected List getMBeanAttributesCollection(Collection result) throws IOException, ReflectionException, InstanceNotFoundException, NoSuchMethodException, IntrospectionException {
-        List mbeansCollection = new ArrayList();
-
-        for (Iterator i=result.iterator(); i.hasNext();) {
-            Object mbean = i.next();
-            if (mbean instanceof ObjectInstance) {
-                mbeansCollection.add(getMBeanAttributes(((ObjectInstance)mbean).getObjectName(), attribView));
-            } else if (mbean instanceof ObjectName) {
-                mbeansCollection.add(getMBeanAttributes((ObjectName)mbean, attribView));
-            } else {
-                throw new NoSuchMethodException("Cannot get the mbean attributes for class: " + mbean.getClass().getName());
-            }
-        }
-
-        return mbeansCollection;
-    }
-
-    /**
-     * Retrieve the specified attributes of the mbean
-     * @param obj - mbean ObjectInstance
-     * @param attrView - list of attributes to retrieve
-     * @return AttributeList for the mbean
-     * @throws ReflectionException
-     * @throws InstanceNotFoundException
-     * @throws IOException
-     */
-    protected AttributeList getMBeanAttributes(ObjectInstance obj, Set attrView) throws ReflectionException, InstanceNotFoundException, IOException, IntrospectionException {
-        return getMBeanAttributes(obj.getObjectName(), attrView);
-    }
-
-    /**
-     * Retrieve the specified attributes of the mbean
-     * @param objName - mbean ObjectName
-     * @param attrView - list of attributes to retrieve
-     * @return AttributeList for the mbean
-     * @throws IOException
-     * @throws ReflectionException
-     * @throws InstanceNotFoundException
-     */
-    protected AttributeList getMBeanAttributes(ObjectName objName, Set attrView) throws IOException, ReflectionException, InstanceNotFoundException, IntrospectionException {
-        JMXConnector jmxConnector    = JMXConnectorFactory.connect(jmxServiceUrl);
-        MBeanServerConnection server = jmxConnector.getMBeanServerConnection();
-
-        // If no attribute view specified, get all attributes
-        String[] attribs;
-        if (attrView == null || attrView.isEmpty()) {
-            MBeanAttributeInfo[] infos = server.getMBeanInfo(objName).getAttributes();
-            attribs = new String[infos.length];
-
-            for (int i=0; i<infos.length; i++) {
-                if (infos[i].isReadable()) {
-                    attribs[i] = infos[i].getName();
-                }
-            }
-
-        // Get selected attributes
-        } else {
-
-            attribs = new String[attrView.size()];
-            int count = 0;
-            for (Iterator i=attrView.iterator(); i.hasNext();) {
-                attribs[count++] = (String)i.next();
-            }
-        }
-
-        AttributeList attribList = server.getAttributes(objName, attribs);
-
-        jmxConnector.close();
-
-        attribList.add(0, new Attribute(KEY_OBJECT_NAME_ATTRIBUTE, objName));
-
-        return attribList;
-    }
-}
+/**
+ *
+ * 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.console.filter;
+
+import javax.management.remote.JMXServiceURL;
+import javax.management.remote.JMXConnectorFactory;
+import javax.management.remote.JMXConnector;
+import javax.management.ObjectInstance;
+import javax.management.ObjectName;
+import javax.management.MBeanServerConnection;
+import javax.management.ReflectionException;
+import javax.management.InstanceNotFoundException;
+import javax.management.AttributeList;
+import javax.management.Attribute;
+import javax.management.MBeanAttributeInfo;
+import javax.management.IntrospectionException;
+import java.util.Set;
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.ArrayList;
+import java.util.List;
+import java.io.IOException;
+
+public class MBeansAttributeQueryFilter extends AbstractQueryFilter {
+    public static final String KEY_OBJECT_NAME_ATTRIBUTE = "Attribute:ObjectName:";
+
+    private JMXServiceURL jmxServiceUrl;
+    private Set           attribView;
+
+    /**
+     * Create an mbean attributes query filter that is able to select specific mbean attributes based on the object name to get.
+     * @param jmxServiceUrl - JMX service url to connect to.
+     * @param attribView - the attributes to extract
+     * @param next - the next query filter
+     */
+    public MBeansAttributeQueryFilter(JMXServiceURL jmxServiceUrl, Set attribView, MBeansObjectNameQueryFilter next) {
+        super(next);
+        this.jmxServiceUrl = jmxServiceUrl;
+        this.attribView    = attribView;
+    }
+
+    /**
+     * Filter the query by retrieving the attributes specified, this will modify the collection to a list of AttributeList
+     * @param queries - query list
+     * @return List of AttributeList, which includes the ObjectName, which has a key of MBeansAttributeQueryFilter.KEY_OBJECT_NAME_ATTRIBUTE
+     * @throws Exception
+     */
+    public List query(List queries) throws Exception {
+        return getMBeanAttributesCollection(next.query(queries));
+    }
+
+    /**
+     * Retrieve the specified attributes of the mbean
+     * @param result - collection of ObjectInstances and/or ObjectNames
+     * @return List of AttributeList
+     * @throws IOException
+     * @throws ReflectionException
+     * @throws InstanceNotFoundException
+     * @throws NoSuchMethodException
+     */
+    protected List getMBeanAttributesCollection(Collection result) throws IOException, ReflectionException, InstanceNotFoundException, NoSuchMethodException, IntrospectionException {
+        List mbeansCollection = new ArrayList();
+
+        for (Iterator i=result.iterator(); i.hasNext();) {
+            Object mbean = i.next();
+            if (mbean instanceof ObjectInstance) {
+                mbeansCollection.add(getMBeanAttributes(((ObjectInstance)mbean).getObjectName(), attribView));
+            } else if (mbean instanceof ObjectName) {
+                mbeansCollection.add(getMBeanAttributes((ObjectName)mbean, attribView));
+            } else {
+                throw new NoSuchMethodException("Cannot get the mbean attributes for class: " + mbean.getClass().getName());
+            }
+        }
+
+        return mbeansCollection;
+    }
+
+    /**
+     * Retrieve the specified attributes of the mbean
+     * @param obj - mbean ObjectInstance
+     * @param attrView - list of attributes to retrieve
+     * @return AttributeList for the mbean
+     * @throws ReflectionException
+     * @throws InstanceNotFoundException
+     * @throws IOException
+     */
+    protected AttributeList getMBeanAttributes(ObjectInstance obj, Set attrView) throws ReflectionException, InstanceNotFoundException, IOException, IntrospectionException {
+        return getMBeanAttributes(obj.getObjectName(), attrView);
+    }
+
+    /**
+     * Retrieve the specified attributes of the mbean
+     * @param objName - mbean ObjectName
+     * @param attrView - list of attributes to retrieve
+     * @return AttributeList for the mbean
+     * @throws IOException
+     * @throws ReflectionException
+     * @throws InstanceNotFoundException
+     */
+    protected AttributeList getMBeanAttributes(ObjectName objName, Set attrView) throws IOException, ReflectionException, InstanceNotFoundException, IntrospectionException {
+        JMXConnector jmxConnector    = JMXConnectorFactory.connect(jmxServiceUrl);
+        MBeanServerConnection server = jmxConnector.getMBeanServerConnection();
+
+        // If no attribute view specified, get all attributes
+        String[] attribs;
+        if (attrView == null || attrView.isEmpty()) {
+            MBeanAttributeInfo[] infos = server.getMBeanInfo(objName).getAttributes();
+            attribs = new String[infos.length];
+
+            for (int i=0; i<infos.length; i++) {
+                if (infos[i].isReadable()) {
+                    attribs[i] = infos[i].getName();
+                }
+            }
+
+        // Get selected attributes
+        } else {
+
+            attribs = new String[attrView.size()];
+            int count = 0;
+            for (Iterator i=attrView.iterator(); i.hasNext();) {
+                attribs[count++] = (String)i.next();
+            }
+        }
+
+        AttributeList attribList = server.getAttributes(objName, attribs);
+
+        jmxConnector.close();
+
+        attribList.add(0, new Attribute(KEY_OBJECT_NAME_ATTRIBUTE, objName));
+
+        return attribList;
+    }
+}

Propchange: incubator/activemq/trunk/activemq-console/src/main/java/org/apache/activemq/console/filter/MBeansAttributeQueryFilter.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: incubator/activemq/trunk/activemq-console/src/main/java/org/apache/activemq/console/filter/MBeansObjectNameQueryFilter.java
URL: http://svn.apache.org/viewcvs/incubator/activemq/trunk/activemq-console/src/main/java/org/apache/activemq/console/filter/MBeansObjectNameQueryFilter.java?rev=379619&r1=379618&r2=379619&view=diff
==============================================================================
--- incubator/activemq/trunk/activemq-console/src/main/java/org/apache/activemq/console/filter/MBeansObjectNameQueryFilter.java (original)
+++ incubator/activemq/trunk/activemq-console/src/main/java/org/apache/activemq/console/filter/MBeansObjectNameQueryFilter.java Tue Feb 21 15:12:56 2006
@@ -1,161 +1,161 @@
-/**
- *
- * 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.console.filter;
-
-import javax.management.remote.JMXServiceURL;
-import javax.management.remote.JMXConnector;
-import javax.management.remote.JMXConnectorFactory;
-import javax.management.ObjectName;
-import javax.management.MalformedObjectNameException;
-import javax.management.MBeanServerConnection;
-import javax.management.QueryExp;
-import java.util.Iterator;
-import java.util.List;
-import java.util.ArrayList;
-import java.net.MalformedURLException;
-import java.io.IOException;
-
-public class MBeansObjectNameQueryFilter extends AbstractQueryFilter {
-
-    public static final String DEFAULT_JMX_DOMAIN = "org.apache.activemq";
-    public static final String QUERY_EXP_PREFIX   = "MBeans.QueryExp.";
-
-    private JMXServiceURL jmxServiceUrl;
-
-    /**
-     * Creates an mbeans object name query filter that will query on the given JMX Service URL
-     * @param jmxUrl - JMX service URL to connect to
-     * @throws MalformedURLException
-     */
-    public MBeansObjectNameQueryFilter(String jmxUrl) throws MalformedURLException {
-        this(new JMXServiceURL(jmxUrl));
-    }
-
-    /**
-     * Creates an mbeans objecet name query filter that will query on the given JMX Service URL
-     * @param jmxUrl - JMX service URL to connect to
-     */
-    public MBeansObjectNameQueryFilter(JMXServiceURL jmxUrl) {
-        super(null);
-        this.jmxServiceUrl = jmxUrl;
-    }
-
-    /**
-     * Queries the JMX service using a mapping of keys and values to construct the object name
-     * @param queries - mapping of keys and values
-     * @return collection of ObjectInstance that matches the query
-     * @throws MalformedObjectNameException - if the given string is an invalid object name
-     * @throws IOException - if there is a problem querying the JMX context
-     */
-    public List query(List queries) throws MalformedObjectNameException, IOException {
-
-        // Query all mbeans
-        if (queries == null || queries.isEmpty()) {
-            return queryMBeans(new ObjectName(DEFAULT_JMX_DOMAIN + ":*"), null);
-        }
-
-        // Constructs object name query
-        String objNameQuery = "";
-        String queryExp = "";
-        for (Iterator i=queries.iterator(); i.hasNext();) {
-            String key = (String)i.next();
-            String val = "";
-            int pos = key.indexOf("=");
-            if (pos >= 0) {
-                val = key.substring(pos + 1);
-                key = key.substring(0, pos);
-            }
-
-            if (val.startsWith(QUERY_EXP_PREFIX)) {
-                // do nothing as of the moment
-            } else if (key != "" && val != "") {
-                objNameQuery = objNameQuery + key + "=" + val + ",";
-            }
-        }
-
-        // Append * to object name
-        objNameQuery = objNameQuery + "*";
-
-        return queryMBeans(new ObjectName(DEFAULT_JMX_DOMAIN + ":" + objNameQuery), queryExp);
-    }
-
-    /**
-     * Advance query that enables you to specify both the object name and the query expression to use.
-     * Note: Query expression is currently unsupported.
-     * @param objName - object name to use for query
-     * @param queryExpStr - query expression string
-     * @return set of mbeans that matches the query
-     * @throws IOException - if there is a problem querying the JMX context
-     */
-    protected List queryMBeans(ObjectName objName, String queryExpStr) throws IOException {
-        JMXConnector jmxConn = createJmxConnector();
-        MBeanServerConnection server = jmxConn.getMBeanServerConnection();
-
-        QueryExp queryExp = createQueryExp(queryExpStr);
-
-        // Convert mbeans set to list to make it standard throughout the query filter
-        List mbeans = new ArrayList(server.queryMBeans(objName, queryExp));
-
-        jmxConn.close();
-
-        return mbeans;
-    }
-
-    /**
-     * Get the JMX service URL the query is connecting to.
-     * @return JMX service URL
-     */
-    public JMXServiceURL getJmxServiceUrl() {
-        return jmxServiceUrl;
-    }
-
-    /**
-     * Sets the JMX service URL the query is going to connect to.
-     * @param jmxServiceUrl - new JMX service URL
-     */
-    public void setJmxServiceUrl(JMXServiceURL jmxServiceUrl) {
-        this.jmxServiceUrl = jmxServiceUrl;
-    }
-
-    /**
-     * Sets the JMX service URL the query is going to connect to.
-     * @param jmxServiceUrl - new JMX service URL
-     */
-    public void setJmxServiceUrl(String jmxServiceUrl) throws MalformedURLException {
-        setJmxServiceUrl(new JMXServiceURL(jmxServiceUrl));
-    }
-
-    /**
-     * Creates a JMX connector
-     * @return JMX connector
-     * @throws IOException
-     */
-    protected JMXConnector createJmxConnector() throws IOException {
-        return JMXConnectorFactory.connect(getJmxServiceUrl());
-    }
-
-    /**
-     * Creates a query expression based on the query expression string
-     * Note: currently unsupported
-     * @param queryExpStr - query expression string
-     * @return the created query expression
-     */
-    protected QueryExp createQueryExp(String queryExpStr) {
-        // Currently unsupported
-        return null;
-    }
-}
+/**
+ *
+ * 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.console.filter;
+
+import javax.management.remote.JMXServiceURL;
+import javax.management.remote.JMXConnector;
+import javax.management.remote.JMXConnectorFactory;
+import javax.management.ObjectName;
+import javax.management.MalformedObjectNameException;
+import javax.management.MBeanServerConnection;
+import javax.management.QueryExp;
+import java.util.Iterator;
+import java.util.List;
+import java.util.ArrayList;
+import java.net.MalformedURLException;
+import java.io.IOException;
+
+public class MBeansObjectNameQueryFilter extends AbstractQueryFilter {
+
+    public static final String DEFAULT_JMX_DOMAIN = "org.apache.activemq";
+    public static final String QUERY_EXP_PREFIX   = "MBeans.QueryExp.";
+
+    private JMXServiceURL jmxServiceUrl;
+
+    /**
+     * Creates an mbeans object name query filter that will query on the given JMX Service URL
+     * @param jmxUrl - JMX service URL to connect to
+     * @throws MalformedURLException
+     */
+    public MBeansObjectNameQueryFilter(String jmxUrl) throws MalformedURLException {
+        this(new JMXServiceURL(jmxUrl));
+    }
+
+    /**
+     * Creates an mbeans objecet name query filter that will query on the given JMX Service URL
+     * @param jmxUrl - JMX service URL to connect to
+     */
+    public MBeansObjectNameQueryFilter(JMXServiceURL jmxUrl) {
+        super(null);
+        this.jmxServiceUrl = jmxUrl;
+    }
+
+    /**
+     * Queries the JMX service using a mapping of keys and values to construct the object name
+     * @param queries - mapping of keys and values
+     * @return collection of ObjectInstance that matches the query
+     * @throws MalformedObjectNameException - if the given string is an invalid object name
+     * @throws IOException - if there is a problem querying the JMX context
+     */
+    public List query(List queries) throws MalformedObjectNameException, IOException {
+
+        // Query all mbeans
+        if (queries == null || queries.isEmpty()) {
+            return queryMBeans(new ObjectName(DEFAULT_JMX_DOMAIN + ":*"), null);
+        }
+
+        // Constructs object name query
+        String objNameQuery = "";
+        String queryExp = "";
+        for (Iterator i=queries.iterator(); i.hasNext();) {
+            String key = (String)i.next();
+            String val = "";
+            int pos = key.indexOf("=");
+            if (pos >= 0) {
+                val = key.substring(pos + 1);
+                key = key.substring(0, pos);
+            }
+
+            if (val.startsWith(QUERY_EXP_PREFIX)) {
+                // do nothing as of the moment
+            } else if (key != "" && val != "") {
+                objNameQuery = objNameQuery + key + "=" + val + ",";
+            }
+        }
+
+        // Append * to object name
+        objNameQuery = objNameQuery + "*";
+
+        return queryMBeans(new ObjectName(DEFAULT_JMX_DOMAIN + ":" + objNameQuery), queryExp);
+    }
+
+    /**
+     * Advance query that enables you to specify both the object name and the query expression to use.
+     * Note: Query expression is currently unsupported.
+     * @param objName - object name to use for query
+     * @param queryExpStr - query expression string
+     * @return set of mbeans that matches the query
+     * @throws IOException - if there is a problem querying the JMX context
+     */
+    protected List queryMBeans(ObjectName objName, String queryExpStr) throws IOException {
+        JMXConnector jmxConn = createJmxConnector();
+        MBeanServerConnection server = jmxConn.getMBeanServerConnection();
+
+        QueryExp queryExp = createQueryExp(queryExpStr);
+
+        // Convert mbeans set to list to make it standard throughout the query filter
+        List mbeans = new ArrayList(server.queryMBeans(objName, queryExp));
+
+        jmxConn.close();
+
+        return mbeans;
+    }
+
+    /**
+     * Get the JMX service URL the query is connecting to.
+     * @return JMX service URL
+     */
+    public JMXServiceURL getJmxServiceUrl() {
+        return jmxServiceUrl;
+    }
+
+    /**
+     * Sets the JMX service URL the query is going to connect to.
+     * @param jmxServiceUrl - new JMX service URL
+     */
+    public void setJmxServiceUrl(JMXServiceURL jmxServiceUrl) {
+        this.jmxServiceUrl = jmxServiceUrl;
+    }
+
+    /**
+     * Sets the JMX service URL the query is going to connect to.
+     * @param jmxServiceUrl - new JMX service URL
+     */
+    public void setJmxServiceUrl(String jmxServiceUrl) throws MalformedURLException {
+        setJmxServiceUrl(new JMXServiceURL(jmxServiceUrl));
+    }
+
+    /**
+     * Creates a JMX connector
+     * @return JMX connector
+     * @throws IOException
+     */
+    protected JMXConnector createJmxConnector() throws IOException {
+        return JMXConnectorFactory.connect(getJmxServiceUrl());
+    }
+
+    /**
+     * Creates a query expression based on the query expression string
+     * Note: currently unsupported
+     * @param queryExpStr - query expression string
+     * @return the created query expression
+     */
+    protected QueryExp createQueryExp(String queryExpStr) {
+        // Currently unsupported
+        return null;
+    }
+}

Propchange: incubator/activemq/trunk/activemq-console/src/main/java/org/apache/activemq/console/filter/MBeansObjectNameQueryFilter.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: incubator/activemq/trunk/activemq-console/src/main/java/org/apache/activemq/console/filter/MBeansRegExQueryFilter.java
URL: http://svn.apache.org/viewcvs/incubator/activemq/trunk/activemq-console/src/main/java/org/apache/activemq/console/filter/MBeansRegExQueryFilter.java?rev=379619&r1=379618&r2=379619&view=diff
==============================================================================
--- incubator/activemq/trunk/activemq-console/src/main/java/org/apache/activemq/console/filter/MBeansRegExQueryFilter.java (original)
+++ incubator/activemq/trunk/activemq-console/src/main/java/org/apache/activemq/console/filter/MBeansRegExQueryFilter.java Tue Feb 21 15:12:56 2006
@@ -1,127 +1,127 @@
-/**
- *
- * 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.console.filter;
-
-import javax.management.ObjectInstance;
-import javax.management.ObjectName;
-import javax.management.AttributeList;
-import javax.management.Attribute;
-import java.util.Map;
-import java.util.Iterator;
-import java.util.regex.Pattern;
-import java.lang.reflect.Method;
-
-public class MBeansRegExQueryFilter extends RegExQueryFilter {
-    /**
-     * Creates a regular expression query that is able to match the values of specific mbeans
-     * @param next - next query filter
-     */
-    public MBeansRegExQueryFilter(QueryFilter next) {
-        super(next);
-    }
-
-    /**
-     * Try to match the object data using the regular expression map. The regex map contains a key-value mapping of an attribute
-     * key to a regular expression the value of the key should match. The basic rule of matching is that the data must contain
-     * a property key that is included in the regex map, and that the value of the property key should match the regex specified.
-     * @param data - object data to match
-     * @param regex - regex map
-     * @return true if the data matches the regex map specified
-     * @throws Exception
-     */
-    protected boolean matches(Object data, Map regex) throws Exception {
-        // Use reflection to determine where the object should go
-        try {
-            Method method = this.getClass().getDeclaredMethod("matches", new Class[] {data.getClass(), Map.class});
-            return ((Boolean)method.invoke(this, new Object[] {data, regex})).booleanValue();
-        } catch (NoSuchMethodException e) {
-            return false;
-        }
-    }
-
-    /**
-     * Try to match the object instance using the regular expression map
-     * @param data - object instance to match
-     * @param regex - regex map
-     * @return true if the object instance matches the regex map
-     */
-    protected boolean matches(ObjectInstance data, Map regex) {
-        return matches(data.getObjectName(), regex);
-    }
-
-    /**
-     * Try to match the object name instance using the regular expression map
-     * @param data - object name to match
-     * @param regex - regex map
-     * @return true if the object name matches the regex map
-     */
-    protected boolean matches(ObjectName data, Map regex) {
-        for (Iterator i=regex.keySet().iterator(); i.hasNext();) {
-            String key = (String)i.next();
-            String target = data.getKeyProperty(key);
-
-            // Try to match the value of the property of the object name
-            if (target != null && !((Pattern)regex.get(key)).matcher(target).matches()) {
-                return false;
-            }
-        }
-        return true;
-    }
-
-    /**
-     * Try to match the attribute list using the regular expression map
-     * @param data - attribute list to match
-     * @param regex - regex map
-     * @return true if the attribute list matches the regex map
-     */
-    protected boolean matches(AttributeList data, Map regex) {
-        for (Iterator i=regex.keySet().iterator(); i.hasNext();) {
-            String key = (String)i.next();
-
-            // Try to match each regex to the attributes of the mbean including its ObjectName
-            for (Iterator j=data.iterator(); j.hasNext();) {
-                Attribute attrib = (Attribute)j.next();
-
-                // Try to match to the properties of the ObjectName
-                if (attrib.getName().equals(MBeansAttributeQueryFilter.KEY_OBJECT_NAME_ATTRIBUTE)) {
-                    String target = ((ObjectName)attrib.getValue()).getKeyProperty(key);
-
-                    if (target == null || !((Pattern)regex.get(key)).matcher(target).matches()) {
-                        return false;
-                    } else {
-                        // If match skip to the next regex
-                        break;
-                    }
-
-                // Try to match to the mbean attributes
-                } else if (attrib.getName().equals(key)) {
-                    if (!((Pattern)regex.get(key)).matcher(attrib.getValue().toString()).matches()) {
-                        return false;
-                    } else {
-                        // If match skip to the next regex
-                        break;
-                    }
-
-                // If mbean does not contain the specified attribute
-                } else {
-                    return false;
-                }
-            }
-        }
-        return true;
-    }
-}
+/**
+ *
+ * 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.console.filter;
+
+import javax.management.ObjectInstance;
+import javax.management.ObjectName;
+import javax.management.AttributeList;
+import javax.management.Attribute;
+import java.util.Map;
+import java.util.Iterator;
+import java.util.regex.Pattern;
+import java.lang.reflect.Method;
+
+public class MBeansRegExQueryFilter extends RegExQueryFilter {
+    /**
+     * Creates a regular expression query that is able to match the values of specific mbeans
+     * @param next - next query filter
+     */
+    public MBeansRegExQueryFilter(QueryFilter next) {
+        super(next);
+    }
+
+    /**
+     * Try to match the object data using the regular expression map. The regex map contains a key-value mapping of an attribute
+     * key to a regular expression the value of the key should match. The basic rule of matching is that the data must contain
+     * a property key that is included in the regex map, and that the value of the property key should match the regex specified.
+     * @param data - object data to match
+     * @param regex - regex map
+     * @return true if the data matches the regex map specified
+     * @throws Exception
+     */
+    protected boolean matches(Object data, Map regex) throws Exception {
+        // Use reflection to determine where the object should go
+        try {
+            Method method = this.getClass().getDeclaredMethod("matches", new Class[] {data.getClass(), Map.class});
+            return ((Boolean)method.invoke(this, new Object[] {data, regex})).booleanValue();
+        } catch (NoSuchMethodException e) {
+            return false;
+        }
+    }
+
+    /**
+     * Try to match the object instance using the regular expression map
+     * @param data - object instance to match
+     * @param regex - regex map
+     * @return true if the object instance matches the regex map
+     */
+    protected boolean matches(ObjectInstance data, Map regex) {
+        return matches(data.getObjectName(), regex);
+    }
+
+    /**
+     * Try to match the object name instance using the regular expression map
+     * @param data - object name to match
+     * @param regex - regex map
+     * @return true if the object name matches the regex map
+     */
+    protected boolean matches(ObjectName data, Map regex) {
+        for (Iterator i=regex.keySet().iterator(); i.hasNext();) {
+            String key = (String)i.next();
+            String target = data.getKeyProperty(key);
+
+            // Try to match the value of the property of the object name
+            if (target != null && !((Pattern)regex.get(key)).matcher(target).matches()) {
+                return false;
+            }
+        }
+        return true;
+    }
+
+    /**
+     * Try to match the attribute list using the regular expression map
+     * @param data - attribute list to match
+     * @param regex - regex map
+     * @return true if the attribute list matches the regex map
+     */
+    protected boolean matches(AttributeList data, Map regex) {
+        for (Iterator i=regex.keySet().iterator(); i.hasNext();) {
+            String key = (String)i.next();
+
+            // Try to match each regex to the attributes of the mbean including its ObjectName
+            for (Iterator j=data.iterator(); j.hasNext();) {
+                Attribute attrib = (Attribute)j.next();
+
+                // Try to match to the properties of the ObjectName
+                if (attrib.getName().equals(MBeansAttributeQueryFilter.KEY_OBJECT_NAME_ATTRIBUTE)) {
+                    String target = ((ObjectName)attrib.getValue()).getKeyProperty(key);
+
+                    if (target == null || !((Pattern)regex.get(key)).matcher(target).matches()) {
+                        return false;
+                    } else {
+                        // If match skip to the next regex
+                        break;
+                    }
+
+                // Try to match to the mbean attributes
+                } else if (attrib.getName().equals(key)) {
+                    if (!((Pattern)regex.get(key)).matcher(attrib.getValue().toString()).matches()) {
+                        return false;
+                    } else {
+                        // If match skip to the next regex
+                        break;
+                    }
+
+                // If mbean does not contain the specified attribute
+                } else {
+                    return false;
+                }
+            }
+        }
+        return true;
+    }
+}

Propchange: incubator/activemq/trunk/activemq-console/src/main/java/org/apache/activemq/console/filter/MBeansRegExQueryFilter.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: incubator/activemq/trunk/activemq-console/src/main/java/org/apache/activemq/console/filter/MapTransformFilter.java
URL: http://svn.apache.org/viewcvs/incubator/activemq/trunk/activemq-console/src/main/java/org/apache/activemq/console/filter/MapTransformFilter.java?rev=379619&r1=379618&r2=379619&view=diff
==============================================================================
--- incubator/activemq/trunk/activemq-console/src/main/java/org/apache/activemq/console/filter/MapTransformFilter.java (original)
+++ incubator/activemq/trunk/activemq-console/src/main/java/org/apache/activemq/console/filter/MapTransformFilter.java Tue Feb 21 15:12:56 2006
@@ -1,315 +1,315 @@
-/**
- *
- * 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.console.filter;
-
-import org.apache.activemq.console.formatter.GlobalWriter;
-import org.apache.activemq.console.util.AmqMessagesUtil;
-import org.apache.activemq.command.ActiveMQDestination;
-import org.apache.activemq.command.ActiveMQObjectMessage;
-import org.apache.activemq.command.ActiveMQBytesMessage;
-import org.apache.activemq.command.ActiveMQTextMessage;
-import org.apache.activemq.command.ActiveMQMapMessage;
-import org.apache.activemq.command.ActiveMQStreamMessage;
-import org.apache.activemq.command.ActiveMQMessage;
-
-import javax.management.ObjectInstance;
-import javax.management.ObjectName;
-import javax.management.AttributeList;
-import javax.management.Attribute;
-import javax.management.openmbean.CompositeDataSupport;
-import javax.jms.JMSException;
-import javax.jms.DeliveryMode;
-import java.util.Map;
-import java.util.Properties;
-import java.util.Iterator;
-import java.util.Enumeration;
-import java.lang.reflect.Method;
-
-public class MapTransformFilter extends ResultTransformFilter {
-    /**
-     * Creates a Map transform filter that is able to transform a variety of objects to a properties map object
-     * @param next - the next query filter
-     */
-    public MapTransformFilter(QueryFilter next) {
-        super(next);
-    }
-
-    /**
-     * Transform the given object to a Map object
-     * @param object - object to transform
-     * @return map object
-     */
-    protected Object transformElement(Object object) throws Exception {
-        // Use reflection to determine how the object should be transformed
-        try {
-            Method method = this.getClass().getDeclaredMethod("transformToMap", new Class[] {object.getClass()});
-            return (Map)method.invoke(this, new Object[] {object});
-        } catch (NoSuchMethodException e) {
-            GlobalWriter.print("Unable to transform mbean of type: " + object.getClass().getName() + ". No corresponding transformToMap method found.");
-            return null;
-        }
-    }
-
-    /**
-     * Transform an ObjectInstance mbean to a Map
-     * @param obj - ObjectInstance format of an mbean
-     * @return map object
-     */
-    protected Map transformToMap(ObjectInstance obj) {
-        return transformToMap(obj.getObjectName());
-    }
-
-    /**
-     * Transform an ObjectName mbean to a Map
-     * @param objname - ObjectName format of an mbean
-     * @return map object
-     */
-    protected Map transformToMap(ObjectName objname) {
-        Properties props = new Properties();
-
-        // Parse object properties
-        Map objProps = objname.getKeyPropertyList();
-        for (Iterator i=objProps.keySet().iterator(); i.hasNext();) {
-            Object key = i.next();
-            Object val = objProps.get(key);
-            if (val != null) {
-                props.setProperty(key.toString(), val.toString());
-            }
-        }
-
-        return props;
-    }
-
-    /**
-     * Transform an Attribute List format of an mbean to a Map
-     * @param list - AttributeList format of an mbean
-     * @return map object
-     */
-    protected Map transformToMap(AttributeList list) {
-        Properties props = new Properties();
-        for (Iterator i=list.iterator(); i.hasNext();) {
-            Attribute attrib = (Attribute)i.next();
-
-            // If attribute is an ObjectName
-            if (attrib.getName().equals(MBeansAttributeQueryFilter.KEY_OBJECT_NAME_ATTRIBUTE)) {
-                props.putAll(transformToMap((ObjectName)attrib.getValue()));
-            } else {
-                if (attrib.getValue() != null) {
-                    props.setProperty(attrib.getName(), attrib.getValue().toString());
-                }
-            }
-        }
-
-        return props;
-    }
-
-    /**
-     * Transform an ActiveMQTextMessage to a Map
-     * @param msg - text message to trasnform
-     * @return map object
-     * @throws JMSException
-     */
-    protected Map transformToMap(ActiveMQTextMessage msg) throws JMSException {
-        Properties props = new Properties();
-
-        props.putAll(transformToMap((ActiveMQMessage)msg));
-        if (msg.getText() != null) {
-            props.setProperty(AmqMessagesUtil.JMS_MESSAGE_BODY_PREFIX + "JMSText", msg.getText());
-        }
-
-        return props;
-    }
-
-    /**
-     * Transform an ActiveMQBytesMessage to a Map
-     * @param msg - bytes message to transform
-     * @return map object
-     * @throws JMSException
-     */
-    protected Map transformToMap(ActiveMQBytesMessage msg) throws JMSException {
-        Properties props = new Properties();
-
-        props.putAll(transformToMap((ActiveMQMessage)msg));
-
-        long bodyLength = msg.getBodyLength();
-        byte[] msgBody;
-        int i=0;
-        // Create separate bytes messages
-        for (i=0; i<(bodyLength/Integer.MAX_VALUE); i++) {
-            msgBody = new byte[Integer.MAX_VALUE];
-            props.setProperty(AmqMessagesUtil.JMS_MESSAGE_BODY_PREFIX + "JMSBytes:" + (i+1), new String(msgBody));
-        }
-        msgBody = new byte[(int)(bodyLength % Integer.MAX_VALUE)];
-        props.setProperty(AmqMessagesUtil.JMS_MESSAGE_BODY_PREFIX + "JMSBytes:" + (i+1), new String(msgBody));
-
-        return props;
-    }
-
-    /**
-     * Transform an ActiveMQMessage to a Map
-     * @param msg - object message to transform
-     * @return map object
-     * @throws JMSException
-     */
-    protected Map transformToMap(ActiveMQObjectMessage msg) throws JMSException {
-        Properties props = new Properties();
-
-        props.putAll(transformToMap((ActiveMQMessage)msg));
-        if (msg.getObject() != null) {
-            // Just add the class name and toString value of the object
-            props.setProperty(AmqMessagesUtil.JMS_MESSAGE_BODY_PREFIX + "JMSObjectClass", msg.getObject().getClass().getName());
-            props.setProperty(AmqMessagesUtil.JMS_MESSAGE_BODY_PREFIX + "JMSObjectString", msg.getObject().toString());
-        }
-        return props;
-    }
-
-    /**
-     * Transform an ActiveMQMapMessage to a Map
-     * @param msg - map message to transform
-     * @return map object
-     * @throws JMSException
-     */
-    protected Map transformToMap(ActiveMQMapMessage msg) throws JMSException {
-        Properties props = new Properties();
-
-        props.putAll(transformToMap((ActiveMQMessage)msg));
-
-        // Get map properties
-        Enumeration e = msg.getMapNames();
-        while (e.hasMoreElements()) {
-            String key = (String)e.nextElement();
-            Object val = msg.getObject(key);
-            if (val != null) {
-                props.setProperty(AmqMessagesUtil.JMS_MESSAGE_BODY_PREFIX + key, val.toString());
-            }
-        }
-
-        return props;
-    }
-
-    /**
-     * Transform an ActiveMQStreamMessage to a Map
-     * @param msg - stream message to transform
-     * @return map object
-     * @throws JMSException
-     */
-    protected Map transformToMap(ActiveMQStreamMessage msg) throws JMSException {
-        Properties props = new Properties();
-
-        props.putAll(transformToMap((ActiveMQMessage)msg));
-        // Just set the toString of the message as the body of the stream message
-        props.setProperty(AmqMessagesUtil.JMS_MESSAGE_BODY_PREFIX + "JMSStreamMessage", msg.toString());
-
-        return props;
-    }
-
-    /**
-     * Transform an ActiveMQMessage to a Map
-     * @param msg - message to transform
-     * @return map object
-     * @throws JMSException
-     */
-    protected Map transformToMap(ActiveMQMessage msg) throws JMSException {
-        Properties props = new Properties();
-
-        // Get JMS properties
-        if (msg.getJMSCorrelationID() != null) {
-            props.setProperty(AmqMessagesUtil.JMS_MESSAGE_HEADER_PREFIX + "JMSCorrelationID", msg.getJMSCorrelationID());
-        }
-        props.setProperty(AmqMessagesUtil.JMS_MESSAGE_HEADER_PREFIX + "JMSDeliveryMode", (msg.getJMSDeliveryMode()==DeliveryMode.PERSISTENT) ? "persistent" : "non-persistent");
-        if (msg.getJMSDestination() != null) {
-            props.setProperty(AmqMessagesUtil.JMS_MESSAGE_HEADER_PREFIX + "JMSDestination", ((ActiveMQDestination)msg.getJMSDestination()).getPhysicalName());
-        }
-        props.setProperty(AmqMessagesUtil.JMS_MESSAGE_HEADER_PREFIX + "JMSExpiration", Long.toString(msg.getJMSExpiration()));
-        props.setProperty(AmqMessagesUtil.JMS_MESSAGE_HEADER_PREFIX + "JMSMessageID", msg.getJMSMessageID());
-        props.setProperty(AmqMessagesUtil.JMS_MESSAGE_HEADER_PREFIX + "JMSPriority", Integer.toString(msg.getJMSPriority()));
-        props.setProperty(AmqMessagesUtil.JMS_MESSAGE_HEADER_PREFIX + "JMSRedelivered", Boolean.toString(msg.getJMSRedelivered()));
-        if (msg.getJMSReplyTo() != null) {
-            props.setProperty(AmqMessagesUtil.JMS_MESSAGE_HEADER_PREFIX + "JMSReplyTo", ((ActiveMQDestination)msg.getJMSReplyTo()).getPhysicalName());
-        }
-        props.setProperty(AmqMessagesUtil.JMS_MESSAGE_HEADER_PREFIX + "JMSTimestamp", Long.toString(msg.getJMSTimestamp()));
-        if (msg.getJMSType() != null) {
-            props.setProperty(AmqMessagesUtil.JMS_MESSAGE_HEADER_PREFIX + "JMSType", msg.getJMSType());
-        }
-
-        // Get custom properties
-        Enumeration e = msg.getPropertyNames();
-        while (e.hasMoreElements()) {
-            String name = (String)e.nextElement();
-            if (msg.getObjectProperty(name) != null) {
-                props.setProperty(AmqMessagesUtil.JMS_MESSAGE_CUSTOM_PREFIX + name, msg.getObjectProperty(name).toString());
-            }
-        }
-
-        return props;
-    }
-
-    /**
-     * Transform an openMBean composite data to a Map
-     * @param data - composite data to transform
-     * @return map object
-     */
-    protected Map transformToMap(CompositeDataSupport data) {
-        Properties props = new Properties();
-
-        String typeName = data.getCompositeType().getTypeName();
-
-        // Retrieve text message
-        if (typeName.equals(ActiveMQTextMessage.class.getName())) {
-            props.setProperty(AmqMessagesUtil.JMS_MESSAGE_BODY_PREFIX + "Text", data.get("Text").toString());
-
-        // Retrieve byte preview
-        } else if (typeName.equals(ActiveMQBytesMessage.class.getName())) {
-            props.setProperty(AmqMessagesUtil.JMS_MESSAGE_BODY_PREFIX + "BodyLength", data.get("BodyLength").toString());
-            props.setProperty(AmqMessagesUtil.JMS_MESSAGE_BODY_PREFIX + "BodyPreview", new String((byte[])data.get("BodyPreview")));
-
-        // Expand content map
-        } else if (typeName.equals(ActiveMQMapMessage.class.getName())) {
-            Map contentMap = (Map)data.get("ContentMap");
-            for (Iterator i=contentMap.keySet().iterator(); i.hasNext();) {
-                String key = (String)i.next();
-                props.setProperty(AmqMessagesUtil.JMS_MESSAGE_BODY_PREFIX + key, contentMap.get(key).toString());
-            }
-
-        // Do nothing
-        } else if (typeName.equals(ActiveMQObjectMessage.class.getName()) ||
-                   typeName.equals(ActiveMQStreamMessage.class.getName()) ||
-                   typeName.equals(ActiveMQMessage.class.getName())) {
-
-        // Unrecognized composite data. Throw exception.
-        } else {
-            throw new IllegalArgumentException("Unrecognized composite data to transform. composite type: " + typeName);
-        }
-
-        // Process the JMS message header values
-        props.setProperty(AmqMessagesUtil.JMS_MESSAGE_HEADER_PREFIX + "JMSCorrelationID", "" + data.get("JMSCorrelationID"));
-        props.setProperty(AmqMessagesUtil.JMS_MESSAGE_HEADER_PREFIX + "JMSDestination",   "" + data.get("JMSDestination"));
-        props.setProperty(AmqMessagesUtil.JMS_MESSAGE_HEADER_PREFIX + "JMSMessageID",     "" + data.get("JMSMessageID"));
-        props.setProperty(AmqMessagesUtil.JMS_MESSAGE_HEADER_PREFIX + "JMSReplyTo",       "" + data.get("JMSReplyTo"));
-        props.setProperty(AmqMessagesUtil.JMS_MESSAGE_HEADER_PREFIX + "JMSType",          "" + data.get("JMSType"));
-        props.setProperty(AmqMessagesUtil.JMS_MESSAGE_HEADER_PREFIX + "JMSDeliveryMode",  "" + data.get("JMSDeliveryMode"));
-        props.setProperty(AmqMessagesUtil.JMS_MESSAGE_HEADER_PREFIX + "JMSExpiration",    "" + data.get("JMSExpiration"));
-        props.setProperty(AmqMessagesUtil.JMS_MESSAGE_HEADER_PREFIX + "JMSPriority",      "" + data.get("JMSPriority"));
-        props.setProperty(AmqMessagesUtil.JMS_MESSAGE_HEADER_PREFIX + "JMSRedelivered",   "" + data.get("JMSRedelivered"));
-        props.setProperty(AmqMessagesUtil.JMS_MESSAGE_HEADER_PREFIX + "JMSTimestamp",     "" + data.get("JMSTimestamp"));
-
-        // Process the JMS custom message properties
-        props.setProperty(AmqMessagesUtil.JMS_MESSAGE_CUSTOM_PREFIX + "Properties", "" + data.get("Properties"));
-
-        return props;
-    }
-}
+/**
+ *
+ * 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.console.filter;
+
+import org.apache.activemq.console.formatter.GlobalWriter;
+import org.apache.activemq.console.util.AmqMessagesUtil;
+import org.apache.activemq.command.ActiveMQDestination;
+import org.apache.activemq.command.ActiveMQObjectMessage;
+import org.apache.activemq.command.ActiveMQBytesMessage;
+import org.apache.activemq.command.ActiveMQTextMessage;
+import org.apache.activemq.command.ActiveMQMapMessage;
+import org.apache.activemq.command.ActiveMQStreamMessage;
+import org.apache.activemq.command.ActiveMQMessage;
+
+import javax.management.ObjectInstance;
+import javax.management.ObjectName;
+import javax.management.AttributeList;
+import javax.management.Attribute;
+import javax.management.openmbean.CompositeDataSupport;
+import javax.jms.JMSException;
+import javax.jms.DeliveryMode;
+import java.util.Map;
+import java.util.Properties;
+import java.util.Iterator;
+import java.util.Enumeration;
+import java.lang.reflect.Method;
+
+public class MapTransformFilter extends ResultTransformFilter {
+    /**
+     * Creates a Map transform filter that is able to transform a variety of objects to a properties map object
+     * @param next - the next query filter
+     */
+    public MapTransformFilter(QueryFilter next) {
+        super(next);
+    }
+
+    /**
+     * Transform the given object to a Map object
+     * @param object - object to transform
+     * @return map object
+     */
+    protected Object transformElement(Object object) throws Exception {
+        // Use reflection to determine how the object should be transformed
+        try {
+            Method method = this.getClass().getDeclaredMethod("transformToMap", new Class[] {object.getClass()});
+            return (Map)method.invoke(this, new Object[] {object});
+        } catch (NoSuchMethodException e) {
+            GlobalWriter.print("Unable to transform mbean of type: " + object.getClass().getName() + ". No corresponding transformToMap method found.");
+            return null;
+        }
+    }
+
+    /**
+     * Transform an ObjectInstance mbean to a Map
+     * @param obj - ObjectInstance format of an mbean
+     * @return map object
+     */
+    protected Map transformToMap(ObjectInstance obj) {
+        return transformToMap(obj.getObjectName());
+    }
+
+    /**
+     * Transform an ObjectName mbean to a Map
+     * @param objname - ObjectName format of an mbean
+     * @return map object
+     */
+    protected Map transformToMap(ObjectName objname) {
+        Properties props = new Properties();
+
+        // Parse object properties
+        Map objProps = objname.getKeyPropertyList();
+        for (Iterator i=objProps.keySet().iterator(); i.hasNext();) {
+            Object key = i.next();
+            Object val = objProps.get(key);
+            if (val != null) {
+                props.setProperty(key.toString(), val.toString());
+            }
+        }
+
+        return props;
+    }
+
+    /**
+     * Transform an Attribute List format of an mbean to a Map
+     * @param list - AttributeList format of an mbean
+     * @return map object
+     */
+    protected Map transformToMap(AttributeList list) {
+        Properties props = new Properties();
+        for (Iterator i=list.iterator(); i.hasNext();) {
+            Attribute attrib = (Attribute)i.next();
+
+            // If attribute is an ObjectName
+            if (attrib.getName().equals(MBeansAttributeQueryFilter.KEY_OBJECT_NAME_ATTRIBUTE)) {
+                props.putAll(transformToMap((ObjectName)attrib.getValue()));
+            } else {
+                if (attrib.getValue() != null) {
+                    props.setProperty(attrib.getName(), attrib.getValue().toString());
+                }
+            }
+        }
+
+        return props;
+    }
+
+    /**
+     * Transform an ActiveMQTextMessage to a Map
+     * @param msg - text message to trasnform
+     * @return map object
+     * @throws JMSException
+     */
+    protected Map transformToMap(ActiveMQTextMessage msg) throws JMSException {
+        Properties props = new Properties();
+
+        props.putAll(transformToMap((ActiveMQMessage)msg));
+        if (msg.getText() != null) {
+            props.setProperty(AmqMessagesUtil.JMS_MESSAGE_BODY_PREFIX + "JMSText", msg.getText());
+        }
+
+        return props;
+    }
+
+    /**
+     * Transform an ActiveMQBytesMessage to a Map
+     * @param msg - bytes message to transform
+     * @return map object
+     * @throws JMSException
+     */
+    protected Map transformToMap(ActiveMQBytesMessage msg) throws JMSException {
+        Properties props = new Properties();
+
+        props.putAll(transformToMap((ActiveMQMessage)msg));
+
+        long bodyLength = msg.getBodyLength();
+        byte[] msgBody;
+        int i=0;
+        // Create separate bytes messages
+        for (i=0; i<(bodyLength/Integer.MAX_VALUE); i++) {
+            msgBody = new byte[Integer.MAX_VALUE];
+            props.setProperty(AmqMessagesUtil.JMS_MESSAGE_BODY_PREFIX + "JMSBytes:" + (i+1), new String(msgBody));
+        }
+        msgBody = new byte[(int)(bodyLength % Integer.MAX_VALUE)];
+        props.setProperty(AmqMessagesUtil.JMS_MESSAGE_BODY_PREFIX + "JMSBytes:" + (i+1), new String(msgBody));
+
+        return props;
+    }
+
+    /**
+     * Transform an ActiveMQMessage to a Map
+     * @param msg - object message to transform
+     * @return map object
+     * @throws JMSException
+     */
+    protected Map transformToMap(ActiveMQObjectMessage msg) throws JMSException {
+        Properties props = new Properties();
+
+        props.putAll(transformToMap((ActiveMQMessage)msg));
+        if (msg.getObject() != null) {
+            // Just add the class name and toString value of the object
+            props.setProperty(AmqMessagesUtil.JMS_MESSAGE_BODY_PREFIX + "JMSObjectClass", msg.getObject().getClass().getName());
+            props.setProperty(AmqMessagesUtil.JMS_MESSAGE_BODY_PREFIX + "JMSObjectString", msg.getObject().toString());
+        }
+        return props;
+    }
+
+    /**
+     * Transform an ActiveMQMapMessage to a Map
+     * @param msg - map message to transform
+     * @return map object
+     * @throws JMSException
+     */
+    protected Map transformToMap(ActiveMQMapMessage msg) throws JMSException {
+        Properties props = new Properties();
+
+        props.putAll(transformToMap((ActiveMQMessage)msg));
+
+        // Get map properties
+        Enumeration e = msg.getMapNames();
+        while (e.hasMoreElements()) {
+            String key = (String)e.nextElement();
+            Object val = msg.getObject(key);
+            if (val != null) {
+                props.setProperty(AmqMessagesUtil.JMS_MESSAGE_BODY_PREFIX + key, val.toString());
+            }
+        }
+
+        return props;
+    }
+
+    /**
+     * Transform an ActiveMQStreamMessage to a Map
+     * @param msg - stream message to transform
+     * @return map object
+     * @throws JMSException
+     */
+    protected Map transformToMap(ActiveMQStreamMessage msg) throws JMSException {
+        Properties props = new Properties();
+
+        props.putAll(transformToMap((ActiveMQMessage)msg));
+        // Just set the toString of the message as the body of the stream message
+        props.setProperty(AmqMessagesUtil.JMS_MESSAGE_BODY_PREFIX + "JMSStreamMessage", msg.toString());
+
+        return props;
+    }
+
+    /**
+     * Transform an ActiveMQMessage to a Map
+     * @param msg - message to transform
+     * @return map object
+     * @throws JMSException
+     */
+    protected Map transformToMap(ActiveMQMessage msg) throws JMSException {
+        Properties props = new Properties();
+
+        // Get JMS properties
+        if (msg.getJMSCorrelationID() != null) {
+            props.setProperty(AmqMessagesUtil.JMS_MESSAGE_HEADER_PREFIX + "JMSCorrelationID", msg.getJMSCorrelationID());
+        }
+        props.setProperty(AmqMessagesUtil.JMS_MESSAGE_HEADER_PREFIX + "JMSDeliveryMode", (msg.getJMSDeliveryMode()==DeliveryMode.PERSISTENT) ? "persistent" : "non-persistent");
+        if (msg.getJMSDestination() != null) {
+            props.setProperty(AmqMessagesUtil.JMS_MESSAGE_HEADER_PREFIX + "JMSDestination", ((ActiveMQDestination)msg.getJMSDestination()).getPhysicalName());
+        }
+        props.setProperty(AmqMessagesUtil.JMS_MESSAGE_HEADER_PREFIX + "JMSExpiration", Long.toString(msg.getJMSExpiration()));
+        props.setProperty(AmqMessagesUtil.JMS_MESSAGE_HEADER_PREFIX + "JMSMessageID", msg.getJMSMessageID());
+        props.setProperty(AmqMessagesUtil.JMS_MESSAGE_HEADER_PREFIX + "JMSPriority", Integer.toString(msg.getJMSPriority()));
+        props.setProperty(AmqMessagesUtil.JMS_MESSAGE_HEADER_PREFIX + "JMSRedelivered", Boolean.toString(msg.getJMSRedelivered()));
+        if (msg.getJMSReplyTo() != null) {
+            props.setProperty(AmqMessagesUtil.JMS_MESSAGE_HEADER_PREFIX + "JMSReplyTo", ((ActiveMQDestination)msg.getJMSReplyTo()).getPhysicalName());
+        }
+        props.setProperty(AmqMessagesUtil.JMS_MESSAGE_HEADER_PREFIX + "JMSTimestamp", Long.toString(msg.getJMSTimestamp()));
+        if (msg.getJMSType() != null) {
+            props.setProperty(AmqMessagesUtil.JMS_MESSAGE_HEADER_PREFIX + "JMSType", msg.getJMSType());
+        }
+
+        // Get custom properties
+        Enumeration e = msg.getPropertyNames();
+        while (e.hasMoreElements()) {
+            String name = (String)e.nextElement();
+            if (msg.getObjectProperty(name) != null) {
+                props.setProperty(AmqMessagesUtil.JMS_MESSAGE_CUSTOM_PREFIX + name, msg.getObjectProperty(name).toString());
+            }
+        }
+
+        return props;
+    }
+
+    /**
+     * Transform an openMBean composite data to a Map
+     * @param data - composite data to transform
+     * @return map object
+     */
+    protected Map transformToMap(CompositeDataSupport data) {
+        Properties props = new Properties();
+
+        String typeName = data.getCompositeType().getTypeName();
+
+        // Retrieve text message
+        if (typeName.equals(ActiveMQTextMessage.class.getName())) {
+            props.setProperty(AmqMessagesUtil.JMS_MESSAGE_BODY_PREFIX + "Text", data.get("Text").toString());
+
+        // Retrieve byte preview
+        } else if (typeName.equals(ActiveMQBytesMessage.class.getName())) {
+            props.setProperty(AmqMessagesUtil.JMS_MESSAGE_BODY_PREFIX + "BodyLength", data.get("BodyLength").toString());
+            props.setProperty(AmqMessagesUtil.JMS_MESSAGE_BODY_PREFIX + "BodyPreview", new String((byte[])data.get("BodyPreview")));
+
+        // Expand content map
+        } else if (typeName.equals(ActiveMQMapMessage.class.getName())) {
+            Map contentMap = (Map)data.get("ContentMap");
+            for (Iterator i=contentMap.keySet().iterator(); i.hasNext();) {
+                String key = (String)i.next();
+                props.setProperty(AmqMessagesUtil.JMS_MESSAGE_BODY_PREFIX + key, contentMap.get(key).toString());
+            }
+
+        // Do nothing
+        } else if (typeName.equals(ActiveMQObjectMessage.class.getName()) ||
+                   typeName.equals(ActiveMQStreamMessage.class.getName()) ||
+                   typeName.equals(ActiveMQMessage.class.getName())) {
+
+        // Unrecognized composite data. Throw exception.
+        } else {
+            throw new IllegalArgumentException("Unrecognized composite data to transform. composite type: " + typeName);
+        }
+
+        // Process the JMS message header values
+        props.setProperty(AmqMessagesUtil.JMS_MESSAGE_HEADER_PREFIX + "JMSCorrelationID", "" + data.get("JMSCorrelationID"));
+        props.setProperty(AmqMessagesUtil.JMS_MESSAGE_HEADER_PREFIX + "JMSDestination",   "" + data.get("JMSDestination"));
+        props.setProperty(AmqMessagesUtil.JMS_MESSAGE_HEADER_PREFIX + "JMSMessageID",     "" + data.get("JMSMessageID"));
+        props.setProperty(AmqMessagesUtil.JMS_MESSAGE_HEADER_PREFIX + "JMSReplyTo",       "" + data.get("JMSReplyTo"));
+        props.setProperty(AmqMessagesUtil.JMS_MESSAGE_HEADER_PREFIX + "JMSType",          "" + data.get("JMSType"));
+        props.setProperty(AmqMessagesUtil.JMS_MESSAGE_HEADER_PREFIX + "JMSDeliveryMode",  "" + data.get("JMSDeliveryMode"));
+        props.setProperty(AmqMessagesUtil.JMS_MESSAGE_HEADER_PREFIX + "JMSExpiration",    "" + data.get("JMSExpiration"));
+        props.setProperty(AmqMessagesUtil.JMS_MESSAGE_HEADER_PREFIX + "JMSPriority",      "" + data.get("JMSPriority"));
+        props.setProperty(AmqMessagesUtil.JMS_MESSAGE_HEADER_PREFIX + "JMSRedelivered",   "" + data.get("JMSRedelivered"));
+        props.setProperty(AmqMessagesUtil.JMS_MESSAGE_HEADER_PREFIX + "JMSTimestamp",     "" + data.get("JMSTimestamp"));
+
+        // Process the JMS custom message properties
+        props.setProperty(AmqMessagesUtil.JMS_MESSAGE_CUSTOM_PREFIX + "Properties", "" + data.get("Properties"));
+
+        return props;
+    }
+}

Propchange: incubator/activemq/trunk/activemq-console/src/main/java/org/apache/activemq/console/filter/MapTransformFilter.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: incubator/activemq/trunk/activemq-console/src/main/java/org/apache/activemq/console/filter/MessagesQueryFilter.java
URL: http://svn.apache.org/viewcvs/incubator/activemq/trunk/activemq-console/src/main/java/org/apache/activemq/console/filter/MessagesQueryFilter.java?rev=379619&r1=379618&r2=379619&view=diff
==============================================================================
--- incubator/activemq/trunk/activemq-console/src/main/java/org/apache/activemq/console/filter/MessagesQueryFilter.java (original)
+++ incubator/activemq/trunk/activemq-console/src/main/java/org/apache/activemq/console/filter/MessagesQueryFilter.java Tue Feb 21 15:12:56 2006
@@ -1,116 +1,116 @@
-/**
- *
- * 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.console.filter;
-
-import javax.management.remote.JMXConnector;
-import javax.management.remote.JMXServiceURL;
-import javax.management.remote.JMXConnectorFactory;
-import javax.management.MBeanServerConnection;
-import javax.management.ObjectName;
-import javax.management.openmbean.CompositeData;
-import java.net.MalformedURLException;
-import java.util.List;
-import java.util.Iterator;
-import java.util.Arrays;
-import java.io.IOException;
-
-public class MessagesQueryFilter extends AbstractQueryFilter {
-
-    private JMXServiceURL jmxServiceUrl;
-    private ObjectName    destName;
-
-    /**
-     * Create a JMS message query filter
-     * @param jmxServiceUrl - JMX service URL to connect to
-     * @param destName - object name query to retrieve the destination
-     */
-    public MessagesQueryFilter(JMXServiceURL jmxServiceUrl, ObjectName destName) {
-        super(null);
-        this.jmxServiceUrl = jmxServiceUrl;
-        this.destName      = destName;
-    }
-
-    /**
-     * Queries the specified destination using the message selector format query
-     * @param queries - message selector queries
-     * @return list messages that matches the selector
-     * @throws Exception
-     */
-    public List query(List queries) throws Exception {
-        String selector = "";
-
-        // Convert to message selector
-        for (Iterator i=queries.iterator(); i.hasNext();) {
-            selector = selector + "(" + i.next().toString() + ") AND ";
-        }
-
-        // Remove last AND
-        if (selector != "") {
-            selector = selector.substring(0, selector.length() - 5);
-        }
-
-        return queryMessages(selector);
-    }
-
-    /**
-     * Query the messages of a queue destination using JMX
-     * @param selector - message selector
-     * @return list of messages that matches the selector
-     * @throws Exception
-     */
-    protected List queryMessages(String selector) throws Exception {
-        JMXConnector connector = createJmxConnector();
-        MBeanServerConnection server = connector.getMBeanServerConnection();
-        CompositeData[] messages = (CompositeData[])server.invoke(destName, "browse", new Object[] {}, new String[] {});
-        connector.close();
-
-        return Arrays.asList(messages);
-    }
-
-    /**
-     * Get the JMX service URL the query is connecting to.
-     * @return JMX service URL
-     */
-    public JMXServiceURL getJmxServiceUrl() {
-        return jmxServiceUrl;
-    }
-
-    /**
-     * Sets the JMX service URL the query is going to connect to.
-     * @param jmxServiceUrl - new JMX service URL
-     */
-    public void setJmxServiceUrl(JMXServiceURL jmxServiceUrl) {
-        this.jmxServiceUrl = jmxServiceUrl;
-    }
-
-    /**
-     * Sets the JMX service URL the query is going to connect to.
-     * @param jmxServiceUrl - new JMX service URL
-     */
-    public void setJmxServiceUrl(String jmxServiceUrl) throws MalformedURLException {
-        setJmxServiceUrl(new JMXServiceURL(jmxServiceUrl));
-    }
-
-    /**
-     * Creates a JMX connector
-     * @return JMX connector
-     * @throws java.io.IOException
-     */
-    protected JMXConnector createJmxConnector() throws IOException {
-        return JMXConnectorFactory.connect(getJmxServiceUrl());
-    }
-}
+/**
+ *
+ * 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.console.filter;
+
+import javax.management.remote.JMXConnector;
+import javax.management.remote.JMXServiceURL;
+import javax.management.remote.JMXConnectorFactory;
+import javax.management.MBeanServerConnection;
+import javax.management.ObjectName;
+import javax.management.openmbean.CompositeData;
+import java.net.MalformedURLException;
+import java.util.List;
+import java.util.Iterator;
+import java.util.Arrays;
+import java.io.IOException;
+
+public class MessagesQueryFilter extends AbstractQueryFilter {
+
+    private JMXServiceURL jmxServiceUrl;
+    private ObjectName    destName;
+
+    /**
+     * Create a JMS message query filter
+     * @param jmxServiceUrl - JMX service URL to connect to
+     * @param destName - object name query to retrieve the destination
+     */
+    public MessagesQueryFilter(JMXServiceURL jmxServiceUrl, ObjectName destName) {
+        super(null);
+        this.jmxServiceUrl = jmxServiceUrl;
+        this.destName      = destName;
+    }
+
+    /**
+     * Queries the specified destination using the message selector format query
+     * @param queries - message selector queries
+     * @return list messages that matches the selector
+     * @throws Exception
+     */
+    public List query(List queries) throws Exception {
+        String selector = "";
+
+        // Convert to message selector
+        for (Iterator i=queries.iterator(); i.hasNext();) {
+            selector = selector + "(" + i.next().toString() + ") AND ";
+        }
+
+        // Remove last AND
+        if (selector != "") {
+            selector = selector.substring(0, selector.length() - 5);
+        }
+
+        return queryMessages(selector);
+    }
+
+    /**
+     * Query the messages of a queue destination using JMX
+     * @param selector - message selector
+     * @return list of messages that matches the selector
+     * @throws Exception
+     */
+    protected List queryMessages(String selector) throws Exception {
+        JMXConnector connector = createJmxConnector();
+        MBeanServerConnection server = connector.getMBeanServerConnection();
+        CompositeData[] messages = (CompositeData[])server.invoke(destName, "browse", new Object[] {}, new String[] {});
+        connector.close();
+
+        return Arrays.asList(messages);
+    }
+
+    /**
+     * Get the JMX service URL the query is connecting to.
+     * @return JMX service URL
+     */
+    public JMXServiceURL getJmxServiceUrl() {
+        return jmxServiceUrl;
+    }
+
+    /**
+     * Sets the JMX service URL the query is going to connect to.
+     * @param jmxServiceUrl - new JMX service URL
+     */
+    public void setJmxServiceUrl(JMXServiceURL jmxServiceUrl) {
+        this.jmxServiceUrl = jmxServiceUrl;
+    }
+
+    /**
+     * Sets the JMX service URL the query is going to connect to.
+     * @param jmxServiceUrl - new JMX service URL
+     */
+    public void setJmxServiceUrl(String jmxServiceUrl) throws MalformedURLException {
+        setJmxServiceUrl(new JMXServiceURL(jmxServiceUrl));
+    }
+
+    /**
+     * Creates a JMX connector
+     * @return JMX connector
+     * @throws java.io.IOException
+     */
+    protected JMXConnector createJmxConnector() throws IOException {
+        return JMXConnectorFactory.connect(getJmxServiceUrl());
+    }
+}

Propchange: incubator/activemq/trunk/activemq-console/src/main/java/org/apache/activemq/console/filter/MessagesQueryFilter.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: incubator/activemq/trunk/activemq-console/src/main/java/org/apache/activemq/console/filter/PropertiesViewFilter.java
URL: http://svn.apache.org/viewcvs/incubator/activemq/trunk/activemq-console/src/main/java/org/apache/activemq/console/filter/PropertiesViewFilter.java?rev=379619&r1=379618&r2=379619&view=diff
==============================================================================
--- incubator/activemq/trunk/activemq-console/src/main/java/org/apache/activemq/console/filter/PropertiesViewFilter.java (original)
+++ incubator/activemq/trunk/activemq-console/src/main/java/org/apache/activemq/console/filter/PropertiesViewFilter.java Tue Feb 21 15:12:56 2006
@@ -1,118 +1,118 @@
-/**
- *
- * 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.console.filter;
-
-import java.util.Set;
-import java.util.Iterator;
-import java.util.Map;
-import java.util.HashMap;
-import java.util.Collection;
-import java.util.ArrayList;
-import java.util.List;
-
-public class PropertiesViewFilter implements QueryFilter {
-    protected QueryFilter next;
-    protected Set viewFilter;
-
-    /**
-     * Creates a filter that will select the properties of a map object to view
-     * @param next - the next query filter that will return a collection of maps
-     */
-    public PropertiesViewFilter(QueryFilter next) {
-        this(null, next);
-    }
-
-    /**
-     * Creates a filter that will select the properties of a map object to view
-     * @param viewFilter - the properties to view
-     * @param next - the next query filter that will return a collection of maps
-     */
-    public PropertiesViewFilter(Set viewFilter, QueryFilter next) {
-        this.next = next;
-        this.viewFilter = viewFilter;
-    }
-
-    /**
-     * Filter the properties to view of the query result
-     * @param query - the query string
-     * @return list of objects that has been view filtered
-     */
-    public List query(String query) throws Exception {
-        return filterViewCollection(next.query(query), viewFilter);
-    }
-
-    /**
-     * Filter the properties to view of the query result
-     * @param queries - the query map
-     * @return list of objects that has been view filtered
-     * @throws Exception
-     */
-    public List query(List queries) throws Exception {
-        return filterViewCollection(next.query(queries), viewFilter);
-    }
-
-    /**
-     * Filter the view of each element in the collection
-     * @param result - the lists to filter the view from
-     * @param viewFilter - the views to select
-     * @return lsit of objects whose view has been filtered
-     */
-    protected List filterViewCollection(Collection result, Set viewFilter) {
-        // Use a list to allow duplicate entries
-        List newCollection = new ArrayList();
-
-        for (Iterator i=result.iterator(); i.hasNext();) {
-            newCollection.add(filterView((Map)i.next()));
-        }
-
-        return newCollection;
-    }
-
-    /**
-     * Select only the attributes to view from the map data
-     * @param data - data to filter the view from
-     * @return - data with the view filtered
-     */
-    protected Map filterView(Map data) {
-        // If no view specified, display all attributes
-        if (viewFilter == null || viewFilter.isEmpty()) {
-            return data;
-        }
-
-        Map newData;
-        try {
-            // Lets try to use the same class as the original
-            newData = (Map)data.getClass().newInstance();
-        } catch (Exception e) {
-            // Lets use a default HashMap
-            newData = new HashMap();
-        }
-
-        // Filter the keys to view
-        for (Iterator i=viewFilter.iterator(); i.hasNext();) {
-            Object key = i.next();
-            Object val = data.get(key);
-
-            if (val != null) {
-                newData.put(key, val);
-            }
-        }
-
-        return newData;
-    }
-
-}
+/**
+ *
+ * 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.console.filter;
+
+import java.util.Set;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.HashMap;
+import java.util.Collection;
+import java.util.ArrayList;
+import java.util.List;
+
+public class PropertiesViewFilter implements QueryFilter {
+    protected QueryFilter next;
+    protected Set viewFilter;
+
+    /**
+     * Creates a filter that will select the properties of a map object to view
+     * @param next - the next query filter that will return a collection of maps
+     */
+    public PropertiesViewFilter(QueryFilter next) {
+        this(null, next);
+    }
+
+    /**
+     * Creates a filter that will select the properties of a map object to view
+     * @param viewFilter - the properties to view
+     * @param next - the next query filter that will return a collection of maps
+     */
+    public PropertiesViewFilter(Set viewFilter, QueryFilter next) {
+        this.next = next;
+        this.viewFilter = viewFilter;
+    }
+
+    /**
+     * Filter the properties to view of the query result
+     * @param query - the query string
+     * @return list of objects that has been view filtered
+     */
+    public List query(String query) throws Exception {
+        return filterViewCollection(next.query(query), viewFilter);
+    }
+
+    /**
+     * Filter the properties to view of the query result
+     * @param queries - the query map
+     * @return list of objects that has been view filtered
+     * @throws Exception
+     */
+    public List query(List queries) throws Exception {
+        return filterViewCollection(next.query(queries), viewFilter);
+    }
+
+    /**
+     * Filter the view of each element in the collection
+     * @param result - the lists to filter the view from
+     * @param viewFilter - the views to select
+     * @return lsit of objects whose view has been filtered
+     */
+    protected List filterViewCollection(Collection result, Set viewFilter) {
+        // Use a list to allow duplicate entries
+        List newCollection = new ArrayList();
+
+        for (Iterator i=result.iterator(); i.hasNext();) {
+            newCollection.add(filterView((Map)i.next()));
+        }
+
+        return newCollection;
+    }
+
+    /**
+     * Select only the attributes to view from the map data
+     * @param data - data to filter the view from
+     * @return - data with the view filtered
+     */
+    protected Map filterView(Map data) {
+        // If no view specified, display all attributes
+        if (viewFilter == null || viewFilter.isEmpty()) {
+            return data;
+        }
+
+        Map newData;
+        try {
+            // Lets try to use the same class as the original
+            newData = (Map)data.getClass().newInstance();
+        } catch (Exception e) {
+            // Lets use a default HashMap
+            newData = new HashMap();
+        }
+
+        // Filter the keys to view
+        for (Iterator i=viewFilter.iterator(); i.hasNext();) {
+            Object key = i.next();
+            Object val = data.get(key);
+
+            if (val != null) {
+                newData.put(key, val);
+            }
+        }
+
+        return newData;
+    }
+
+}

Propchange: incubator/activemq/trunk/activemq-console/src/main/java/org/apache/activemq/console/filter/PropertiesViewFilter.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: incubator/activemq/trunk/activemq-console/src/main/java/org/apache/activemq/console/filter/QueryFilter.java
URL: http://svn.apache.org/viewcvs/incubator/activemq/trunk/activemq-console/src/main/java/org/apache/activemq/console/filter/QueryFilter.java?rev=379619&r1=379618&r2=379619&view=diff
==============================================================================
--- incubator/activemq/trunk/activemq-console/src/main/java/org/apache/activemq/console/filter/QueryFilter.java (original)
+++ incubator/activemq/trunk/activemq-console/src/main/java/org/apache/activemq/console/filter/QueryFilter.java Tue Feb 21 15:12:56 2006
@@ -1,39 +1,39 @@
-/**
- *
- * 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.console.filter;
-
-import java.util.List;
-
-public interface QueryFilter {
-    public static final String QUERY_DELIMETER = ",";
-
-    /**
-     * Interface for querying
-     * @param queryStr - the query string
-     * @return collection of objects that satisfies the query
-     * @throws Exception
-     */
-    public List query(String queryStr) throws Exception;
-
-    /**
-     * Interface for querying
-     * @param queries - list of individual queries
-     * @return collection of objects that satisfies the query
-     * @throws Exception
-     */
-    public List query(List queries) throws Exception;
-}
+/**
+ *
+ * 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.console.filter;
+
+import java.util.List;
+
+public interface QueryFilter {
+    public static final String QUERY_DELIMETER = ",";
+
+    /**
+     * Interface for querying
+     * @param queryStr - the query string
+     * @return collection of objects that satisfies the query
+     * @throws Exception
+     */
+    public List query(String queryStr) throws Exception;
+
+    /**
+     * Interface for querying
+     * @param queries - list of individual queries
+     * @return collection of objects that satisfies the query
+     * @throws Exception
+     */
+    public List query(List queries) throws Exception;
+}

Propchange: incubator/activemq/trunk/activemq-console/src/main/java/org/apache/activemq/console/filter/QueryFilter.java
------------------------------------------------------------------------------
    svn:eol-style = native



Mime
View raw message