geode-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dschnei...@apache.org
Subject [12/18] incubator-geode git commit: GEODE-80: Imported databrowser from geode-1.0.0-SNAPSHOT-2.src.tar
Date Mon, 06 Jul 2015 21:47:37 GMT
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/e2ccf3da/databrowser/src/com/gemstone/gemfire/mgmt/DataBrowser/prefs/DataBrowserPreferences.java
----------------------------------------------------------------------
diff --git a/databrowser/src/com/gemstone/gemfire/mgmt/DataBrowser/prefs/DataBrowserPreferences.java b/databrowser/src/com/gemstone/gemfire/mgmt/DataBrowser/prefs/DataBrowserPreferences.java
new file mode 100644
index 0000000..507cfaf
--- /dev/null
+++ b/databrowser/src/com/gemstone/gemfire/mgmt/DataBrowser/prefs/DataBrowserPreferences.java
@@ -0,0 +1,473 @@
+/*
+ * ========================================================================= (c)
+ * Copyright 2002-2011, GemStone Systems, Inc. All Rights Reserved. 1260 NW
+ * Waterhouse Ave., Suite 200, Beaverton, OR 97006 All Rights Reserved.
+ * ========================================================================
+ */
+package com.gemstone.gemfire.mgmt.DataBrowser.prefs;
+
+import java.util.ArrayList;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.StringTokenizer;
+import java.util.prefs.BackingStoreException;
+import java.util.prefs.Preferences;
+
+import com.gemstone.gemfire.mgmt.DataBrowser.app.VersionInfo;
+import com.gemstone.gemfire.mgmt.DataBrowser.ui.SecurityPropComposite.SecurityProp;
+import com.gemstone.gemfire.mgmt.DataBrowser.utils.LogUtil;
+
+
+/**
+ * This class represents the Preferences to be set for Data Browser. 
+ * 
+ * @author mjha
+ */
+public class DataBrowserPreferences extends PreferencesAdapter {
+  // Connection Preferences key
+  public static final String KEY_NO_CON_RETRY_ATTEMPTS          = "connection-retry-attempts";
+
+  public static final String KEY_CON_RETRY_INTERVAL             = "connection-retry-interval";
+
+  public static final String KEY_CONNECTION_HOSTS               = "connection-default-host";
+
+  public static final String KEY_CONNECTION_PORTS               = "connection-default-port";
+
+  public static final String KEY_MRU_HOST_PORT_LIST_LIMIT       = "mru-host-port-list-limit";
+
+  public static final String KEY_CONNECTION_TIMEOUT             = "connection-timeout";
+
+  // Query Preferences key
+  public static final String KEY_QUERY_TIMEOUT                  = "query-timeout"; //TODO: This property is currently unused. Why was it added?
+  
+  public static final String KEY_SCOKET_READ_TIMEOUT            = "socket-read-timeout";
+
+  public static final String KEY_QUERY_RESULT_LIMIT             = "query-result-limit";
+
+  public static final String KEY_RESULT_AUTO_SCROLL             = "result-auto-scroll";
+
+  public static final String KEY_ENFORCE_LIMIT_TO_QUERY_RESULT  = "enforce-limit-to-query";
+
+  // Security Preferences key
+  public static final String KEY_SEURITY_PLUGIN                 = "security-plugin";
+
+  public static final String KEY_SEURITY_PROPS_HIDDEN           = "security-proprties-hidden";
+
+  // Misc Preferences key
+  public static final String KEY_LOGGING_LEVEL                  = "logging-level";
+
+  public static final String KEY_DS_REFRESH_INTERVAL            = "ds-refresh-interval";
+
+  public static final String KEY_APPLICATION_CLASSES            = "application-classes";
+
+  public static final String KEY_LOG_DIR                        = "log-dir";
+  
+  public static final String KEY_LOG_FILE_SIZE                  = "log-file-size"; //In MB
+  
+  public static final String KEY_LOG_FILE_COUNT                 = "log-file-count";
+  
+  //Prefernce node
+  private static final String CURRENT_USER                      = System.getProperty("user.name");
+
+  private static final Preferences USER_ROOT                    = Preferences.userRoot();
+  
+  private static final String GEMSTONE_NAME                     = "GemStone";
+  
+  private static final String DATA_BROWSER_NAME                 = "Data Browser";
+  
+  private static final String DATA_BROWSER_VERSION              = VersionInfo.getInstance().toString();
+
+  private static final Preferences DATA_BROWSER_NODE            = USER_ROOT.node(GEMSTONE_NAME).node(DATA_BROWSER_NAME).node(DATA_BROWSER_VERSION);
+  
+  private static final Preferences CURRENT_USER_NODE            = DATA_BROWSER_NODE.node(CURRENT_USER);
+  
+  private static final Preferences SECURITY_NODE                = CURRENT_USER_NODE.node("Security-Prop");
+  
+  private static final Preferences APPLICATION_JAR              = CURRENT_USER_NODE.node("Application-Jars");
+
+  private static DataBrowserPreferences dbPrefernces_           = new DataBrowserPreferences(CURRENT_USER_NODE);
+  
+  private static DataBrowserPreferences dbSecurityProps_        = new DataBrowserPreferences(SECURITY_NODE);
+  
+  private static DataBrowserPreferences dbApplicationJars_      = new DataBrowserPreferences(APPLICATION_JAR);
+  
+  /**
+   * Fix added for BUG711 to make sure that logging configuration is loaded only once during the application startup and any 
+   * changes to the logging preferences are activated only after tool restart.
+   **/
+  private static String log_dir                                 = null;
+  
+  private static String log_level                               = null;  
+  
+  private static int log_file_size                              = DefaultPreferences.DEFAULT_LOG_FILE_SIZE;   
+  
+  private static int log_file_count                             = DefaultPreferences.DEFAULT_LOG_FILE_COUNT;   
+  
+  static {
+    try {
+      log_dir = dbPrefernces_.get(KEY_LOG_DIR, DefaultPreferences.DEFAULT_LOG_DIR);
+    } catch (Throwable e) {
+      //System.out.println("Failed to get the logging directory preference :"+e); // Since the Logger is not yet initialized...
+      log_dir = DefaultPreferences.DEFAULT_LOG_DIR;
+    }
+    
+    try {
+      log_level = dbPrefernces_.get(KEY_LOGGING_LEVEL, DefaultPreferences.DEFAULT_LOGGING_LEVEL);
+    } catch (Throwable e) {
+      //System.out.println("Failed to get the log level preference :"+e); // Since the Logger is not yet initialized...
+      log_level = DefaultPreferences.DEFAULT_LOGGING_LEVEL;
+    }
+    
+    try {
+      log_file_size = dbPrefernces_.getInt(KEY_LOG_FILE_SIZE, DefaultPreferences.DEFAULT_LOG_FILE_SIZE);
+    } catch (Throwable e) {
+      //System.out.println("Failed to get the log file size preference :"+e); // Since the Logger is not yet initialized...
+      log_file_size = DefaultPreferences.DEFAULT_LOG_FILE_SIZE;
+    }
+    
+    try {
+      log_file_count = dbPrefernces_.getInt(KEY_LOG_FILE_COUNT, DefaultPreferences.DEFAULT_LOG_FILE_COUNT);
+    } catch (Throwable e) {
+      //System.out.println("Failed to get the log file count preference :"+e); // Since the Logger is not yet initialized...
+      log_file_count = DefaultPreferences.DEFAULT_LOG_FILE_COUNT;
+    }
+  }
+  
+  private DataBrowserPreferences(Preferences toBeWrapped) {
+    super(toBeWrapped);
+  }
+  
+  public static void setConRetryAttempts(int val) {
+    dbPrefernces_.put(KEY_NO_CON_RETRY_ATTEMPTS, String.valueOf(val));
+  }
+
+  public static int getConRetryAttempts() {
+    return dbPrefernces_.getInt(KEY_NO_CON_RETRY_ATTEMPTS, DefaultPreferences.DEFAULT_NO_CON_RETRY_ATTEMPTS);
+  }
+  
+  public static void setDefaultConRetryAttempts() {
+    dbPrefernces_.put(KEY_NO_CON_RETRY_ATTEMPTS, String.valueOf(DefaultPreferences.DEFAULT_NO_CON_RETRY_ATTEMPTS));
+  }
+
+  public static void setConRetryInterval(long val) {
+    dbPrefernces_.put(KEY_CON_RETRY_INTERVAL, String.valueOf(val));
+  }
+
+  public static long getConRetryInterval() {
+    return dbPrefernces_.getLong(KEY_CON_RETRY_INTERVAL, DefaultPreferences.DEFAULT_CON_RETRY_INTERVAL);
+  }
+  
+  public static void setDefaultConRetryInterval() {
+    dbPrefernces_.put(KEY_CON_RETRY_INTERVAL, String.valueOf(DefaultPreferences.DEFAULT_CON_RETRY_INTERVAL));
+  }
+  
+  public static long getConnectionTimeoutInterval() {
+    return dbPrefernces_.getLong(KEY_CONNECTION_TIMEOUT, DefaultPreferences.DEFAULT_CONNECTION_TIMEOUT);
+  }
+
+  public static void setConnectionTimeoutInterval(long val) {
+    dbPrefernces_.put(KEY_CONNECTION_TIMEOUT, String.valueOf(val));
+  }
+  
+  public static void setDefaultConnectionTimeoutInterval() {
+    dbPrefernces_.put(KEY_CONNECTION_TIMEOUT, String.valueOf(DefaultPreferences.DEFAULT_CONNECTION_TIMEOUT));
+  }
+  
+  public static int getSocketReadTimeoutInterval() {
+    return dbPrefernces_.getInt(KEY_SCOKET_READ_TIMEOUT, DefaultPreferences.DEFAULT_SOCKET_READ_TIMEOUT);
+  }
+
+  public static void setSocketReadTimeoutInterval(int val) {
+    dbPrefernces_.put(KEY_SCOKET_READ_TIMEOUT, String.valueOf(val));
+  }
+  
+  public static void setDefaultSocketReadTimeoutInterval() {
+    dbPrefernces_.put(KEY_SCOKET_READ_TIMEOUT, String.valueOf(DefaultPreferences.DEFAULT_SOCKET_READ_TIMEOUT));
+  }
+  
+  public static void setConnectionMRUHListLimit(int val) {
+    dbPrefernces_.put(KEY_MRU_HOST_PORT_LIST_LIMIT, String.valueOf(val));
+  }
+  
+  public static int getConnectionMRUHListLimit() {
+   return dbPrefernces_.getInt(KEY_MRU_HOST_PORT_LIST_LIMIT,DefaultPreferences.DEFAULT_MRU_HOST_PORT_LIST_LIMIT);
+  }
+  
+  public static void setDefaultConnectionMRUHListLimit() {
+    dbPrefernces_.put(KEY_MRU_HOST_PORT_LIST_LIMIT, String.valueOf(DefaultPreferences.DEFAULT_MRU_HOST_PORT_LIST_LIMIT));
+  }
+  
+  public static void setConnectionMRUPorts(LinkedList<String> val) {
+    dbPrefernces_.put(KEY_CONNECTION_PORTS, 
+                              getSelectedStringSetAsCommaSeperatedString(val));
+  }
+  
+  public static LinkedList<String> getConnectionMRUPorts() {
+    String value = dbPrefernces_.get(KEY_CONNECTION_PORTS, 
+                                            DefaultPreferences.DEFAULT_CONNECTION_PORTS);
+    return getCommaSeperatedStringAsStringList(value);
+  }
+  
+  public static LinkedList<String> getConnectionMRUHosts() {
+    String value = dbPrefernces_.get(KEY_CONNECTION_HOSTS, 
+                                        DefaultPreferences.DEFAULT_CONNECTION_HOSTS);
+    return getCommaSeperatedStringAsStringList(value);
+  }
+  
+  public static void setConnectionMRUHosts(LinkedList<String> val) {
+    dbPrefernces_.put(KEY_CONNECTION_HOSTS, 
+                              getSelectedStringSetAsCommaSeperatedString(val));
+  }
+  
+  public static boolean getEnforceLimitToQuery() {
+    return dbPrefernces_.getBoolean(KEY_ENFORCE_LIMIT_TO_QUERY_RESULT, DefaultPreferences.DEFAULT_ENFORCE_LIMIT_TO_QUERY_RESULT);
+  }
+  
+  public static void setEnforceLimitToQuery(boolean limit) {
+    dbPrefernces_.putBoolean(KEY_ENFORCE_LIMIT_TO_QUERY_RESULT, Boolean.valueOf(limit));
+  }
+  
+  public static void setDefaultEnforceLimitToQuery() {
+    dbPrefernces_.putBoolean(KEY_ENFORCE_LIMIT_TO_QUERY_RESULT, Boolean.valueOf(DefaultPreferences.DEFAULT_ENFORCE_LIMIT_TO_QUERY_RESULT));
+  }
+  
+  public static long getQueryLimit() {
+    return dbPrefernces_.getLong(KEY_QUERY_RESULT_LIMIT, DefaultPreferences.DEFAULT_QUERY_RESULT_LIMIT);
+  }
+  
+  public static void setQueryLimit(long limit) {
+    dbPrefernces_.put(KEY_QUERY_RESULT_LIMIT, String.valueOf(limit));
+  }
+  
+  public static void setDefaultQueryLimit() {
+    dbPrefernces_.put(KEY_QUERY_RESULT_LIMIT, String.valueOf(DefaultPreferences.DEFAULT_QUERY_RESULT_LIMIT));
+  }
+  
+  public static long getQueryExecutionTimeout() {
+    return dbPrefernces_.getLong(KEY_QUERY_TIMEOUT, DefaultPreferences.DEFAULT_QUERY_TIMEOUT);
+  }
+  
+  public static void setQueryExecutionTimeout(long interval) {
+    dbPrefernces_.put(KEY_QUERY_TIMEOUT, String.valueOf(interval));
+  }
+  
+  public static void setDefaultQueryExecutionTimeout() {
+    dbPrefernces_.put(KEY_QUERY_TIMEOUT, String.valueOf(DefaultPreferences.DEFAULT_QUERY_TIMEOUT));
+  }
+  
+  public static boolean getResultAutoScroll() {
+    return dbPrefernces_.getBoolean(KEY_RESULT_AUTO_SCROLL, DefaultPreferences.DEFAULT_RESULT_AUTO_SCROLL);
+  }
+  
+  public static void setResultAutoScroll(boolean auto) {
+    dbPrefernces_.putBoolean(KEY_RESULT_AUTO_SCROLL, Boolean.valueOf(auto));
+  }
+  
+  public static void setDefaultResultAutoScroll() {
+    dbPrefernces_.putBoolean(KEY_RESULT_AUTO_SCROLL, Boolean.valueOf(DefaultPreferences.DEFAULT_RESULT_AUTO_SCROLL));
+  }
+  
+  public static String getSecurityPlugin() {
+    return dbPrefernces_.get(KEY_SEURITY_PLUGIN, DefaultPreferences.DEFAULT_SEURITY_PLUGIN);
+  }
+  
+  public static void setSecurityPlugin(String plugin) {
+    dbPrefernces_.put(KEY_SEURITY_PLUGIN, plugin);
+  }
+  
+  public static void setDefaultSecurityPlugin() {
+    dbPrefernces_.put(KEY_SEURITY_PLUGIN, DefaultPreferences.DEFAULT_SEURITY_PLUGIN);
+  }
+  
+  public static boolean getSecurityPropsHidden() {
+    return dbPrefernces_.getBoolean(KEY_SEURITY_PROPS_HIDDEN, DefaultPreferences.DEFAULT_SEURITY_PROPS_HIDDEN);
+  }
+  
+  public static void setSecurityPropsHidden(boolean hidden) {
+    dbPrefernces_.putBoolean(KEY_SEURITY_PROPS_HIDDEN, hidden);
+  }
+  
+  public static void setDefaultSecurityPropsHidden() {
+    dbPrefernces_.putBoolean(KEY_SEURITY_PROPS_HIDDEN, DefaultPreferences.DEFAULT_SEURITY_PROPS_HIDDEN);
+  }
+  
+  public static List<SecurityProp> getSecurityProperties() throws BackingStoreException {
+    String[] childrenNames = dbSecurityProps_.keys();
+    List<SecurityProp> props = new ArrayList<SecurityProp>();
+    boolean hidden = getSecurityPropsHidden();
+    for (int i = 0; i < childrenNames.length; i++) {
+      String key = childrenNames[i];
+      String value = dbSecurityProps_.get(key, null);
+      if(value != null){
+        SecurityProp prop = new SecurityProp(key,value,hidden);
+        props.add(prop);
+      }
+    }
+    return props;
+  }
+  
+  public static void setSecurityProperties(List<SecurityProp> props) {
+    try {
+      dbSecurityProps_.clear();
+      
+      for (SecurityProp prop : props) {
+        String key = prop.getKey();
+        String value = prop.getValue();
+        dbSecurityProps_.put(key, value);
+      }
+    }
+    catch (BackingStoreException e) {
+     LogUtil.warning("Exception while saving security preferences.", e); 
+    }
+  }
+  
+  public static void setDefaultSecurityProperties() throws BackingStoreException {
+    List<SecurityProp> defaultSeurityProperties = DefaultPreferences.DEFAULT_SEURITY_PROPERTIES;
+    if(defaultSeurityProperties != null)
+      setSecurityProperties(defaultSeurityProperties);
+    else{
+      String[] childrenNames = dbSecurityProps_.keys();
+      for (int i = 0; i < childrenNames.length; i++) {
+        String key = childrenNames[i];
+        dbSecurityProps_.remove(key);
+      }
+    }
+  }
+    
+  public static void save() throws BackingStoreException{
+    dbPrefernces_.flush();
+    dbSecurityProps_.flush();
+  }
+  
+  public static String getLogDirectory() {
+    return log_dir;
+  }
+  
+  public static String getLogDirectoryPref() {
+    return dbPrefernces_.get(KEY_LOG_DIR, DefaultPreferences.DEFAULT_LOG_DIR);
+  }
+  
+  public static void setLogDirectory(String dir) {
+    dbPrefernces_.put(KEY_LOG_DIR, dir);
+  }
+  
+  public static void setDefaultLogDirectory() {
+    dbPrefernces_.put(KEY_LOG_DIR, DefaultPreferences.DEFAULT_LOG_DIR);
+  }
+    
+  public static String getLoggingLevel() {
+    return log_level;
+  }
+  
+  public static String getLoggingLevelPref() {
+    return dbPrefernces_.get(KEY_LOGGING_LEVEL, DefaultPreferences.DEFAULT_LOGGING_LEVEL);
+  }
+  
+  public static void setLoggingLevel(String level) {
+    dbPrefernces_.put(KEY_LOGGING_LEVEL, level);
+  }
+  
+  public static void setDefaultLoggingLevel() {
+    dbPrefernces_.put(KEY_LOGGING_LEVEL, DefaultPreferences.DEFAULT_LOGGING_LEVEL);
+  }
+  
+  public static int getLogFileSize() {
+    return log_file_size;
+  }
+  
+  public static int getLogFileSizePref() {
+    return dbPrefernces_.getInt(KEY_LOG_FILE_SIZE, DefaultPreferences.DEFAULT_LOG_FILE_SIZE);
+  }
+  
+  public static void setLogFileSize(int size) {
+    dbPrefernces_.putInt(KEY_LOG_FILE_SIZE, size);
+  }
+  
+  public static void setDefaultLogFileSize() {
+    dbPrefernces_.putInt(KEY_LOG_FILE_SIZE, DefaultPreferences.DEFAULT_LOG_FILE_SIZE);
+  }
+
+  public static int getLogFileCount() {
+    return log_file_count;
+  }
+  
+  public static int getLogFileCountPref() {
+    return dbPrefernces_.getInt(KEY_LOG_FILE_COUNT, DefaultPreferences.DEFAULT_LOG_FILE_COUNT);
+  }
+  
+  public static void setLogFileCount(int count) {
+    dbPrefernces_.putInt(KEY_LOG_FILE_COUNT, count);
+  }
+  
+  public static void setDefaultLogFileCount() {
+    dbPrefernces_.putInt(KEY_LOG_FILE_COUNT, DefaultPreferences.DEFAULT_LOG_FILE_COUNT);
+  }
+  
+  public static long getDSRefreshInterval() {
+    return dbPrefernces_.getLong(KEY_DS_REFRESH_INTERVAL, DefaultPreferences.DEFAULT_DS_REFRESH_INTERVAL);
+  }
+  
+  public static void setDSRefreshInterval(long interval) {
+    dbPrefernces_.put(KEY_DS_REFRESH_INTERVAL, String.valueOf(interval));
+  }
+  
+  public static void setDefaultDSRefreshInterval() {
+    dbPrefernces_.put(KEY_DS_REFRESH_INTERVAL, String.valueOf(DefaultPreferences.DEFAULT_DS_REFRESH_INTERVAL));
+  }
+  
+  public static String[] getApplicationClasses() {
+    String[] keys;
+    String[]applicationClasses = new String[0];
+    try {
+      keys = dbApplicationJars_.keys();
+      applicationClasses = new String[keys.length];
+      for (int i = 0; i < keys.length; i++) {
+        applicationClasses[i]= dbApplicationJars_.get(keys[i], null);
+      }
+    }
+    catch (BackingStoreException e) {
+      LogUtil.warning("Exception while fetching application class from prefrences.", e); 
+    }
+    
+    return applicationClasses;
+  }
+  
+  public static void setApplicationClasses(String[] jars){
+    try {
+      dbApplicationJars_.clear();
+      java.util.List<String> jarList = new ArrayList<String>();
+      for (int i = 0; i < jars.length; i++) {
+        jarList.add(jars[i]);
+        dbApplicationJars_.put("ApplicationJar" + i, jars[i]);
+      }
+    }
+    catch (BackingStoreException e) {
+      LogUtil.warning("Exception while saving application class.", e); 
+     }
+  }
+  
+  public static void setDefaultApplicationClasses() {
+    setApplicationClasses(DefaultPreferences.DEFAULT_APPLICATION_CLASSES);
+  }
+  
+  private static String getSelectedStringSetAsCommaSeperatedString(List<String> selections) {
+    StringBuffer buf = new StringBuffer();
+    for (String next: selections) {
+      buf.append(next + ",");
+    }
+    return buf.toString();
+  }
+
+  private static LinkedList<String> getCommaSeperatedStringAsStringList(String selection) {
+    LinkedList<String> list = new LinkedList<String>();
+    StringTokenizer tokenizer = new StringTokenizer(selection, ",");
+    int limit = getConnectionMRUHListLimit();
+    int index = 0;
+    while (tokenizer.hasMoreTokens() && (index < limit)) {
+      String info = tokenizer.nextToken().trim();
+      list.add(info);
+      index++;
+    }
+    return list;
+  }
+}

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/e2ccf3da/databrowser/src/com/gemstone/gemfire/mgmt/DataBrowser/prefs/DefaultPreferences.java
----------------------------------------------------------------------
diff --git a/databrowser/src/com/gemstone/gemfire/mgmt/DataBrowser/prefs/DefaultPreferences.java b/databrowser/src/com/gemstone/gemfire/mgmt/DataBrowser/prefs/DefaultPreferences.java
new file mode 100644
index 0000000..5d31be6
--- /dev/null
+++ b/databrowser/src/com/gemstone/gemfire/mgmt/DataBrowser/prefs/DefaultPreferences.java
@@ -0,0 +1,109 @@
+/*
+ * ========================================================================= (c)
+ * Copyright 2002-2011, GemStone Systems, Inc. All Rights Reserved. 1260 NW
+ * Waterhouse Ave., Suite 200, Beaverton, OR 97006 All Rights Reserved.
+ * ========================================================================
+ */
+package com.gemstone.gemfire.mgmt.DataBrowser.prefs;
+
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.List;
+
+import com.gemstone.gemfire.admin.jmx.AgentConfig;
+import com.gemstone.gemfire.cache.client.PoolFactory;
+import com.gemstone.gemfire.mgmt.DataBrowser.ui.SecurityPropComposite.SecurityProp;
+import com.gemstone.gemfire.mgmt.DataBrowser.utils.LogUtil;
+
+
+/**
+ * This class represents the Defaults Preferences to be set for Data Browser
+ *
+ * @author mjha
+ */
+public class DefaultPreferences implements Serializable {
+  private static final long serialVersionUID                            = -8501486898786022599L;
+
+  // Connection Preferences
+  public static final int DEFAULT_NO_CON_RETRY_ATTEMPTS                 = 5;
+
+  public static final long DEFAULT_CON_RETRY_INTERVAL                    = 2000;
+
+  public static final String DEFAULT_CONNECTION_HOSTS                   = "localhost";
+
+  public static final String DEFAULT_CONNECTION_PORTS                   = String.valueOf(AgentConfig.DEFAULT_RMI_PORT);
+
+  public static final int DEFAULT_MRU_HOST_PORT_LIST_LIMIT              = 5;
+
+  public static final long DEFAULT_CONNECTION_TIMEOUT                   = 60000;
+  
+  public static final int DEFAULT_SOCKET_READ_TIMEOUT                   = PoolFactory.DEFAULT_READ_TIMEOUT;
+
+  // Query Preferences
+  public static final long DEFAULT_QUERY_TIMEOUT                        = 60000;
+
+  public static final long DEFAULT_QUERY_RESULT_LIMIT                   = 1000;
+
+  public static final boolean DEFAULT_RESULT_AUTO_SCROLL                = true;
+
+  public static final boolean DEFAULT_ENFORCE_LIMIT_TO_QUERY_RESULT     = true;
+
+  // Security Preferences
+  public static final String DEFAULT_SEURITY_PLUGIN                     = "";
+
+  public static final List<SecurityProp> DEFAULT_SEURITY_PROPERTIES     = new ArrayList<SecurityProp>();
+
+  public static final boolean DEFAULT_SEURITY_PROPS_HIDDEN              = false;
+
+  // Misc Preferences
+  public static final String DEFAULT_LOGGING_LEVEL                      = LogUtil.LOG_LEVEL_INFO.getLocalizedName();
+
+  public static final long DEFAULT_DS_REFRESH_INTERVAL                  = 60000;
+
+  public static final String[] DEFAULT_APPLICATION_CLASSES                = new String[0];
+
+  private static final String ENV_FILE_SYS_SEPARATOR                    = System
+                                                                            .getProperty("file.separator");
+
+  private static final String ENV_JAVA_LOGDIR                           = System.getProperty("log.dir");
+
+  private static final String ENV_USER_HOME                             = System.getProperty("user.home");
+
+  private static final String ENV_CWD                                   = System.getProperty("user.dir");
+
+  private static final String ENV_JAVA_TMPDIR                           = System.getProperty("java.io.tmpdir");
+
+  public static final String DEFAULT_LOG_DIR;
+
+  public static final int DEFAULT_LOG_FILE_SIZE                         = 1  ; //In MB
+  
+  public static final int  DEFAULT_LOG_FILE_COUNT                      = 10;
+  
+  static{
+    String logDir = ENV_JAVA_LOGDIR;
+    if (null == logDir || 0 == logDir.length()) {
+      logDir = ENV_USER_HOME;
+
+      if (null == logDir || 0 == logDir.length()) {
+        logDir = ENV_CWD;
+      }
+
+      if (null == logDir || 0 == logDir.length()) {
+        logDir = ENV_JAVA_TMPDIR;
+      }
+
+      if (null == logDir) {
+        logDir = "";
+      } else {
+        logDir = logDir.concat(ENV_FILE_SYS_SEPARATOR);
+      }
+
+      // TODO MGH - May need to localize the file name for non-english systems?
+      logDir = logDir.concat("GemStone").concat(ENV_FILE_SYS_SEPARATOR)
+          .concat("GemFire").concat(ENV_FILE_SYS_SEPARATOR).concat(
+              "DataBrowser").concat(ENV_FILE_SYS_SEPARATOR).concat( "logs" );
+    }
+    DEFAULT_LOG_DIR = logDir;
+  }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/e2ccf3da/databrowser/src/com/gemstone/gemfire/mgmt/DataBrowser/prefs/PreferencesAdapter.java
----------------------------------------------------------------------
diff --git a/databrowser/src/com/gemstone/gemfire/mgmt/DataBrowser/prefs/PreferencesAdapter.java b/databrowser/src/com/gemstone/gemfire/mgmt/DataBrowser/prefs/PreferencesAdapter.java
new file mode 100644
index 0000000..43bd71b
--- /dev/null
+++ b/databrowser/src/com/gemstone/gemfire/mgmt/DataBrowser/prefs/PreferencesAdapter.java
@@ -0,0 +1,180 @@
+/*
+ * ========================================================================= (c)
+ * Copyright 2002-2007, GemStone Systems, Inc. All Rights Reserved. 1260 NW
+ * Waterhouse Ave., Suite 200, Beaverton, OR 97006 All Rights Reserved.
+ * ========================================================================
+ */
+package com.gemstone.gemfire.mgmt.DataBrowser.prefs;
+
+import java.io.IOException;
+import java.io.OutputStream;
+import java.util.prefs.BackingStoreException;
+import java.util.prefs.NodeChangeListener;
+import java.util.prefs.PreferenceChangeListener;
+import java.util.prefs.Preferences;
+
+/**
+ * This is an abstract class that extends java.util.prefs.Preferences and wraps
+ * another Preferences object. This class can be extended by other Preferences
+ * implementations that want to add new features to wrapped Preferences object.
+ * The methods for persisting/retriving objects are added.
+ * 
+ * @author mjha
+ */
+public abstract class PreferencesAdapter extends Preferences {
+  /* wrapped Preferences object */
+  protected Preferences wrapped;
+
+  /**
+   * Constructor for wrapping the java.util.Preferences object
+   * 
+   * @param toBeWrapped
+   *                java.util.Preferences object to be wrapped
+   */
+  public PreferencesAdapter(Preferences toBeWrapped) {
+    this.wrapped = toBeWrapped;
+  }
+
+  public String absolutePath() {
+    return wrapped.absolutePath();
+  }
+
+  public void addNodeChangeListener(NodeChangeListener ncl) {
+    wrapped.addNodeChangeListener(ncl);
+  }
+
+  public void addPreferenceChangeListener(PreferenceChangeListener pcl) {
+    wrapped.addPreferenceChangeListener(pcl);
+  }
+
+  public String[] childrenNames() throws BackingStoreException {
+    return wrapped.childrenNames();
+  }
+
+  public void clear() throws BackingStoreException {
+    wrapped.clear();
+  }
+
+  public void exportNode(OutputStream os) throws IOException,
+      BackingStoreException {
+    wrapped.exportNode(os);
+  }
+
+  public void exportSubtree(OutputStream os) throws IOException,
+      BackingStoreException {
+    wrapped.exportSubtree(os);
+  }
+
+  public void flush() throws BackingStoreException {
+    wrapped.flush();
+  }
+
+  public String get(String key, String def) {
+    return wrapped.get(key, def);
+  }
+
+  public boolean getBoolean(String key, boolean def) {
+    return wrapped.getBoolean(key, def);
+  }
+
+  public byte[] getByteArray(String key, byte[] def) {
+    return wrapped.getByteArray(key, def);
+  }
+
+  public double getDouble(String key, double def) {
+    return wrapped.getDouble(key, def);
+  }
+
+  public float getFloat(String key, float def) {
+    return wrapped.getFloat(key, def);
+  }
+
+  public int getInt(String key, int def) {
+    return wrapped.getInt(key, def);
+  }
+
+  public long getLong(String key, long def) {
+    return wrapped.getLong(key, def);
+  }
+
+  public boolean isUserNode() {
+    return wrapped.isUserNode();
+  }
+
+  public String[] keys() throws BackingStoreException {
+    return wrapped.keys();
+  }
+
+  public String name() {
+    return wrapped.name();
+  }
+
+  public Preferences node(String pathName) {
+    return wrapped.node(pathName);
+  }
+
+  public boolean nodeExists(String pathName) throws BackingStoreException {
+    return wrapped.nodeExists(pathName);
+  }
+
+  public Preferences parent() {
+    return wrapped.parent();
+  }
+
+  public void put(String key, String value) {
+    wrapped.put(key, value);
+  }
+
+  public void putBoolean(String key, boolean value) {
+    wrapped.putBoolean(key, value);
+  }
+
+  public void putByteArray(String key, byte[] value) {
+    wrapped.putByteArray(key, value);
+  }
+
+  public void putDouble(String key, double value) {
+    wrapped.putDouble(key, value);
+  }
+
+  public void putFloat(String key, float value) {
+    wrapped.putFloat(key, value);
+  }
+
+  public void putInt(String key, int value) {
+    wrapped.putInt(key, value);
+  }
+
+  public void putLong(String key, long value) {
+    wrapped.putLong(key, value);
+  }
+
+  public void remove(String key) {
+    wrapped.remove(key);
+  }
+
+  public void removeNode() throws BackingStoreException {
+    wrapped.removeNode();
+  }
+
+  public void removeNodeChangeListener(NodeChangeListener ncl) {
+    wrapped.removeNodeChangeListener(ncl);
+  }
+
+  public void removePreferenceChangeListener(PreferenceChangeListener pcl) {
+    wrapped.removePreferenceChangeListener(pcl);
+  }
+
+  public void sync() throws BackingStoreException {
+    wrapped.sync();
+  }
+
+  /**
+   * Returns a string representation of the object.
+   * 
+   * @return a string representation of the object
+   */
+  public String toString() {
+    return this.getClass() + " : " + wrapped.toString();
+  }
+}

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/e2ccf3da/databrowser/src/com/gemstone/gemfire/mgmt/DataBrowser/query/ColumnNotFoundException.java
----------------------------------------------------------------------
diff --git a/databrowser/src/com/gemstone/gemfire/mgmt/DataBrowser/query/ColumnNotFoundException.java b/databrowser/src/com/gemstone/gemfire/mgmt/DataBrowser/query/ColumnNotFoundException.java
new file mode 100644
index 0000000..ac27530
--- /dev/null
+++ b/databrowser/src/com/gemstone/gemfire/mgmt/DataBrowser/query/ColumnNotFoundException.java
@@ -0,0 +1,31 @@
+/*========================================================================= 
+ * (c)Copyright 2002-2009, GemStone Systems, Inc. All Rights Reserved.
+ * 1260 NW Waterhouse Ave., Suite 200, Beaverton, OR 97006 
+ * All Rights Reserved.
+ * =======================================================================*/
+package com.gemstone.gemfire.mgmt.DataBrowser.query;
+
+public class ColumnNotFoundException extends Exception {
+
+  /**
+   * 
+   */
+  private static final long serialVersionUID = 1L;
+
+  public ColumnNotFoundException() {
+    super();
+  }
+
+  public ColumnNotFoundException(String arg0, Throwable arg1) {
+    super(arg0, arg1);
+  }
+
+  public ColumnNotFoundException(String arg0) {
+    super(arg0);
+  }
+
+  public ColumnNotFoundException(Throwable arg0) {
+    super(arg0);
+  }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/e2ccf3da/databrowser/src/com/gemstone/gemfire/mgmt/DataBrowser/query/ColumnValueNotAvailableException.java
----------------------------------------------------------------------
diff --git a/databrowser/src/com/gemstone/gemfire/mgmt/DataBrowser/query/ColumnValueNotAvailableException.java b/databrowser/src/com/gemstone/gemfire/mgmt/DataBrowser/query/ColumnValueNotAvailableException.java
new file mode 100644
index 0000000..f16bce1
--- /dev/null
+++ b/databrowser/src/com/gemstone/gemfire/mgmt/DataBrowser/query/ColumnValueNotAvailableException.java
@@ -0,0 +1,30 @@
+/*========================================================================= 
+ * (c)Copyright 2002-2009, GemStone Systems, Inc. All Rights Reserved.
+ * 1260 NW Waterhouse Ave., Suite 200, Beaverton, OR 97006 
+ * All Rights Reserved.
+ * =======================================================================*/
+package com.gemstone.gemfire.mgmt.DataBrowser.query;
+
+public class ColumnValueNotAvailableException extends Exception {
+
+  /**
+   * 
+   */
+  private static final long serialVersionUID = 1L;
+
+  public ColumnValueNotAvailableException(String arg0, Throwable arg1) {
+    super(arg0, arg1);
+    // TODO Auto-generated constructor stub
+  }
+
+  public ColumnValueNotAvailableException(String arg0) {
+    super(arg0);
+    // TODO Auto-generated constructor stub
+  }
+
+  public ColumnValueNotAvailableException(Throwable arg0) {
+    super(arg0);
+    // TODO Auto-generated constructor stub
+  }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/e2ccf3da/databrowser/src/com/gemstone/gemfire/mgmt/DataBrowser/query/IntrospectionException.java
----------------------------------------------------------------------
diff --git a/databrowser/src/com/gemstone/gemfire/mgmt/DataBrowser/query/IntrospectionException.java b/databrowser/src/com/gemstone/gemfire/mgmt/DataBrowser/query/IntrospectionException.java
new file mode 100644
index 0000000..4fe5dde
--- /dev/null
+++ b/databrowser/src/com/gemstone/gemfire/mgmt/DataBrowser/query/IntrospectionException.java
@@ -0,0 +1,31 @@
+/*========================================================================= 
+ * (c)Copyright 2002-2009, GemStone Systems, Inc. All Rights Reserved.
+ * 1260 NW Waterhouse Ave., Suite 200, Beaverton, OR 97006 
+ * All Rights Reserved.
+ * =======================================================================*/
+package com.gemstone.gemfire.mgmt.DataBrowser.query;
+
+public class IntrospectionException extends QueryExecutionException {
+
+  /**
+   * 
+   */
+  private static final long serialVersionUID = 1L;
+
+  public IntrospectionException() {
+    super();
+  }
+
+  public IntrospectionException(String arg0, Throwable arg1) {
+    super(arg0, arg1);
+  }
+
+  public IntrospectionException(String arg0) {
+    super(arg0);
+  }
+
+  public IntrospectionException(Throwable arg0) {
+    super(arg0);
+  }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/e2ccf3da/databrowser/src/com/gemstone/gemfire/mgmt/DataBrowser/query/IntrospectionRepository.java
----------------------------------------------------------------------
diff --git a/databrowser/src/com/gemstone/gemfire/mgmt/DataBrowser/query/IntrospectionRepository.java b/databrowser/src/com/gemstone/gemfire/mgmt/DataBrowser/query/IntrospectionRepository.java
new file mode 100644
index 0000000..caccdfc
--- /dev/null
+++ b/databrowser/src/com/gemstone/gemfire/mgmt/DataBrowser/query/IntrospectionRepository.java
@@ -0,0 +1,179 @@
+/*========================================================================= 
+ * (c)Copyright 2002-2011, GemStone Systems, Inc. All Rights Reserved.
+ * 1260 NW Waterhouse Ave., Suite 200, Beaverton, OR 97006 
+ * All Rights Reserved.
+ * =======================================================================*/
+package com.gemstone.gemfire.mgmt.DataBrowser.query;
+
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.Set;
+import java.util.Map.Entry;
+
+import com.gemstone.gemfire.cache.query.types.StructType;
+import com.gemstone.gemfire.mgmt.DataBrowser.query.internal.CollectionTypeResultImpl;
+import com.gemstone.gemfire.mgmt.DataBrowser.query.internal.MapTypeResultImpl;
+import com.gemstone.gemfire.mgmt.DataBrowser.query.internal.ObjectIntrospector;
+import com.gemstone.gemfire.mgmt.DataBrowser.query.internal.PdxHelper;
+import com.gemstone.gemfire.mgmt.DataBrowser.query.internal.PrimitiveTypeResultImpl;
+import com.gemstone.gemfire.mgmt.DataBrowser.query.internal.StructTypeResultImpl;
+import com.gemstone.gemfire.mgmt.DataBrowser.utils.LogUtil;
+
+public class IntrospectionRepository {
+
+  private Map<Object, IntrospectionResult> types      = null;
+  private static IntrospectionRepository   repository = null;
+
+  private IntrospectionRepository() {
+    types = new HashMap<Object, IntrospectionResult>();
+  }
+
+  public static synchronized IntrospectionRepository singleton() {
+    if (repository == null) {
+      repository = new IntrospectionRepository();
+    }
+    return repository;
+  }
+
+  public IntrospectionResult getIntrospectionResult(Object type) {
+    return this.types.get(type);
+  }
+
+  public void addIntrospectionResult(Object type, IntrospectionResult result) {
+    LogUtil.fine("Adding a type for :" + type);
+    this.types.put(type, result);
+  }
+
+  /**
+   * Introspect the type using given object instance
+   * 
+   * @param objInstance
+   *          Instance of an object whose type is to be introspected
+   * @return IntrospectionResult instance for the type
+   * @throws IntrospectionException
+   *           if fails to introspect
+   */
+  public IntrospectionResult introspectTypeByObject(Object objInstance) 
+      throws IntrospectionException {
+    IntrospectionResult metaInfo = null;
+    if (QueryUtil.isPdxInstance(objInstance)) {
+      metaInfo = introspectPdxType(objInstance);
+    } else {
+      metaInfo = introspectType(objInstance.getClass());
+    }
+    return metaInfo;
+  }
+
+  /**
+   * Introspect the type using given
+   * com.gemstone.gemfire.pdx.internal.PdxInstanceImpl object instance. The type
+   * used for storing the introspection result for Pdx Instances is
+   * com.gemstone.gemfire.mgmt.DataBrowser.query.internal.PdxInfoType unlike
+   * java.lang.Class for other objects.
+   * 
+   * It returns null if given pdxObjInstance is not a PdxInstance.
+   * 
+   * @param pdxObjInstance
+   *          Instance of an object whose type is to be introspected
+   * @return IntrospectionResult instance for the PdxInstanceImpl, null if
+   *          given pdxObjInstance is not a PdxInstance.
+   * @throws IntrospectionException
+   *           if fails to introspect
+   */
+  public IntrospectionResult introspectPdxType(Object pdxObjInstance)
+    throws IntrospectionException {
+    IntrospectionResult metaInfo = null;
+    
+    if (QueryUtil.isPdxInstance(pdxObjInstance)) {
+      PdxHelper pdxHelper   = PdxHelper.getInstance();
+      Object    pdxInfoType = pdxHelper.getPdxInfoType(pdxObjInstance);
+      if(!repository.isTypeIntrospected(pdxInfoType)) {//PdxInstance not known
+        metaInfo = pdxHelper.getPdxMetaInfo(pdxObjInstance);
+        repository.addIntrospectionResult(pdxInfoType, metaInfo);
+      } else { //PdxInstance already known
+        metaInfo = repository.getIntrospectionResult(pdxInfoType);
+      }
+    }
+    return metaInfo;
+  }
+
+  public IntrospectionResult introspectType(Object type)
+      throws IntrospectionException {
+    if (type instanceof Class) {
+      Class classType = (Class) type;
+      IntrospectionResult metaInfo = null;
+
+      if (QueryUtil.isPrimitiveType(classType)) {
+        if (!repository.isTypeIntrospected(type)) {
+          metaInfo = new PrimitiveTypeResultImpl(classType);
+          repository.addIntrospectionResult(classType, metaInfo);
+        }
+      } else if (QueryUtil.isCompositeType(classType)) {
+        if (!repository.isTypeIntrospected(type)) {
+          metaInfo = ObjectIntrospector.introspectClass(classType);
+          repository.addIntrospectionResult(classType, metaInfo);
+        }
+      }
+
+      else if (QueryUtil.isCollectionType(classType)) {
+        if (!repository.isTypeIntrospected(type)) {
+          metaInfo = new CollectionTypeResultImpl(classType);
+          repository.addIntrospectionResult(classType, metaInfo);
+        }
+      }
+
+      else if (QueryUtil.isMapType(classType)) {
+        if (!repository.isTypeIntrospected(type)) {
+          metaInfo = new MapTypeResultImpl(classType);
+          repository.addIntrospectionResult(classType, metaInfo);
+        }
+      }
+    }
+
+    if (type instanceof StructType) {
+      StructType sType = (StructType) type;
+      if (!repository.isTypeIntrospected(type)) {
+        IntrospectionResult metaInfo = new StructTypeResultImpl(sType);
+        repository.addIntrospectionResult(type, metaInfo);
+      }
+    }
+
+    return repository.getIntrospectionResult(type);
+  }
+
+  public boolean isTypeIntrospected(Object type) {
+    return this.types.containsKey(type);
+  }
+
+  public IntrospectionResult[] getIntrospectionResultInfo() {
+    return types.values().toArray(new IntrospectionResult[0]);
+  }
+
+  /**
+   * Cleans up introspected Pdx Types. Should be called on re-connect. 
+   */
+  //NOTE: Why to do this?:
+  // The next connection from Data Browser could be to some other
+  // DS/Cache Server which might have different version of the same object
+  public boolean removePdxIntrospectionResults() {
+    boolean clearedOldInfo = false;
+    if (!types.isEmpty()) {
+      Set<Entry<Object, IntrospectionResult>> entries = types.entrySet();
+      for (Iterator<Entry<Object, IntrospectionResult>> it = entries.iterator(); it.hasNext();) {
+        Entry<Object, IntrospectionResult> entry = (Entry<Object, IntrospectionResult>) it.next();
+        IntrospectionResult metaInfo = entry.getValue();
+        /* remove if metaInfo is null or it is PdxIntrospectionResult */
+        if (metaInfo == null || 
+            metaInfo.getResultType() == IntrospectionResult.PDX_TYPE_COLUMN || 
+            metaInfo.getResultType() == IntrospectionResult.PDX_OBJECT_TYPE_COLUMN) {
+          it.remove();
+        }
+      }
+      PdxHelper.getInstance().clearKnownPdxTypeInfo();
+      clearedOldInfo = true;
+    }
+    
+    return clearedOldInfo;
+  }
+}

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/e2ccf3da/databrowser/src/com/gemstone/gemfire/mgmt/DataBrowser/query/IntrospectionResult.java
----------------------------------------------------------------------
diff --git a/databrowser/src/com/gemstone/gemfire/mgmt/DataBrowser/query/IntrospectionResult.java b/databrowser/src/com/gemstone/gemfire/mgmt/DataBrowser/query/IntrospectionResult.java
new file mode 100644
index 0000000..e5ae96f
--- /dev/null
+++ b/databrowser/src/com/gemstone/gemfire/mgmt/DataBrowser/query/IntrospectionResult.java
@@ -0,0 +1,104 @@
+/*========================================================================= 
+ * (c)Copyright 2002-2011, GemStone Systems, Inc. All Rights Reserved.
+ * 1260 NW Waterhouse Ave., Suite 200, Beaverton, OR 97006 
+ * All Rights Reserved.
+ * =======================================================================*/
+package com.gemstone.gemfire.mgmt.DataBrowser.query;
+
+/**
+ * This interface provides meta-data about the result of the query result by
+ * performing runtime introspection on the same.
+ * 
+ * @author Hrishi
+ **/
+public interface IntrospectionResult {
+
+  public static final int UNDEFINED = -1;
+  public static final int UNKNOWN_TYPE_COLUMN = 0;
+  public static final int PRIMITIVE_TYPE_COLUMN = 1;
+  public static final int COMPOSITE_TYPE_COLUMN = 2;
+  public static final int COLLECTION_TYPE_COLUMN = 4;
+  public static final int MAP_TYPE_COLUMN = 8;
+  public static final int PDX_TYPE_COLUMN = 16; //PDX Object
+  public static final int PDX_OBJECT_TYPE_COLUMN = 18; //nested PDX Object
+  
+  public static final int PRIMITIVE_TYPE_RESULT = 10;
+  public static final int COMPOSITE_TYPE_RESULT = 11;
+  public static final int STRUCT_TYPE_RESULT = 12;
+  public static final int COLLECTION_TYPE_RESULT = 13;
+  public static final int MAP_TYPE_RESULT = 14;
+  public static final int PDX_TYPE_RESULT = 20;
+  
+  
+  public static final String CONST_COLUMN_NAME = "Result";
+  
+  public int getResultType();
+  
+  /**
+   * This method returns the total number of fields (columns) in this result.
+   **/
+  public int getColumnCount();
+
+  /**
+   * This method returns the name of the field (column) at the given index.
+   **/
+  public String getColumnName(int index) throws ColumnNotFoundException;
+  
+  /**
+   * This method returns the index of the column by specified name.
+   **/
+  public int getColumnIndex(String name) throws ColumnNotFoundException;
+  
+  /**
+   * This method returns the class name of the field (column) at the given
+   * index.
+   **/
+  public Class getColumnClass(int index) throws ColumnNotFoundException;
+  
+  public Class getColumnClass(Object tuple, int index) throws ColumnNotFoundException;
+
+  /**
+   * This method returns if the given field (column) type is composite.
+   **/
+  public int getColumnType(int index) throws ColumnNotFoundException;
+  
+  public int getColumnType(Object tuple, int index) throws ColumnNotFoundException;
+
+  /**
+   * This method returns the value of given field (column) for a given object
+   * (tuple).
+   **/
+  public Object getColumnValue(Object tuple, int index)
+      throws ColumnNotFoundException, ColumnValueNotAvailableException;
+
+  /**
+   * This method returns a Java type associated with this introspection result.
+   * 
+   * @return The Java type associated with this meta-data.
+   */
+  public Class getJavaType();
+
+  /**
+   * This method returns the name of a Java type associated with this
+   * introspection result. This is in general same as calling
+   * getJavaType().getName() except when the query contains PdxInstance objects.
+   * For PdxInstance objects, this information is taken from PdxType. 
+   * 
+   * @return The name of a Java type associated with this meta-data.
+   */
+  public String getJavaTypeName();
+
+  /**
+   * Whether the given Object is compatible with this IntrospectionResult.
+   * Currently, for all IntrospectionResult implementations except
+   * PdxIntrospectionResult, this is same as checking whether
+   * {@link IntrospectionResult#getJavaType()} is same as data.getClass()
+   * 
+   * @param data
+   *          Object to check for compatibility
+   * @return true if type of the given Object is same as the type for which this
+   *         IntrospectionResult is created, false otherwise
+   */
+  public boolean isCompatible(Object data);
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/e2ccf3da/databrowser/src/com/gemstone/gemfire/mgmt/DataBrowser/query/Query.java
----------------------------------------------------------------------
diff --git a/databrowser/src/com/gemstone/gemfire/mgmt/DataBrowser/query/Query.java b/databrowser/src/com/gemstone/gemfire/mgmt/DataBrowser/query/Query.java
new file mode 100644
index 0000000..765bd0f
--- /dev/null
+++ b/databrowser/src/com/gemstone/gemfire/mgmt/DataBrowser/query/Query.java
@@ -0,0 +1,118 @@
+/**
+ * 
+ */
+package com.gemstone.gemfire.mgmt.DataBrowser.query;
+
+/**
+ * Replicating the GFE query interface authored by Eric Zoerner
+ * @author mghosh
+ *
+ */
+public interface Query {
+
+  /**
+   * Return the original query string that was specified in the constructor.
+   * @return the original query string
+   */
+  public String getQueryString();
+  
+  
+  /**
+   * Execute this query and returns an object that represent its
+   * result.  If the query resolves to a primitive type, an instance
+   * of the corresponding wrapper type ({@link java.lang.Integer},
+   * etc.) is returned.  If the query resolves to more than one
+   * object, a {@link SelectResults} is returned.
+   *
+   * @return The object that represents the result of the query. Note that if
+   *         a query is just a select statement then it will return a result
+   *         that is an instance of {@link SelectResults}. However, since a query is not
+   *         necessarily just a select statement, the return type of this
+   *         method is <code>Object</code>.
+   *         For example, the query <code><b>(select distinct * from /rgn).size</b></code>
+   *         returns an instance of <code>java.lang.Integer</code>.
+   *
+   * @throws FunctionDomainException
+   *         A function was applied to a parameter that is improper
+   *         for that function.  For example, the ELEMENT function
+   *         was applied to a collection of more than one element 
+   * @throws TypeMismatchException
+   *         If a bound parameter is not of the expected type.
+   * @throws NameResolutionException
+   *         If a name in the query cannot be resolved.
+   * @throws IllegalArgumentException
+   *         The number of bound parameters does not match the number
+   *         of placeholders
+   * @throws IllegalStateException
+   *         If the query is not permitted on this type of region
+   */
+  public Object execute();
+//    throws FunctionDomainException, TypeMismatchException, NameResolutionException,
+//           QueryInvocationTargetException;
+  
+  /**
+   * Executes this query with the given parameters and returns an
+   * object that represent its result.  If the query resolves to a
+   * primitive type, an instance of the corresponding wrapper type
+   * ({@link java.lang.Integer}, etc.) is returned.  If the query
+   * resolves to more than one object, a {@link SelectResults} is
+   * returned.
+   *
+   * @param params
+   *        Values that are bound to parameters (such as
+   *        <code>$1</code>) in this query. 
+   *
+   * @return The object that represents the result of the query. Note that if
+   *         a query is just a select statement then it will return a result
+   *         that is an instance of {@link SelectResults}. However, since a query is not
+   *         necessarily just a select statement, the return type of this
+   *         method is <code>Object</code>.
+   *         For example, the query <code><b>(select distinct * from /rgn).size</b></code>
+   *         returns an instance of <code>java.lang.Integer</code>.
+   *
+   * @throws FunctionDomainException
+   *         A function was applied to a parameter that is improper
+   *         for that function.  For example, the ELEMENT function
+   *         was applied to a collection of more than one element 
+   * @throws TypeMismatchException
+   *         If a bound parameter is not of the expected type.
+   * @throws NameResolutionException
+   *         If a name in the query cannot be resolved.
+   * @throws IllegalArgumentException
+   *         The number of bound parameters does not match the number
+   *         of placeholders
+   * @throws IllegalStateException
+   *         If the query is not permitted on this type of region
+   */
+  public Object execute(Object[] params);
+//    throws FunctionDomainException, TypeMismatchException, NameResolutionException,
+//           QueryInvocationTargetException;
+
+  /**
+   * Compiles this <code>Query</code> to achieve higher performance
+   * execution.
+   *
+   * @throws TypeMismatchException 
+   *         If the compile-time type of a name, parameter, or
+   *         expression is not the expected type 
+   * @throws QueryInvalidException 
+   *         The syntax of the query string is not correct
+   */
+  public void compile(); 
+ //   throws TypeMismatchException, NameResolutionException;
+  
+ // IPreferenceConstants
+
+
+  /**
+   * Return whether this query has been compiled into VM bytecodes.
+   * @return <code>true</code> if this query has been compiled into bytecodes
+   */
+  public boolean isCompiled();
+
+  
+  /**
+   * Get statistics information for this query.
+   */
+  public QueryStatistics getStatistics();
+}

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/e2ccf3da/databrowser/src/com/gemstone/gemfire/mgmt/DataBrowser/query/QueryExecutionException.java
----------------------------------------------------------------------
diff --git a/databrowser/src/com/gemstone/gemfire/mgmt/DataBrowser/query/QueryExecutionException.java b/databrowser/src/com/gemstone/gemfire/mgmt/DataBrowser/query/QueryExecutionException.java
new file mode 100644
index 0000000..7d20462
--- /dev/null
+++ b/databrowser/src/com/gemstone/gemfire/mgmt/DataBrowser/query/QueryExecutionException.java
@@ -0,0 +1,97 @@
+package com.gemstone.gemfire.mgmt.DataBrowser.query;
+
+
+import com.gemstone.gemfire.security.AuthenticationFailedException;
+import com.gemstone.gemfire.security.AuthenticationRequiredException;
+import com.gemstone.gemfire.security.NotAuthorizedException;
+
+public class QueryExecutionException extends Exception {
+
+  /**
+   * 
+   */
+  private static final long serialVersionUID = 1L;
+  private static final String SERIALIZATION_EXCEPTION = "Failed to deserialize the Query results";
+  private static final String QUERY_EXEC_EXCEPTION = "Failed to execute a Query";
+  
+  public QueryExecutionException() {
+    super();
+  }
+
+  public QueryExecutionException(String arg0, Throwable arg1) {
+    super(arg0, arg1);
+  }
+
+  public QueryExecutionException(String arg0) {
+    super(arg0);
+  }
+
+  public QueryExecutionException(Throwable arg0) {
+    super(arg0);
+  }
+  
+  public boolean isAuthenticationFailed(){
+    boolean failed = false;
+    Throwable cause = getCause();
+    while(cause != null) {
+      if(cause instanceof AuthenticationRequiredException || 
+          cause instanceof AuthenticationFailedException ) {
+        failed = true;
+        break;
+      }
+        
+      cause = cause.getCause();
+    }
+    return failed;
+  }
+  
+  public boolean isAuthorizationFailed(){
+    boolean failed = false;
+    Throwable cause = getCause();
+    while(cause != null) {
+      if(cause instanceof NotAuthorizedException ) {
+        failed = true;
+        break;
+      }
+        
+      cause = cause.getCause();
+    }
+    return failed;
+  }
+  
+
+  @Override
+  public String getMessage() {
+    Throwable cause = getCause();
+    boolean serverOp = (cause instanceof com.gemstone.gemfire.cache.client.ServerOperationException);
+    
+    if ( serverOp || (cause instanceof com.gemstone.gemfire.SerializationException)) {
+     StringBuffer buffer = new StringBuffer();
+      
+      if(serverOp)
+        buffer.append(QUERY_EXEC_EXCEPTION);
+      else
+        buffer.append(SERIALIZATION_EXCEPTION);
+      
+      buffer.append(" : ");
+      buffer.append(cause);
+      
+      cause = cause.getCause();
+      
+      while(cause != null) {
+        buffer.append('\n');
+        buffer.append("Caused by ");
+        buffer.append(cause);   
+        cause = cause.getCause();
+      }
+      
+      return buffer.toString();
+    }
+    
+    return super.getMessage();
+  }
+  
+  
+  
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/e2ccf3da/databrowser/src/com/gemstone/gemfire/mgmt/DataBrowser/query/QueryResult.java
----------------------------------------------------------------------
diff --git a/databrowser/src/com/gemstone/gemfire/mgmt/DataBrowser/query/QueryResult.java b/databrowser/src/com/gemstone/gemfire/mgmt/DataBrowser/query/QueryResult.java
new file mode 100644
index 0000000..7fc0a78
--- /dev/null
+++ b/databrowser/src/com/gemstone/gemfire/mgmt/DataBrowser/query/QueryResult.java
@@ -0,0 +1,92 @@
+/*========================================================================= 
+ * (c)Copyright 2002-2009, GemStone Systems, Inc. All Rights Reserved.
+ * 1260 NW Waterhouse Ave., Suite 200, Beaverton, OR 97006 
+ * All Rights Reserved.
+ * =======================================================================*/
+package com.gemstone.gemfire.mgmt.DataBrowser.query;
+
+import java.util.Collection;
+import java.util.Map;
+
+import com.gemstone.gemfire.cache.query.QueryStatistics;
+import com.gemstone.gemfire.mgmt.DataBrowser.query.internal.ResultSetImpl;
+
+/**
+ * This class represents the results of a GemFire query execution which also
+ * includes, 1. Meta-data about results of query. 2. GemFire Query execution
+ * statistics.
+ * 
+ * @author Hrishi
+ **/
+public class QueryResult implements ResultSet {
+
+  private ResultSet                        result;  
+  private QueryStatistics                  statistics;
+  
+  public QueryResult(Map<Object, IntrospectionResult> typesInRes,
+       Collection<?> res, QueryStatistics stats) {
+    result = new ResultSetImpl(typesInRes, res);
+    statistics = stats;
+  }
+  
+  public QueryResult(ResultSet res, QueryStatistics stats) {
+    result = res;
+    statistics = stats;
+  }
+
+  public boolean isEmpty() {
+    return result.isEmpty();
+  }
+
+  /**
+   * This method returns the meta-data about the result of executed query.
+   * 
+   * @return The meta-data of result of the query execution.
+   */
+  public IntrospectionResult[] getIntrospectionResult() {
+    return result.getIntrospectionResult();
+  }
+
+  /**
+   * This method returns the results of the executed query.
+   * 
+   * @return The result of query execution.
+   */
+  public Collection<?> getQueryResult() {
+    return this.result.getQueryResult();
+  }
+
+  /**
+   * This method returns the subset of result of the executed query for a given
+   * introspection type.
+   * 
+   * @param metaInfo
+   *          IntrospectionResult type for which we require result
+   * @return subset of result of the query execution.
+   */
+  public Collection<?> getQueryResult(IntrospectionResult metaInfo) {
+    return this.result.getQueryResult(metaInfo);
+  }
+
+  /**
+   * This method returns the statistics of the Query execution.
+   * 
+   * @return The GemFire query execution statistics.
+   */
+  public QueryStatistics getQueryStatistics() {
+    return this.statistics;
+  }
+
+  /**
+   * This method returns the value of given field (column) for a given object
+   * (tuple).
+   **/
+  public Object getColumnValue(Object tuple, int index)
+      throws ColumnNotFoundException, ColumnValueNotAvailableException {
+    return this.result.getColumnValue(tuple, index);
+  }
+  
+  public void close() {
+    //this.result.close();    
+  }
+}

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/e2ccf3da/databrowser/src/com/gemstone/gemfire/mgmt/DataBrowser/query/QueryStatistics.java
----------------------------------------------------------------------
diff --git a/databrowser/src/com/gemstone/gemfire/mgmt/DataBrowser/query/QueryStatistics.java b/databrowser/src/com/gemstone/gemfire/mgmt/DataBrowser/query/QueryStatistics.java
new file mode 100644
index 0000000..cbd5f2c
--- /dev/null
+++ b/databrowser/src/com/gemstone/gemfire/mgmt/DataBrowser/query/QueryStatistics.java
@@ -0,0 +1,19 @@
+/**
+ * 
+ */
+package com.gemstone.gemfire.mgmt.DataBrowser.query;
+
+/**
+ * @author mghosh
+ *
+ */
+public class QueryStatistics {
+
+  /**
+   * 
+   */
+  public QueryStatistics() {
+    // TODO Auto-generated constructor stub
+  }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/e2ccf3da/databrowser/src/com/gemstone/gemfire/mgmt/DataBrowser/query/QueryUtil.java
----------------------------------------------------------------------
diff --git a/databrowser/src/com/gemstone/gemfire/mgmt/DataBrowser/query/QueryUtil.java b/databrowser/src/com/gemstone/gemfire/mgmt/DataBrowser/query/QueryUtil.java
new file mode 100644
index 0000000..ad46070
--- /dev/null
+++ b/databrowser/src/com/gemstone/gemfire/mgmt/DataBrowser/query/QueryUtil.java
@@ -0,0 +1,407 @@
+/*========================================================================= 
+ * (c)Copyright 2002-2011, GemStone Systems, Inc. All Rights Reserved.
+ * 1260 NW Waterhouse Ave., Suite 200, Beaverton, OR 97006 
+ * All Rights Reserved.
+ * =======================================================================*/
+package com.gemstone.gemfire.mgmt.DataBrowser.query;
+
+import java.lang.reflect.Array;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import com.gemstone.gemfire.cache.query.Query;
+import com.gemstone.gemfire.cache.query.QueryService;
+import com.gemstone.gemfire.cache.query.SelectResults;
+import com.gemstone.gemfire.cache.query.Struct;
+import com.gemstone.gemfire.cache.query.types.ObjectType;
+import com.gemstone.gemfire.cache.query.types.StructType;
+import com.gemstone.gemfire.mgmt.DataBrowser.prefs.DataBrowserPreferences;
+import com.gemstone.gemfire.mgmt.DataBrowser.query.internal.CollectionTypeResultImpl;
+import com.gemstone.gemfire.mgmt.DataBrowser.query.internal.MapTypeResultImpl;
+import com.gemstone.gemfire.mgmt.DataBrowser.query.internal.ObjectColumn;
+import com.gemstone.gemfire.mgmt.DataBrowser.query.internal.ObjectIntrospector;
+import com.gemstone.gemfire.mgmt.DataBrowser.query.internal.ObjectTypeResultImpl;
+import com.gemstone.gemfire.mgmt.DataBrowser.query.internal.PdxHelper;
+import com.gemstone.gemfire.mgmt.DataBrowser.query.internal.PrimitiveTypeResultImpl;
+import com.gemstone.gemfire.mgmt.DataBrowser.query.internal.ResultSetImpl;
+import com.gemstone.gemfire.mgmt.DataBrowser.query.internal.StructTypeResultImpl;
+import com.gemstone.gemfire.mgmt.DataBrowser.utils.LogUtil;
+
+/**
+ * This class is responsible to perform the query execution as well as conversion
+ * of the query results into the Data-Browser representation. This class also provides
+ * functionality to identify primitive and composite data types.
+ * 
+ * @author Hrishi
+ **/
+public class QueryUtil {
+  
+  /**
+   * This method executes the specified query using the provided QueryService. It
+   * then converts the GemFire Query execution results into the Data-Browser type.
+   * 
+   * @param service QueryService to be used.
+   * @param query Query to be executed.
+   * @return Data-Browser representation of the Query results.
+   * @throws QueryExecutionException in case of error during query execution.
+   */
+  public static QueryResult executeQuery(QueryService service, String query, boolean enforceLimit) throws QueryExecutionException {
+   
+    if(null == query) {
+     throw new IllegalArgumentException("query string can not be null"); 
+    }
+    
+    if(enforceLimit) {
+      LogUtil.info("QueryUtil.executeQuery ==>"+query);
+      query = applyLimitClause(query);
+      LogUtil.info("QueryUtil.executeQuery after enforcing LIMIT ==>"+query);
+    }
+    
+    Query queryObj = service.newQuery(query);
+    Object result = null;
+    
+    try {
+      result = queryObj.execute();  
+    }
+    catch (Exception e) {
+      //Exception during Query execution.
+      throw new QueryExecutionException(e);
+    }
+    
+    if(result == null) {
+      return new QueryResult(new HashMap<Object, IntrospectionResult>(),
+          new ArrayList(), queryObj.getStatistics());
+      
+    } else if(result instanceof SelectResults) {
+      SelectResults temp = (SelectResults)result;
+      
+      ResultSet result_s = introspectCollectionObject(temp);
+      QueryResult queryResult = new QueryResult(result_s, queryObj.getStatistics());
+      return queryResult;     
+    } else if (isPrimitiveType(result.getClass())) {  
+      IntrospectionRepository repo = IntrospectionRepository.singleton();
+      Map<Object, IntrospectionResult> types = new HashMap<Object, IntrospectionResult>();
+      IntrospectionResult metaInfo = null;
+      Class type = result.getClass();
+      
+      if(repo.isTypeIntrospected(type)) {
+        metaInfo = repo.getIntrospectionResult(type);  
+      } else {
+        metaInfo = new PrimitiveTypeResultImpl(type);
+        repo.addIntrospectionResult(type, metaInfo);        
+      }
+            
+      types.put(type , metaInfo);
+      
+      List data = new ArrayList();
+      data.add(result);
+      
+      QueryResult queryResult = new QueryResult(types, data , queryObj.getStatistics());
+      return queryResult;      
+      
+    } else if(isCompositeType(result.getClass())) {
+      Class type = result.getClass();
+           
+      ResultSet result_s = introspectCompositeObject(type, result);
+      QueryResult queryResult = new QueryResult(result_s , queryObj.getStatistics());
+      return queryResult;      
+    }
+    
+    throw new QueryExecutionException("Could not parse GemFire Query result. type is "+result.getClass());
+  }
+  
+  /**
+   * This method introspect the java.util.Collection object and returns
+   * the corresponding ResultSet representation.
+   * 
+   * @param result The java.util.Collection object which is to be introspected.
+   * @return The Data-Browser representation of the input.
+   * @throws QueryExecutionException in case of error during processing.
+   */
+  public static ResultSet introspectCollectionObject(Collection result) throws QueryExecutionException {
+    Map<Object, IntrospectionResult> types = new HashMap<Object, IntrospectionResult>();    
+        
+    if((result == null) || (result.size() == 0) ) {
+      return new ResultSetImpl(types, result);
+    }
+    
+    //fix #830
+    // for the the time being its workaround to counter  gemfire bug #40892
+    ObjectType elementType = null;
+    if(result instanceof SelectResults<?>) {
+      elementType=((SelectResults<?>)result).getCollectionType().getElementType();
+    }
+    IntrospectionRepository repo = IntrospectionRepository.singleton();
+    Iterator iter = result.iterator();
+    
+    while(iter.hasNext()) {
+      Object obj = iter.next();
+      
+      if ( obj == null) {
+        continue;
+      } else if (obj instanceof Struct) {
+        Struct struct = (Struct)obj;
+        if(elementType == null)
+          elementType =  struct.getStructType();
+        IntrospectionResult metaInfo = null;
+        
+        if(!repo.isTypeIntrospected(elementType)) {
+          metaInfo = new StructTypeResultImpl((StructType)elementType);  
+          repo.addIntrospectionResult(elementType, metaInfo);
+        } else {
+          metaInfo = repo.getIntrospectionResult(elementType);
+        }
+        
+        types.put(elementType, metaInfo);
+                
+      } else if (isPrimitiveType(obj.getClass())) {
+        IntrospectionResult metaInfo = null;
+        Class type = obj.getClass();
+        
+        if(!repo.isTypeIntrospected(type)) {
+          metaInfo = new PrimitiveTypeResultImpl(type);
+          repo.addIntrospectionResult(type, metaInfo);  
+        } else {
+          metaInfo = repo.getIntrospectionResult(type);
+        }
+        
+        types.put(type, metaInfo);        
+          
+      } else if (isCompositeType(obj.getClass())) {
+        IntrospectionResult metaInfo = null;
+        Class type = obj.getClass();
+        
+        if(!repo.isTypeIntrospected(type)) {
+          metaInfo = ObjectIntrospector.introspectClass(type);
+          repo.addIntrospectionResult(type, metaInfo);
+        } else {
+          metaInfo = repo.getIntrospectionResult(type);
+        }
+        
+        types.put(type, metaInfo);        
+        
+      } else if (isCollectionType(obj.getClass())) {
+        IntrospectionResult metaInfo = null;
+        Class type = obj.getClass();
+                
+        if(!repo.isTypeIntrospected(type)) {
+          metaInfo = new CollectionTypeResultImpl(type);
+          repo.addIntrospectionResult(type, metaInfo);
+        } else {
+          metaInfo = repo.getIntrospectionResult(type);
+        }
+        
+        types.put(type, metaInfo);    
+        
+      } else if (isMapType(obj.getClass())) {
+        IntrospectionResult metaInfo = null;
+        Class type = obj.getClass();
+                
+        if(!repo.isTypeIntrospected(type)) {
+          metaInfo = new MapTypeResultImpl(type);
+          repo.addIntrospectionResult(type, metaInfo);
+        } else {
+          metaInfo = repo.getIntrospectionResult(type);
+        }
+        
+        types.put(type, metaInfo);            
+      } else if (isPdxInstance(obj)) {
+        PdxHelper pdxHelper = PdxHelper.getInstance();
+        IntrospectionResult metaInfo = null;
+        
+        /*PdxInfoType*/Object pdxInfoType = pdxHelper.getPdxInfoType(obj);
+                
+        if(!repo.isTypeIntrospected(pdxInfoType)) {
+          metaInfo = pdxHelper.getPdxMetaInfo(obj);
+          repo.addIntrospectionResult(pdxInfoType, metaInfo);
+        } else
+          metaInfo = repo.getIntrospectionResult(pdxInfoType);
+        
+        types.put(pdxInfoType, metaInfo);
+      } else {
+        LogUtil.info("Not yet implemented."+obj);
+        continue;
+      }  
+    }
+    
+    return new ResultSetImpl(types, result);    
+ }
+  
+  public static IntrospectionResult introspectJavaType(Class type) throws IntrospectionException {
+    IntrospectionRepository repo = IntrospectionRepository.singleton();
+    
+    if(!repo.isTypeIntrospected(type)) {
+     IntrospectionResult result = null;      
+     if(isPrimitiveType(type)) {
+       result = new PrimitiveTypeResultImpl(type);
+     } else {
+       result = ObjectIntrospector.introspectClass(type);
+     }      
+     repo.addIntrospectionResult(type, result);
+     return result;
+    }
+    
+    return repo.getIntrospectionResult(type);
+  }
+  
+  
+  public static ResultSet introspectCompositeObject(Class type, Object tuple) throws IntrospectionException {
+    IntrospectionRepository repo = IntrospectionRepository.singleton();
+    Map<Object, IntrospectionResult> types = new HashMap<Object, IntrospectionResult>();
+    IntrospectionResult metaInfo = null;
+    
+    if(repo.isTypeIntrospected(type)) {
+      metaInfo = repo.getIntrospectionResult(type);  
+    } else {
+      metaInfo = ObjectIntrospector.introspectClass(type);
+      repo.addIntrospectionResult(type, metaInfo);        
+    }
+          
+    types.put(type , metaInfo);
+    
+    List data = new ArrayList();
+    //We will add the tuple in the result only if it is not null.
+    //Otherwise we don't have any data & hence result would be empty.
+    if(tuple != null)
+     data.add(tuple);
+    
+    ResultSetImpl impl = new ResultSetImpl(types, data); 
+   
+    return impl;
+  }
+  
+  /**
+   * This method can be used to identify if a specified type is 'Primitive'.
+   * 
+   * @param type type to be checked.
+   * @return true if the type is primitive
+   *         false otherwise. 
+   */
+  public static boolean isPrimitiveType(Class type) {
+    boolean result = type.isPrimitive()
+                     || java.lang.Number.class.isAssignableFrom(type)
+                     || java.lang.Character.class.isAssignableFrom(type)
+                     || java.lang.Boolean.class.isAssignableFrom(type)
+                     || java.lang.CharSequence.class.isAssignableFrom(type)
+                     || java.util.Date.class.isAssignableFrom(type);    
+     return result;    
+  }
+  
+  /**
+   * This method can be used to identify if a specified object is 'Composite'.
+   * 
+   * @param object the object to be checked.
+   * @return true if the specified object is composite.
+   *         false otherwise.
+   */
+  public static boolean isCompositeType(Class type) {
+    boolean result = (!isPrimitiveType(type)
+                      && !java.util.Collection.class.isAssignableFrom(type) 
+                      && !type.isArray()
+                      && !java.util.Map.class.isAssignableFrom(type)
+                      && !isPdxInstanceType(type));    
+    return result;    
+  }  
+  
+  public static boolean isCollectionType(Class type) {
+    return java.util.Collection.class.isAssignableFrom(type)
+           || type.isArray() ;    
+  }
+  
+  public static boolean isMapType(Class type) {
+    return java.util.Map.class.isAssignableFrom(type);
+  }
+
+  /**
+   * Checks whether give type (java.lang.Class) is same as or sub-type of
+   * GemFire type PdxInstanceImpl.
+   * 
+   * @param type
+   *          type to be checked
+   * @return true if given type is same as or sub-type of GemFire type
+   *         PdxInstanceImpl, false otherwise
+   */
+  public static boolean isPdxInstanceType(Class<?> type) {
+    return PdxHelper.getInstance().isPdxInstanceType(type);
+  }
+  
+  /**
+   * Checks whether give type (java.lang.Class) of given object is same as or 
+   * sub-type of GemFire type PdxInstanceImpl.
+   * 
+   * @param object
+   *          object to be checked
+   * @return true if type of given object is same as or sub-type of GemFire type
+   *         PdxInstanceImpl, false otherwise
+   */
+  public static boolean isPdxInstance(Object object) {
+    return PdxHelper.getInstance().isPdxInstance(object);
+  }
+  
+  public static ResultSet introspectArrayType(Class type, Object array) throws IntrospectionException {
+    if(type.isArray()) {
+      Class component = type.getComponentType();
+      //Get the type representation of array component;
+      IntrospectionResult metaInfo = IntrospectionRepository.singleton().introspectType(component);
+      ArrayList<Object> result = new ArrayList<Object>();    
+      
+      if(array != null) {
+        int length = Array.getLength(array);
+        for(int i = 0; i < length ; i++) {
+          result.add(Array.get(array, i));
+        }
+      }
+      
+      Map<Object, IntrospectionResult> types = new HashMap<Object, IntrospectionResult>();
+      types.put(component, metaInfo);
+      
+      return new ResultSetImpl(types, result);      
+    }
+
+    throw new IllegalArgumentException("The parameter is not of type Array. "+type.getCanonicalName());
+  
+  }
+  
+  
+  public static boolean isColumnDeclaredInType(IntrospectionResult type, int index) {
+    if(type.getResultType() == IntrospectionResult.COMPOSITE_TYPE_RESULT) {
+      ObjectTypeResultImpl temp = (ObjectTypeResultImpl)type;
+      ObjectColumn col = temp.getObjectColumn(index);
+      if(col == null)
+       return false; 
+      return col.getDeclaringClass().equals(type.getJavaType());
+    }
+    
+    return true;
+  }
+  
+  static String applyLimitClause(String query) {
+    Matcher matcher = SELECT_EXPR_PATTERN.matcher(query);
+   
+    if(matcher.matches()) {
+      Matcher limit_matcher = SELECT_WITH_LIMIT_EXPR_PATTERN.matcher(query);
+      boolean matchResult = limit_matcher.matches();
+      
+      if(!matchResult) {
+        long limit = DataBrowserPreferences.getQueryLimit();
+        String result = new String(query);
+        result += " LIMIT "+limit; 
+        return result;
+      }
+    }
+    
+    return query;
+  }
+  
+  static final String SELECT_EXPR = "\\s*SELECT\\s+.+\\s+FROM\\s+.+";
+  static Pattern SELECT_EXPR_PATTERN = Pattern.compile(SELECT_EXPR, Pattern.CASE_INSENSITIVE);
+  
+  static final String SELECT_WITH_LIMIT_EXPR = "\\s*SELECT\\s+.+\\s+FROM(\\s+|(.*\\s+))LIMIT\\s+[0-9]+.*";
+  static Pattern SELECT_WITH_LIMIT_EXPR_PATTERN = Pattern.compile(SELECT_WITH_LIMIT_EXPR, Pattern.CASE_INSENSITIVE);
+}

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/e2ccf3da/databrowser/src/com/gemstone/gemfire/mgmt/DataBrowser/query/ResultSet.java
----------------------------------------------------------------------
diff --git a/databrowser/src/com/gemstone/gemfire/mgmt/DataBrowser/query/ResultSet.java b/databrowser/src/com/gemstone/gemfire/mgmt/DataBrowser/query/ResultSet.java
new file mode 100644
index 0000000..73af65d
--- /dev/null
+++ b/databrowser/src/com/gemstone/gemfire/mgmt/DataBrowser/query/ResultSet.java
@@ -0,0 +1,48 @@
+/*========================================================================= 
+ * (c)Copyright 2002-2009, GemStone Systems, Inc. All Rights Reserved.
+ * 1260 NW Waterhouse Ave., Suite 200, Beaverton, OR 97006 
+ * All Rights Reserved.
+ * =======================================================================*/
+package com.gemstone.gemfire.mgmt.DataBrowser.query;
+
+import java.util.Collection;
+
+public interface ResultSet {
+
+  public boolean isEmpty();
+  
+  /**
+   * This method returns the meta-data about the result of executed query.
+   * 
+   * @return The meta-data of result of the query execution.
+   */
+  public IntrospectionResult[] getIntrospectionResult();
+  
+  /**
+   * This method returns the results of the executed query.
+   * 
+   * @return The result of query execution.
+   */
+  public Collection<?> getQueryResult();
+  
+  /**
+   * This method returns the subset of result of the executed query for a given
+   * introspection type.
+   * 
+   * @param metaInfo
+   *          IntrospectionResult type for which we require result
+   * @return subset of result of the query execution.
+   */
+  public Collection<?> getQueryResult(IntrospectionResult metaInfo);
+  
+  /**
+   * This method returns the statistics of the Query execution.
+   * 
+   * @return The GemFire query execution statistics.
+   */  
+  public Object getColumnValue(Object tuple, int index)
+  throws ColumnNotFoundException, ColumnValueNotAvailableException; 
+  
+  public void close();
+  
+}

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/e2ccf3da/databrowser/src/com/gemstone/gemfire/mgmt/DataBrowser/query/cq/CQEventListener.java
----------------------------------------------------------------------
diff --git a/databrowser/src/com/gemstone/gemfire/mgmt/DataBrowser/query/cq/CQEventListener.java b/databrowser/src/com/gemstone/gemfire/mgmt/DataBrowser/query/cq/CQEventListener.java
new file mode 100644
index 0000000..dcbd977
--- /dev/null
+++ b/databrowser/src/com/gemstone/gemfire/mgmt/DataBrowser/query/cq/CQEventListener.java
@@ -0,0 +1,24 @@
+/*========================================================================= 
+ * (c)Copyright 2002-2009, GemStone Systems, Inc. All Rights Reserved.
+ * 1260 NW Waterhouse Ave., Suite 200, Beaverton, OR 97006 
+ * All Rights Reserved.
+ * =======================================================================*/
+package com.gemstone.gemfire.mgmt.DataBrowser.query.cq;
+
+import com.gemstone.gemfire.mgmt.DataBrowser.query.cq.event.ICQEvent;
+
+public interface CQEventListener {
+
+  /**
+   * This method is invoked when an event is occurred on the region
+   * that satisfied the query condition of this CQ or an exception scenario.
+   */
+  public void onEvent(ICQEvent aCqEvent);
+  
+  /**
+   * This method is invoked when a given CQ is stopped.
+   */
+  public void close();
+  
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/e2ccf3da/databrowser/src/com/gemstone/gemfire/mgmt/DataBrowser/query/cq/CQException.java
----------------------------------------------------------------------
diff --git a/databrowser/src/com/gemstone/gemfire/mgmt/DataBrowser/query/cq/CQException.java b/databrowser/src/com/gemstone/gemfire/mgmt/DataBrowser/query/cq/CQException.java
new file mode 100644
index 0000000..3f699eb
--- /dev/null
+++ b/databrowser/src/com/gemstone/gemfire/mgmt/DataBrowser/query/cq/CQException.java
@@ -0,0 +1,28 @@
+/*========================================================================= 
+ * (c)Copyright 2002-2009, GemStone Systems, Inc. All Rights Reserved.
+ * 1260 NW Waterhouse Ave., Suite 200, Beaverton, OR 97006 
+ * All Rights Reserved.
+ * =======================================================================*/
+package com.gemstone.gemfire.mgmt.DataBrowser.query.cq;
+
+import com.gemstone.gemfire.mgmt.DataBrowser.query.QueryExecutionException;
+
+public class CQException extends QueryExecutionException {
+
+  /**
+   * 
+   */
+  private static final long serialVersionUID = 1L;
+
+  public CQException(String arg0, Throwable arg1) {
+    super(arg0, arg1);
+  }
+
+  public CQException(String arg0) {
+    super(arg0);
+  }
+
+  public CQException(Throwable arg0) {
+    super(arg0);
+  }
+}

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/e2ccf3da/databrowser/src/com/gemstone/gemfire/mgmt/DataBrowser/query/cq/CQQuery.java
----------------------------------------------------------------------
diff --git a/databrowser/src/com/gemstone/gemfire/mgmt/DataBrowser/query/cq/CQQuery.java b/databrowser/src/com/gemstone/gemfire/mgmt/DataBrowser/query/cq/CQQuery.java
new file mode 100644
index 0000000..d8b2221
--- /dev/null
+++ b/databrowser/src/com/gemstone/gemfire/mgmt/DataBrowser/query/cq/CQQuery.java
@@ -0,0 +1,110 @@
+/*=========================================================================
+ * (c) Copyright 2002-2009, GemStone Systems, Inc. All Rights Reserved.
+ * 1260 NW Waterhouse Ave., Suite 200,  Beaverton, OR 97006
+ * All Rights Reserved.
+ *========================================================================
+ */
+
+package com.gemstone.gemfire.mgmt.DataBrowser.query.cq;
+
+import com.gemstone.gemfire.admin.RegionNotFoundException;
+import com.gemstone.gemfire.cache.query.CqClosedException;
+import com.gemstone.gemfire.cache.query.CqStatistics;
+import com.gemstone.gemfire.mgmt.DataBrowser.model.member.GemFireMember;
+
+
+/**
+ * Interface for continuous query. This provides methods for managing a CQ 
+ * once it is created through the QueryService. 
+ * The methods allow you to retrieve CQ related information, operate on CQ
+ * like execute, stop, close and get the state of the CQ.
+ *
+ * @author      Hrishi
+ **/
+
+public interface CQQuery {
+  
+  public GemFireMember getMember();  
+
+  /**
+   * Get the original query string that was specified with CQ.
+   * @return String the query string associated with CQ.
+   */
+  public String getQueryString();
+
+  /**
+   * Get the query object generated for this CQs query.
+   * @return Query query object for the query string.
+   */
+  public CQResult getQueryResult();
+
+  /**
+   * Get the name of the CQ.
+   * @return the name of the CQ.
+   */
+  public String getName();
+
+  /**
+   * Get statistics information for this CQ.
+   * @return CqStatistics CQ statistics object.
+   */
+  public CqStatistics getStatistics();  
+
+  /**
+   * Start executing the CQ or if this CQ is stopped earlier, resumes execution of the CQ.
+   * The CQ is executed on primary and redundant servers, if CQ execution fails on all the 
+   * server then a CqException is thrown.
+   * @throws CqClosedException if this CqQuery is closed.
+   * @throws RegionNotFoundException if the specified region in the
+   *         query string is not found.
+   * @throws IllegalStateException if the CqQuery is in the RUNNING state
+   *         already.
+   * @throws CQException if failed to execute.
+   */
+  public void execute() throws CQException;
+
+  /**
+   *  Stops this CqQuery without releasing resources. Puts the CqQuery into
+   *  the STOPPED state. Can be resumed by calling execute or
+   *  executeWithInitialResults.
+   *  @throws IllegalStateException if the CqQuery is in the STOPPED state
+   *          already.
+   *  @throws CqClosedException if the CQ is CLOSED.
+   */
+  public void stop() throws CQException;
+
+  /**
+   * Close the CQ and stop execution.  
+   * Releases the resources associated with this CqQuery.
+   * @throws CqClosedException Further calls on this CqQuery instance except 
+   *         for getState() or getName().
+   * @throws CQException - if failure during cleanup of CQ resources.
+   */ 
+  public void close() throws CQException;
+
+  /**
+   * This allows to check if the CQ is in running or active.
+   * @return boolean true if running, false otherwise
+   */
+  public boolean isRunning();
+
+  /**
+   * This allows to check if the CQ is in stopped.
+   * @return boolean true if stopped, false otherwise
+   */ 
+  public boolean isStopped();
+
+  /**
+   * This allows to check if the CQ is closed.
+   * @return boolean true if closed, false otherwise
+   */
+  public boolean isClosed();
+  
+  /**
+   * This allows to check if the CQ is durable.
+   * @return boolean true if durable, false otherwise
+   * @since 5.5
+   */
+  public boolean isDurable();
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/e2ccf3da/databrowser/src/com/gemstone/gemfire/mgmt/DataBrowser/query/cq/CQQueryImpl.java
----------------------------------------------------------------------
diff --git a/databrowser/src/com/gemstone/gemfire/mgmt/DataBrowser/query/cq/CQQueryImpl.java b/databrowser/src/com/gemstone/gemfire/mgmt/DataBrowser/query/cq/CQQueryImpl.java
new file mode 100644
index 0000000..b24a687
--- /dev/null
+++ b/databrowser/src/com/gemstone/gemfire/mgmt/DataBrowser/query/cq/CQQueryImpl.java
@@ -0,0 +1,88 @@
+/*========================================================================= 
+ * (c)Copyright 2002-2009, GemStone Systems, Inc. All Rights Reserved.
+ * 1260 NW Waterhouse Ave., Suite 200, Beaverton, OR 97006 
+ * All Rights Reserved.
+ * =======================================================================*/
+package com.gemstone.gemfire.mgmt.DataBrowser.query.cq;
+
+import com.gemstone.gemfire.cache.query.CqQuery;
+import com.gemstone.gemfire.cache.query.CqStatistics;
+import com.gemstone.gemfire.mgmt.DataBrowser.model.member.GemFireMember;
+
+public class CQQueryImpl implements CQQuery {
+  private GemFireMember member;
+  private CqQuery query;
+  private CQResult result;
+
+  public CQQueryImpl(GemFireMember mbr, CqQuery qry, CQResult res) {
+    super();
+    member = mbr;
+    query = qry;
+    result = res;
+  }
+  
+  public GemFireMember getMember() {
+    return member;
+  }
+
+  public void close() throws CQException {
+    try {
+      query.close();
+      result.close();
+    }
+    catch (com.gemstone.gemfire.cache.query.CqException e) {
+      throw new CQException(e);
+    }
+  }
+
+  public void execute() throws CQException {
+    try {
+      query.execute();
+    }
+    catch (Exception e) {
+      throw new CQException(e);
+    }
+  }
+
+  public String getName() {
+    return query.getName();
+  }
+
+  public CQResult getQueryResult() {
+    return result;
+  }
+
+  public String getQueryString() {
+    return query.getQueryString();
+  }
+
+  public CqStatistics getStatistics() {
+    return this.query.getStatistics();
+  }
+
+  public boolean isClosed() {
+    return this.query.isClosed();
+  }
+
+  public boolean isDurable() {
+    return this.query.isDurable();
+  }
+
+  public boolean isRunning() {
+    return this.query.isRunning();
+  }
+
+  public boolean isStopped() {
+    return this.query.isStopped();
+  }
+
+  public void stop() throws CQException {
+    try {
+      this.query.stop();
+    }
+    catch (Exception e) {
+      throw new CQException(e);
+    }
+  }
+
+}


Mime
View raw message