You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@geode.apache.org by jb...@apache.org on 2017/05/17 17:50:23 UTC

[41/46] geode-native git commit: GEODE-2741: Remove custom shared pointer from clicache

GEODE-2741: Remove custom shared pointer from clicache


Project: http://git-wip-us.apache.org/repos/asf/geode-native/repo
Commit: http://git-wip-us.apache.org/repos/asf/geode-native/commit/6027574a
Tree: http://git-wip-us.apache.org/repos/asf/geode-native/tree/6027574a
Diff: http://git-wip-us.apache.org/repos/asf/geode-native/diff/6027574a

Branch: refs/heads/develop
Commit: 6027574a2078b35fadcef450020af775415f1c36
Parents: c009812
Author: Jacob Barrett <jb...@pivotal.io>
Authored: Fri Apr 21 22:59:27 2017 +0000
Committer: David Kimura <dk...@pivotal.io>
Committed: Mon May 15 11:43:09 2017 -0700

----------------------------------------------------------------------
 src/clicache/CMakeLists.txt                     |   1 +
 .../integration-test/SystemPropertiesTestsN.cs  | 103 ---
 .../integration-test/UnitTests.csproj.in        |   1 -
 src/clicache/src/AttributesFactory.cpp          | 283 ++++--
 src/clicache/src/AttributesFactory.hpp          |  22 +-
 src/clicache/src/AttributesMutator.cpp          | 169 ++--
 src/clicache/src/AttributesMutator.hpp          |  21 +-
 src/clicache/src/Cache.cpp                      | 195 +++--
 src/clicache/src/Cache.hpp                      |  28 +-
 src/clicache/src/CacheFactory.cpp               | 270 ++++--
 src/clicache/src/CacheFactory.hpp               |  17 +-
 src/clicache/src/CacheStatistics.cpp            |  26 +-
 src/clicache/src/CacheStatistics.hpp            |  20 +-
 src/clicache/src/CacheTransactionManager.cpp    | 119 ++-
 src/clicache/src/CacheTransactionManager.hpp    |  62 +-
 src/clicache/src/CacheableBuiltins.hpp          | 108 ++-
 src/clicache/src/CacheableDate.cpp              |   4 -
 src/clicache/src/CacheableDate.hpp              |   3 -
 src/clicache/src/CacheableHashSet.hpp           | 189 ++--
 src/clicache/src/CacheableKey.cpp               |  39 +-
 src/clicache/src/CacheableKey.hpp               |   6 +-
 src/clicache/src/CacheableObjectArray.cpp       |  18 +-
 src/clicache/src/CacheableStack.cpp             |   3 +-
 src/clicache/src/CacheableString.cpp            |   8 +-
 src/clicache/src/CacheableString.hpp            |   7 +-
 src/clicache/src/CacheableStringArray.hpp       |   7 +-
 src/clicache/src/CqAttributes.cpp               |  49 +-
 src/clicache/src/CqAttributes.hpp               |  28 +-
 src/clicache/src/CqAttributesFactory.cpp        |  72 +-
 src/clicache/src/CqAttributesFactory.hpp        |  26 +-
 src/clicache/src/CqAttributesMutator.cpp        | 108 ++-
 src/clicache/src/CqAttributesMutator.hpp        |  25 +-
 src/clicache/src/CqEvent.cpp                    |  17 +-
 src/clicache/src/CqEvent.hpp                    |  25 +-
 src/clicache/src/CqListener.hpp                 | 112 ---
 src/clicache/src/CqOperation.hpp                |  31 +-
 src/clicache/src/CqQuery.cpp                    | 174 +++-
 src/clicache/src/CqQuery.hpp                    |  24 +-
 src/clicache/src/CqServiceStatistics.cpp        |  78 +-
 src/clicache/src/CqServiceStatistics.hpp        |  24 +-
 src/clicache/src/CqState.cpp                    |  58 +-
 src/clicache/src/CqState.hpp                    |  29 +-
 src/clicache/src/CqStatistics.cpp               |  64 +-
 src/clicache/src/CqStatistics.hpp               |  24 +-
 src/clicache/src/DataInput.cpp                  | 105 ++-
 src/clicache/src/DataInput.hpp                  |  91 +-
 src/clicache/src/DataOutput.cpp                 |  76 +-
 src/clicache/src/DataOutput.hpp                 | 107 ++-
 src/clicache/src/DiskPolicyType.hpp             |   3 +
 src/clicache/src/DistributedSystem.cpp          | 413 ++++-----
 src/clicache/src/DistributedSystem.hpp          |  20 +-
 src/clicache/src/EntryEvent.cpp                 |  38 +-
 src/clicache/src/EntryEvent.hpp                 |  30 +-
 src/clicache/src/ExceptionTypes.cpp             |   1 -
 src/clicache/src/ExceptionTypes.hpp             |  15 +-
 src/clicache/src/Execution.cpp                  |  68 +-
 src/clicache/src/Execution.hpp                  |  25 +-
 src/clicache/src/ExpirationAction.hpp           |   3 +
 src/clicache/src/FunctionService.cpp            |  95 +-
 src/clicache/src/FunctionService.hpp            |  25 +-
 src/clicache/src/GeodeClassIds.hpp              |   3 +
 src/clicache/src/ICacheLoader.hpp               |   3 +
 src/clicache/src/ICacheableKey.hpp              |   1 -
 src/clicache/src/ICqResults.hpp                 |   5 +-
 src/clicache/src/IGeodeSerializable.hpp         |   4 +-
 src/clicache/src/IRegion.hpp                    |   3 +
 src/clicache/src/ISelectResults.hpp             |   5 +-
 src/clicache/src/ISubscriptionService.hpp       |   3 +-
 src/clicache/src/LocalRegion.cpp                | 548 ++++++++----
 src/clicache/src/LocalRegion.hpp                |  28 +-
 src/clicache/src/Log.hpp                        |   3 +
 src/clicache/src/Pool.cpp                       | 413 +++++++--
 src/clicache/src/Pool.hpp                       |  29 +-
 src/clicache/src/PoolFactory.cpp                | 310 +++++--
 src/clicache/src/PoolFactory.hpp                |  27 +-
 src/clicache/src/PoolManager.cpp                |  48 +-
 src/clicache/src/PoolManager.hpp                |   5 +-
 src/clicache/src/Properties.cpp                 | 497 +++--------
 src/clicache/src/Properties.hpp                 |  81 +-
 src/clicache/src/Query.cpp                      | 103 ++-
 src/clicache/src/Query.hpp                      |  23 +-
 src/clicache/src/QueryService.cpp               |  97 +-
 src/clicache/src/QueryService.hpp               |  22 +-
 src/clicache/src/Region.cpp                     | 874 ++++++++++++-------
 src/clicache/src/Region.hpp                     |  38 +-
 src/clicache/src/RegionAttributes.cpp           | 433 +++++++--
 src/clicache/src/RegionAttributes.hpp           |  31 +-
 src/clicache/src/RegionEntry.cpp                |  60 +-
 src/clicache/src/RegionEntry.hpp                |  21 +-
 src/clicache/src/RegionEvent.cpp                |  28 +-
 src/clicache/src/RegionEvent.hpp                |  30 +-
 src/clicache/src/RegionFactory.cpp              | 289 ++++--
 src/clicache/src/RegionFactory.hpp              |  29 +-
 src/clicache/src/ResultCollector.cpp            |  61 +-
 src/clicache/src/ResultCollector.hpp            |  44 +-
 src/clicache/src/ResultSet.cpp                  |  55 +-
 src/clicache/src/ResultSet.hpp                  |  21 +-
 src/clicache/src/SelectResultsIterator.cpp      |  60 +-
 src/clicache/src/SelectResultsIterator.hpp      |  22 +-
 src/clicache/src/Serializable.cpp               | 637 +++++++-------
 src/clicache/src/Serializable.hpp               | 181 ++--
 src/clicache/src/StatisticDescriptor.cpp        |  18 +-
 src/clicache/src/StatisticDescriptor.hpp        |  21 +-
 src/clicache/src/Statistics.cpp                 |  76 +-
 src/clicache/src/Statistics.hpp                 |  21 +-
 src/clicache/src/StatisticsFactory.cpp          |  42 +-
 src/clicache/src/StatisticsFactory.hpp          |  16 +-
 src/clicache/src/StatisticsType.cpp             |  16 +-
 src/clicache/src/StatisticsType.hpp             |  27 +-
 src/clicache/src/Struct.cpp                     |  94 +-
 src/clicache/src/Struct.hpp                     |   9 +-
 src/clicache/src/StructSet.cpp                  |  67 +-
 src/clicache/src/StructSet.hpp                  |  21 +-
 src/clicache/src/SystemProperties.cpp           | 100 +--
 src/clicache/src/SystemProperties.hpp           |  39 +-
 src/clicache/src/TransactionEvent.cpp           |   6 +-
 src/clicache/src/TransactionEvent.hpp           |   2 +-
 src/clicache/src/TransactionId.hpp              |  26 +-
 .../src/UserFunctionExecutionException.cpp      |  80 +-
 .../src/UserFunctionExecutionException.hpp      |  18 +-
 src/clicache/src/Utils.cpp                      |   3 +-
 src/clicache/src/begin_native.hpp               |  22 +
 src/clicache/src/end_native.hpp                 |   6 +
 src/clicache/src/geode_defs.hpp                 |   3 -
 src/clicache/src/impl/AppDomainContext.hpp      |   2 +
 src/clicache/src/impl/AssemblyInfo.cpp.in       |   1 +
 src/clicache/src/impl/AuthenticatedCache.cpp    |  67 +-
 src/clicache/src/impl/AuthenticatedCache.hpp    |  33 +-
 src/clicache/src/impl/CacheListener.hpp         |  26 +-
 src/clicache/src/impl/CacheLoader.hpp           |   4 +-
 src/clicache/src/impl/CacheWriter.hpp           |  13 +-
 src/clicache/src/impl/CqListenerProxy.hpp       |   4 +-
 src/clicache/src/impl/CqStatusListenerProxy.hpp |   4 +-
 src/clicache/src/impl/ManagedAuthInitialize.cpp |   5 +-
 src/clicache/src/impl/ManagedAuthInitialize.hpp |   3 +
 src/clicache/src/impl/ManagedCacheListener.cpp  |   4 +-
 src/clicache/src/impl/ManagedCacheListener.hpp  |   3 +
 src/clicache/src/impl/ManagedCacheLoader.cpp    |  15 +-
 src/clicache/src/impl/ManagedCacheLoader.hpp    |   3 +
 src/clicache/src/impl/ManagedCacheWriter.cpp    |   2 +-
 src/clicache/src/impl/ManagedCacheWriter.hpp    |   3 +
 src/clicache/src/impl/ManagedCacheableDelta.cpp |   8 +-
 src/clicache/src/impl/ManagedCacheableDelta.hpp |   3 +
 .../src/impl/ManagedCacheableDeltaBytes.cpp     |  14 +-
 .../src/impl/ManagedCacheableDeltaBytes.hpp     |   9 +-
 src/clicache/src/impl/ManagedCacheableKey.cpp   |   8 +-
 src/clicache/src/impl/ManagedCacheableKey.hpp   |   3 +
 .../src/impl/ManagedCacheableKeyBytes.cpp       |  10 +-
 .../src/impl/ManagedCacheableKeyBytes.hpp       |   5 +-
 src/clicache/src/impl/ManagedCqListener.hpp     |   3 +
 .../src/impl/ManagedCqStatusListener.hpp        |   3 +
 .../src/impl/ManagedFixedPartitionResolver.hpp  |   3 +
 .../src/impl/ManagedPartitionResolver.hpp       |   3 +
 .../src/impl/ManagedPersistenceManager.hpp      |   3 +
 .../src/impl/ManagedResultCollector.cpp         |   2 -
 .../src/impl/ManagedResultCollector.hpp         |   3 +
 src/clicache/src/impl/ManagedVisitor.cpp        |   4 +-
 src/clicache/src/impl/ManagedVisitor.hpp        |   3 +
 src/clicache/src/impl/MemoryPressureHandler.cpp |   7 +-
 src/clicache/src/impl/MemoryPressureHandler.hpp |   2 +
 src/clicache/src/impl/NativeWrapper.hpp         | 528 -----------
 src/clicache/src/impl/PdxFieldType.cpp          |   3 +
 src/clicache/src/impl/PdxHelper.cpp             |  10 +-
 src/clicache/src/impl/PdxHelper.hpp             |   3 +
 src/clicache/src/impl/PdxInstanceImpl.cpp       |  11 +-
 .../src/impl/PdxManagedCacheableKey.cpp         |   8 +-
 .../src/impl/PdxManagedCacheableKey.hpp         |  11 +-
 .../src/impl/PdxManagedCacheableKeyBytes.cpp    |  14 +-
 .../src/impl/PdxManagedCacheableKeyBytes.hpp    |   8 +-
 .../src/impl/PdxReaderWithTypeCollector.cpp     |   3 +
 .../src/impl/PdxWriterWithTypeCollector.cpp     |   3 +
 .../src/impl/PersistenceManagerProxy.hpp        |   4 +-
 src/clicache/src/impl/RegionImpl.hpp            |   5 +-
 src/clicache/src/impl/SafeConvert.hpp           | 288 +++---
 .../src/native_conditional_unique_ptr.hpp       |  42 +
 src/clicache/src/native_shared_ptr.hpp          |  39 +
 src/clicache/src/native_unique_ptr.hpp          |  35 +
 src/clicache/test/AssemblyInfo.cpp.in           |  32 +
 src/clicache/test/CMakeLists.txt                |  72 ++
 src/clicache/test/Utils.hpp                     |  14 +
 .../test/native_conditional_unqiue_ptrTests.cpp | 229 +++++
 src/clicache/test/native_shared_ptrTests.cpp    | 189 ++++
 src/clicache/test/native_unique_ptrTests.cpp    | 178 ++++
 src/cppcache/include/geode/CacheFactory.hpp     |   1 -
 src/cppcache/include/geode/RegionEntry.hpp      |   8 +-
 src/cppcache/include/geode/TransactionId.hpp    |  10 +-
 src/cppcache/include/geode/geode_base.hpp       |  10 +-
 src/cppcache/src/CacheFactory.cpp               |   5 +-
 src/cppcache/src/CacheImpl.cpp                  |   2 +
 src/cppcache/src/PdxTypeRegistry.cpp            |   2 +
 src/cppcache/src/PooledBase.cpp                 |  55 --
 src/cppcache/src/PooledBase.hpp                 |  64 --
 src/cppcache/src/PooledBasePool.hpp             |  85 --
 src/cppcache/src/RegionEntry.cpp                |  18 +-
 src/cppcache/src/RegionInternal.cpp             |   2 +-
 src/tests/cli/PkcsWrapper/PkcsAuthInitMN.cpp    |  21 +-
 src/tests/cli/PkcsWrapper/PkcsAuthInitMN.hpp    |  15 +-
 src/tests/cli/QueryHelper/QueryStringsM.cpp     |  33 +-
 src/tests/cli/QueryHelper/QueryStringsM.hpp     |  12 +-
 199 files changed, 7161 insertions(+), 4919 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/geode-native/blob/6027574a/src/clicache/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/src/clicache/CMakeLists.txt b/src/clicache/CMakeLists.txt
index 1424afa..9ea4f82 100644
--- a/src/clicache/CMakeLists.txt
+++ b/src/clicache/CMakeLists.txt
@@ -16,4 +16,5 @@ cmake_minimum_required(VERSION 3.4)
 project(clicache_src)
 
 add_subdirectory(src)
+add_subdirectory(test)
 add_subdirectory(integration-test)

http://git-wip-us.apache.org/repos/asf/geode-native/blob/6027574a/src/clicache/integration-test/SystemPropertiesTestsN.cs
----------------------------------------------------------------------
diff --git a/src/clicache/integration-test/SystemPropertiesTestsN.cs b/src/clicache/integration-test/SystemPropertiesTestsN.cs
deleted file mode 100644
index c903be9..0000000
--- a/src/clicache/integration-test/SystemPropertiesTestsN.cs
+++ /dev/null
@@ -1,103 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-using System;
-using System.IO;
-
-namespace Apache.Geode.Client.UnitTests
-{
-  using NUnit.Framework;
-  using Apache.Geode.DUnitFramework;
-  using Apache.Geode.Client;
-
-  [TestFixture]
-  [Category("group3")]
-  [Category("unicast_only")]
-  [Category("generics")]
-  
-  public class SystemPropertiesTests : UnitTests
-  {
-    protected override ClientBase[] GetClients()
-    {
-      return null;
-    }
-
-    [Test]
-    public void Default()
-    {
-      SystemProperties sp = new SystemProperties(null, '.' +
-        Path.DirectorySeparatorChar + "non-existent");
-      Assert.AreEqual(1, sp.StatisticsSampleInterval);
-      Assert.IsTrue(sp.StatisticsEnabled);
-      Assert.AreEqual("statArchive.gfs", sp.StatisticsArchiveFile);
-      Assert.AreEqual(LogLevel.Config, sp.GFLogLevel);
-      Util.Log("Default: ReadTimeoutUnitInMillis = {0} ", sp.ReadTimeoutUnitInMillis);
-      Assert.AreEqual(false, sp.ReadTimeoutUnitInMillis);
-    }
-
-    [Test]
-    public void Config()
-    {
-      // create a file for alternate properties...
-      //StreamWriter sw = new StreamWriter("test.properties");
-      //sw.WriteLine("gf.transport.config=./gfconfig");
-      //sw.WriteLine("statistics.sample.interval=2000");
-      //sw.WriteLine("statistics.enabled=false");
-      //sw.WriteLine("statistics.archive.file=./stats.gfs");
-      //sw.WriteLine("log.level=error");
-      //sw.Close();
-
-      SystemProperties sp = new SystemProperties(null, "test.properties");
-      Assert.AreEqual(1, sp.StatisticsSampleInterval);
-      Assert.IsTrue(sp.StatisticsEnabled);
-      Assert.AreEqual("statArchive.gfs", sp.StatisticsArchiveFile);
-      Assert.AreEqual(LogLevel.Config, sp.GFLogLevel);
-      Assert.AreEqual(LogLevel.Config, sp.GFLogLevel);
-      Assert.IsFalse(sp.OnClientDisconnectClearPdxTypeIds);
-    }
-
-    [Test]
-    public void NewConfig()
-    {
-      // When the tests are run from the build script the environment variable
-      // TESTSRC is set.
-      string filePath = CacheHelper.TestDir + Path.DirectorySeparatorChar + "system.properties";
-
-      SystemProperties sp = new SystemProperties(null, filePath);
-
-      Assert.AreEqual(700, sp.StatisticsSampleInterval);
-      Assert.IsFalse(sp.StatisticsEnabled);
-      Assert.AreEqual("stats.gfs", sp.StatisticsArchiveFile);
-      Assert.AreEqual("gfcpp.log", sp.LogFileName);
-      Assert.AreEqual(LogLevel.Debug, sp.GFLogLevel);
-      Assert.AreEqual("system", sp.Name);
-      Assert.AreEqual("cache.xml", sp.CacheXmlFile);
-      Assert.AreEqual(1024000000, sp.LogFileSizeLimit);
-      Assert.AreEqual(1024000000, sp.StatsFileSizeLimit);
-      Assert.AreEqual(123, sp.PingInterval);
-      Assert.AreEqual(345, sp.ConnectTimeout);
-      Assert.AreEqual(456, sp.RedundancyMonitorInterval);
-      Assert.AreEqual(123, sp.HeapLRULimit);
-      Assert.AreEqual(45, sp.HeapLRUDelta);
-      Assert.AreEqual(1234, sp.NotifyAckInterval);
-      Assert.AreEqual(5678, sp.NotifyDupCheckLife);
-      Util.Log("NewConfig: ReadTimeoutUnitInMillis = {0} ", sp.ReadTimeoutUnitInMillis);
-      Assert.IsTrue(sp.ReadTimeoutUnitInMillis);
-      Assert.IsTrue(sp.OnClientDisconnectClearPdxTypeIds);
-    }
-  }
-}

http://git-wip-us.apache.org/repos/asf/geode-native/blob/6027574a/src/clicache/integration-test/UnitTests.csproj.in
----------------------------------------------------------------------
diff --git a/src/clicache/integration-test/UnitTests.csproj.in b/src/clicache/integration-test/UnitTests.csproj.in
index 328c1ab..b505388 100644
--- a/src/clicache/integration-test/UnitTests.csproj.in
+++ b/src/clicache/integration-test/UnitTests.csproj.in
@@ -197,7 +197,6 @@
     <Compile Include="$(CMAKE_CURRENT_SOURCE_DIR)\ExpirationTestsN.cs" />
     <Compile Include="$(CMAKE_CURRENT_SOURCE_DIR)\OverflowTestsN.cs" />
     <Compile Include="$(CMAKE_CURRENT_SOURCE_DIR)\SerializationTestsN.cs" />
-    <Compile Include="$(CMAKE_CURRENT_SOURCE_DIR)\SystemPropertiesTestsN.cs" />
     <Compile Include="$(CMAKE_CURRENT_SOURCE_DIR)\ThinClientConflationTestsN.cs" />
     <Compile Include="$(CMAKE_CURRENT_SOURCE_DIR)\ThinClientCqIRTestsN.cs" />
     <Compile Include="$(CMAKE_CURRENT_SOURCE_DIR)\ThinClientCqTestsN.cs" />

http://git-wip-us.apache.org/repos/asf/geode-native/blob/6027574a/src/clicache/src/AttributesFactory.cpp
----------------------------------------------------------------------
diff --git a/src/clicache/src/AttributesFactory.cpp b/src/clicache/src/AttributesFactory.cpp
index 67c4d97..90a34b6 100644
--- a/src/clicache/src/AttributesFactory.cpp
+++ b/src/clicache/src/AttributesFactory.cpp
@@ -15,7 +15,6 @@
  * limitations under the License.
  */
 
-//#include "geode_includes.hpp"
 #include "AttributesFactory.hpp"
 #include "Region.hpp"
 #include "impl/ManagedCacheLoader.hpp"
@@ -38,8 +37,7 @@
 #include "impl/SafeConvert.hpp"
 #include "ExceptionTypes.hpp"
 
-using namespace System;
-using namespace System::Collections::Generic;
+#include <memory>
 
 namespace Apache
 {
@@ -47,14 +45,16 @@ namespace Apache
   {
     namespace Client
     {
+      using namespace System;
+      using namespace System::Collections::Generic;
+
+      namespace native = apache::geode::client;
 
       generic<class TKey, class TValue>
       AttributesFactory<TKey, TValue>::AttributesFactory( Apache::Geode::Client::RegionAttributes<TKey, TValue>^ regionAttributes )
-        : UMWrap( )
       {
-        apache::geode::client::RegionAttributesPtr attribptr(
-          GetNativePtrFromSBWrapGeneric<apache::geode::client::RegionAttributes>( regionAttributes ) );
-        SetPtr( new apache::geode::client::AttributesFactory( attribptr ), true );
+        auto attribptr = regionAttributes->GetNative();
+        m_nativeptr = gcnew native_unique_ptr<native::AttributesFactory>(std::make_unique<native::AttributesFactory>(attribptr));
       }
 
       // CALLBACKS
@@ -62,64 +62,91 @@ namespace Apache
       generic<class TKey, class TValue>
       void AttributesFactory<TKey, TValue>::SetCacheLoader( ICacheLoader<TKey, TValue>^ cacheLoader )
       {
-        apache::geode::client::CacheLoaderPtr loaderptr;
+        native::CacheLoaderPtr loaderptr;
         if ( cacheLoader != nullptr ) {
           CacheLoaderGeneric<TKey, TValue>^ clg = gcnew CacheLoaderGeneric<TKey, TValue>();
           clg->SetCacheLoader(cacheLoader);
-          loaderptr = new apache::geode::client::ManagedCacheLoaderGeneric( /*clg,*/ cacheLoader );
-          ((apache::geode::client::ManagedCacheLoaderGeneric*)loaderptr.get())->setptr(clg);
+          loaderptr = std::shared_ptr<native::ManagedCacheLoaderGeneric>(new native::ManagedCacheLoaderGeneric(cacheLoader));
+          ((native::ManagedCacheLoaderGeneric*)loaderptr.get())->setptr(clg);
+        }
+        try
+        {
+          m_nativeptr->get()->setCacheLoader( loaderptr );
+        }
+        finally
+        {
+          GC::KeepAlive(m_nativeptr);
         }
-        NativePtr->setCacheLoader( loaderptr );
       }
 
       generic<class TKey, class TValue>
       void AttributesFactory<TKey, TValue>::SetCacheWriter( ICacheWriter<TKey, TValue>^ cacheWriter )
       {
-        apache::geode::client::CacheWriterPtr writerptr;
+        native::CacheWriterPtr writerptr;
         if ( cacheWriter != nullptr ) {
           CacheWriterGeneric<TKey, TValue>^ cwg = gcnew CacheWriterGeneric<TKey, TValue>();
           cwg->SetCacheWriter(cacheWriter);
-          writerptr = new apache::geode::client::ManagedCacheWriterGeneric( /*cwg,*/ cacheWriter );
-          ((apache::geode::client::ManagedCacheWriterGeneric*)writerptr.get())->setptr(cwg);
+          writerptr = std::shared_ptr<native::ManagedCacheWriterGeneric>(new native::ManagedCacheWriterGeneric(cacheWriter));
+          ((native::ManagedCacheWriterGeneric*)writerptr.get())->setptr(cwg);
+        }
+        try
+        {
+          m_nativeptr->get()->setCacheWriter( writerptr );
+        }
+        finally
+        {
+          GC::KeepAlive(m_nativeptr);
         }
-        NativePtr->setCacheWriter( writerptr );
       }
 
       generic<class TKey, class TValue>
       void AttributesFactory<TKey, TValue>::SetCacheListener( ICacheListener<TKey, TValue>^ cacheListener )
       {
-        apache::geode::client::CacheListenerPtr listenerptr;
+        native::CacheListenerPtr listenerptr;
         if ( cacheListener != nullptr ) {
           CacheListenerGeneric<TKey, TValue>^ clg = gcnew CacheListenerGeneric<TKey, TValue>();
           clg->SetCacheListener(cacheListener);
-          //listenerptr = new apache::geode::client::ManagedCacheListenerGeneric( (ICacheListener<Object^, Object^>^)cacheListener );
-          listenerptr = new apache::geode::client::ManagedCacheListenerGeneric( /*clg,*/ cacheListener );
-          ((apache::geode::client::ManagedCacheListenerGeneric*)listenerptr.get())->setptr(clg);
+          listenerptr = std::shared_ptr<native::ManagedCacheListenerGeneric>(new native::ManagedCacheListenerGeneric(cacheListener));
+          ((native::ManagedCacheListenerGeneric*)listenerptr.get())->setptr(clg);
+        }
+        try
+        {
+          m_nativeptr->get()->setCacheListener( listenerptr );
+        }
+        finally
+        {
+          GC::KeepAlive(m_nativeptr);
         }
-        NativePtr->setCacheListener( listenerptr );
       }
 
       generic<class TKey, class TValue>
       void AttributesFactory<TKey, TValue>::SetPartitionResolver( IPartitionResolver<TKey, TValue>^ partitionresolver )
       {
-        apache::geode::client::PartitionResolverPtr resolverptr;
+        native::PartitionResolverPtr resolverptr;
         if ( partitionresolver != nullptr ) {
           Client::IFixedPartitionResolver<TKey, TValue>^ resolver = 
             dynamic_cast<Client::IFixedPartitionResolver<TKey, TValue>^>(partitionresolver);
           if (resolver != nullptr) {            
             FixedPartitionResolverGeneric<TKey, TValue>^ prg = gcnew FixedPartitionResolverGeneric<TKey, TValue>();
             prg->SetPartitionResolver(partitionresolver);
-            resolverptr = new apache::geode::client::ManagedFixedPartitionResolverGeneric( partitionresolver ); 
-            ((apache::geode::client::ManagedFixedPartitionResolverGeneric*)resolverptr.get())->setptr(prg);
+            resolverptr = std::shared_ptr<native::ManagedFixedPartitionResolverGeneric>(new native::ManagedFixedPartitionResolverGeneric(partitionresolver)); 
+            ((native::ManagedFixedPartitionResolverGeneric*)resolverptr.get())->setptr(prg);
           }
           else {            
             PartitionResolverGeneric<TKey, TValue>^ prg = gcnew PartitionResolverGeneric<TKey, TValue>();
             prg->SetPartitionResolver(partitionresolver);
-            resolverptr = new apache::geode::client::ManagedPartitionResolverGeneric( partitionresolver );
-            ((apache::geode::client::ManagedPartitionResolverGeneric*)resolverptr.get())->setptr(prg);            
+            resolverptr = std::shared_ptr<native::ManagedPartitionResolverGeneric>(new native::ManagedPartitionResolverGeneric(partitionresolver));
+            ((native::ManagedPartitionResolverGeneric*)resolverptr.get())->setptr(prg);            
           }         
         }
-        NativePtr->setPartitionResolver( resolverptr );
+        try
+        {
+          m_nativeptr->get()->setPartitionResolver( resolverptr );
+        }
+        finally
+        {
+          GC::KeepAlive(m_nativeptr);
+        }
       }
 
       generic<class TKey, class TValue>
@@ -129,8 +156,14 @@ namespace Apache
         ManagedString mg_libpath( libPath );
         ManagedString mg_factoryFunctionName( factoryFunctionName );
 
-        NativePtr->setCacheLoader( mg_libpath.CharPtr,
-          mg_factoryFunctionName.CharPtr );
+        try
+        {
+          m_nativeptr->get()->setCacheLoader( mg_libpath.CharPtr, mg_factoryFunctionName.CharPtr );
+        }
+        finally
+        {
+          GC::KeepAlive(m_nativeptr);
+        }
       }
 
       generic<class TKey, class TValue>
@@ -140,8 +173,14 @@ namespace Apache
         ManagedString mg_libpath( libPath );
         ManagedString mg_factoryFunctionName( factoryFunctionName );
 
-        NativePtr->setCacheWriter( mg_libpath.CharPtr,
-          mg_factoryFunctionName.CharPtr );
+        try
+        {
+          m_nativeptr->get()->setCacheWriter( mg_libpath.CharPtr, mg_factoryFunctionName.CharPtr );
+        }
+        finally
+        {
+          GC::KeepAlive(m_nativeptr);
+        }
       }
 
       generic<class TKey, class TValue>
@@ -151,8 +190,14 @@ namespace Apache
         ManagedString mg_libpath( libPath );
         ManagedString mg_factoryFunctionName( factoryFunctionName );
 
-        NativePtr->setCacheListener( mg_libpath.CharPtr,
-          mg_factoryFunctionName.CharPtr );
+        try
+        {
+          m_nativeptr->get()->setCacheListener( mg_libpath.CharPtr, mg_factoryFunctionName.CharPtr );
+        }
+        finally
+        {
+          GC::KeepAlive(m_nativeptr);
+        }
       }
 
       generic<class TKey, class TValue>
@@ -162,8 +207,14 @@ namespace Apache
         ManagedString mg_libpath( libPath );
         ManagedString mg_factoryFunctionName( factoryFunctionName );
 
-        NativePtr->setPartitionResolver( mg_libpath.CharPtr,
-          mg_factoryFunctionName.CharPtr );
+        try
+        {
+          m_nativeptr->get()->setPartitionResolver( mg_libpath.CharPtr, mg_factoryFunctionName.CharPtr );
+        }
+        finally
+        {
+          GC::KeepAlive(m_nativeptr);
+        }
       }
 
       // EXPIRATION ATTRIBUTES
@@ -171,44 +222,74 @@ namespace Apache
       generic<class TKey, class TValue>
       void AttributesFactory<TKey, TValue>::SetEntryIdleTimeout( ExpirationAction action, System::UInt32 idleTimeout )
       {
-        NativePtr->setEntryIdleTimeout(
-          static_cast<apache::geode::client::ExpirationAction::Action>( action ), idleTimeout );
+        try
+        {
+          m_nativeptr->get()->setEntryIdleTimeout(static_cast<native::ExpirationAction::Action>( action ), idleTimeout );
+        }
+        finally
+        {
+          GC::KeepAlive(m_nativeptr);
+        }
       }
 
       generic<class TKey, class TValue>
       void AttributesFactory<TKey, TValue>::SetEntryTimeToLive( ExpirationAction action, System::UInt32 timeToLive )
       {
-        NativePtr->setEntryTimeToLive(
-          static_cast<apache::geode::client::ExpirationAction::Action>( action ), timeToLive );
+        try
+        {
+          m_nativeptr->get()->setEntryTimeToLive( static_cast<native::ExpirationAction::Action>( action ), timeToLive );
+        }
+        finally
+        {
+          GC::KeepAlive(m_nativeptr);
+        }
       }
 
       generic<class TKey, class TValue>
       void AttributesFactory<TKey, TValue>::SetRegionIdleTimeout( ExpirationAction action, System::UInt32 idleTimeout )
       {
-        NativePtr->setRegionIdleTimeout(
-          static_cast<apache::geode::client::ExpirationAction::Action>( action ), idleTimeout );
+        try
+        {
+          m_nativeptr->get()->setRegionIdleTimeout( static_cast<native::ExpirationAction::Action>( action ), idleTimeout );
+        }
+        finally
+        {
+          GC::KeepAlive(m_nativeptr);
+        }
       }
 
       generic<class TKey, class TValue>
       void AttributesFactory<TKey, TValue>::SetRegionTimeToLive( ExpirationAction action, System::UInt32 timeToLive )
       {
-        NativePtr->setRegionTimeToLive(
-          static_cast<apache::geode::client::ExpirationAction::Action>( action ), timeToLive );
+        try
+        {
+          m_nativeptr->get()->setRegionTimeToLive( static_cast<native::ExpirationAction::Action>( action ), timeToLive );
+        }
+        finally
+        {
+          GC::KeepAlive(m_nativeptr);
+        }
       }
 
       // PERSISTENCE
       generic<class TKey, class TValue>
       void AttributesFactory<TKey, TValue>::SetPersistenceManager(IPersistenceManager<TKey, TValue>^ persistenceManager, Properties<String^, String^>^ config )
       {
-        apache::geode::client::PersistenceManagerPtr persistenceManagerptr;
+        native::PersistenceManagerPtr persistenceManagerptr;
         if ( persistenceManager != nullptr ) {
           PersistenceManagerGeneric<TKey, TValue>^ clg = gcnew PersistenceManagerGeneric<TKey, TValue>();
           clg->SetPersistenceManager(persistenceManager);
-          persistenceManagerptr = new apache::geode::client::ManagedPersistenceManagerGeneric( /*clg,*/ persistenceManager );
-          ((apache::geode::client::ManagedPersistenceManagerGeneric*)persistenceManagerptr.get())->setptr(clg);
+          persistenceManagerptr = std::shared_ptr<native::ManagedPersistenceManagerGeneric>(new native::ManagedPersistenceManagerGeneric(persistenceManager));
+          ((native::ManagedPersistenceManagerGeneric*)persistenceManagerptr.get())->setptr(clg);
         }
-         apache::geode::client::PropertiesPtr configptr(GetNativePtr<apache::geode::client::Properties>( config ) );
-         NativePtr->setPersistenceManager( persistenceManagerptr, configptr );
+         try
+         {
+           m_nativeptr->get()->setPersistenceManager( persistenceManagerptr, config->GetNative() );
+         }
+         finally
+         {
+           GC::KeepAlive(m_nativeptr);
+         }
       }
       
       generic<class TKey, class TValue>
@@ -230,13 +311,15 @@ namespace Apache
       {        
         ManagedString mg_libpath( libPath );
         ManagedString mg_factoryFunctionName( factoryFunctionName );
-        //  TODO:
-				//TODO::split
-        apache::geode::client::PropertiesPtr configptr(
-          GetNativePtr<apache::geode::client::Properties>( config ) );
 
-        NativePtr->setPersistenceManager( mg_libpath.CharPtr,
-          mg_factoryFunctionName.CharPtr, configptr );
+        try
+        {
+          m_nativeptr->get()->setPersistenceManager(mg_libpath.CharPtr, mg_factoryFunctionName.CharPtr, config->GetNative());
+        }
+        finally
+        {
+          GC::KeepAlive(m_nativeptr);
+        }
           
       }
 
@@ -247,7 +330,14 @@ namespace Apache
       {
         ManagedString mg_poolName( poolName );
 
-        NativePtr->setPoolName( mg_poolName.CharPtr );
+        try
+        {
+          m_nativeptr->get()->setPoolName( mg_poolName.CharPtr );
+        }
+        finally
+        {
+          GC::KeepAlive(m_nativeptr);
+        }
       }
 
       // MAP ATTRIBUTES
@@ -257,7 +347,14 @@ namespace Apache
       {
         _GF_MG_EXCEPTION_TRY2/* due to auto replace */
 
-          NativePtr->setInitialCapacity( initialCapacity );
+          try
+          {
+            m_nativeptr->get()->setInitialCapacity( initialCapacity );
+          }
+          finally
+          {
+            GC::KeepAlive(m_nativeptr);
+          }
 
         _GF_MG_EXCEPTION_CATCH_ALL2/* due to auto replace */
       }
@@ -267,7 +364,14 @@ namespace Apache
       {
         _GF_MG_EXCEPTION_TRY2/* due to auto replace */
 
-          NativePtr->setLoadFactor( loadFactor );
+          try
+          {
+            m_nativeptr->get()->setLoadFactor( loadFactor );
+          }
+          finally
+          {
+            GC::KeepAlive(m_nativeptr);
+          }
 
         _GF_MG_EXCEPTION_CATCH_ALL2/* due to auto replace */
       }
@@ -277,7 +381,14 @@ namespace Apache
       {
         _GF_MG_EXCEPTION_TRY2/* due to auto replace */
 
-          NativePtr->setConcurrencyLevel( concurrencyLevel );
+          try
+          {
+            m_nativeptr->get()->setConcurrencyLevel( concurrencyLevel );
+          }
+          finally
+          {
+            GC::KeepAlive(m_nativeptr);
+          }
 
         _GF_MG_EXCEPTION_CATCH_ALL2/* due to auto replace */
       }
@@ -285,32 +396,66 @@ namespace Apache
       generic<class TKey, class TValue>
       void AttributesFactory<TKey, TValue>::SetLruEntriesLimit( System::UInt32 entriesLimit )
       {
-        NativePtr->setLruEntriesLimit( entriesLimit );
+        try
+        {
+          m_nativeptr->get()->setLruEntriesLimit( entriesLimit );
+        }
+        finally
+        {
+          GC::KeepAlive(m_nativeptr);
+        }
       }
 
       generic<class TKey, class TValue>
       void AttributesFactory<TKey, TValue>::SetDiskPolicy( DiskPolicyType diskPolicy )
       {
-        NativePtr->setDiskPolicy(
-          static_cast<apache::geode::client::DiskPolicyType::PolicyType>( diskPolicy ) );
+        try
+        {
+          m_nativeptr->get()->setDiskPolicy(static_cast<native::DiskPolicyType::PolicyType>( diskPolicy ) );
+        }
+        finally
+        {
+          GC::KeepAlive(m_nativeptr);
+        }
       }
 
       generic<class TKey, class TValue>
       void AttributesFactory<TKey, TValue>::SetCachingEnabled( bool cachingEnabled )
       {
-        NativePtr->setCachingEnabled( cachingEnabled );
+        try
+        {
+          m_nativeptr->get()->setCachingEnabled( cachingEnabled );
+        }
+        finally
+        {
+          GC::KeepAlive(m_nativeptr);
+        }
       }
 
       generic<class TKey, class TValue>
       void AttributesFactory<TKey, TValue>::SetCloningEnabled( bool cloningEnabled )
       {
-        NativePtr->setCloningEnabled( cloningEnabled );
+        try
+        {
+          m_nativeptr->get()->setCloningEnabled( cloningEnabled );
+        }
+        finally
+        {
+          GC::KeepAlive(m_nativeptr);
+        }
       }
 
       generic<class TKey, class TValue>
       void  AttributesFactory<TKey, TValue>::SetConcurrencyChecksEnabled( bool concurrencyChecksEnabled )
       {
-        NativePtr->setConcurrencyChecksEnabled( concurrencyChecksEnabled );
+        try
+        {
+          m_nativeptr->get()->setConcurrencyChecksEnabled( concurrencyChecksEnabled );
+        }
+        finally
+        {
+          GC::KeepAlive(m_nativeptr);
+        }
       }
       // FACTORY METHOD
 
@@ -319,9 +464,15 @@ namespace Apache
       {
         _GF_MG_EXCEPTION_TRY2/* due to auto replace */
 
-          apache::geode::client::RegionAttributesPtr& nativeptr(
-          NativePtr->createRegionAttributes());
-        return Apache::Geode::Client::RegionAttributes<TKey, TValue>::Create(nativeptr.get());
+          try
+          {
+            native::RegionAttributesPtr nativeptr = m_nativeptr->get()->createRegionAttributes();
+            return Apache::Geode::Client::RegionAttributes<TKey, TValue>::Create(nativeptr);
+          }
+          finally
+          {
+            GC::KeepAlive(m_nativeptr);
+          }
 
         _GF_MG_EXCEPTION_CATCH_ALL2/* due to auto replace */
       }

http://git-wip-us.apache.org/repos/asf/geode-native/blob/6027574a/src/clicache/src/AttributesFactory.hpp
----------------------------------------------------------------------
diff --git a/src/clicache/src/AttributesFactory.hpp b/src/clicache/src/AttributesFactory.hpp
index 870ceae..608c372 100644
--- a/src/clicache/src/AttributesFactory.hpp
+++ b/src/clicache/src/AttributesFactory.hpp
@@ -18,8 +18,10 @@
 #pragma once
 
 #include "geode_defs.hpp"
+#include "begin_native.hpp"
 #include <geode/AttributesFactory.hpp>
-//#include "impl/NativeWrapper.hpp"
+#include "end_native.hpp"
+
 #include "ExpirationAction.hpp"
 #include "DiskPolicyType.hpp"
 
@@ -31,6 +33,7 @@
 #include "IPersistenceManager.hpp"
 #include "RegionAttributes.hpp"
 #include "RegionAttributes.hpp"
+#include "native_unique_ptr.hpp"
 
 
 using namespace System;
@@ -42,14 +45,7 @@ namespace Apache
   {
     namespace Client
     {
-
-      //ref class RegionAttributes;
-      //interface class ICacheLoader;
-      //interface class ICacheWriter;
-      //interface class ICacheListener;
-      //interface class IPartitionResolver;
-      //interface class IFixedPartitionResolver;
-
+      namespace native = apache::geode::client;
 
       /// <summary>
       /// Factory class to create instances of <see cref="RegionAttributes" />.
@@ -156,7 +152,6 @@ namespace Apache
       /// <seealso cref="Region.CreateSubRegion" />
       generic<class TKey, class TValue>
       public ref class AttributesFactory sealed
-        : public Internal::UMWrap<apache::geode::client::AttributesFactory>
       {
       public:
 
@@ -165,7 +160,9 @@ namespace Apache
         /// a <c>RegionAttributes</c> with default settings.
         /// </summary>
         inline AttributesFactory<TKey, TValue>( )
-          : UMWrap( new apache::geode::client::AttributesFactory( ), true ) { }
+        {
+          m_nativeptr = gcnew native_unique_ptr<native::AttributesFactory>(std::make_unique<native::AttributesFactory>());
+        }
 
         /// <summary>
         /// Creates a new instance of <c>AttributesFactory</c> ready to create
@@ -506,6 +503,9 @@ namespace Apache
         /// compatibility rules.
         /// </exception>
         RegionAttributes<TKey, TValue>^ CreateRegionAttributes( );
+
+        private:
+          native_unique_ptr<native::AttributesFactory>^ m_nativeptr;
       };
     }  // namespace Client
   }  // namespace Geode

http://git-wip-us.apache.org/repos/asf/geode-native/blob/6027574a/src/clicache/src/AttributesMutator.cpp
----------------------------------------------------------------------
diff --git a/src/clicache/src/AttributesMutator.cpp b/src/clicache/src/AttributesMutator.cpp
index 081dccb..9702ae3 100644
--- a/src/clicache/src/AttributesMutator.cpp
+++ b/src/clicache/src/AttributesMutator.cpp
@@ -15,9 +15,8 @@
  * limitations under the License.
  */
 
-//#include "geode_includes.hpp"
 #include "AttributesMutator.hpp"
-//#include "Region.hpp"
+
 #include "impl/ManagedCacheListener.hpp"
 #include "impl/ManagedCacheLoader.hpp"
 #include "impl/ManagedCacheWriter.hpp"
@@ -33,85 +32,156 @@ namespace Apache
   {
     namespace Client
     {
+      namespace native = apache::geode::client;
 
       generic<class TKey, class TValue>
       System::Int32 AttributesMutator<TKey, TValue>::SetEntryIdleTimeout( System::Int32 idleTimeout )
       {
-        return NativePtr->setEntryIdleTimeout( idleTimeout );
+        try
+        {
+          return m_nativeptr->get()->setEntryIdleTimeout( idleTimeout );
+        }
+        finally
+        {
+          GC::KeepAlive(m_nativeptr);
+        }
       }
 
       generic<class TKey, class TValue>
       ExpirationAction AttributesMutator<TKey, TValue>::SetEntryIdleTimeoutAction(
         ExpirationAction action )
       {
-        return static_cast<ExpirationAction>(
-          NativePtr->setEntryIdleTimeoutAction(
-          static_cast<apache::geode::client::ExpirationAction::Action>( action ) ) );
+        try
+        {
+          return static_cast<ExpirationAction>(
+            m_nativeptr->get()->setEntryIdleTimeoutAction(
+              static_cast<native::ExpirationAction::Action>(action)));
+        }
+        finally
+        {
+          GC::KeepAlive(m_nativeptr);
+        }
       }
 
       generic<class TKey, class TValue>
       System::Int32 AttributesMutator<TKey, TValue>::SetEntryTimeToLive( System::Int32 timeToLive )
       {
-        return NativePtr->setEntryTimeToLive( timeToLive );
+        try
+        {
+          return m_nativeptr->get()->setEntryTimeToLive( timeToLive );
+        }
+        finally
+        {
+          GC::KeepAlive(m_nativeptr);
+        }
       }
 
       generic<class TKey, class TValue>
       ExpirationAction AttributesMutator<TKey, TValue>::SetEntryTimeToLiveAction(
         ExpirationAction action )
       {
-        return static_cast<ExpirationAction>(
-          NativePtr->setEntryTimeToLiveAction(
-          static_cast<apache::geode::client::ExpirationAction::Action>( action ) ) );
-      }
+        try
+        {
+          return static_cast<ExpirationAction>(
+            m_nativeptr->get()->setEntryTimeToLiveAction(
+              static_cast<native::ExpirationAction::Action>(action)));
+        }
+        finally
+        {
+          GC::KeepAlive(m_nativeptr);
+        }
+     }
 
       generic<class TKey, class TValue>
       System::Int32 AttributesMutator<TKey, TValue>::SetRegionIdleTimeout( System::Int32 idleTimeout )
       {
-        return NativePtr->setRegionIdleTimeout( idleTimeout );
+        try
+        {
+          return m_nativeptr->get()->setRegionIdleTimeout( idleTimeout );
+        }
+        finally
+        {
+          GC::KeepAlive(m_nativeptr);
+        }
       }
 
       generic<class TKey, class TValue>
       ExpirationAction AttributesMutator<TKey, TValue>::SetRegionIdleTimeoutAction(
         ExpirationAction action )
       {
-        return static_cast<ExpirationAction>(
-          NativePtr->setRegionIdleTimeoutAction(
-          static_cast<apache::geode::client::ExpirationAction::Action>( action ) ) );
+        try
+        {
+          return static_cast<ExpirationAction>(
+            m_nativeptr->get()->setRegionIdleTimeoutAction(
+              static_cast<native::ExpirationAction::Action>(action)));
+        }
+        finally
+        {
+          GC::KeepAlive(m_nativeptr);
+        }
       }
 
       generic<class TKey, class TValue>
       System::Int32 AttributesMutator<TKey, TValue>::SetRegionTimeToLive( System::Int32 timeToLive )
       {
-        return NativePtr->setRegionTimeToLive( timeToLive );
+        try
+        {
+          return m_nativeptr->get()->setRegionTimeToLive( timeToLive );
+        }
+        finally
+        {
+          GC::KeepAlive(m_nativeptr);
+        }
       }
 
       generic<class TKey, class TValue>
       ExpirationAction AttributesMutator<TKey, TValue>::SetRegionTimeToLiveAction(
         ExpirationAction action )
       {
-        return static_cast<ExpirationAction>(
-          NativePtr->setRegionTimeToLiveAction(
-          static_cast<apache::geode::client::ExpirationAction::Action>( action ) ) );
+        try
+        {
+          return static_cast<ExpirationAction>(
+            m_nativeptr->get()->setRegionTimeToLiveAction(
+              static_cast<native::ExpirationAction::Action>(action)));
+        }
+        finally
+        {
+          GC::KeepAlive(m_nativeptr);
+        }
       }
 
       generic<class TKey, class TValue>
       System::UInt32 AttributesMutator<TKey, TValue>::SetLruEntriesLimit( System::UInt32 entriesLimit )
       {
-        return NativePtr->setLruEntriesLimit( entriesLimit );
+        try
+        {
+          return m_nativeptr->get()->setLruEntriesLimit( entriesLimit );
+        }
+        finally
+        {
+          GC::KeepAlive(m_nativeptr);
+        }
       }
 
       generic<class TKey, class TValue>
       void AttributesMutator<TKey, TValue>::SetCacheListener( ICacheListener<TKey, TValue>^ cacheListener )
       {
-        apache::geode::client::CacheListenerPtr listenerptr;
+        native::CacheListenerPtr listenerptr;
         if (cacheListener != nullptr)
         {
-          CacheListenerGeneric<TKey, TValue>^ clg = gcnew CacheListenerGeneric<TKey, TValue>();
+          auto clg = gcnew CacheListenerGeneric<TKey, TValue>();
           clg->SetCacheListener(cacheListener);
-          listenerptr = new apache::geode::client::ManagedCacheListenerGeneric( /*clg,*/ cacheListener );
-          ((apache::geode::client::ManagedCacheListenerGeneric*)listenerptr.get())->setptr(clg);
+          listenerptr = std::shared_ptr<native::ManagedCacheListenerGeneric>( new native::ManagedCacheListenerGeneric(cacheListener) );
+          ((native::ManagedCacheListenerGeneric*)listenerptr.get())->setptr(clg);
+        }
+        try
+        {
+          m_nativeptr->get()->setCacheListener( listenerptr );
+        }
+        finally
+        {
+          GC::KeepAlive(m_nativeptr);
         }
-        NativePtr->setCacheListener( listenerptr );
       }
 
       generic<class TKey, class TValue>
@@ -119,25 +189,27 @@ namespace Apache
         String^ factoryFunctionName )
       {
         throw gcnew System::NotSupportedException;
-        ManagedString mg_libpath( libPath );
-        ManagedString mg_factoryFunctionName( factoryFunctionName );
-
-        NativePtr->setCacheListener( mg_libpath.CharPtr,
-          mg_factoryFunctionName.CharPtr );
       }
 
       generic<class TKey, class TValue>
       void AttributesMutator<TKey, TValue>::SetCacheLoader( ICacheLoader<TKey, TValue>^ cacheLoader )
       {
-        apache::geode::client::CacheLoaderPtr loaderptr;
+        native::CacheLoaderPtr loaderptr;
         if (cacheLoader != nullptr)
         {
-          CacheLoaderGeneric<TKey, TValue>^ clg = gcnew CacheLoaderGeneric<TKey, TValue>();
+          auto clg = gcnew CacheLoaderGeneric<TKey, TValue>();
           clg->SetCacheLoader(cacheLoader);
-          loaderptr = new apache::geode::client::ManagedCacheLoaderGeneric( /*clg,*/ cacheLoader );
-          ((apache::geode::client::ManagedCacheLoaderGeneric*)loaderptr.get())->setptr(clg);
+          loaderptr = std::shared_ptr<native::ManagedCacheLoaderGeneric>( new native::ManagedCacheLoaderGeneric(cacheLoader) );
+          ((native::ManagedCacheLoaderGeneric*)loaderptr.get())->setptr(clg);
+        }
+        try
+        {
+          m_nativeptr->get()->setCacheLoader( loaderptr );
+        }
+        finally
+        {
+          GC::KeepAlive(m_nativeptr);
         }
-        NativePtr->setCacheLoader( loaderptr );
       }
 
       generic<class TKey, class TValue>
@@ -145,25 +217,27 @@ namespace Apache
         String^ factoryFunctionName )
       {
         throw gcnew System::NotSupportedException;
-        ManagedString mg_libpath( libPath );
-        ManagedString mg_factoryFunctionName( factoryFunctionName );
-
-        NativePtr->setCacheLoader( mg_libpath.CharPtr,
-          mg_factoryFunctionName.CharPtr );
       }
 
       generic<class TKey, class TValue>
       void AttributesMutator<TKey, TValue>::SetCacheWriter( ICacheWriter<TKey, TValue>^ cacheWriter )
       {
-        apache::geode::client::CacheWriterPtr writerptr;
+        native::CacheWriterPtr writerptr;
         if (cacheWriter != nullptr)
         {
-          CacheWriterGeneric<TKey, TValue>^ cwg = gcnew CacheWriterGeneric<TKey, TValue>();
+          auto cwg = gcnew CacheWriterGeneric<TKey, TValue>();
           cwg->SetCacheWriter(cacheWriter);
-          writerptr = new apache::geode::client::ManagedCacheWriterGeneric( /*cwg,*/ cacheWriter );
-          ((apache::geode::client::ManagedCacheWriterGeneric*)writerptr.get())->setptr(cwg);
+          writerptr = std::shared_ptr<native::ManagedCacheWriterGeneric>( new native::ManagedCacheWriterGeneric(cacheWriter) );
+          ((native::ManagedCacheWriterGeneric*)writerptr.get())->setptr(cwg);
+        }
+        try
+        {
+          m_nativeptr->get()->setCacheWriter( writerptr );
+        }
+        finally
+        {
+          GC::KeepAlive(m_nativeptr);
         }
-        NativePtr->setCacheWriter( writerptr );
       }
 
       generic<class TKey, class TValue>
@@ -171,11 +245,6 @@ namespace Apache
         String^ factoryFunctionName )
       {
         throw gcnew System::NotSupportedException;
-        ManagedString mg_libpath( libPath );
-        ManagedString mg_factoryFunctionName( factoryFunctionName );
-
-        NativePtr->setCacheWriter( mg_libpath.CharPtr,
-          mg_factoryFunctionName.CharPtr );
       }
     }  // namespace Client
   }  // namespace Geode

http://git-wip-us.apache.org/repos/asf/geode-native/blob/6027574a/src/clicache/src/AttributesMutator.hpp
----------------------------------------------------------------------
diff --git a/src/clicache/src/AttributesMutator.hpp b/src/clicache/src/AttributesMutator.hpp
index 43ce638..db0bd62 100644
--- a/src/clicache/src/AttributesMutator.hpp
+++ b/src/clicache/src/AttributesMutator.hpp
@@ -18,8 +18,11 @@
 #pragma once
 
 #include "geode_defs.hpp"
+#include "begin_native.hpp"
 #include <geode/AttributesMutator.hpp>
-//#include "impl/NativeWrapper.hpp"
+#include "end_native.hpp"
+
+#include "native_shared_ptr.hpp"
 #include "ExpirationAction.hpp"
 #include "ICacheListener.hpp"
 #include "ICacheLoader.hpp"
@@ -34,6 +37,7 @@ namespace Apache
   {
     namespace Client
     {
+      namespace native = apache::geode::client;
 
       /// <summary>
       /// Supports modification of certain region attributes after the region
@@ -54,7 +58,6 @@ namespace Apache
       /// <seealso cref="AttributesFactory" />
       generic<class TKey, class TValue>
       public ref class AttributesMutator sealed
-        : public Internal::SBWrap<apache::geode::client::AttributesMutator>
       {
       public:
 
@@ -242,10 +245,10 @@ namespace Apache
         /// <returns>
         /// The managed wrapper object; null if the native pointer is null.
         /// </returns>
-        inline static AttributesMutator<TKey, TValue>^ Create( apache::geode::client::AttributesMutator* nativeptr )
+        inline static AttributesMutator<TKey, TValue>^ Create( native::AttributesMutatorPtr nativeptr )
         {
-          return ( nativeptr != nullptr ?
-            gcnew AttributesMutator<TKey, TValue>( nativeptr ) : nullptr );
+          return __nullptr == nativeptr ? nullptr :
+            gcnew AttributesMutator<TKey, TValue>( nativeptr );
         }
 
 
@@ -255,8 +258,12 @@ namespace Apache
         /// Private constructor to wrap a native object pointer
         /// </summary>
         /// <param name="nativeptr">The native object pointer</param>
-        inline AttributesMutator<TKey, TValue>( apache::geode::client::AttributesMutator* nativeptr )
-          : SBWrap( nativeptr ) { }
+        inline AttributesMutator<TKey, TValue>( native::AttributesMutatorPtr nativeptr )
+        {
+          m_nativeptr = gcnew native_shared_ptr<native::AttributesMutator>(nativeptr);
+        }
+
+        native_shared_ptr<native::AttributesMutator>^ m_nativeptr;
       };
     }  // namespace Client
   }  // namespace Geode

http://git-wip-us.apache.org/repos/asf/geode-native/blob/6027574a/src/clicache/src/Cache.cpp
----------------------------------------------------------------------
diff --git a/src/clicache/src/Cache.cpp b/src/clicache/src/Cache.cpp
index 1906830..e900f76 100644
--- a/src/clicache/src/Cache.cpp
+++ b/src/clicache/src/Cache.cpp
@@ -41,33 +41,57 @@ namespace Apache
   {
     namespace Client
     {
+      namespace native = apache::geode::client;
 
       String^ Cache::Name::get( )
       {
-        return ManagedString::Get( NativePtr->getName( ) );
+        try
+        {
+          return ManagedString::Get( m_nativeptr->get()->getName( ) );
+        }
+        finally
+        {
+          GC::KeepAlive(m_nativeptr);
+        }
       }
 
       bool Cache::IsClosed::get( )
       {
-        return NativePtr->isClosed( );
+        try
+        {
+          return m_nativeptr->get()->isClosed( );
+        }
+        finally
+        {
+          GC::KeepAlive(m_nativeptr);
+        }
       }
 
       DistributedSystem^ Cache::DistributedSystem::get( )
       {
-        apache::geode::client::DistributedSystemPtr& nativeptr(
-          NativePtr->getDistributedSystem( ) );
-
-        return Apache::Geode::Client::DistributedSystem::Create(
-          nativeptr.ptr( ) );
+        try
+        {
+          return Client::DistributedSystem::Create(m_nativeptr->get()->getDistributedSystem());
+        }
+        finally
+        {
+          GC::KeepAlive(m_nativeptr);
+        }
       }
 
       CacheTransactionManager^ Cache::CacheTransactionManager::get( )
       {
-        apache::geode::client::InternalCacheTransactionManager2PCPtr& nativeptr = static_cast<InternalCacheTransactionManager2PCPtr>(
-          NativePtr->getCacheTransactionManager( ) );
-
-        return Apache::Geode::Client::CacheTransactionManager::Create(
-          nativeptr.ptr( ) );
+        // TODO shared_ptr this should be checking the return type for which tx mgr
+        try
+        {
+          auto nativeptr = std::dynamic_pointer_cast<InternalCacheTransactionManager2PC>(
+            m_nativeptr->get()->getCacheTransactionManager());
+          return Apache::Geode::Client::CacheTransactionManager::Create(nativeptr);
+        }
+        finally
+        {
+          GC::KeepAlive(m_nativeptr);
+        }
       }
 
       void Cache::Close( )
@@ -81,10 +105,17 @@ namespace Apache
 
           Apache::Geode::Client::DistributedSystem::acquireDisconnectLock();
 
-        Apache::Geode::Client::DistributedSystem::disconnectInstance();
+          Apache::Geode::Client::DistributedSystem::disconnectInstance();
           CacheFactory::m_connected = false;
 
-          NativePtr->close( keepalive );
+          try
+          {
+            m_nativeptr->get()->close( keepalive );
+          }
+          finally
+          {
+            GC::KeepAlive(m_nativeptr);
+          }
 
           // If DS automatically disconnected due to the new bootstrap API, then cleanup the C++/CLI side
           //if (!apache::geode::client::DistributedSystem::isConnected())
@@ -106,7 +137,14 @@ namespace Apache
       {
         _GF_MG_EXCEPTION_TRY2
 
-          NativePtr->readyForEvents( );
+          try
+          {
+            m_nativeptr->get()->readyForEvents( );
+          }
+          finally
+          {
+            GC::KeepAlive(m_nativeptr);
+          }
 
         _GF_MG_EXCEPTION_CATCH_ALL2
       }
@@ -117,10 +155,14 @@ namespace Apache
         _GF_MG_EXCEPTION_TRY2/* due to auto replace */
 
           ManagedString mg_path( path );
-          apache::geode::client::RegionPtr& nativeptr(
-            NativePtr->getRegion( mg_path.CharPtr ) );
-
-          return Client::Region<TKey,TValue>::Create( nativeptr.ptr( ) );
+          try
+          {
+            return Client::Region<TKey, TValue>::Create(m_nativeptr->get()->getRegion(mg_path.CharPtr));
+          }
+          finally
+          {
+            GC::KeepAlive(m_nativeptr);
+          }
 
         _GF_MG_EXCEPTION_CATCH_ALL2/* due to auto replace */
       }
@@ -129,14 +171,21 @@ namespace Apache
       array<Client::IRegion<TKey, TValue>^>^ Cache::RootRegions( )
       {
         apache::geode::client::VectorOfRegion vrr;
-        NativePtr->rootRegions( vrr );
+        try
+        {
+          m_nativeptr->get()->rootRegions( vrr );
+        }
+        finally
+        {
+          GC::KeepAlive(m_nativeptr);
+        }
         array<Client::IRegion<TKey, TValue>^>^ rootRegions =
           gcnew array<Client::IRegion<TKey, TValue>^>( vrr.size( ) );
 
         for( System::Int32 index = 0; index < vrr.size( ); index++ )
         {
           apache::geode::client::RegionPtr& nativeptr( vrr[ index ] );
-          rootRegions[ index ] = Client::Region<TKey, TValue>::Create( nativeptr.ptr( ) );
+          rootRegions[ index ] = Client::Region<TKey, TValue>::Create( nativeptr );
         }
         return rootRegions;
       }
@@ -146,7 +195,14 @@ namespace Apache
       {
         _GF_MG_EXCEPTION_TRY2
 
-          return Client::QueryService<TKey, TResult>::Create( NativePtr->getQueryService( ).ptr( ) );
+          try
+          {
+            return Client::QueryService<TKey, TResult>::Create(m_nativeptr->get()->getQueryService());
+          }
+          finally
+          {
+            GC::KeepAlive(m_nativeptr);
+          }
 
         _GF_MG_EXCEPTION_CATCH_ALL2
       }
@@ -157,7 +213,14 @@ namespace Apache
         _GF_MG_EXCEPTION_TRY2
 
           ManagedString mg_poolName( poolName );
-          return QueryService<TKey, TResult>::Create( NativePtr->getQueryService(mg_poolName.CharPtr).ptr( ) );
+          try
+          {
+            return QueryService<TKey, TResult>::Create(m_nativeptr->get()->getQueryService(mg_poolName.CharPtr));
+          }
+          finally
+          {
+            GC::KeepAlive(m_nativeptr);
+          }
 
         _GF_MG_EXCEPTION_CATCH_ALL2
       }
@@ -187,26 +250,30 @@ namespace Apache
               break;          
           }
 
-          return RegionFactory::Create(NativePtr->createRegionFactory(preDefineRegionAttr).get());
+          try
+          {
+            return RegionFactory::Create(m_nativeptr->get()->createRegionFactory(preDefineRegionAttr));
+          }
+          finally
+          {
+            GC::KeepAlive(m_nativeptr);
+          }
           
         _GF_MG_EXCEPTION_CATCH_ALL2
       }
 
       IRegionService^ Cache::CreateAuthenticatedView(Properties<String^, Object^>^ credentials)
-      {
-        //  TODO:
-				//TODO::split
-        apache::geode::client::Properties* prop = NULL;
-
-        if (credentials != nullptr)
-          prop = GetNativePtr<apache::geode::client::Properties>( credentials );
-
-        apache::geode::client::PropertiesPtr credPtr(prop);
-        
-        
+      {        
         _GF_MG_EXCEPTION_TRY2
 
-          return AuthenticatedCache::Create( (NativePtr->createAuthenticatedView(credPtr)).get());
+          try
+          {
+            return AuthenticatedCache::Create((m_nativeptr->get()->createAuthenticatedView(credentials->GetNative())));
+          }
+          finally
+          {
+            GC::KeepAlive(m_nativeptr);
+          }
 
         _GF_MG_EXCEPTION_CATCH_ALL2   
       }
@@ -215,7 +282,14 @@ namespace Apache
 			{
 				_GF_MG_EXCEPTION_TRY2
 
-					return	NativePtr->getPdxIgnoreUnreadFields();
+					try
+					{
+					  return	m_nativeptr->get()->getPdxIgnoreUnreadFields();
+					}
+					finally
+					{
+					  GC::KeepAlive(m_nativeptr);
+					}
 
 				_GF_MG_EXCEPTION_CATCH_ALL2   
 			}
@@ -224,28 +298,32 @@ namespace Apache
 			{
 				_GF_MG_EXCEPTION_TRY2
 
-					return	NativePtr->getPdxReadSerialized();
+					try
+					{
+					  return	m_nativeptr->get()->getPdxReadSerialized();
+					}
+					finally
+					{
+					  GC::KeepAlive(m_nativeptr);
+					}
 
 				_GF_MG_EXCEPTION_CATCH_ALL2   
 			}
 
       IRegionService^ Cache::CreateAuthenticatedView(Properties<String^, Object^>^ credentials, String^ poolName)
       {
-         // TODO:
-				//TODO::split
-        apache::geode::client::Properties* prop = NULL;
-
-        if (credentials != nullptr)
-          prop = GetNativePtr<apache::geode::client::Properties>( credentials );
-
-        apache::geode::client::PropertiesPtr credPtr(prop);
-
         ManagedString mg_poolName( poolName );
-        
-        
+
         _GF_MG_EXCEPTION_TRY2
 
-          return AuthenticatedCache::Create( (NativePtr->createAuthenticatedView(credPtr, mg_poolName.CharPtr)).get());
+          try
+          {
+            return AuthenticatedCache::Create( (m_nativeptr->get()->createAuthenticatedView(credentials->GetNative(), mg_poolName.CharPtr)));
+          }
+          finally
+          {
+            GC::KeepAlive(m_nativeptr);
+          }
 
         _GF_MG_EXCEPTION_CATCH_ALL2   
       }
@@ -253,14 +331,21 @@ namespace Apache
 			 void Cache::InitializeDeclarativeCache( String^ cacheXml )
       {
         ManagedString mg_cacheXml( cacheXml );
-        NativePtr->initializeDeclarativeCache( mg_cacheXml.CharPtr );
+        try
+        {
+          m_nativeptr->get()->initializeDeclarativeCache( mg_cacheXml.CharPtr );
+        }
+        finally
+        {
+          GC::KeepAlive(m_nativeptr);
+        }
       }
 
-        IPdxInstanceFactory^ Cache::CreatePdxInstanceFactory(String^ className)
-        {
-          return gcnew Internal::PdxInstanceFactoryImpl(className);
+       IPdxInstanceFactory^ Cache::CreatePdxInstanceFactory(String^ className)
+       {
+         return gcnew Internal::PdxInstanceFactoryImpl(className);
+       }
     }  // namespace Client
   }  // namespace Geode
 }  // namespace Apache
 
-}

http://git-wip-us.apache.org/repos/asf/geode-native/blob/6027574a/src/clicache/src/Cache.hpp
----------------------------------------------------------------------
diff --git a/src/clicache/src/Cache.hpp b/src/clicache/src/Cache.hpp
index 67bd11c..889faaf 100644
--- a/src/clicache/src/Cache.hpp
+++ b/src/clicache/src/Cache.hpp
@@ -18,16 +18,9 @@
 #pragma once
 
 #include "geode_defs.hpp"
-//#include <geode/Cache.hpp>
-//#include "impl/NativeWrapper.hpp"
 #include "RegionShortcut.hpp"
-//#include "RegionFactory.hpp"
 #include "IGeodeCache.hpp"
-//#include "IRegionService.hpp"
 #include "IRegion.hpp"
-//#include "QueryService.hpp"
-
-
 #include "RegionAttributes.hpp"
 
 using namespace System;
@@ -38,6 +31,7 @@ namespace Apache
   {
     namespace Client
     {
+      namespace native = apache::geode::client;
 
       generic<class TKey, class TResult>
       ref class QueryService;
@@ -63,7 +57,7 @@ namespace Apache
       /// </para>
       /// </remarks>
       public ref class Cache sealed
-        : public IGeodeCache, Internal::SBWrap<apache::geode::client::Cache>
+        : public IGeodeCache
       {
       public:
 
@@ -268,12 +262,16 @@ namespace Apache
         /// <returns>
         /// The managed wrapper object; null if the native pointer is null.
         /// </returns>
-        inline static Cache^ Create(apache::geode::client::Cache* nativeptr)
+        inline static Cache^ Create(native::CachePtr nativeptr)
         {
-          return (nativeptr != nullptr ?
-                  gcnew Cache(nativeptr) : nullptr);
+          return __nullptr == nativeptr ? nullptr :
+            gcnew Cache( nativeptr );
         }
 
+        std::shared_ptr<native::Cache> GetNative()
+        {
+          return m_nativeptr->get_shared_ptr();
+        }
 
       private:
 
@@ -281,8 +279,12 @@ namespace Apache
         /// Private constructor to wrap a native object pointer
         /// </summary>
         /// <param name="nativeptr">The native object pointer</param>
-        inline Cache(apache::geode::client::Cache* nativeptr)
-          : SBWrap(nativeptr) { }
+        inline Cache(native::CachePtr nativeptr)
+        {
+          m_nativeptr = gcnew native_shared_ptr<native::Cache>(nativeptr);
+        }
+
+        native_shared_ptr<native::Cache>^ m_nativeptr;
       };
     }  // namespace Client
   }  // namespace Geode

http://git-wip-us.apache.org/repos/asf/geode-native/blob/6027574a/src/clicache/src/CacheFactory.cpp
----------------------------------------------------------------------
diff --git a/src/clicache/src/CacheFactory.cpp b/src/clicache/src/CacheFactory.cpp
index 8c71107..6bdda46 100644
--- a/src/clicache/src/CacheFactory.cpp
+++ b/src/clicache/src/CacheFactory.cpp
@@ -39,6 +39,8 @@ namespace Apache
     namespace Client
     {
 
+      namespace native = apache::geode::client;
+
       CacheFactory^ CacheFactory::CreateCacheFactory()
       {
         return CacheFactory::CreateCacheFactory(Properties<String^, String^>::Create<String^, String^>());
@@ -48,16 +50,13 @@ namespace Apache
       {
         _GF_MG_EXCEPTION_TRY2
 
-           apache::geode::client::PropertiesPtr nativepropsptr(
-            GetNativePtr<apache::geode::client::Properties>(dsProps));
-
-          apache::geode::client::CacheFactoryPtr& nativeptr( apache::geode::client::CacheFactory::createCacheFactory( nativepropsptr) );         
-          if (nativeptr.get() != nullptr)
-            return gcnew CacheFactory( nativeptr.get(), dsProps );
+          auto nativeCacheFactory = native::CacheFactory::createCacheFactory(dsProps->GetNative());         
+          if (nativeCacheFactory)
+            return gcnew CacheFactory( nativeCacheFactory, dsProps );
             
           return nullptr;
 
-        _GF_MG_EXCEPTION_CATCH_ALL2        
+        _GF_MG_EXCEPTION_CATCH_ALL2
       }
 
       Cache^ CacheFactory::Create()
@@ -71,28 +70,26 @@ namespace Apache
     
           if(!m_connected)
           {
-             apache::geode::client::PropertiesPtr nativepropsptr(
-               GetNativePtr<apache::geode::client::Properties>(m_dsProps));
-            DistributedSystem::AppDomainInstanceInitialization(nativepropsptr);                  
+            DistributedSystem::AppDomainInstanceInitialization(m_dsProps->GetNative());                  
           }
 
-          apache::geode::client::CachePtr& nativeptr( NativePtr->create( ) );
-					pdxIgnoreUnreadFields = nativeptr->getPdxIgnoreUnreadFields();
-          pdxReadSerialized = nativeptr->getPdxReadSerialized();
+          auto nativeCache = m_nativeptr->get()->create( );
+					pdxIgnoreUnreadFields = nativeCache->getPdxIgnoreUnreadFields();
+          pdxReadSerialized = nativeCache->getPdxReadSerialized();
 
           appDomainEnable = DistributedSystem::SystemProperties->AppDomainEnabled;
-          Log::SetLogLevel(static_cast<LogLevel>(apache::geode::client::Log::logLevel( )));
+          Log::SetLogLevel(static_cast<LogLevel>(native::Log::logLevel( )));
 					//TODO::split
           SafeConvertClassGeneric::SetAppDomainEnabled(appDomainEnable);
 
           if (appDomainEnable)
           {
             // Register managed AppDomain context with unmanaged.
-            apache::geode::client::createAppDomainContext = &Apache::Geode::Client::createAppDomainContext;
+            native::createAppDomainContext = &Apache::Geode::Client::createAppDomainContext;
           }
 
             Serializable::RegisterTypeGeneric(
-              apache::geode::client::GeodeTypeIds::PdxType,
+              native::GeodeTypeIds::PdxType,
               gcnew TypeFactoryMethodGeneric(Apache::Geode::Client::Internal::PdxType::CreateDeserializable),
               nullptr);
 
@@ -106,9 +103,10 @@ namespace Apache
           
            m_connected = true;
            
-           return Cache::Create( nativeptr.ptr( ) );
+           return Cache::Create( nativeCache );
         _GF_MG_EXCEPTION_CATCH_ALL2
           finally {
+            GC::KeepAlive(m_nativeptr);
             DistributedSystem::registerCliCallback();
 						Serializable::RegisterPDXManagedCacheableKey(appDomainEnable);
 					Apache::Geode::Client::Internal::PdxTypeRegistry::PdxIgnoreUnreadFields = pdxIgnoreUnreadFields; 
@@ -121,12 +119,7 @@ namespace Apache
       {
         _GF_MG_EXCEPTION_TRY2
 
-          apache::geode::client::DistributedSystemPtr p_system(
-            GetNativePtr<apache::geode::client::DistributedSystem>( system ) );
-          apache::geode::client::CachePtr& nativeptr(
-            apache::geode::client::CacheFactory::getInstance( p_system ) );
-
-          return Cache::Create( nativeptr.ptr( ) );
+         return Cache::Create( native::CacheFactory::getInstance( system->GetNative() ) );
 
         _GF_MG_EXCEPTION_CATCH_ALL2
       }
@@ -135,12 +128,7 @@ namespace Apache
       {
         _GF_MG_EXCEPTION_TRY2
 
-          apache::geode::client::DistributedSystemPtr p_system(
-            GetNativePtr<apache::geode::client::DistributedSystem>( system ) );
-          apache::geode::client::CachePtr& nativeptr(
-            apache::geode::client::CacheFactory::getInstanceCloseOk( p_system ) );
-
-          return Cache::Create( nativeptr.ptr( ) );
+          return Cache::Create( native::CacheFactory::getInstanceCloseOk( system->GetNative() ) );
 
         _GF_MG_EXCEPTION_CATCH_ALL2
       }
@@ -149,22 +137,20 @@ namespace Apache
       {
         _GF_MG_EXCEPTION_TRY2
 
-          apache::geode::client::CachePtr& nativeptr(
-            apache::geode::client::CacheFactory::getAnyInstance( ) );
-          return Cache::Create( nativeptr.ptr( ) );
+          return Cache::Create( native::CacheFactory::getAnyInstance( ) );
 
         _GF_MG_EXCEPTION_CATCH_ALL2
       }
 
       String^ CacheFactory::Version::get( )
       {
-        return ManagedString::Get( apache::geode::client::CacheFactory::getVersion( ) );
+        return ManagedString::Get( native::CacheFactory::getVersion( ) );
       }
 
       String^ CacheFactory::ProductDescription::get( )
       {
         return ManagedString::Get(
-          apache::geode::client::CacheFactory::getProductDescription( ) );
+          native::CacheFactory::getProductDescription( ) );
       }
 
 
@@ -172,7 +158,14 @@ namespace Apache
 		  {
 			  _GF_MG_EXCEPTION_TRY2
 
-			  NativePtr->setFreeConnectionTimeout( connectionTimeout );
+			  try
+			  {
+			    m_nativeptr->get()->setFreeConnectionTimeout( connectionTimeout );
+			  }
+			  finally
+			  {
+			    GC::KeepAlive(m_nativeptr);
+			  }
 
         return this;
 
@@ -183,7 +176,14 @@ namespace Apache
 		  {
 			  _GF_MG_EXCEPTION_TRY2
 
-			  NativePtr->setLoadConditioningInterval( loadConditioningInterval );
+			  try
+			  {
+			    m_nativeptr->get()->setLoadConditioningInterval( loadConditioningInterval );
+			  }
+			  finally
+			  {
+			    GC::KeepAlive(m_nativeptr);
+			  }
         return this;
 
 			  _GF_MG_EXCEPTION_CATCH_ALL2
@@ -193,7 +193,14 @@ namespace Apache
       {
 			  _GF_MG_EXCEPTION_TRY2
 
-          NativePtr->setSocketBufferSize( bufferSize );
+          try
+          {
+            m_nativeptr->get()->setSocketBufferSize( bufferSize );
+          }
+          finally
+          {
+            GC::KeepAlive(m_nativeptr);
+          }
           return this;
 
 			  _GF_MG_EXCEPTION_CATCH_ALL2
@@ -203,7 +210,14 @@ namespace Apache
       {
 			  _GF_MG_EXCEPTION_TRY2
 
-          NativePtr->setReadTimeout( timeout );
+          try
+          {
+            m_nativeptr->get()->setReadTimeout( timeout );
+          }
+          finally
+          {
+            GC::KeepAlive(m_nativeptr);
+          }
           return this;
 
 			  _GF_MG_EXCEPTION_CATCH_ALL2
@@ -213,7 +227,14 @@ namespace Apache
       {
 			  _GF_MG_EXCEPTION_TRY2
 
-          NativePtr->setMinConnections( minConnections );
+          try
+          {
+            m_nativeptr->get()->setMinConnections( minConnections );
+          }
+          finally
+          {
+            GC::KeepAlive(m_nativeptr);
+          }
           return this;
 
 			  _GF_MG_EXCEPTION_CATCH_ALL2
@@ -223,7 +244,14 @@ namespace Apache
       {
 			  _GF_MG_EXCEPTION_TRY2
 
-          NativePtr->setMaxConnections( maxConnections );
+          try
+          {
+            m_nativeptr->get()->setMaxConnections( maxConnections );
+          }
+          finally
+          {
+            GC::KeepAlive(m_nativeptr);
+          }
           return this;
 
 			  _GF_MG_EXCEPTION_CATCH_ALL2
@@ -233,7 +261,14 @@ namespace Apache
       {
 			  _GF_MG_EXCEPTION_TRY2
 
-          NativePtr->setIdleTimeout( idleTimeout );
+          try
+          {
+            m_nativeptr->get()->setIdleTimeout( idleTimeout );
+          }
+          finally
+          {
+            GC::KeepAlive(m_nativeptr);
+          }
           return this;
 
 			  _GF_MG_EXCEPTION_CATCH_ALL2
@@ -243,7 +278,14 @@ namespace Apache
       {
 			  _GF_MG_EXCEPTION_TRY2
 
-			  NativePtr->setRetryAttempts( retryAttempts );
+			  try
+			  {
+			    m_nativeptr->get()->setRetryAttempts( retryAttempts );
+			  }
+			  finally
+			  {
+			    GC::KeepAlive(m_nativeptr);
+			  }
         return this;
 
 			  _GF_MG_EXCEPTION_CATCH_ALL2
@@ -253,7 +295,14 @@ namespace Apache
       {
 			  _GF_MG_EXCEPTION_TRY2
 
-          NativePtr->setPingInterval( pingInterval );
+          try
+          {
+            m_nativeptr->get()->setPingInterval( pingInterval );
+          }
+          finally
+          {
+            GC::KeepAlive(m_nativeptr);
+          }
           return this;
 
 			  _GF_MG_EXCEPTION_CATCH_ALL2
@@ -263,7 +312,14 @@ namespace Apache
       {
 			  _GF_MG_EXCEPTION_TRY2
 
-          NativePtr->setUpdateLocatorListInterval( updateLocatorListInterval );
+          try
+          {
+            m_nativeptr->get()->setUpdateLocatorListInterval( updateLocatorListInterval );
+          }
+          finally
+          {
+            GC::KeepAlive(m_nativeptr);
+          }
           return this;
 
 			  _GF_MG_EXCEPTION_CATCH_ALL2
@@ -273,7 +329,14 @@ namespace Apache
       {
 			  _GF_MG_EXCEPTION_TRY2
 
-          NativePtr->setStatisticInterval( statisticInterval );
+          try
+          {
+            m_nativeptr->get()->setStatisticInterval( statisticInterval );
+          }
+          finally
+          {
+            GC::KeepAlive(m_nativeptr);
+          }
           return this;
 
 			  _GF_MG_EXCEPTION_CATCH_ALL2
@@ -284,7 +347,14 @@ namespace Apache
 			  _GF_MG_EXCEPTION_TRY2
 
         ManagedString mg_servergroup( group );
-        NativePtr->setServerGroup( mg_servergroup.CharPtr );
+        try
+        {
+          m_nativeptr->get()->setServerGroup( mg_servergroup.CharPtr );
+        }
+        finally
+        {
+          GC::KeepAlive(m_nativeptr);
+        }
         return this;
 
 			  _GF_MG_EXCEPTION_CATCH_ALL2
@@ -295,7 +365,14 @@ namespace Apache
 			  _GF_MG_EXCEPTION_TRY2
 
         ManagedString mg_host( host );
-        NativePtr->addLocator( mg_host.CharPtr, port );
+        try
+        {
+          m_nativeptr->get()->addLocator( mg_host.CharPtr, port );
+        }
+        finally
+        {
+          GC::KeepAlive(m_nativeptr);
+        }
         return this;
 
 			  _GF_MG_EXCEPTION_CATCH_ALL2
@@ -306,7 +383,14 @@ namespace Apache
 			  _GF_MG_EXCEPTION_TRY2
 
 			  ManagedString mg_host( host );
-        NativePtr->addServer( mg_host.CharPtr, port );
+        try
+        {
+          m_nativeptr->get()->addServer( mg_host.CharPtr, port );
+        }
+        finally
+        {
+          GC::KeepAlive(m_nativeptr);
+        }
         return this;
 
 			  _GF_MG_EXCEPTION_CATCH_ALL2
@@ -316,7 +400,14 @@ namespace Apache
       {
 			  _GF_MG_EXCEPTION_TRY2
 
-			  NativePtr->setSubscriptionEnabled( enabled );
+			  try
+			  {
+			    m_nativeptr->get()->setSubscriptionEnabled( enabled );
+			  }
+			  finally
+			  {
+			    GC::KeepAlive(m_nativeptr);
+			  }
         return this;
 
 			  _GF_MG_EXCEPTION_CATCH_ALL2
@@ -326,7 +417,14 @@ namespace Apache
       {
         _GF_MG_EXCEPTION_TRY2
 
-          NativePtr->setPRSingleHopEnabled(enabled);
+          try
+          {
+            m_nativeptr->get()->setPRSingleHopEnabled(enabled);
+          }
+          finally
+          {
+            GC::KeepAlive(m_nativeptr);
+          }
           return this;
 
          _GF_MG_EXCEPTION_CATCH_ALL2
@@ -336,7 +434,14 @@ namespace Apache
       {
 			  _GF_MG_EXCEPTION_TRY2
 
-          NativePtr->setSubscriptionRedundancy( redundancy );
+          try
+          {
+            m_nativeptr->get()->setSubscriptionRedundancy( redundancy );
+          }
+          finally
+          {
+            GC::KeepAlive(m_nativeptr);
+          }
           return this;
 
 			  _GF_MG_EXCEPTION_CATCH_ALL2
@@ -346,7 +451,14 @@ namespace Apache
       {
 			  _GF_MG_EXCEPTION_TRY2
 
-          NativePtr->setSubscriptionMessageTrackingTimeout( messageTrackingTimeout );
+          try
+          {
+            m_nativeptr->get()->setSubscriptionMessageTrackingTimeout( messageTrackingTimeout );
+          }
+          finally
+          {
+            GC::KeepAlive(m_nativeptr);
+          }
           return this;
 
 			  _GF_MG_EXCEPTION_CATCH_ALL2
@@ -356,7 +468,14 @@ namespace Apache
       {
 			  _GF_MG_EXCEPTION_TRY2
 
-          NativePtr->setSubscriptionAckInterval( ackInterval );
+          try
+          {
+            m_nativeptr->get()->setSubscriptionAckInterval( ackInterval );
+          }
+          finally
+          {
+            GC::KeepAlive(m_nativeptr);
+          }
           return this;
 
 			  _GF_MG_EXCEPTION_CATCH_ALL2
@@ -366,7 +485,14 @@ namespace Apache
       {
         _GF_MG_EXCEPTION_TRY2
 
-        NativePtr->setThreadLocalConnections( enabled );
+        try
+        {
+          m_nativeptr->get()->setThreadLocalConnections( enabled );
+        }
+        finally
+        {
+          GC::KeepAlive(m_nativeptr);
+        }
 
         _GF_MG_EXCEPTION_CATCH_ALL2
 
@@ -377,7 +503,14 @@ namespace Apache
       {
 			  _GF_MG_EXCEPTION_TRY2
 
-          NativePtr->setMultiuserAuthentication( multiuserAuthentication );
+          try
+          {
+            m_nativeptr->get()->setMultiuserAuthentication( multiuserAuthentication );
+          }
+          finally
+          {
+            GC::KeepAlive(m_nativeptr);
+          }
           return this;
 
 			  _GF_MG_EXCEPTION_CATCH_ALL2
@@ -387,7 +520,14 @@ namespace Apache
 			{
 				_GF_MG_EXCEPTION_TRY2
 
-          NativePtr->setPdxIgnoreUnreadFields( ignore );
+          try
+          {
+            m_nativeptr->get()->setPdxIgnoreUnreadFields( ignore );
+          }
+          finally
+          {
+            GC::KeepAlive(m_nativeptr);
+          }
           return this;
 
 			  _GF_MG_EXCEPTION_CATCH_ALL2
@@ -397,7 +537,14 @@ namespace Apache
       {
         	_GF_MG_EXCEPTION_TRY2
 
-          NativePtr->setPdxReadSerialized( pdxReadSerialized );
+          try
+          {
+            m_nativeptr->get()->setPdxReadSerialized( pdxReadSerialized );
+          }
+          finally
+          {
+            GC::KeepAlive(m_nativeptr);
+          }
           return this;
 
 			  _GF_MG_EXCEPTION_CATCH_ALL2
@@ -408,7 +555,14 @@ namespace Apache
         _GF_MG_EXCEPTION_TRY2
           ManagedString mg_name( name );
           ManagedString mg_value( value );
-          NativePtr->set( mg_name.CharPtr, mg_value.CharPtr );
+          try
+          {
+            m_nativeptr->get()->set( mg_name.CharPtr, mg_value.CharPtr );
+          }
+          finally
+          {
+            GC::KeepAlive(m_nativeptr);
+          }
           return this;
 
 			  _GF_MG_EXCEPTION_CATCH_ALL2

http://git-wip-us.apache.org/repos/asf/geode-native/blob/6027574a/src/clicache/src/CacheFactory.hpp
----------------------------------------------------------------------
diff --git a/src/clicache/src/CacheFactory.hpp b/src/clicache/src/CacheFactory.hpp
index acaca31..5133681 100644
--- a/src/clicache/src/CacheFactory.hpp
+++ b/src/clicache/src/CacheFactory.hpp
@@ -18,11 +18,13 @@
 #pragma once
 
 #include "geode_defs.hpp"
-#include "impl/NativeWrapper.hpp"
+#include "begin_native.hpp"
 #include <geode/CacheFactory.hpp>
+#include "end_native.hpp"
+
+#include "native_shared_ptr.hpp"
 #include "Properties.hpp"
 
-//using namespace System;
 using namespace System::Collections::Generic;
 
 namespace Apache
@@ -31,6 +33,7 @@ namespace Apache
   {
     namespace Client
     {
+      namespace native = apache::geode::client;
 
       ref class Cache;
       ref class CacheAttributes;
@@ -45,7 +48,7 @@ namespace Apache
       /// To get an existing unclosed cache instance, use <see cref="CacheFactory.GetInstance" />.
       /// </para>
       /// </remarks>
-      public ref class CacheFactory :public Internal::SBWrap<apache::geode::client::CacheFactory>
+      public ref class CacheFactory
       {
       public:
 
@@ -127,7 +130,7 @@ namespace Apache
         /// </summary>
         static void SetNewAndDelete()
         {
-          apache::geode::client::setNewAndDelete(&operator new, &operator delete);
+          native::setNewAndDelete(&operator new, &operator delete);
         }
 
         /// <summary>
@@ -591,9 +594,9 @@ namespace Apache
         /// Private constructor to wrap a native object pointer
         /// </summary>
         /// <param name="nativeptr">The native object pointer</param>
-        inline CacheFactory(apache::geode::client::CacheFactory* nativeptr, Properties<String^, String^>^ dsProps)
-          : SBWrap(nativeptr)
+        inline CacheFactory(native::CacheFactoryPtr nativeptr, Properties<String^, String^>^ dsProps)
         {
+          m_nativeptr = gcnew native_shared_ptr<native::CacheFactory>(nativeptr);
           m_dsProps = dsProps;
         }
 
@@ -601,6 +604,8 @@ namespace Apache
 
         static System::Object^ m_singletonSync = gcnew System::Object();
 
+        native_shared_ptr<native::CacheFactory>^ m_nativeptr;
+
       internal:
         static bool m_connected = false;
       };

http://git-wip-us.apache.org/repos/asf/geode-native/blob/6027574a/src/clicache/src/CacheStatistics.cpp
----------------------------------------------------------------------
diff --git a/src/clicache/src/CacheStatistics.cpp b/src/clicache/src/CacheStatistics.cpp
index 7edaeeb..4259246 100644
--- a/src/clicache/src/CacheStatistics.cpp
+++ b/src/clicache/src/CacheStatistics.cpp
@@ -15,7 +15,6 @@
  * limitations under the License.
  */
 
-//#include "geode_includes.hpp"
 #include "CacheStatistics.hpp"
 
 
@@ -26,16 +25,31 @@ namespace Apache
     namespace Client
     {
 
+      using namespace System;
+
       System::UInt32 CacheStatistics::LastModifiedTime::get( )
       {
-        return NativePtr->getLastModifiedTime( );
+        try
+        {
+          return m_nativeptr->get()->getLastModifiedTime( );
+        }
+        finally
+        {
+          GC::KeepAlive(m_nativeptr);
+        }
       }
 
-      System::UInt32 CacheStatistics::LastAccessedTime::get( )
+      System::UInt32 CacheStatistics::LastAccessedTime::get()
       {
-        return NativePtr->getLastAccessedTime( );
+        try
+        {
+          return m_nativeptr->get()->getLastAccessedTime();
+        }
+        finally
+        {
+          GC::KeepAlive(m_nativeptr);
+        }
+      }
     }  // namespace Client
   }  // namespace Geode
 }  // namespace Apache
-
- } //namespace 

http://git-wip-us.apache.org/repos/asf/geode-native/blob/6027574a/src/clicache/src/CacheStatistics.hpp
----------------------------------------------------------------------
diff --git a/src/clicache/src/CacheStatistics.hpp b/src/clicache/src/CacheStatistics.hpp
index d91f1d5..ec006ac 100644
--- a/src/clicache/src/CacheStatistics.hpp
+++ b/src/clicache/src/CacheStatistics.hpp
@@ -18,8 +18,11 @@
 #pragma once
 
 #include "geode_defs.hpp"
+#include "begin_native.hpp"
 #include <geode/CacheStatistics.hpp>
-#include "impl/NativeWrapper.hpp"
+#include "end_native.hpp"
+
+#include "native_shared_ptr.hpp"
 
 
 namespace Apache
@@ -28,6 +31,7 @@ namespace Apache
   {
     namespace Client
     {
+      namespace native = apache::geode::client;
 
       /// <summary>
       /// Defines common statistical information for both the region and its entries.
@@ -39,7 +43,6 @@ namespace Apache
       /// <seealso cref="Region.Statistics" />
       /// <seealso cref="RegionEntry.Statistics" />
       public ref class CacheStatistics sealed
-        : public Internal::SBWrap<apache::geode::client::CacheStatistics>
       {
       public:
 
@@ -131,10 +134,10 @@ namespace Apache
         /// <returns>
         /// The managed wrapper object; null if the native pointer is null.
         /// </returns>
-        inline static CacheStatistics^ Create( apache::geode::client::CacheStatistics* nativeptr )
+        inline static CacheStatistics^ Create( apache::geode::client::CacheStatisticsPtr nativeptr )
         {
-          return ( nativeptr != nullptr ?
-            gcnew CacheStatistics( nativeptr ) : nullptr );
+          return __nullptr == nativeptr ? nullptr :
+            gcnew CacheStatistics( nativeptr );
         }
 
 
@@ -144,8 +147,11 @@ namespace Apache
         /// Private constructor to wrap a native object pointer
         /// </summary>
         /// <param name="nativeptr">The native object pointer</param>
-        inline CacheStatistics( apache::geode::client::CacheStatistics* nativeptr )
-          : SBWrap( nativeptr ) { }
+        inline CacheStatistics( apache::geode::client::CacheStatisticsPtr nativeptr )
+        {
+           m_nativeptr = gcnew native_shared_ptr<native::CacheStatistics>(nativeptr);
+        }
+        native_shared_ptr<native::CacheStatistics>^ m_nativeptr;
       };
     }  // namespace Client
   }  // namespace Geode