geode-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From r..@apache.org
Subject [49/51] [partial] incubator-geode git commit: Init
Date Tue, 28 Apr 2015 21:40:54 GMT
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/19459053/gemfire-assembly/src/main/dist/bin/gfsh-completion.bash
----------------------------------------------------------------------
diff --git a/gemfire-assembly/src/main/dist/bin/gfsh-completion.bash b/gemfire-assembly/src/main/dist/bin/gfsh-completion.bash
new file mode 100755
index 0000000..6db7ef1
--- /dev/null
+++ b/gemfire-assembly/src/main/dist/bin/gfsh-completion.bash
@@ -0,0 +1,88 @@
+#!/usr/bin/env bash
+#
+# Auto completion script for GemFire's gfsh script
+#
+# Either explicitly source it into your shell enviroment, set it up in your
+# .bashrc or .bash_profile or copy it to /etc/bash_completion.d
+#
+
+_gfsh() {
+    # The main verbs gfsh understands
+    declare -r VERBS="compact describe encrypt help run start status stop validate version"
+
+    # The nouns relevant to the verbs
+    declare -r N_compact="offline-disk-store"
+    declare -r N_describe="offline-disk-store"
+    declare -r N_encrypt="password"
+    declare -r N_help="$VERBS"
+    declare -r N_start="jconsole jvisualvm locator pulse server vsd"
+    declare -r N_status="locator server"
+    declare -r N_stop="locator server"
+    declare -r N_validate="offline-disk-store"
+
+    # The options relevant to each verb-noun combination
+    declare -r OPT_compact_offline_disk_store="--name --disk-dirs --max-oplog-size --J"
+    declare -r OPT_describe_offline_disk_store="--name=value --disk-dirs --region"
+    declare -r OPT_encrypt_password="--password"
+    declare -r OPT_run="--file --quiet --continue-on-error"
+    declare -r OPT_start_jconsole="--interval --notile --pluginpath --version --J"
+    declare -r OPT_start_jvisualvm="--J"
+    declare -r OPT_start_locator="--name --bind-address --force --group \
+        --hostname-for-clients --locators --log-level --mcast-address \
+        --mcast-port --port --dir --properties-file --security-properties-file \
+        --initial-heap --max-heap --J --connect --enable-cluster-configuration \
+        --load-cluster-configuration-from-dir"
+    declare -r OPT_start_pulse="--url"
+    declare -r OPT_start_server="--name --assign-buckets --bind-address \
+        --cache-xml-file --classpath --disable-default-server \
+        --disable-exit-when-out-of-memory --enable-time-statistics --force \
+        --properties-file --security-properties-file --group \
+        --locators \
+        --log-level --mcast-address --mcast-port --name --memcached-port \
+        --memcached-protocol --rebalance --server-bind-address --server-port \
+        --spring-xml-location --statistic-archive-file --dir --initial-heap \
+        --max-heap --use-cluster-configuration --J --critical-heap-percentage \
+        --eviction-heap-percentage --hostname-for-clients --max-connections \
+        --message-time-to-live --max-message-count --max-threads --socket-buffer-size"
+    declare -r OPT_start_vsd="--file"
+    declare -r OPT_status_locator="--name --host --port --pid --dir"
+    declare -r OPT_status_server="--name --pid --dir"
+    declare -r OPT_stop_locator="--name --pid --dir"
+    declare -r OPT_stop_server="--name --pid --dir"
+    declare -r OPT_validate_offline_disk_store="--name --disk-dirs"
+    declare -r OPT_version="--full"
+
+    local cur=${COMP_WORDS[COMP_CWORD]}
+    local use="VERBS"
+
+    local verb=${COMP_WORDS[1]}
+    local noun=${COMP_WORDS[2]}
+
+    # Ignore potential options
+    noun=${noun##-*}
+
+    # Because variable names can't have dashes
+    noun=${noun//-/_}
+
+    if [[ -n "$noun" ]]; then
+        use="OPT_${verb}_${noun}"
+        if [[ -z "${!use}" ]]; then
+            use="N_$verb"
+        fi
+    elif [[ -n "$verb" ]]; then
+        # Special handling for these as they don't have associated nouns
+        if [[ "$verb" = "run" || "$verb" = "version" ]]; then
+            use="OPT_$verb"
+        else
+            use="N_$verb"
+            if [[ -z "${!use}" ]]; then
+                use="VERBS"
+            fi
+        fi
+    fi
+
+    COMPREPLY=( $( compgen -W "${!use}" -- "$cur" ) )
+}
+
+complete -F _gfsh gfsh
+    

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/19459053/gemfire-assembly/src/main/dist/bin/gfsh.bat
----------------------------------------------------------------------
diff --git a/gemfire-assembly/src/main/dist/bin/gfsh.bat b/gemfire-assembly/src/main/dist/bin/gfsh.bat
new file mode 100755
index 0000000..c4a9480
--- /dev/null
+++ b/gemfire-assembly/src/main/dist/bin/gfsh.bat
@@ -0,0 +1,73 @@
+@echo off
+
+REM
+REM Environment variables:
+REM
+REM GF_JAVA - java executable path. 
+REM
+REM JAVA_ARGS - java arguments, i.e., -Xms1024m -Xmx1024m ... 
+REM
+REM GEMFIRE - GemFire product Directory
+REM
+REM
+
+@setlocal enableextensions
+@set scriptdir=%~dp0
+@set gf=%scriptdir:\bin\=%
+REM echo %gf%
+REM echo %scriptdir%
+@if exist "%gf%\lib\gemfire-core-dependencies.jar" @goto gfok
+@echo Could not determine GEMFIRE location
+@verify other 2>nul
+@goto done
+:gfok
+@set GEMFIRE=%gf%
+
+@set GEMFIRE_JARS=%GEMFIRE%\lib\gfsh-dependencies.jar
+@if defined CLASSPATH (
+@set GEMFIRE_JARS=%GEMFIRE_JARS%;%CLASSPATH%
+)
+
+@if not defined GF_JAVA (
+@REM %GF_JAVA% is not defined, assume it is on the PATH
+@if defined JAVA_HOME (
+@set GF_JAVA=%JAVA_HOME%\bin\java.exe
+) else (
+@set GF_JAVA=java
+)
+) 
+
+REM
+REM GFSH_JARS
+REM
+@set GFSH_JARS=;%GEMFIRE%\lib\gfsh-dependencies.jar
+@set CLASSPATH=%GFSH_JARS%;%GEMFIRE_JARS%
+
+REM
+REM Copy default .gfshrc to the home directory. Uncomment if needed.
+REM
+REM @if not exist "%USERPROFILE%\.gemfire\.gfsh2rc" (
+REM @xcopy /q "%GEMFIRE%\defaultConfigs\.gfsh2rc" "%USERPROFILE%\.gemfire"
+REM )
+
+REM
+REM Make dir if .gemfire does not exist. Uncomment if needed.
+REM
+REM @if not exist "%USERPROFILE%\.gemfire" (
+REM @mkdir "%USERPROFILE%\.gemfire"
+REM )
+
+REM  Consider java is from JDK
+@set TOOLS_JAR=%JAVA_HOME%\lib\tools.jar
+@IF EXIST "%TOOLS_JAR%" (
+    @set CLASSPATH=%CLASSPATH%;%TOOLS_JAR%
+) ELSE (
+    set TOOLS_JAR=
+)
+
+@set LAUNCHER=com.gemstone.gemfire.management.internal.cli.Launcher
+@if defined JAVA_ARGS (
+@set JAVA_ARGS="%JAVA_ARGS%"
+)
+@"%GF_JAVA%" -Dgfsh=true -Dlog4j.configurationFile=/com/gemstone/gemfire/internal/logging/log4j/log4j2-cli.xml %JAVA_ARGS% %LAUNCHER% %*
+:done

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/19459053/gemfire-core/build.gradle
----------------------------------------------------------------------
diff --git a/gemfire-core/build.gradle b/gemfire-core/build.gradle
new file mode 100755
index 0000000..7639aa4
--- /dev/null
+++ b/gemfire-core/build.gradle
@@ -0,0 +1,133 @@
+sourceSets {
+  jca {
+    compileClasspath += configurations.compile
+    runtimeClasspath += configurations.runtime
+  }
+}
+
+configurations {
+  //declaring new configuration that will be used to associate with artifacts
+  archives
+}
+
+dependencies {
+  provided files("${System.getProperty('java.home')}/../lib/tools.jar")
+  compile 'antlr:antlr:2.7.7'
+  compile 'com.fasterxml.jackson.core:jackson-annotations:2.2.0'
+  compile 'com.fasterxml.jackson.core:jackson-core:2.2.0'
+  compile 'com.fasterxml.jackson.core:jackson-databind:2.2.0'
+  compile 'com.google.code.findbugs:annotations:3.0.0'
+  compile 'commons-io:commons-io:2.3'
+  compile 'commons-logging:commons-logging:1.1.1'
+  compile 'commons-modeler:commons-modeler:2.0'
+  compile 'it.unimi.dsi:fastutil:6.6.2'
+  compile 'javax.activation:activation:1.1.1'
+  compile 'javax.mail:javax.mail-api:1.4.5'
+  compile 'javax.resource:javax.resource-api:1.7'
+  compile 'javax.servlet:javax.servlet-api:3.1.0'
+  compile 'javax.transaction:javax.transaction-api:1.2'
+  compile 'mx4j:mx4j:3.0.1'
+  compile 'mx4j:mx4j-remote:3.0.1'
+  compile 'mx4j:mx4j-tools:3.0.1'
+  compile 'net.java.dev.jna:jna:4.0.0'
+  compile 'net.sourceforge.jline:jline:1.0.S2-B'
+  compile 'org.eclipse.jetty:jetty-http:9.2.3.v20140905'
+  compile 'org.eclipse.jetty:jetty-io:9.2.3.v20140905'
+  compile 'org.eclipse.jetty:jetty-security:9.2.3.v20140905'
+  compile 'org.eclipse.jetty:jetty-server:9.2.3.v20140905'
+  compile 'org.eclipse.jetty:jetty-servlet:9.2.3.v20140905'
+  compile 'org.eclipse.jetty:jetty-util:9.2.3.v20140905'
+  compile 'org.eclipse.jetty:jetty-webapp:9.2.3.v20140905'
+  compile 'org.eclipse.jetty:jetty-xml:9.2.3.v20140905'
+  compile 'org.fusesource.jansi:jansi:1.8'
+  compile 'org.apache.logging.log4j:log4j-api:2.1'
+  compile 'org.apache.logging.log4j:log4j-core:2.1'
+  compile 'org.apache.logging.log4j:log4j-slf4j-impl:2.1'
+  compile 'org.apache.logging.log4j:log4j-jcl:2.1'
+  compile 'org.slf4j:slf4j-api:1.7.7'
+  compile 'org.springframework.data:spring-data-commons:1.9.1.RELEASE'
+  compile 'org.springframework.data:spring-data-gemfire:1.5.1.RELEASE'
+  compile 'org.springframework:spring-tx:3.2.12.RELEASE'
+  compile 'org.springframework.shell:spring-shell:1.0.0.RELEASE'
+  compile 'org.xerial.snappy:snappy-java:1.1.1.6'
+
+  compile project(':gemfire-jgroups')
+  compile project(':gemfire-joptsimple')
+  compile project(':gemfire-json')
+  
+  testCompile 'org.apache.bcel:bcel:5.2'
+
+  jcaCompile sourceSets.main.output
+
+  provided project(path: ':gemfire-junit', configuration: 'testOutput')
+}
+
+// Creates the version properties file and writes it to the classes dir
+task createVersionPropertiesFile << {
+  ext.gitBranch = 'master'
+  ext.commitId = '1366ff2d4fcbf54bfad684e9ba9822db2a2b0ff5'
+  ext.sourceDate = '2015-04-06 14:54:51 -0700'
+  
+  ext.osArch = System.getProperty('os.arch')
+  ext.osName = System.getProperty('os.name')
+  ext.osVersion = System.getProperty('os.version')
+  ext.buildDate = new Date().format('yyyy-MM-dd HH:mm:ss Z')
+  ext.buildNumber = new Date().format('MMddyy')
+  ext.jdkVersion = System.getProperty('java.version')
+
+  def props = [
+    "Product-Name"      : "Pivotal GemFire",
+    "Product-Version"   : version,
+    "Build-Id"          : System.env.USER + ' ' + ext.buildNumber,
+    "Build-Date"        : ext.buildDate,
+    "Build-Platform"    : ext.osName + ' ' + ext.osVersion + ' ' + ext.osArch,
+    "Build-Java-Version": ext.jdkVersion,
+    "Source-Date"       : ext.sourceDate,
+    "Source-Revision"   : ext.commitId,
+    "Source-Repository" : ext.gitBranch
+  ] as Properties
+
+  new FileOutputStream(file("$buildDir/classes/main/com/gemstone/gemfire/internal/GemFireVersion.properties")).withStream { fos ->
+    props.store(fos, '')
+  }
+}
+
+jar {
+
+  from sourceSets.main.output
+  from sourceSets.jca.output
+  
+  exclude 'com/gemstone/gemfire/management/internal/web/**'
+  exclude 'com/gemstone/gemfire/internal/i18n/StringIdResourceBundle_ja.txt'
+  exclude 'com/gemstone/gemfire/admin/doc-files/ds4_0.dtd'
+}
+
+task webJar (type: Jar, dependsOn: classes) {
+  description 'Assembles the jar archive containing the gemfire management web classes.'
+  from sourceSets.main.output
+  baseName 'gemfire-web'
+  include 'com/gemstone/gemfire/management/internal/web/**'
+}
+
+task raJar (type: Jar, dependsOn: classes) {
+  description 'Assembles the jar archive that contains the JCA classes'
+  from sourceSets.jca.output
+  exclude 'com/gemstone/gemfire/ra/**'
+  archiveName 'ra.jar'
+}
+
+task jcaJar (type: Jar, dependsOn: raJar) {
+  description 'Assembles the jar archive that contains the JCA bundle'
+  baseName 'gemfire-jca'
+  extension 'rar'
+  metaInf { from 'src/jca/ra.xml' }
+  from raJar.archivePath
+}
+
+artifacts {
+  archives webJar, raJar, jcaJar
+}
+
+compileJava.doLast {
+    tasks.createVersionPropertiesFile.execute()
+}

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/19459053/gemfire-core/src/jca/java/com/gemstone/gemfire/internal/ra/GFConnectionFactoryImpl.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/jca/java/com/gemstone/gemfire/internal/ra/GFConnectionFactoryImpl.java b/gemfire-core/src/jca/java/com/gemstone/gemfire/internal/ra/GFConnectionFactoryImpl.java
new file mode 100644
index 0000000..0453cf7
--- /dev/null
+++ b/gemfire-core/src/jca/java/com/gemstone/gemfire/internal/ra/GFConnectionFactoryImpl.java
@@ -0,0 +1,57 @@
+/*=========================================================================
+ * Copyright (c) 2010-2014 Pivotal Software, Inc. All Rights Reserved.
+ * This product is protected by U.S. and international copyright
+ * and intellectual property laws. Pivotal products are covered by
+ * one or more patents listed at http://www.pivotal.io/patents.
+ *=========================================================================
+ */
+package com.gemstone.gemfire.internal.ra;
+
+import javax.naming.NamingException;
+import javax.naming.Reference;
+import javax.resource.ResourceException;
+import javax.resource.spi.ConnectionManager;
+import javax.resource.spi.ManagedConnectionFactory;
+
+import com.gemstone.gemfire.ra.GFConnectionFactory;
+/**
+ * 
+ * @author asif
+ *
+ */
+public class GFConnectionFactoryImpl implements GFConnectionFactory
+{
+  final private ConnectionManager cm;
+
+  final private ManagedConnectionFactory mcf;
+
+  private Reference ref;
+
+  public GFConnectionFactoryImpl(ManagedConnectionFactory mcf) {
+    this.cm = null;
+    this.mcf = mcf;
+  }
+
+  public GFConnectionFactoryImpl(ConnectionManager cm,
+      ManagedConnectionFactory mcf) {
+    this.cm = cm;
+    this.mcf = mcf;
+  }
+
+  public GFConnectionImpl getConnection() throws ResourceException
+  {
+    return (GFConnectionImpl)cm.allocateConnection(mcf, null);
+  }
+
+  public void setReference(Reference ref)
+  {
+    this.ref = ref;
+
+  }
+
+  public Reference getReference() throws NamingException
+  {
+    return this.ref;
+  }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/19459053/gemfire-core/src/jca/java/com/gemstone/gemfire/internal/ra/GFConnectionImpl.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/jca/java/com/gemstone/gemfire/internal/ra/GFConnectionImpl.java b/gemfire-core/src/jca/java/com/gemstone/gemfire/internal/ra/GFConnectionImpl.java
new file mode 100644
index 0000000..095fe9f
--- /dev/null
+++ b/gemfire-core/src/jca/java/com/gemstone/gemfire/internal/ra/GFConnectionImpl.java
@@ -0,0 +1,62 @@
+/*=========================================================================
+ * Copyright (c) 2010-2014 Pivotal Software, Inc. All Rights Reserved.
+ * This product is protected by U.S. and international copyright
+ * and intellectual property laws. Pivotal products are covered by
+ * one or more patents listed at http://www.pivotal.io/patents.
+ *=========================================================================
+ */
+package com.gemstone.gemfire.internal.ra;
+
+import javax.naming.NamingException;
+import javax.naming.Reference;
+import javax.resource.ResourceException;
+
+import com.gemstone.gemfire.internal.ra.spi.JCAManagedConnection;
+import com.gemstone.gemfire.ra.GFConnection;
+
+/**
+ * 
+ * @author asif
+ *
+ */
+public class GFConnectionImpl implements GFConnection
+{
+  private JCAManagedConnection mc;
+
+  private Reference ref;
+
+  public GFConnectionImpl(JCAManagedConnection mc) {
+    this.mc = mc;
+  }
+
+  public void resetManagedConnection(JCAManagedConnection mc)
+  {
+    this.mc = mc;
+  }
+
+  public void close() throws ResourceException
+  {
+    // Check if the connection is associated with a JTA. If yes, then
+    // we should throw an exception on close being invoked.
+    if (this.mc != null) {
+      this.mc.onClose(this);
+    }
+  }
+
+  public void invalidate()
+  {
+    this.mc = null;
+  }
+
+  public void setReference(Reference ref)
+  {
+    this.ref = ref;
+
+  }
+
+  public Reference getReference() throws NamingException
+  {
+    return this.ref;
+  }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/19459053/gemfire-core/src/jca/java/com/gemstone/gemfire/internal/ra/spi/JCALocalTransaction.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/jca/java/com/gemstone/gemfire/internal/ra/spi/JCALocalTransaction.java b/gemfire-core/src/jca/java/com/gemstone/gemfire/internal/ra/spi/JCALocalTransaction.java
new file mode 100644
index 0000000..1d1a61b
--- /dev/null
+++ b/gemfire-core/src/jca/java/com/gemstone/gemfire/internal/ra/spi/JCALocalTransaction.java
@@ -0,0 +1,227 @@
+/*=========================================================================
+ * Copyright (c) 2010-2014 Pivotal Software, Inc. All Rights Reserved.
+ * This product is protected by U.S. and international copyright
+ * and intellectual property laws. Pivotal products are covered by
+ * one or more patents listed at http://www.pivotal.io/patents.
+ *=========================================================================
+ */
+package com.gemstone.gemfire.internal.ra.spi;
+
+import javax.resource.ResourceException;
+import javax.resource.spi.LocalTransaction;
+import javax.resource.spi.LocalTransactionException;
+import javax.transaction.SystemException;
+import javax.transaction.TransactionManager;
+
+import com.gemstone.gemfire.LogWriter;
+import com.gemstone.gemfire.cache.CacheFactory;
+import com.gemstone.gemfire.cache.TransactionId;
+import com.gemstone.gemfire.internal.cache.GemFireCacheImpl;
+import com.gemstone.gemfire.internal.cache.TXStateProxy;
+
+import com.gemstone.gemfire.internal.cache.TXManagerImpl;
+import com.gemstone.gemfire.internal.i18n.LocalizedStrings;
+
+/**
+ * 
+ * @author asif
+ *
+ */
+public class JCALocalTransaction implements LocalTransaction
+{
+  private volatile GemFireCacheImpl cache;
+
+  private volatile TXManagerImpl gfTxMgr;
+
+  private volatile TransactionId tid;
+
+  private static final boolean DEBUG = false;
+
+  private volatile boolean initDone = false;
+
+  JCALocalTransaction(GemFireCacheImpl cache, TXManagerImpl tm) {
+    this.cache = cache;
+    this.gfTxMgr = tm;
+    this.initDone = true;
+    // System.out.println("Asif:JCALocalTransaction:Param contrcutr for tx ="+
+    // this );
+  }
+
+  JCALocalTransaction() {
+    this.cache = null;
+    this.gfTxMgr = null;
+    this.initDone = false;
+    // System.out.println("Asif:JCALocalTransaction:Empty constructor for tx ="+
+    // this );
+  }
+
+  public void begin() throws ResourceException
+  {
+    if (DEBUG) {
+      try {
+        throw new NullPointerException("Asif:JCALocalTransaction:begin");
+      }
+      catch (NullPointerException npe) {
+        npe.printStackTrace();
+      }
+    }
+    try {
+      if (!initDone || this.cache.isClosed()) {
+        this.init();
+      }
+      // System.out.println("JCALocalTransaction:Asif: cache is ="+cache +
+      // " for tx ="+this);
+      LogWriter logger = cache.getLogger();
+      if (logger.fineEnabled()) {
+        logger.fine("JCALocalTransaction::begin:");
+      }
+      TransactionManager tm = cache.getJTATransactionManager();
+      if (this.tid != null) {
+        throw new LocalTransactionException(
+            " A transaction is already in progress");
+      }
+      if (tm != null && tm.getTransaction() != null) {
+        if (logger.fineEnabled()) {
+          logger.fine("JCAManagedConnection: JTA transaction is on");
+        }
+        // This is having a JTA transaction. Assuming ignore jta flag is true,
+        // explicitly being a gemfire transaction.
+        TXStateProxy tsp = this.gfTxMgr.getTXState();
+        if (tsp == null) {
+          this.gfTxMgr.begin();
+          tsp = this.gfTxMgr.getTXState();
+          tsp.setJCATransaction();
+          this.tid = tsp.getTransactionId();
+          if (logger.fineEnabled()) {
+            logger.fine("JCALocalTransaction:begun GFE transaction");
+          }
+        }
+        else {
+          throw new LocalTransactionException(
+              "GemFire is already associated with a transaction");
+        }
+      }
+      else {
+        if (logger.fineEnabled()) {
+          logger.fine("JCAManagedConnection: JTA Transaction does not exist.");
+        }
+      }
+    }
+    catch (SystemException e) {
+      // this.onError();
+      throw new ResourceException(e);
+    }
+    // Not to be invoked for local transactions managed by the container
+    // Iterator<ConnectionEventListener> itr = this.listeners.iterator();
+    // ConnectionEvent ce = new ConnectionEvent(this,
+    // ConnectionEvent.LOCAL_TRANSACTION_STARTED);
+    // while (itr.hasNext()) {
+    // itr.next().localTransactionStarted(ce);
+    // }
+
+  }
+
+  public void commit() throws ResourceException
+  {
+    if (DEBUG) {
+      try {
+        throw new NullPointerException("Asif:JCALocalTransaction:commit");
+      }
+      catch (NullPointerException npe) {
+        npe.printStackTrace();
+      }
+    }
+    LogWriter logger = cache.getLogger();
+    if (logger.fineEnabled()) {
+      logger.fine("JCALocalTransaction:invoked commit");
+    }
+    TXStateProxy tsp = this.gfTxMgr.getTXState();
+    if (tsp != null && this.tid != tsp.getTransactionId()) {
+      throw new IllegalStateException(
+          "Local Transaction associated with Tid = " + this.tid
+              + " attempting to commit a different transaction");
+    }
+    try {
+      this.gfTxMgr.commit();
+      this.tid = null;
+    }
+    catch (Exception e) {
+      throw new LocalTransactionException(e.toString());
+    }
+    // Iterator<ConnectionEventListener> itr = this.listeners.iterator();
+    // ConnectionEvent ce = new
+    // ConnectionEvent(this,ConnectionEvent.LOCAL_TRANSACTION_COMMITTED);
+    // while( itr.hasNext()) {
+    // itr.next().localTransactionCommitted(ce);
+    // }
+
+  }
+
+  public void rollback() throws ResourceException
+  {
+    if (DEBUG) {
+      try {
+        throw new NullPointerException("Asif:JJCALocalTransaction:rollback");
+      }
+      catch (NullPointerException npe) {
+        npe.printStackTrace();
+      }
+    }
+    TXStateProxy tsp = this.gfTxMgr.getTXState();
+    if (tsp != null && this.tid != tsp.getTransactionId()) {
+      throw new IllegalStateException(
+          "Local Transaction associated with Tid = " + this.tid
+              + " attempting to commit a different transaction");
+    }
+    LogWriter logger = cache.getLogger();
+    if (logger.fineEnabled()) {
+      logger.fine("JCALocalTransaction:invoked rollback");
+    }
+    try {
+      this.gfTxMgr.rollback();
+    }
+    catch (IllegalStateException ise) {
+      // It is possible that the GFE transaction has already been rolled back.
+      if (ise
+          .getMessage()
+          .equals(
+              LocalizedStrings.TXManagerImpl_THREAD_DOES_NOT_HAVE_AN_ACTIVE_TRANSACTION
+                  .toLocalizedString())) {
+        // /ignore;
+      }
+      else {
+        throw new ResourceException(ise);
+      }
+    }
+    catch (Exception e) {
+      throw new ResourceException(e);
+    }
+    finally {
+      this.tid = null;
+    }
+    // Iterator<ConnectionEventListener> itr = this.listeners.iterator();
+    // ConnectionEvent ce = new ConnectionEvent(this,
+    // ConnectionEvent.LOCAL_TRANSACTION_ROLLEDBACK);
+    // while (itr.hasNext()) {
+    // itr.next().localTransactionRolledback(ce);
+    // }
+
+  }
+
+  private void init() throws SystemException
+  {
+    this.cache = (GemFireCacheImpl)CacheFactory.getAnyInstance();
+    LogWriter logger = this.cache.getLogger();
+    if (logger.fineEnabled()) {
+      logger.fine("JCAManagedConnection:init. Inside init");
+    }
+    gfTxMgr = cache.getTxManager();
+    this.initDone = true;
+  }
+
+  boolean transactionInProgress()
+  {
+    return this.tid != null;
+  }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/19459053/gemfire-core/src/jca/java/com/gemstone/gemfire/internal/ra/spi/JCAManagedConnection.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/jca/java/com/gemstone/gemfire/internal/ra/spi/JCAManagedConnection.java b/gemfire-core/src/jca/java/com/gemstone/gemfire/internal/ra/spi/JCAManagedConnection.java
new file mode 100644
index 0000000..9b54c33
--- /dev/null
+++ b/gemfire-core/src/jca/java/com/gemstone/gemfire/internal/ra/spi/JCAManagedConnection.java
@@ -0,0 +1,290 @@
+/*=========================================================================
+ * Copyright (c) 2010-2014 Pivotal Software, Inc. All Rights Reserved.
+ * This product is protected by U.S. and international copyright
+ * and intellectual property laws. Pivotal products are covered by
+ * one or more patents listed at http://www.pivotal.io/patents.
+ *=========================================================================
+ */
+package com.gemstone.gemfire.internal.ra.spi;
+
+import java.io.PrintWriter;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Set;
+
+import javax.resource.NotSupportedException;
+import javax.resource.ResourceException;
+import javax.resource.spi.ConnectionEvent;
+import javax.resource.spi.ConnectionEventListener;
+import javax.resource.spi.ConnectionRequestInfo;
+import javax.resource.spi.LocalTransaction;
+import javax.resource.spi.ManagedConnection;
+import javax.resource.spi.ManagedConnectionMetaData;
+import javax.security.auth.Subject;
+import javax.transaction.SystemException;
+import javax.transaction.xa.XAResource;
+
+import com.gemstone.gemfire.LogWriter;
+import com.gemstone.gemfire.cache.CacheFactory;
+import com.gemstone.gemfire.internal.cache.GemFireCacheImpl;
+import com.gemstone.gemfire.internal.cache.TXManagerImpl;
+import com.gemstone.gemfire.internal.ra.GFConnectionImpl;
+
+/**
+ * 
+ * @author asif
+ *
+ */
+public class JCAManagedConnection implements ManagedConnection
+
+{
+  private final List<ConnectionEventListener> listeners;
+
+  private volatile TXManagerImpl gfTxMgr;
+
+  // private volatile TransactionId currentTxID;
+  private volatile GemFireCacheImpl cache;
+
+  private volatile boolean initDone = false;
+
+  private volatile PrintWriter logger;
+
+  private JCAManagedConnectionFactory factory;
+
+  private volatile Set<GFConnectionImpl> connections;
+
+  private volatile JCALocalTransaction localTran;
+
+  private final static boolean DEBUG = false;
+
+  public JCAManagedConnection(JCAManagedConnectionFactory fact) {
+    this.factory = fact;
+    this.listeners = Collections
+        .<ConnectionEventListener> synchronizedList(new ArrayList<ConnectionEventListener>());
+    this.localTran = new JCALocalTransaction();
+    this.connections = Collections
+        .<GFConnectionImpl> synchronizedSet(new HashSet<GFConnectionImpl>());
+  }
+
+  public void addConnectionEventListener(ConnectionEventListener listener)
+  {
+    this.listeners.add(listener);
+
+  }
+
+  public void associateConnection(Object conn) throws ResourceException
+  {
+    if (!(conn instanceof GFConnectionImpl)) {
+      throw new ResourceException("Connection is not of type GFConnection");
+    }
+
+    ((GFConnectionImpl)conn).resetManagedConnection(this);
+    this.connections.add((GFConnectionImpl)conn);
+  }
+
+  public void cleanup() throws ResourceException
+  {
+    if (DEBUG) {
+      try {
+        throw new NullPointerException("Asif:JCAManagedConnection:cleanup");
+      }
+      catch (NullPointerException npe) {
+        npe.printStackTrace();
+      }
+    }
+    synchronized (this.connections) {
+      Iterator<GFConnectionImpl> connsItr = this.connections.iterator();
+      while (connsItr.hasNext()) {
+        GFConnectionImpl conn = connsItr.next();
+        conn.invalidate();
+        connsItr.remove();
+      }
+    }
+    if (this.localTran == null || this.localTran.transactionInProgress()) {
+      if (this.initDone && !this.cache.isClosed()) {
+        this.localTran = new JCALocalTransaction(cache, gfTxMgr);
+      }
+      else {
+        this.localTran = new JCALocalTransaction();
+      }
+    }
+
+  }
+
+  public void destroy() throws ResourceException
+  {
+    if (DEBUG) {
+      try {
+        throw new NullPointerException("Asif:JCAManagedConnection:destroy");
+      }
+      catch (NullPointerException npe) {
+        npe.printStackTrace();
+      }
+    }
+    synchronized (this.connections) {
+      Iterator<GFConnectionImpl> connsItr = this.connections.iterator();
+      while (connsItr.hasNext()) {
+        GFConnectionImpl conn = connsItr.next();
+        conn.invalidate();
+        connsItr.remove();
+      }
+    }
+    this.gfTxMgr = null;
+    this.cache = null;
+    this.localTran = null;
+    this.listeners.clear();
+  }
+
+  public Object getConnection(Subject arg0, ConnectionRequestInfo arg1)
+      throws ResourceException
+  {
+    if (DEBUG) {
+      try {
+        throw new NullPointerException(
+            "Asif:JCAManagedConnection:getConnection");
+      }
+      catch (NullPointerException npe) {
+        npe.printStackTrace();
+      }
+    }
+    try {
+      if (!this.initDone || this.cache.isClosed()) {
+        init();
+      }
+      LogWriter logger = this.cache.getLogger();
+      if (logger.fineEnabled()) {
+        logger
+            .fine("JCAManagedConnection:getConnection. Returning new Connection");
+      }
+
+      GFConnectionImpl conn = new GFConnectionImpl(this);
+      this.connections.add(conn);
+      return conn;
+    }
+    catch (SystemException e) {
+      this.onError(e);
+      throw new ResourceException("GemFire Resource unavailable", e);
+    }
+  }
+
+  private void init() throws SystemException
+  {
+    this.cache = (GemFireCacheImpl)CacheFactory.getAnyInstance();
+    LogWriter logger = this.cache.getLogger();
+    if (logger.fineEnabled()) {
+      logger.fine("JCAManagedConnection:init. Inside init");
+    }
+    gfTxMgr = cache.getTxManager();
+    this.initDone = true;
+  }
+
+  public LocalTransaction getLocalTransaction() throws ResourceException
+  {
+    if (DEBUG) {
+      try {
+        throw new NullPointerException(
+            "Asif:JCAManagedConnection:getLocalTransaction");
+      }
+      catch (NullPointerException npe) {
+        npe.printStackTrace();
+      }
+    }
+
+    return this.localTran;
+  }
+
+  public PrintWriter getLogWriter() throws ResourceException
+  {
+    return this.logger;
+  }
+
+  public ManagedConnectionMetaData getMetaData() throws ResourceException
+  {
+    if (DEBUG) {
+      try {
+        throw new NullPointerException("Asif:JCAManagedConnection:getMetaData");
+      }
+      catch (NullPointerException npe) {
+        npe.printStackTrace();
+      }
+    }
+    if (this.initDone && !this.cache.isClosed()) {
+      LogWriter logger = this.cache.getLogger();
+      if (logger.fineEnabled()) {
+        logger.fine("JCAManagedConnection:getMetaData");
+      }
+    }
+    return new JCAManagedConnectionMetaData(this.factory.getProductName(),
+        this.factory.getVersion(), this.factory.getUserName());
+  }
+
+  public XAResource getXAResource() throws ResourceException
+  {
+    throw new NotSupportedException("XA Transaction not supported");
+  }
+
+  public void removeConnectionEventListener(ConnectionEventListener arg0)
+  {
+    this.listeners.remove(arg0);
+
+  }
+
+  public void setLogWriter(PrintWriter logger) throws ResourceException
+  {
+    this.logger = logger;
+  }
+
+  private void onError(Exception e)
+  {
+
+    this.localTran = null;
+
+    synchronized (this.connections) {
+      Iterator<GFConnectionImpl> connsItr = this.connections.iterator();
+      while (connsItr.hasNext()) {
+        GFConnectionImpl conn = connsItr.next();
+        conn.invalidate();
+        synchronized (this.listeners) {
+          Iterator<ConnectionEventListener> itr = this.listeners.iterator();
+          ConnectionEvent ce = new ConnectionEvent(this,
+              ConnectionEvent.CONNECTION_ERROR_OCCURRED, e);
+          ce.setConnectionHandle(conn);
+          while (itr.hasNext()) {
+            itr.next().connectionErrorOccurred(ce);
+          }
+        }
+        connsItr.remove();
+      }
+    }
+
+  }
+
+  public void onClose(GFConnectionImpl conn) throws ResourceException
+  {
+    conn.invalidate();
+    this.connections.remove(conn);
+    synchronized (this.listeners) {
+      Iterator<ConnectionEventListener> itr = this.listeners.iterator();
+      ConnectionEvent ce = new ConnectionEvent(this,
+          ConnectionEvent.CONNECTION_CLOSED);
+      ce.setConnectionHandle(conn);
+      while (itr.hasNext()) {
+        itr.next().connectionClosed(ce);
+      }
+    }
+    if (this.connections.isEmpty()) {
+      // safe to dissociate this managedconnection so that it can go to pool
+      if (this.initDone && !this.cache.isClosed()) {
+        this.localTran = new JCALocalTransaction(this.cache, this.gfTxMgr);
+      }
+      else {
+        this.localTran = new JCALocalTransaction();
+      }
+    }
+
+  }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/19459053/gemfire-core/src/jca/java/com/gemstone/gemfire/internal/ra/spi/JCAManagedConnectionFactory.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/jca/java/com/gemstone/gemfire/internal/ra/spi/JCAManagedConnectionFactory.java b/gemfire-core/src/jca/java/com/gemstone/gemfire/internal/ra/spi/JCAManagedConnectionFactory.java
new file mode 100644
index 0000000..8f6784d
--- /dev/null
+++ b/gemfire-core/src/jca/java/com/gemstone/gemfire/internal/ra/spi/JCAManagedConnectionFactory.java
@@ -0,0 +1,136 @@
+/*=========================================================================
+ * Copyright (c) 2010-2014 Pivotal Software, Inc. All Rights Reserved.
+ * This product is protected by U.S. and international copyright
+ * and intellectual property laws. Pivotal products are covered by
+ * one or more patents listed at http://www.pivotal.io/patents.
+ *=========================================================================
+ */
+package com.gemstone.gemfire.internal.ra.spi;
+
+import java.io.PrintWriter;
+import java.util.Set;
+
+import javax.resource.ResourceException;
+import javax.resource.spi.ConnectionManager;
+import javax.resource.spi.ConnectionRequestInfo;
+import javax.resource.spi.ManagedConnection;
+import javax.resource.spi.ManagedConnectionFactory;
+import javax.security.auth.Subject;
+
+import com.gemstone.gemfire.internal.ra.GFConnectionFactoryImpl;
+/**
+ * 
+ * @author asif
+ *
+ */
+public class JCAManagedConnectionFactory implements ManagedConnectionFactory
+{
+  private String productName;
+
+  private String version;
+
+  private String user;
+
+  private PrintWriter logger;
+
+  public Object createConnectionFactory() throws ResourceException
+  {
+
+    return new GFConnectionFactoryImpl(this);
+  }
+
+  public Object createConnectionFactory(ConnectionManager cm)
+      throws ResourceException
+  {
+
+    return new GFConnectionFactoryImpl(cm, this);
+  }
+
+  public ManagedConnection createManagedConnection(Subject arg0,
+      ConnectionRequestInfo arg1) throws ResourceException
+  {
+    return new JCAManagedConnection(this);
+
+  }
+
+  public PrintWriter getLogWriter() throws ResourceException
+  {
+
+    return this.logger;
+  }
+
+  public ManagedConnection matchManagedConnections(Set arg0, Subject arg1,
+      ConnectionRequestInfo arg2) throws ResourceException
+  {
+    // TODO Auto-generated method stub
+    return null;
+  }
+
+  public void setLogWriter(PrintWriter logger) throws ResourceException
+  {
+    this.logger = logger;
+
+  }
+
+  public boolean equals(Object obj)
+  {
+    if (obj instanceof JCAManagedConnectionFactory) {
+      return true;
+    }
+    else {
+      return false;
+    }
+  }
+
+  public int hashCode()
+  {
+    return 0;
+  }
+
+  public void setUserName(String user)
+  {
+
+    if (this.logger != null) {
+      logger.println("JCAManagedConnectionFactory::setUserName:. user name is="
+          + user);
+    }
+    this.user = user;
+  }
+
+  public String getUserName()
+  {
+    return this.user;
+  }
+
+  public void setProductName(String name)
+  {
+
+    if (this.logger != null) {
+      logger
+          .println("JCAManagedConnectionFactory::setProductName:. Product name is="
+              + name);
+    }
+    this.productName = name;
+  }
+
+  public String getProductName()
+  {
+    return this.productName;
+  }
+
+  public void setVersion(String version)
+  {
+
+    if (this.logger != null) {
+      logger.println("JCAManagedConnectionFactory::setVersion:. version is="
+          + version);
+    }
+    this.version = version;
+  }
+
+  public String getVersion()
+  {
+    return this.version;
+  }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/19459053/gemfire-core/src/jca/java/com/gemstone/gemfire/internal/ra/spi/JCAManagedConnectionMetaData.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/jca/java/com/gemstone/gemfire/internal/ra/spi/JCAManagedConnectionMetaData.java b/gemfire-core/src/jca/java/com/gemstone/gemfire/internal/ra/spi/JCAManagedConnectionMetaData.java
new file mode 100644
index 0000000..dec4729
--- /dev/null
+++ b/gemfire-core/src/jca/java/com/gemstone/gemfire/internal/ra/spi/JCAManagedConnectionMetaData.java
@@ -0,0 +1,58 @@
+/*=========================================================================
+ * Copyright (c) 2010-2014 Pivotal Software, Inc. All Rights Reserved.
+ * This product is protected by U.S. and international copyright
+ * and intellectual property laws. Pivotal products are covered by
+ * one or more patents listed at http://www.pivotal.io/patents.
+ *=========================================================================
+ */
+package com.gemstone.gemfire.internal.ra.spi;
+
+import javax.resource.ResourceException;
+import javax.resource.spi.ManagedConnectionMetaData;
+/**
+ * 
+ * @author asif
+ *
+ */
+public class JCAManagedConnectionMetaData implements ManagedConnectionMetaData
+{
+  private final String prodName;
+
+  private final String version;
+
+  private final String user;
+
+  public JCAManagedConnectionMetaData(String prodName, String version,
+      String user) {
+    this.prodName = prodName;
+    this.version = version;
+    this.user = user;
+  }
+
+  
+  public String getEISProductName() throws ResourceException
+  {
+    return this.prodName;
+  }
+
+  
+  public String getEISProductVersion() throws ResourceException
+  {
+
+    return this.version;
+  }
+
+  
+  public int getMaxConnections() throws ResourceException
+  {
+
+    return 0;
+  }
+
+  
+  public String getUserName() throws ResourceException
+  {
+    return this.user;
+  }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/19459053/gemfire-core/src/jca/ra.xml
----------------------------------------------------------------------
diff --git a/gemfire-core/src/jca/ra.xml b/gemfire-core/src/jca/ra.xml
new file mode 100644
index 0000000..85c90b8
--- /dev/null
+++ b/gemfire-core/src/jca/ra.xml
@@ -0,0 +1,37 @@
+
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!DOCTYPE connector PUBLIC '-//Sun Microsystems, Inc.//DTD Connector 1.0//EN' 'http://java.sun.com/j2ee/dtds/connector_1_0.dtd'>
+
+<connector>
+    <display-name>GFE JCA Adaptor</display-name>
+    <vendor-name>Pivotal Software</vendor-name>
+    <spec-version>1.5</spec-version>
+    <eis-type>GFE JCA</eis-type>
+    <version>1.5</version>
+    <resourceadapter>
+        <managedconnectionfactory-class>com.gemstone.gemfire.internal.ra.spi.JCAManagedConnectionFactory</managedconnectionfactory-class>
+                <config-property>
+                    <config-property-name>ProductName</config-property-name>
+                    <config-property-type>java.lang.String</config-property-type>
+                    <config-property-value>GemFire</config-property-value>
+                </config-property>
+                <config-property>
+                    <config-property-name>UserName</config-property-name>
+                    <config-property-type>java.lang.String</config-property-type>
+                    <config-property-value/>
+                </config-property>
+                <config-property>
+                    <config-property-name>Version</config-property-name>
+                    <config-property-type>java.lang.String</config-property-type>
+                    <config-property-value>8.0</config-property-value>
+                </config-property>
+        
+        <connectionfactory-interface>com.gemstone.gemfire.ra.GFConnectionFactory</connectionfactory-interface>
+        <connectionfactory-impl-class>com.gemstone.gemfire.internal.ra.GFConnectionFactoryImpl</connectionfactory-impl-class>
+        <connection-interface>com.gemstone.gemfire.ra.GFConnection</connection-interface>
+        <connection-impl-class>com.gemstone.gemfire.internal.ra.GFConnectionImpl</connection-impl-class>
+        <transaction-support>LocalTransaction</transaction-support>
+        <reauthentication-support>false</reauthentication-support> 
+    </resourceadapter>
+</connector>

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/19459053/gemfire-core/src/main/java/com/gemstone/gemfire/CancelCriterion.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/CancelCriterion.java b/gemfire-core/src/main/java/com/gemstone/gemfire/CancelCriterion.java
new file mode 100644
index 0000000..fedbd49
--- /dev/null
+++ b/gemfire-core/src/main/java/com/gemstone/gemfire/CancelCriterion.java
@@ -0,0 +1,100 @@
+/*=========================================================================
+ * Copyright (c) 2010-2014 Pivotal Software, Inc. All Rights Reserved.
+ * This product is protected by U.S. and international copyright
+ * and intellectual property laws. Pivotal products are covered by
+ * one or more patents listed at http://www.pivotal.io/patents.
+ *=========================================================================
+ */
+package com.gemstone.gemfire;
+
+/**
+ * Abstract cancellation proxy for cancelling an operation, esp. a thread.
+ * 
+ * Creators of services or threads should implement a subclass of CancelCriterion,
+ * and implement the two methods - cancelInProgress, and generateCancelledException(e).
+ * 
+ * Code inside the service can check to see if the service is cancelled by calling
+ * {@link #checkCancelInProgress(Throwable)}. Generally the pattern is to check
+ * before performing an operation, check if the service is canceled before propgrating 
+ * an exception futher up the stack, and check for cancelation inside a long loop.
+ * Eg.
+ * 
+ * <code>
+ * while(true) {
+ *   c.checkCancelInProgress(null);
+ *   try {
+ *      dispatchEvents();
+ *   } catch(IOException e) {
+ *     c.checkCancelInProgress(e);
+ *     throw e;
+ *   }
+ * }
+ * </code>
+ * 
+ * @author jpenney
+ * @see CancelException
+ * @since 5.1
+ */
+public abstract class CancelCriterion
+{
+  /**
+   * Indicate if the service is in the progress of being cancelled.  The
+   * typical use of this is to indicate, in the case of an {@link InterruptedException},
+   * that the current operation should be cancelled.
+   * @return null if the service is not shutting down, or a message that can be used to
+   * construct an exception indicating the service is shut down.
+   */
+  public abstract String cancelInProgress();
+//import com.gemstone.gemfire.distributed.internal.DistributionManager;
+//    * <p>
+//    * In particular, a {@link DistributionManager} returns a non-null result if
+//    * message distribution has been terminated.
+  
+  /**
+   * Use this utility  function in your implementation of cancelInProgress()
+   * and cancelled() to indicate a system failure
+   * 
+   * @return failure string if system failure has occurred
+   */
+  protected final String checkFailure() {
+    Throwable tilt = SystemFailure.getFailure();
+    if (tilt != null) {
+      // Allocate no objects here!
+      return SystemFailure.JVM_CORRUPTION;
+    }
+    return null;
+  }
+
+  /**
+   * See if the current operation is being cancelled.  If so, it either
+   * throws a {@link RuntimeException} (usually a {@link CancelException}).
+   * 
+   * @param e an underlying exception or null if there is no exception 
+   * that triggered this check
+   * @see #cancelInProgress()
+   */
+  public final void checkCancelInProgress(Throwable e) {
+    SystemFailure.checkFailure();
+    String reason = cancelInProgress();
+    if (reason == null) {
+      return;
+    }
+    throw generateCancelledException(e);
+  }
+
+  /**
+   * Template factory method for generating the exception to be thrown by
+   * {@link #checkCancelInProgress(Throwable)}. Override this to specify
+   * different exception for checkCancelInProgress() to throw.
+   * 
+   * This method should wrap the exception in a service specific 
+   * CancelationException (eg CacheClosedException). 
+   * or return null if the service is not being canceled.
+   * 
+   * @param e
+   *          an underlying exception, if any
+   * @return RuntimeException to be thrown by checkCancelInProgress(), null if
+   *         the receiver has not been cancelled.
+   */
+  abstract public RuntimeException generateCancelledException(Throwable e);
+}

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/19459053/gemfire-core/src/main/java/com/gemstone/gemfire/CancelException.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/CancelException.java b/gemfire-core/src/main/java/com/gemstone/gemfire/CancelException.java
new file mode 100644
index 0000000..5148825
--- /dev/null
+++ b/gemfire-core/src/main/java/com/gemstone/gemfire/CancelException.java
@@ -0,0 +1,55 @@
+/*=========================================================================
+ * Copyright (c) 2010-2014 Pivotal Software, Inc. All Rights Reserved.
+ * This product is protected by U.S. and international copyright
+ * and intellectual property laws. Pivotal products are covered by
+ * one or more patents listed at http://www.pivotal.io/patents.
+ *=========================================================================
+ */
+/**
+ * 
+ */
+package com.gemstone.gemfire;
+
+import com.gemstone.gemfire.cache.CacheRuntimeException;
+
+/**
+ * Abstract root class of all GemFire exceptions representing system
+ * cancellation
+ * 
+ * @author jpenney
+ * @since 6.0
+ */
+public abstract class CancelException extends CacheRuntimeException {
+
+  /**
+   * for serialization
+   */
+  public CancelException() {
+  }
+
+  /**
+   * Create instance with given message
+   * @param message the message
+   */
+  public CancelException(String message) {
+    super(message);
+  }
+
+  /**
+   * Create instance with given message and cause
+   * @param message the message
+   * @param cause the cause
+   */
+  public CancelException(String message, Throwable cause) {
+    super(message, cause);
+  }
+
+  /**
+   * Create instance with empty message and given cause
+   * @param cause the cause
+   */
+  public CancelException(Throwable cause) {
+    super(cause);
+  }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/19459053/gemfire-core/src/main/java/com/gemstone/gemfire/CanonicalInstantiator.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/CanonicalInstantiator.java b/gemfire-core/src/main/java/com/gemstone/gemfire/CanonicalInstantiator.java
new file mode 100644
index 0000000..4c5568b
--- /dev/null
+++ b/gemfire-core/src/main/java/com/gemstone/gemfire/CanonicalInstantiator.java
@@ -0,0 +1,77 @@
+/*=========================================================================
+ * Copyright (c) 2010-2014 Pivotal Software, Inc. All Rights Reserved.
+ * This product is protected by U.S. and international copyright
+ * and intellectual property laws. Pivotal products are covered by
+ * one or more patents listed at http://www.pivotal.io/patents.
+ *=========================================================================
+ */
+package com.gemstone.gemfire;
+
+import java.io.*;
+
+/**
+ * <code>CanonicalInstantiator</code> is much like its parent
+ * <code>Instantiator</code> except that instead of
+ * needing to implement <code>newInstance()</code>
+ * you now must implement <code>newInstance(DataInput)</code>.
+ * The addition of the <code>DataInput</code> parameter allows the instance
+ * creator to optionally read data from the data input stream and use it to
+ * decide the instance to create. This allows a value that represents a
+ * canonical instance to be written by a class's {@link DataSerializer#toData}
+ * and then be read by <code>newInstance(DataInput)</code>
+ * and map it back to a canonical instance.
+ * <p>
+ * Note that {@link DataSerializer#fromData} is always called on the instance
+ * returned from <code>newInstance(DataInput)</code>.
+ *
+ * @author darrel
+ * @since 5.1
+ */
+public abstract class CanonicalInstantiator extends Instantiator {
+  /**
+   * Creates a new <code>CanonicalInstantiator</code> that instantiates a given
+   * class.
+   *
+   * @param c
+   *        The <code>DataSerializable</code> class to register.  This
+   *        class must have a static initializer that registers this
+   *        <code>Instantiator</code>. 
+   * @param classId
+   *        A unique id for class <code>c</code>.  The
+   *        <code>classId</code> must not be zero.
+   *        This has been an <code>int</code> since dsPhase1.
+   *
+   * @throws IllegalArgumentException
+   *         If <code>c</code> does not implement
+   *         <code>DataSerializable</code>, <code>classId</code> is
+   *         less than or equal to zero.
+   * @throws NullPointerException
+   *         If <code>c</code> is <code>null</code>
+   */
+  public CanonicalInstantiator(Class<? extends DataSerializable> c, int classId) {
+    super(c, classId);
+  }
+  
+  /**
+   * This method is not supported and if called will
+   * throw UnsupportedOperationException.
+   * Use {@link #newInstance(DataInput)} instead.
+   * 
+   * @throws UnsupportedOperationException in all cases
+   */
+  @Override
+  public final DataSerializable newInstance() {
+    throw new UnsupportedOperationException();
+  }
+  /**
+   * Creates a new "empty" instance of a <Code>DataSerializable</code>
+   * class whose state will be filled in by invoking its 
+   * {@link DataSerializable#fromData fromData} method.
+   * @param in the data input that can be read to decide what instance to create.
+   * @return the new "empty" instance.
+   * @throws IOException if a read from <code>in</code> fails.
+   * @since 5.1
+   */
+  public abstract DataSerializable newInstance(DataInput in)
+    throws IOException;
+}

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/19459053/gemfire-core/src/main/java/com/gemstone/gemfire/CopyException.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/CopyException.java b/gemfire-core/src/main/java/com/gemstone/gemfire/CopyException.java
new file mode 100644
index 0000000..3a28298
--- /dev/null
+++ b/gemfire-core/src/main/java/com/gemstone/gemfire/CopyException.java
@@ -0,0 +1,58 @@
+/*=========================================================================
+ * Copyright (c) 2002-2014 Pivotal Software, Inc. All Rights Reserved.
+ * This product is protected by U.S. and international copyright
+ * and intellectual property laws. Pivotal products are covered by
+ * more patents listed at http://www.pivotal.io/patents.
+ *========================================================================
+ */
+package com.gemstone.gemfire;
+
+/**
+ * Indicates a failure to copy an object.
+ *
+ * @author Darrel Schneider
+ *
+ *
+ * @see CopyHelper#copy
+ * @since 4.0
+ */
+public class CopyException extends GemFireException {
+private static final long serialVersionUID = -1143711608610323585L;
+  
+  /**
+   * Constructs a new <code>CopyException</code>.
+   */
+  public CopyException() {
+    super();
+  }
+  
+  /**
+   * Constructs a new <code>CopyException</code> with a message string.
+   *
+   * @param msg a message string
+   */
+  public CopyException(String msg) {
+    super(msg);
+  }
+  
+  /**
+   * Constructs a new <code>CopyException</code> with a message string
+   * and a cause.
+   *
+   * @param msg the message string
+   * @param cause a causal Throwable
+   */
+  public CopyException(String msg, Throwable cause) {
+    super(msg, cause);
+  }
+  
+  /**
+   * Constructs a new <code>CopyException</code> with a cause.
+   *
+   * @param cause a causal Throwable
+   */
+  public CopyException(Throwable cause) {
+    super(cause);
+  }
+}
+

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/19459053/gemfire-core/src/main/java/com/gemstone/gemfire/CopyHelper.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/CopyHelper.java b/gemfire-core/src/main/java/com/gemstone/gemfire/CopyHelper.java
new file mode 100644
index 0000000..cd21c4c
--- /dev/null
+++ b/gemfire-core/src/main/java/com/gemstone/gemfire/CopyHelper.java
@@ -0,0 +1,259 @@
+/*=========================================================================
+ * Copyright (c) 2010-2014 Pivotal Software, Inc. All Rights Reserved.
+ * This product is protected by U.S. and international copyright
+ * and intellectual property laws. Pivotal products are covered by
+ * one or more patents listed at http://www.pivotal.io/patents.
+ *=========================================================================
+ */
+package com.gemstone.gemfire;
+import java.io.DataInputStream;
+import java.io.IOException;
+import java.io.Serializable;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.math.BigDecimal;
+import java.math.BigInteger;
+import java.util.Arrays;
+import java.util.UUID;
+
+import com.gemstone.gemfire.internal.HeapDataOutputStream;
+import com.gemstone.gemfire.internal.Version;
+import com.gemstone.gemfire.internal.cache.CachedDeserializable;
+import com.gemstone.gemfire.internal.cache.Token;
+import com.gemstone.gemfire.internal.i18n.LocalizedStrings;
+import com.gemstone.gemfire.pdx.PdxInstance;
+import com.gemstone.gemfire.pdx.WritablePdxInstance;
+import com.gemstone.gemfire.pdx.internal.PdxUnreadData;
+
+/**
+ * A static helper for optimally creating copies.  Creating copies
+ * of cache values provides improved concurrency as well as isolation.
+ * For transactions, creating a copy is the guaranteed way to enforce
+ * "Read Committed" isolation on changes to cache
+ * <code>Entries</code>.
+
+ * <p>Here is a simple example of how to use <code>CopyHelper.copy</code>
+ *  <pre>
+ *    Object o = r.get("stringBuf");
+ *    StringBuffer s = (StringBuffer) CopyHelper.copy(o);
+ *    s.append("... and they lived happily ever after.  The End.");
+ *    r.put("stringBuf", s);
+ *  </pre>
+ *
+ * @see Cloneable
+ * @see Serializable
+ * @see DataSerializer
+ * @see com.gemstone.gemfire.cache.Cache#setCopyOnRead
+ * @see com.gemstone.gemfire.cache.CacheTransactionManager
+ *
+ * @author Mitch Thomas
+ * @since 4.0
+ */
+
+public final class CopyHelper {
+
+  // no instances allowed
+  private CopyHelper() {
+  }
+
+  /**
+   * Return true if the given object is an instance of a well known
+   * immutable class.
+   * The well known classes are:
+   * <ul>
+   * <li>String
+   * <li>Byte
+   * <li>Character
+   * <li>Short
+   * <li>Integer
+   * <li>Long
+   * <li>Float
+   * <li>Double
+   * <li>BigInteger
+   * <li>BigDecimal
+   * <li>UUID
+   * <li>PdxInstance but not WritablePdxInstance
+   * </ul>
+   * @param o the object to check
+   * @return true if o is an instance of a well known immutable class.
+   * @since 6.6.2
+   */
+  public static boolean isWellKnownImmutableInstance(Object o) {
+    if (o instanceof String) {
+      return true;
+    }
+    if (o instanceof Number) {
+      if (o instanceof Integer) return true;
+      if (o instanceof Long) return true;
+      if (o instanceof Byte) return true;
+      if (o instanceof Short) return true;
+      if (o instanceof Float) return true;
+      if (o instanceof Double) return true;
+      // subclasses of non-final classes may be mutable
+      if (o.getClass().equals(BigInteger.class)) return true;
+      if (o.getClass().equals(BigDecimal.class)) return true;
+    }
+    if (o instanceof PdxInstance && !(o instanceof WritablePdxInstance)) {
+      // no need to copy since it is immutable
+      return true;
+    }
+    if (o instanceof Character) return true;
+    if (o instanceof UUID) return true;
+    return false;
+  }
+  /**
+   * <p>Makes a copy of the specified object. The object returned is not guaranteed
+   * to be a deep copy of the original object, as explained below.
+   * 
+   * <p>Copies can only be made if the original is a <tt>Cloneable</tt> or serializable by 
+   * GemFire.
+   * If o is a {@link #isWellKnownImmutableInstance(Object) well known immutable instance}
+   * then it will be returned without copying it.
+   * 
+   * <p>If the argument o is an instance of {@link java.lang.Cloneable}, a copy is
+   * made by invoking <tt>clone</tt> on it. Note that not all implementations of <tt>clone</tt> 
+   * make deep copies (e.g. {@link java.util.HashMap#clone HashMap.clone}). Otherwise, if the
+   * argument is not an instance of <tt>Cloneable</tt>, a copy is made using serialization: if 
+   * GemFire serialization is implemented, it is used; otherwise, java serialization is used.
+   * 
+   * <p> The difference between this method and {@link #deepCopy(Object) deepCopy}, is that
+   * this method uses <tt>clone</tt> if available, whereas <tt>deepCopy</tt> does not. As a
+   * result, for <tt>Cloneable</tt> objects copied using this method, how deep a copy the 
+   * returned object is depends on its implementation of <tt>clone</tt>. 
+   * 
+   * @param o the original object that a copy is needed of
+   * @return the new instance that is a copy of of the original
+   * @throws CopyException if copying fails because a class could not
+   * be found or could not be serialized.
+   * @see #deepCopy(Object)
+   * @since 4.0
+   */
+  @SuppressWarnings("unchecked")
+  public static <T> T copy(T o) {
+    T copy = null;
+    try {
+      if (o == null) {
+        return null;
+      } else if (o instanceof Token) {
+        return o;
+      } else {
+        if (isWellKnownImmutableInstance(o)) return o;
+        if (o instanceof Cloneable) {
+          try {
+            // Note that Object.clone is protected so we need to use reflection
+            // to call clone even though this guy implements Cloneable
+            Class<?> c = o.getClass();
+            // By convention, the user should make the clone method public.
+            // But even if they don't, let's go ahead and use it.
+            // The other problem is that if the class is private, we still
+            // need to make the method accessible even if the method is public,
+            // because Object.clone is protected.
+            Method m = c.getDeclaredMethod("clone", new Class[0]);
+            m.setAccessible(true);
+            copy = (T)m.invoke(o, new Object[0]);
+            return copy;
+          } catch (NoSuchMethodException ignore) {
+            // try using Serialization
+          } catch (IllegalAccessException ignore) {
+            // try using Serialization
+          } catch (SecurityException ignore) {
+            // try using Serialization
+          } catch (InvocationTargetException ex) {
+            Throwable cause = ex.getTargetException();
+            if (cause instanceof CloneNotSupportedException) {
+              // try using Serialization
+            } else {
+              throw new CopyException(LocalizedStrings.CopyHelper_CLONE_FAILED.toLocalizedString(), cause != null ? cause : ex);
+            }
+          }
+        } else if (o instanceof CachedDeserializable) {
+          copy = (T) ((CachedDeserializable) o).getDeserializedWritableCopy(null, null);
+          return copy;
+        } else if (o.getClass().isArray() && o.getClass().getComponentType().isPrimitive()) {
+          if (o instanceof byte[]) {
+            byte[] a = (byte[])o;
+            copy = (T) Arrays.copyOf(a, a.length);
+          } else if (o instanceof boolean[]) {
+            boolean[] a = (boolean[])o;
+            copy = (T) Arrays.copyOf(a, a.length);
+          } else if (o instanceof char[]) {
+            char[] a = (char[])o;
+            copy = (T) Arrays.copyOf(a, a.length);
+          } else if (o instanceof int[]) {
+            int[] a = (int[])o;
+            copy = (T) Arrays.copyOf(a, a.length);
+          } else if (o instanceof long[]) {
+            long[] a = (long[])o;
+            copy = (T) Arrays.copyOf(a, a.length);
+          } else if (o instanceof short[]) {
+            short[] a = (short[])o;
+            copy = (T) Arrays.copyOf(a, a.length);
+          } else if (o instanceof float[]) {
+            float[] a = (float[])o;
+            copy = (T) Arrays.copyOf(a, a.length);
+          } else if (o instanceof double[]) {
+            double[] a = (double[])o;
+            copy = (T) Arrays.copyOf(a, a.length);
+          }
+          return copy;
+        }
+        // Copy using serialization
+        copy = doDeepCopy(o);
+        return copy;
+      }
+    } finally {
+      if (copy != null) {
+        PdxUnreadData.copy(o, copy);
+      }
+    }
+  }
+
+  /**
+   * Makes a deep copy of the specified object o using serialization, so the object
+   * has to be serializable by GemFire. 
+   * 
+   * <p>If o is a {@link #isWellKnownImmutableInstance(Object) well known immutable 
+   * instance} then it will be returned without copying it.
+   * 
+   * <p>The passed in object is serialized in memory, and then deserialized into 
+   * a new instance, which is returned. If GemFire serialization is implemented 
+   * for the object, it is used; otherwise, java serialization is used.  
+   * 
+   * @param o the original object to be copied
+   * @return the new instance that is a copy of the original
+   * @throws CopyException if copying fails because a class could not
+   * be found or could not be serialized
+   * @see #copy(Object)
+   */
+  public static <T> T deepCopy(T o) {
+    T copy = null;
+    try {
+      if (o == null) {
+        return null;
+      } else if (o instanceof Token || isWellKnownImmutableInstance(o)) {
+        return o;
+      } else {
+        copy = doDeepCopy(o);
+        return copy;
+      }
+    } finally {
+      if (copy != null) {
+        PdxUnreadData.copy(o, copy);
+      }
+    }
+  }
+
+  @SuppressWarnings("unchecked")
+  private static<T> T doDeepCopy(T o) {
+    try {
+      HeapDataOutputStream hdos = new HeapDataOutputStream(Version.CURRENT);
+      DataSerializer.writeObject(o, hdos);
+      return (T)DataSerializer.readObject(new DataInputStream(hdos.getInputStream()));
+    } catch (ClassNotFoundException ex) {
+      throw new CopyException(LocalizedStrings.CopyHelper_COPY_FAILED_ON_INSTANCE_OF_0.toLocalizedString(o.getClass()), ex);
+    } catch (IOException ex) {
+      throw new CopyException(LocalizedStrings.CopyHelper_COPY_FAILED_ON_INSTANCE_OF_0.toLocalizedString(o.getClass()), ex);
+    }
+
+  }
+}

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/19459053/gemfire-core/src/main/java/com/gemstone/gemfire/DataSerializable.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/DataSerializable.java b/gemfire-core/src/main/java/com/gemstone/gemfire/DataSerializable.java
new file mode 100644
index 0000000..034b8ff
--- /dev/null
+++ b/gemfire-core/src/main/java/com/gemstone/gemfire/DataSerializable.java
@@ -0,0 +1,131 @@
+/*=========================================================================
+ * Copyright (c) 2010-2014 Pivotal Software, Inc. All Rights Reserved.
+ * This product is protected by U.S. and international copyright
+ * and intellectual property laws. Pivotal products are covered by
+ * one or more patents listed at http://www.pivotal.io/patents.
+ *=========================================================================
+ */
+package com.gemstone.gemfire;
+
+import java.io.*;
+
+/**
+ * An interface for objects whose state can be written/read as
+ * primitive types and strings ("data").  That is, instead of
+ * serializing itself to an {@link java.io.ObjectOutputStream}, a
+ * <code>DataSerializable</code> can serialize itself to a {@link
+ * DataOutput}.  By implementing this interface, objects can be
+ * serialized faster and in a more compact format than standard Java
+ * serialization.  The {@link DataSerializer} class contains a number
+ * of static methods that may be helpful to implementations of
+ * <code>DataSerializable</code>.
+ *
+ * <P>
+ *
+ * When possible, GemFire respects the <code>DataSerializable</code>
+ * contract to provide optimal object serialization.  For instance, if
+ * a <code>DataSerializable</code> object is 
+ * {@linkplain com.gemstone.gemfire.cache.Region#put(Object, Object) placed} into a distributed
+ * cache region, its <code>toData</code> method will be used to
+ * serialize it when it is sent to another member of the distributed
+ * system.
+ *
+ * <P>
+ *
+ * To avoid the overhead of Java reflection,
+ * <code>DataSerializable</code> classes may register an {@link
+ * Instantiator} to be used during deserialization.  Alternatively,
+ * classes that implement <code>DataSerializable</code> can provide a
+ * zero-argument constructor that will be invoked when they are read
+ * with {@link DataSerializer#readObject}.
+ *
+ * <P>
+ *
+ * Some classes (especially third-party classes that you may not have
+ * the source code to) cannot be modified to implement
+ * <code>DataSerializable</code>.  These classes can be data
+ * serialized by an instance of {@link DataSerializer}.
+ *
+ * <P>
+ *
+ * <code>DataSerializable</code> offers improved performance over
+ * standard Java serialization, but does not offer all of the features
+ * of standard Java serialization.  In particular, data serialization
+ * does not attempt to maintain referential integrity among the
+ * objects it is writing or reading.  As a result, data serialization
+ * should not be used with complex object graphs.  Attempting to data
+ * serialize graphs that contain object cycles will result in infinite
+ * recursion and a {@link StackOverflowError}.  Attempting to
+ * deserialize an object graph that contains multiple reference
+ * paths to the same object will result in multiple copies of the
+ * objects that are referred to through multiple paths.
+ *
+ * <P>
+ *
+ * <CENTER>
+ * <IMG src="doc-files/data-serialization-exceptions.gif" 
+ *      HEIGHT="219" WIDTH="698">
+ * </CENTER>
+ *
+ * @see java.io.Serializable
+ * @see DataSerializer
+ * @see Instantiator
+ *
+ * @author David Whitlock
+ * @since 3.5 */
+public interface DataSerializable extends Serializable {
+
+  /**
+   * Writes the state of this object as primitive data to the given
+   * <code>DataOutput</code>.
+   * <p>
+   * Since 5.7 it is possible for any method call to the specified
+   * <code>DataOutput</code> to throw {@link GemFireRethrowable}.
+   * It should <em>not</em> be caught by user code.
+   * If it is it <em>must</em> be rethrown.
+   *
+   * @throws IOException
+   *         A problem occurs while writing to <code>out</code>
+   */
+  public void toData(DataOutput out) throws IOException;
+
+  /**
+   * Reads the state of this object as primitive data from the given
+   * <code>DataInput</code>. 
+   *
+   * @throws IOException
+   *         A problem occurs while reading from <code>in</code>
+   * @throws ClassNotFoundException
+   *         A class could not be loaded while reading from
+   *         <code>in</code> 
+   */
+  public void fromData(DataInput in)
+    throws IOException, ClassNotFoundException;
+
+  ////////////////////////  Inner Classes  ////////////////////////
+
+  /**
+   * <code>Replaceable</code> allows an object to write an alternative
+   * version of itself to a <code>DataOutput</code>.  It is similar to
+   * the <code>writeReplace</code> method of standard Java
+   * {@linkplain java.io.Serializable serialization}.  
+   *
+   * <P>
+   *
+   * Note that if a <code>Replaceable</code> is also
+   * <code>DataSerializable</code>, its <code>toData</code> method
+   * will <B>not</B> be invoked.  Instead, its replacement object will
+   * be written to the stream using {@link DataSerializer#writeObject(Object, DataOutput)}. 
+   *
+   * @see DataSerializer#writeObject(Object, DataOutput)
+   */
+  public interface Replaceable {
+
+    /**
+     * Replaces this object with another in the "output stream"
+     * written by {@link DataSerializer#writeObject(Object, DataOutput)}.
+     */
+    public Object replace() throws IOException;
+  }
+
+}


Mime
View raw message