geode-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jbarr...@apache.org
Subject [37/46] geode-native git commit: GEODE-2741: Remove custom shared pointer from clicache
Date Wed, 17 May 2017 17:50:19 GMT
http://git-wip-us.apache.org/repos/asf/geode-native/blob/6027574a/src/clicache/src/LocalRegion.cpp
----------------------------------------------------------------------
diff --git a/src/clicache/src/LocalRegion.cpp b/src/clicache/src/LocalRegion.cpp
index 9fd618f..e1d6d2d 100644
--- a/src/clicache/src/LocalRegion.cpp
+++ b/src/clicache/src/LocalRegion.cpp
@@ -15,7 +15,6 @@
  * limitations under the License.
  */
 
-//#include "geode_includes.hpp"
 #include "LocalRegion.hpp"
 #include "Cache.hpp"
 #include "CacheStatistics.hpp"
@@ -23,8 +22,6 @@
 #include "RegionEntry.hpp"
 #include "impl/AuthenticatedCache.hpp"
 #include "impl/SafeConvert.hpp"
-//#include <geode/Serializable.hpp>
-//#include <cppcache/DataOutPut.hpp>
 
 using namespace System;
 
@@ -38,8 +35,8 @@ namespace Apache
       generic<class TKey, class TValue>
       TValue LocalRegion<TKey, TValue>::Get(TKey key, Object^ callbackArg)
       {
-        apache::geode::client::CacheableKeyPtr keyptr( Serializable::GetUnmanagedValueGeneric<TKey>( key ) );
-        apache::geode::client::CacheablePtr nativeptr(this->getRegionEntryValue(keyptr));
+        native::CacheableKeyPtr keyptr = Serializable::GetUnmanagedValueGeneric<TKey>( key );
+        auto nativeptr= this->getRegionEntryValue(keyptr);
         if (nativeptr == nullptr)
         {
           throw gcnew KeyNotFoundException("The given key was not present in the region");
@@ -52,12 +49,18 @@ namespace Apache
       apache::geode::client::SerializablePtr LocalRegion<TKey, TValue>::getRegionEntryValue(apache::geode::client::CacheableKeyPtr& keyptr)
       {
         _GF_MG_EXCEPTION_TRY2/* due to auto replace */
-          apache::geode::client::RegionEntryPtr entryPtr =  NativePtr->getEntry( keyptr );
-          if (entryPtr != nullptr) {
-            return entryPtr->getValue() ;
+          try
+          {
+            if (auto entryPtr = m_nativeptr->get()->getEntry(keyptr)) {
+              return entryPtr->getValue();
+            }
+            else {
+              return nullptr;
+            }
           }
-          else {
-            return nullptr;
+          finally
+          {
+            GC::KeepAlive(m_nativeptr);
           }
         _GF_MG_EXCEPTION_CATCH_ALL2/* due to auto replace */
       }
@@ -67,11 +70,17 @@ namespace Apache
       {
         _GF_MG_EXCEPTION_TRY2/* due to auto replace */
 
-        apache::geode::client::CacheableKeyPtr keyptr( Serializable::GetUnmanagedValueGeneric<TKey>( key ) );
-        apache::geode::client::CacheablePtr valueptr( Serializable::GetUnmanagedValueGeneric<TValue>( value ) );        
-        apache::geode::client::UserDataPtr callbackptr(
-          Serializable::GetUnmanagedValueGeneric<Object^>( callbackArg ) );
-        NativePtr->localPut( keyptr, valueptr, callbackptr );
+        try
+        {
+          native::CacheableKeyPtr keyptr = Serializable::GetUnmanagedValueGeneric<TKey>( key );
+          native::CacheablePtr valueptr = Serializable::GetUnmanagedValueGeneric<TValue>( value );        
+          native::UserDataPtr callbackptr = Serializable::GetUnmanagedValueGeneric<Object^>( callbackArg );
+          m_nativeptr->get()->localPut( keyptr, valueptr, callbackptr );
+        }
+        finally
+        {
+          GC::KeepAlive(m_nativeptr);
+        }
 
         _GF_MG_EXCEPTION_CATCH_ALL2/* due to auto replace */
       }
@@ -79,8 +88,8 @@ namespace Apache
       generic<class TKey, class TValue>
       TValue LocalRegion<TKey, TValue>::default::get(TKey key)
       { 
-        apache::geode::client::CacheableKeyPtr keyptr( Serializable::GetUnmanagedValueGeneric<TKey>( key ) );
-        apache::geode::client::CacheablePtr nativeptr(this->getRegionEntryValue(keyptr));
+        native::CacheableKeyPtr keyptr = Serializable::GetUnmanagedValueGeneric<TKey>( key );
+        auto nativeptr = this->getRegionEntryValue(keyptr);
         if (nativeptr == nullptr)
         {
           throw gcnew KeyNotFoundException("The given key was not present in the region");
@@ -94,9 +103,16 @@ namespace Apache
       {
         _GF_MG_EXCEPTION_TRY2/* due to auto replace */
 
-        apache::geode::client::CacheableKeyPtr keyptr( Serializable::GetUnmanagedValueGeneric<TKey>( key ) );
-        apache::geode::client::CacheablePtr valueptr( Serializable::GetUnmanagedValueGeneric<TValue>( value ) );
-        NativePtr->localPut( keyptr, valueptr );
+        try
+        {
+          native::CacheableKeyPtr keyptr = Serializable::GetUnmanagedValueGeneric<TKey>( key );
+          native::CacheablePtr valueptr = Serializable::GetUnmanagedValueGeneric<TValue>( value );
+          m_nativeptr->get()->localPut( keyptr, valueptr );
+        }
+        finally
+        {
+          GC::KeepAlive(m_nativeptr);
+        }
 
         _GF_MG_EXCEPTION_CATCH_ALL2/* due to auto replace */
       }
@@ -105,20 +121,25 @@ namespace Apache
       System::Collections::Generic::IEnumerator<KeyValuePair<TKey,TValue>>^ 
         LocalRegion<TKey, TValue>::GetEnumerator()
       {
-        array<KeyValuePair<TKey,TValue>>^ toArray;
         apache::geode::client::VectorOfRegionEntry vc;
 
         _GF_MG_EXCEPTION_TRY2/* due to auto replace */
 
-          NativePtr->entries( vc, false );
+          try
+          {
+            m_nativeptr->get()->entries( vc, false );
+          }
+          finally
+          {
+            GC::KeepAlive(m_nativeptr);
+          }
 
         _GF_MG_EXCEPTION_CATCH_ALL2/* due to auto replace */ 
 
-          toArray = gcnew array<KeyValuePair<TKey,TValue>>(vc.size());
-
+        auto toArray = gcnew array<KeyValuePair<TKey,TValue>>(vc.size());
         for( System::Int32 index = 0; index < vc.size( ); index++ )
         {
-          apache::geode::client::RegionEntryPtr nativeptr =  vc[ index ];  
+          auto nativeptr = vc[ index ];  
           TKey key = Serializable::GetManagedValueGeneric<TKey> (nativeptr->getKey());
           TValue val = Serializable::GetManagedValueGeneric<TValue> (nativeptr->getValue());
           toArray[ index ] = KeyValuePair<TKey,TValue>(key, val);           
@@ -130,20 +151,25 @@ namespace Apache
       System::Collections::IEnumerator^ 
         LocalRegion<TKey, TValue>::GetEnumeratorOld()
       {
-        array<Object^>^ toArray;
         apache::geode::client::VectorOfRegionEntry vc;
 
         _GF_MG_EXCEPTION_TRY2/* due to auto replace */
 
-          NativePtr->entries( vc, false );
+          try
+          {
+            m_nativeptr->get()->entries( vc, false );
+          }
+          finally
+          {
+            GC::KeepAlive(m_nativeptr);
+          }
 
         _GF_MG_EXCEPTION_CATCH_ALL2/* due to auto replace */
 
-          toArray = gcnew array<Object^>(vc.size());
-
+        auto toArray = gcnew array<Object^>(vc.size());
         for( System::Int32 index = 0; index < vc.size( ); index++ )
         {
-          apache::geode::client::RegionEntryPtr nativeptr =  vc[ index ];                       
+          auto nativeptr = vc[ index ];                       
           TKey key = Serializable::GetManagedValueGeneric<TKey> (nativeptr->getKey());
           TValue val = Serializable::GetManagedValueGeneric<TValue> (nativeptr->getValue());            
           toArray[ index ] = KeyValuePair<TKey,TValue>(key, val);           
@@ -189,8 +215,8 @@ namespace Apache
       generic<class TKey, class TValue> 
       bool LocalRegion<TKey, TValue>::Contains(KeyValuePair<TKey,TValue> keyValuePair) 
       { 
-        apache::geode::client::CacheableKeyPtr keyptr( Serializable::GetUnmanagedValueGeneric<TKey>( keyValuePair.Key ) ); 
-        apache::geode::client::CacheablePtr nativeptr(this->getRegionEntryValue(keyptr));
+        auto keyptr = Serializable::GetUnmanagedValueGeneric<TKey>( keyValuePair.Key ); 
+        auto nativeptr = this->getRegionEntryValue(keyptr);
         //This means that key is not present.
         if (nativeptr == nullptr) {
           return false;
@@ -204,9 +230,15 @@ namespace Apache
       {
         _GF_MG_EXCEPTION_TRY2/* due to auto replace */
 
-          apache::geode::client::CacheableKeyPtr keyptr( Serializable::GetUnmanagedValueGeneric<TKey>( key ) );          
-
-          return NativePtr->containsKey( keyptr );
+        try
+        {
+          auto keyptr = Serializable::GetUnmanagedValueGeneric<TKey>( key );          
+          return m_nativeptr->get()->containsKey(keyptr);
+        }
+        finally
+        {
+          GC::KeepAlive(m_nativeptr);
+        }
 
         _GF_MG_EXCEPTION_CATCH_ALL2/* due to auto replace */
       }
@@ -214,8 +246,8 @@ namespace Apache
       generic<class TKey, class TValue>
       bool LocalRegion<TKey, TValue>::TryGetValue(TKey key, TValue %val)
       {        
-        apache::geode::client::CacheableKeyPtr keyptr( Serializable::GetUnmanagedValueGeneric<TKey>( key ) );
-        apache::geode::client::CacheablePtr nativeptr(this->getRegionEntryValue(keyptr));
+        auto keyptr = Serializable::GetUnmanagedValueGeneric<TKey>( key );
+        auto nativeptr = this->getRegionEntryValue(keyptr);
         if (nativeptr == nullptr) {            
           val = TValue();
           return false;
@@ -232,17 +264,22 @@ namespace Apache
         _GF_MG_EXCEPTION_TRY2/* due to auto replace */
 
         apache::geode::client::VectorOfCacheableKey vc;
-        NativePtr->keys( vc );
-        //List<TKey>^ collectionlist = gcnew List<TKey>(vc.size());
-        array<TKey>^ keyarr =
-          gcnew array<TKey>( vc.size( ) );
+        try
+        {
+          m_nativeptr->get()->keys(vc);
+        }
+        finally
+        {
+          GC::KeepAlive(m_nativeptr);
+        }
+
+        auto keyarr =  gcnew array<TKey>( vc.size( ) );
         for( System::Int32 index = 0; index < vc.size( ); index++ )
         {            
-          apache::geode::client::CacheableKeyPtr& nativeptr( vc[ index ] );
+          auto& nativeptr = vc[ index ];
           keyarr[ index ] = Serializable::GetManagedValueGeneric<TKey>(nativeptr);
-          //collectionlist[ index ] = Serializable::GetManagedValue<TKey>(nativeptr);
         }
-        System::Collections::Generic::ICollection<TKey>^ collectionlist = (System::Collections::Generic::ICollection<TKey>^)keyarr;
+        auto collectionlist = (System::Collections::Generic::ICollection<TKey>^)keyarr;
         return collectionlist;
 
         _GF_MG_EXCEPTION_CATCH_ALL2/* due to auto replace */
@@ -254,17 +291,23 @@ namespace Apache
         _GF_MG_EXCEPTION_TRY2/* due to auto replace */
 
           apache::geode::client::VectorOfCacheable vc;
-          NativePtr->values( vc );
+          try
+          {
+            m_nativeptr->get()->values( vc );
+          }
+          finally
+          {
+            GC::KeepAlive(m_nativeptr);
+          }
+
           //List<TValue>^ collectionlist = gcnew List<TValue>(vc.size());
-          array<TValue>^ valarr =
-            gcnew array<TValue>( vc.size( ) );
+          auto valarr = gcnew array<TValue>( vc.size( ) );
           for( System::Int32 index = 0; index < vc.size( ); index++ )
           {
-            apache::geode::client::CacheablePtr& nativeptr( vc[ index ] );            
+            auto& nativeptr = vc[ index ];            
             valarr[ index ] = Serializable::GetManagedValueGeneric<TValue>(nativeptr);
-            //collectionlist[ index ] = Serializable::GetManagedValueGeneric<TValue>(nativeptr);
           }
-          System::Collections::Generic::ICollection<TValue>^ collectionlist = (System::Collections::Generic::ICollection<TValue>^)valarr;
+          auto collectionlist = (System::Collections::Generic::ICollection<TValue>^)valarr;
           return collectionlist;
 
         _GF_MG_EXCEPTION_CATCH_ALL2/* due to auto replace */
@@ -275,9 +318,16 @@ namespace Apache
       {
         _GF_MG_EXCEPTION_TRY2/* due to auto replace */
 
-          apache::geode::client::CacheableKeyPtr keyptr( Serializable::GetUnmanagedValueGeneric<TKey>( key ) );
-          apache::geode::client::CacheablePtr valueptr( Serializable::GetUnmanagedValueGeneric<TValue>( value ) );
-          NativePtr->localCreate( keyptr, valueptr );
+          try
+          {
+            native::CacheableKeyPtr keyptr = Serializable::GetUnmanagedValueGeneric<TKey>( key );
+            native::CacheablePtr valueptr = Serializable::GetUnmanagedValueGeneric<TValue>( value );
+            m_nativeptr->get()->localCreate( keyptr, valueptr );
+          }
+          finally
+          {
+            GC::KeepAlive(m_nativeptr);
+          }
 
         _GF_MG_EXCEPTION_CATCH_ALL2/* due to auto replace */
       }
@@ -287,9 +337,16 @@ namespace Apache
       {
         _GF_MG_EXCEPTION_TRY2/* due to auto replace */
 
-          apache::geode::client::CacheableKeyPtr keyptr( Serializable::GetUnmanagedValueGeneric<TKey>( keyValuePair.Key ) );
-          apache::geode::client::CacheablePtr valueptr( Serializable::GetUnmanagedValueGeneric<TValue>( keyValuePair.Value ) );
-          NativePtr->localCreate( keyptr, valueptr );
+          try
+          {
+            native::CacheableKeyPtr keyptr = Serializable::GetUnmanagedValueGeneric<TKey>( keyValuePair.Key );
+            native::CacheablePtr valueptr = Serializable::GetUnmanagedValueGeneric<TValue>( keyValuePair.Value );
+            m_nativeptr->get()->localCreate( keyptr, valueptr );
+          }
+          finally
+          {
+            GC::KeepAlive(m_nativeptr);
+          }
 
        _GF_MG_EXCEPTION_CATCH_ALL2/* due to auto replace */
       }
@@ -299,11 +356,17 @@ namespace Apache
       {
           _GF_MG_EXCEPTION_TRY2/* due to auto replace */
 
-          apache::geode::client::CacheableKeyPtr keyptr( Serializable::GetUnmanagedValueGeneric<TKey>( key ) );
-          apache::geode::client::CacheablePtr valueptr( Serializable::GetUnmanagedValueGeneric<TValue>( value ) );          
-          apache::geode::client::UserDataPtr callbackptr(
-            Serializable::GetUnmanagedValueGeneric<Object^>( callbackArg ) );
-          NativePtr->localCreate( keyptr, valueptr, callbackptr );
+          try
+          {
+            native::CacheableKeyPtr keyptr = Serializable::GetUnmanagedValueGeneric<TKey>( key );
+            native::CacheablePtr valueptr = Serializable::GetUnmanagedValueGeneric<TValue>( value );          
+            native::UserDataPtr callbackptr = Serializable::GetUnmanagedValueGeneric<Object^>( callbackArg );
+            m_nativeptr->get()->localCreate( keyptr, valueptr, callbackptr );
+          }
+          finally
+          {
+            GC::KeepAlive(m_nativeptr);
+          }
 
          _GF_MG_EXCEPTION_CATCH_ALL2/* due to auto replace */
       }
@@ -315,14 +378,18 @@ namespace Apache
     
           try
           {
-            apache::geode::client::CacheableKeyPtr keyptr( Serializable::GetUnmanagedValueGeneric<TKey>( key ) );          
-            NativePtr->localDestroy( keyptr );
+            native::CacheableKeyPtr keyptr = Serializable::GetUnmanagedValueGeneric<TKey>(key);
+            m_nativeptr->get()->localDestroy(keyptr);
             return true;
           }
-          catch(apache::geode::client::EntryNotFoundException /*ex*/)
+          catch (apache::geode::client::EntryNotFoundException /*ex*/)
           {
             return false;
           }
+          finally
+          {
+            GC::KeepAlive(m_nativeptr);
+          }
 
         _GF_MG_EXCEPTION_CATCH_ALL2/* due to auto replace */
         
@@ -332,20 +399,22 @@ namespace Apache
       bool LocalRegion<TKey, TValue>::Remove( TKey key, Object^ callbackArg )
       {
          _GF_MG_EXCEPTION_TRY2/* due to auto replace */
-          try
-          {
-            apache::geode::client::CacheableKeyPtr keyptr( Serializable::GetUnmanagedValueGeneric<TKey>( key ) );                    
-            apache::geode::client::UserDataPtr callbackptr(
-            Serializable::GetUnmanagedValueGeneric<Object^>( callbackArg ) );
-            NativePtr->localDestroy( keyptr, callbackptr );
-            return true;
-          }
-          catch(apache::geode::client::EntryNotFoundException /*ex*/)
-          {
-            return false;
-          }
-
-          _GF_MG_EXCEPTION_CATCH_ALL2/* due to auto replace */
+           try
+           {
+             native::CacheableKeyPtr keyptr = Serializable::GetUnmanagedValueGeneric<TKey>(key);
+             native::UserDataPtr callbackptr = Serializable::GetUnmanagedValueGeneric<Object^>(callbackArg);
+             m_nativeptr->get()->localDestroy(keyptr, callbackptr);
+             return true;
+           }
+           catch (apache::geode::client::EntryNotFoundException /*ex*/)
+           {
+             return false;
+           }
+           finally
+           {
+             GC::KeepAlive(m_nativeptr);
+           }
+        _GF_MG_EXCEPTION_CATCH_ALL2/* due to auto replace */
       }
 
       generic<class TKey, class TValue>
@@ -353,32 +422,18 @@ namespace Apache
       {
         _GF_MG_EXCEPTION_TRY2/* due to auto replace */
 
-          apache::geode::client::CacheableKeyPtr keyptr( Serializable::GetUnmanagedValueGeneric<TKey>( keyValuePair.Key ) );
-          apache::geode::client::CacheablePtr valueptr( Serializable::GetUnmanagedValueGeneric<TValue>( keyValuePair.Value ) );
-          return NativePtr->localRemove(keyptr, valueptr);
+          try
+          {
+            native::CacheableKeyPtr keyptr = Serializable::GetUnmanagedValueGeneric<TKey>( keyValuePair.Key );
+            native::CacheablePtr valueptr = Serializable::GetUnmanagedValueGeneric<TValue>( keyValuePair.Value );
+            return m_nativeptr->get()->localRemove(keyptr, valueptr);
+          }
+          finally
+          {
+            GC::KeepAlive(m_nativeptr);
+          }
 
          _GF_MG_EXCEPTION_CATCH_ALL2/* due to auto replace */
-
-        //_GF_MG_EXCEPTION_TRY2/* due to auto replace */
-
-        //apache::geode::client::CacheableKeyPtr keyptr( Serializable::GetUnmanagedValueGeneric<TKey>( keyValuePair.Key ) );
-        //if (NativePtr->containsKey( keyptr )) {
-        //  apache::geode::client::CacheablePtr nativeptr(this->getRegionEntryValue(keyptr));
-        //  TValue returnVal = Serializable::GetManagedValueGeneric<TValue>( nativeptr );
-        //  apache::geode::client::CacheablePtr valueptr( Serializable::GetUnmanagedValueGeneric<TValue>( keyValuePair.Value ) );
-        //  TValue actualVal = Serializable::GetManagedValueGeneric<TValue>( valueptr );
-        //  if (actualVal->Equals(returnVal)) {
-        //    NativePtr->localDestroy( keyptr );
-        //    return true;
-        //  }
-        //  else {
-        //    return false;
-        //  }
-        //}
-        //else {
-        //  return false;
-        //} 
-        //_GF_MG_EXCEPTION_CATCH_ALL2/* due to auto replace */
       }
 
       generic<class TKey, class TValue>
@@ -386,10 +441,17 @@ namespace Apache
       {
         _GF_MG_EXCEPTION_TRY2/* due to auto replace */
 
-          apache::geode::client::CacheableKeyPtr keyptr( Serializable::GetUnmanagedValueGeneric<TKey>( key ) );                   
-          apache::geode::client::CacheablePtr valueptr ( Serializable::GetUnmanagedValueGeneric<TValue>( value ));                 
-          apache::geode::client::UserDataPtr callbackptr( Serializable::GetUnmanagedValueGeneric<Object^>( callbackArg ) );          
-          return NativePtr->localRemove(keyptr, valueptr, callbackptr);
+          try
+          {
+            native::CacheableKeyPtr keyptr = Serializable::GetUnmanagedValueGeneric<TKey>(key);
+            native::CacheablePtr valueptr = Serializable::GetUnmanagedValueGeneric<TValue>(value);
+            native::UserDataPtr callbackptr = Serializable::GetUnmanagedValueGeneric<Object^>(callbackArg);
+            return m_nativeptr->get()->localRemove(keyptr, valueptr, callbackptr);
+          }
+          finally
+          {
+            GC::KeepAlive(m_nativeptr);
+          }
 
          _GF_MG_EXCEPTION_CATCH_ALL2/* due to auto replace */
       }
@@ -409,9 +471,15 @@ namespace Apache
       {
         _GF_MG_EXCEPTION_TRY2/* due to auto replace */
                     
-          apache::geode::client::UserDataPtr callbackptr(
-            Serializable::GetUnmanagedValueGeneric<Object^>( callbackArg ) );
-          NativePtr->localInvalidateRegion( callbackptr );
+          try
+          {
+            native::UserDataPtr callbackptr = Serializable::GetUnmanagedValueGeneric<Object^>( callbackArg );
+            m_nativeptr->get()->localInvalidateRegion( callbackptr );
+          }
+          finally
+          {
+            GC::KeepAlive(m_nativeptr);
+          }
       
         _GF_MG_EXCEPTION_CATCH_ALL2/* due to auto replace */
       }
@@ -430,9 +498,15 @@ namespace Apache
       void LocalRegion<TKey, TValue>::DestroyRegion(Object^ callbackArg)
       {
         _GF_MG_EXCEPTION_TRY2/* due to auto replace */          
-          apache::geode::client::UserDataPtr callbackptr(
-            Serializable::GetUnmanagedValueGeneric<Object^>( callbackArg ) );
-          NativePtr->localDestroyRegion( callbackptr );
+          try
+          {
+            native::UserDataPtr callbackptr = Serializable::GetUnmanagedValueGeneric<Object^>( callbackArg );
+            m_nativeptr->get()->localDestroyRegion( callbackptr );
+          }
+          finally
+          {
+            GC::KeepAlive(m_nativeptr);
+          }
         _GF_MG_EXCEPTION_CATCH_ALL2/* due to auto replace */
       }
 
@@ -452,10 +526,16 @@ namespace Apache
       {
         _GF_MG_EXCEPTION_TRY2/* due to auto replace */
 
-          apache::geode::client::CacheableKeyPtr keyptr( Serializable::GetUnmanagedValueGeneric<TKey>( key ) );          
-          apache::geode::client::UserDataPtr callbackptr(
-            Serializable::GetUnmanagedValueGeneric<Object^>( callbackArg ) );            
-          NativePtr->localInvalidate( keyptr, callbackptr );
+          try
+          {
+            native::CacheableKeyPtr keyptr = Serializable::GetUnmanagedValueGeneric<TKey>( key );          
+            native::UserDataPtr callbackptr = Serializable::GetUnmanagedValueGeneric<Object^>( callbackArg );            
+            m_nativeptr->get()->localInvalidate( keyptr, callbackptr );
+          }
+          finally
+          {
+            GC::KeepAlive(m_nativeptr);
+          }
 
         _GF_MG_EXCEPTION_CATCH_ALL2/* due to auto replace */
       }
@@ -520,13 +600,27 @@ namespace Apache
       generic<class TKey, class TValue>
       String^ LocalRegion<TKey, TValue>::Name::get()
       { 
-        return ManagedString::Get( NativePtr->getName( ) ); 
+        try
+        {
+          return ManagedString::Get( m_nativeptr->get()->getName( ) );
+        }
+        finally
+        {
+          GC::KeepAlive(m_nativeptr);
+        } 
       } 
 
       generic<class TKey, class TValue>
       String^ LocalRegion<TKey, TValue>::FullPath::get()
       { 
-        return ManagedString::Get( NativePtr->getFullPath( ) ); 
+        try
+        {
+          return ManagedString::Get( m_nativeptr->get()->getFullPath( ) );
+        }
+        finally
+        {
+          GC::KeepAlive(m_nativeptr);
+        } 
       } 
 
       generic<class TKey, class TValue>
@@ -534,14 +628,19 @@ namespace Apache
       {
         _GF_MG_EXCEPTION_TRY2/* due to auto replace */
 
-          apache::geode::client::RegionPtr& nativeptr( NativePtr->getParentRegion( ) );
-
-         IRegion<TKey, TValue>^ region = Region<TKey, TValue>::Create( nativeptr.ptr( ) );
-         if (region == nullptr) {
-           return nullptr;
-         }
-         return region->GetLocalView();
-
+          try
+          {
+            auto parentRegion = m_nativeptr->get()->getParentRegion( );
+            auto region = Region<TKey, TValue>::Create( parentRegion );
+            if (region == nullptr) {
+              return nullptr;
+            }
+            return region->GetLocalView();
+          }
+          finally
+          {
+            GC::KeepAlive(m_nativeptr);
+          }
         _GF_MG_EXCEPTION_CATCH_ALL2/* due to auto replace */
       }
 
@@ -550,9 +649,14 @@ namespace Apache
       { 
         _GF_MG_EXCEPTION_TRY2/* due to auto replace */
 
-        apache::geode::client::RegionAttributesPtr& nativeptr( NativePtr->getAttributes( ) );
-
-        return Apache::Geode::Client::RegionAttributes<TKey, TValue>::Create(nativeptr.get());
+        try
+        {
+          return Apache::Geode::Client::RegionAttributes<TKey, TValue>::Create(m_nativeptr->get()->getAttributes());
+        }
+        finally
+        {
+          GC::KeepAlive(m_nativeptr);
+        }
 
         _GF_MG_EXCEPTION_CATCH_ALL2/* due to auto replace */
       } 
@@ -562,10 +666,14 @@ namespace Apache
       {
         _GF_MG_EXCEPTION_TRY2/* due to auto replace */
 
-          apache::geode::client::AttributesMutatorPtr& nativeptr(
-            NativePtr->getAttributesMutator( ) );
-
-        return Apache::Geode::Client::AttributesMutator<TKey, TValue>::Create( nativeptr.ptr( ) );
+          try
+          {
+            return Apache::Geode::Client::AttributesMutator<TKey, TValue>::Create(m_nativeptr->get()->getAttributesMutator());
+          }
+          finally
+          {
+            GC::KeepAlive(m_nativeptr);
+          }
 
         _GF_MG_EXCEPTION_CATCH_ALL2/* due to auto replace */
       }
@@ -575,8 +683,14 @@ namespace Apache
       {
         _GF_MG_EXCEPTION_TRY2/* due to auto replace */
 
-        apache::geode::client::CacheStatisticsPtr& nativeptr( NativePtr->getStatistics( ) );
-        return Apache::Geode::Client::CacheStatistics::Create( nativeptr.ptr( ) );
+          try
+          {
+            return Apache::Geode::Client::CacheStatistics::Create(m_nativeptr->get()->getStatistics());
+          }
+          finally
+          {
+            GC::KeepAlive(m_nativeptr);
+          }
 
         _GF_MG_EXCEPTION_CATCH_ALL2/* due to auto replace */
       }
@@ -586,14 +700,20 @@ namespace Apache
       {
         _GF_MG_EXCEPTION_TRY2/* due to auto replace */
 
-          ManagedString mg_path( path );
-          apache::geode::client::RegionPtr& nativeptr(
-            NativePtr->getSubregion( mg_path.CharPtr ) );
-          IRegion<TKey, TValue>^ region = Region<TKey, TValue>::Create( nativeptr.ptr( ) );
-          if (region == nullptr) {
-            return nullptr;
+          try
+          {
+            ManagedString mg_path(path);
+            auto nativeptr = m_nativeptr->get()->getSubregion(mg_path.CharPtr);
+            auto region = Region<TKey, TValue>::Create(nativeptr);
+            if (region == nullptr) {
+              return nullptr;
+            }
+            return region->GetLocalView();
+          }
+          finally
+          {
+            GC::KeepAlive(m_nativeptr);
           }
-          return region->GetLocalView();          
 
         _GF_MG_EXCEPTION_CATCH_ALL2/* due to auto replace */
       }
@@ -604,14 +724,16 @@ namespace Apache
       {
         _GF_MG_EXCEPTION_TRY2/* due to auto replace */
 
-          ManagedString mg_subregionName( subRegionName );
-				//TODO::split
-        /*  apache::geode::client::RegionAttributesPtr p_attrs(
-            GetNativePtrFromSBWrap<apache::geode::client::RegionAttributes>( attributes ) );*/
-
-          apache::geode::client::RegionPtr& nativeptr( NativePtr->createSubregion(
-            mg_subregionName.CharPtr, /*p_attrs*/nullptr ) );
-          return Region<TKey, TValue>::Create( nativeptr.ptr( ) )->GetLocalView();
+          try
+          {
+            ManagedString mg_subregionName(subRegionName);
+            return Region<TKey, TValue>::Create(m_nativeptr->get()->createSubregion(
+              mg_subregionName.CharPtr, __nullptr))->GetLocalView();
+          }
+          finally
+          {
+            GC::KeepAlive(m_nativeptr);
+          }
 
         _GF_MG_EXCEPTION_CATCH_ALL2/* due to auto replace */
 
@@ -623,17 +745,23 @@ namespace Apache
         _GF_MG_EXCEPTION_TRY2/* due to auto replace */
 
           apache::geode::client::VectorOfRegion vsr;
-          NativePtr->subregions( recursive, vsr );
+          try
+          {
+            m_nativeptr->get()->subregions( recursive, vsr );
+          }
+          finally
+          {
+            GC::KeepAlive(m_nativeptr);
+          }
           array<IRegion<TKey, TValue>^>^ subRegions =
             gcnew array<IRegion<TKey, TValue>^>( vsr.size( ) );
 
           for( System::Int32 index = 0; index < vsr.size( ); index++ )
           {
-            apache::geode::client::RegionPtr& nativeptr( vsr[ index ] );
-            subRegions[ index ] = Region<TKey, TValue>::Create( nativeptr.ptr( ) )->GetLocalView();
+            auto nativeptr = vsr[ index ];
+            subRegions[ index ] = Region<TKey, TValue>::Create( nativeptr )->GetLocalView();
           }
-          System::Collections::Generic::ICollection<IRegion<TKey, TValue>^>^ collection =
-            (System::Collections::Generic::ICollection<IRegion<TKey, TValue>^>^)subRegions;
+          auto collection = (System::Collections::Generic::ICollection<IRegion<TKey, TValue>^>^)subRegions;
           return collection;
 
         _GF_MG_EXCEPTION_CATCH_ALL2/* due to auto replace */
@@ -644,10 +772,17 @@ namespace Apache
       {
         _GF_MG_EXCEPTION_TRY2/* due to auto replace */
 
-          apache::geode::client::CacheableKeyPtr keyptr( Serializable::GetUnmanagedValueGeneric<TKey>( key ) );
-          apache::geode::client::RegionEntryPtr& nativeptr( NativePtr->getEntry( keyptr ) );
-          return RegionEntry<TKey, TValue>::Create( nativeptr.ptr( ) );
-
+          try
+          {
+            native::CacheableKeyPtr keyptr = Serializable::GetUnmanagedValueGeneric<TKey>(key);
+            auto nativeptr = m_nativeptr->get()->getEntry(keyptr);
+            return RegionEntry<TKey, TValue>::Create(nativeptr);
+          }
+          finally
+          {
+            GC::KeepAlive(m_nativeptr);
+          }
+ 
         _GF_MG_EXCEPTION_CATCH_ALL2/* due to auto replace */
       }
 
@@ -657,18 +792,23 @@ namespace Apache
          _GF_MG_EXCEPTION_TRY2/* due to auto replace */
 
           apache::geode::client::VectorOfRegionEntry vc;
-          NativePtr->entries( vc, recursive );          
-          array<RegionEntry<TKey, TValue>^>^ entryarr = gcnew array<RegionEntry<TKey, TValue>^>( vc.size( ) );
+          try
+          {
+            m_nativeptr->get()->entries( vc, recursive );
+          }
+          finally
+          {
+            GC::KeepAlive(m_nativeptr);
+          }          
+          auto entryarr = gcnew array<RegionEntry<TKey, TValue>^>( vc.size( ) );
 
           for( System::Int32 index = 0; index < vc.size( ); index++ )
           {
-            apache::geode::client::RegionEntryPtr& nativeptr( vc[ index ] );
-            entryarr[ index ] = RegionEntry<TKey, TValue>::Create( nativeptr.ptr( ) );
+            auto nativeptr = vc[ index ] ;
+            entryarr[ index ] = RegionEntry<TKey, TValue>::Create( nativeptr );
           }
-          System::Collections::Generic::ICollection<RegionEntry<TKey, TValue>^>^ collection =
-            (System::Collections::Generic::ICollection<RegionEntry<TKey, TValue>^>^)entryarr;
-
-          return collection;          
+          auto collection = (System::Collections::Generic::ICollection<RegionEntry<TKey, TValue>^>^)entryarr;
+          return collection;
 
          _GF_MG_EXCEPTION_CATCH_ALL2/* due to auto replace */
         
@@ -679,17 +819,21 @@ namespace Apache
       {        
         _GF_MG_EXCEPTION_TRY2/* due to auto replace */
 
-          apache::geode::client::RegionServicePtr& nativeptr( NativePtr->getRegionService( ) );
-
-          apache::geode::client::Cache* realCache = dynamic_cast<apache::geode::client::Cache*>(nativeptr.get());
-
-          if(realCache != NULL)
+          try
           {
-						return Apache::Geode::Client::Cache::Create( ((apache::geode::client::CachePtr)nativeptr).ptr( ) );
+            auto regionService = m_nativeptr->get()->getRegionService();
+            if (auto realCache = std::dynamic_pointer_cast<apache::geode::client::Cache>(regionService))
+            {
+              return Apache::Geode::Client::Cache::Create(realCache);
+            }
+            else
+            {
+              return Apache::Geode::Client::AuthenticatedCache::Create(regionService);
+            }
           }
-          else
+          finally
           {
-            return Apache::Geode::Client::AuthenticatedCache::Create( nativeptr.ptr( ) );
+            GC::KeepAlive(m_nativeptr);
           }
           
         _GF_MG_EXCEPTION_CATCH_ALL2/* due to auto replace */
@@ -700,8 +844,14 @@ namespace Apache
       {
          _GF_MG_EXCEPTION_TRY2/* due to auto replace */
 
-           apache::geode::client::CacheableKeyPtr keyptr( Serializable::GetUnmanagedValueGeneric<TKey>( key ) );
-           return NativePtr->containsValueForKey( keyptr );
+           try
+           {
+             return m_nativeptr->get()->containsValueForKey(Serializable::GetUnmanagedValueGeneric<TKey>(key));
+           }
+           finally
+           {
+             GC::KeepAlive(m_nativeptr);
+           }
 
          _GF_MG_EXCEPTION_CATCH_ALL2/* due to auto replace */
       }
@@ -709,7 +859,14 @@ namespace Apache
       generic<class TKey, class TValue>
       int LocalRegion<TKey, TValue>::Count::get()
       {
-        return NativePtr->size();
+        try
+        {
+          return m_nativeptr->get()->size();
+        }
+        finally
+        {
+          GC::KeepAlive(m_nativeptr);
+        }
       }
 
       generic<class TKey, class TValue>
@@ -721,10 +878,15 @@ namespace Apache
       generic<class TKey, class TValue>
       void LocalRegion<TKey, TValue>::Clear(Object^ callbackArg)
       {
-        _GF_MG_EXCEPTION_TRY2/* due to auto replace */
-          apache::geode::client::UserDataPtr callbackptr(
-              Serializable::GetUnmanagedValueGeneric<Object^>( callbackArg ) );          
-          NativePtr->localClear(callbackptr );
+        _GF_MG_EXCEPTION_TRY2/* due to auto replace */        
+          try
+          {
+            m_nativeptr->get()->localClear(Serializable::GetUnmanagedValueGeneric<Object^>( callbackArg ) );
+          }
+          finally
+          {
+            GC::KeepAlive(m_nativeptr);
+          }
         _GF_MG_EXCEPTION_CATCH_ALL2/* due to auto replace */
       }
 
@@ -745,7 +907,14 @@ namespace Apache
         _GF_MG_EXCEPTION_TRY2/* due to auto replace */
 
         apache::geode::client::VectorOfRegionEntry vc;
-        NativePtr->entries( vc, false );        
+        try
+        {
+          m_nativeptr->get()->entries( vc, false );
+        }
+        finally
+        {
+          GC::KeepAlive(m_nativeptr);
+        }        
 
         if (toArray->Rank > 1 || (vc.size() > (toArray->Length - startIdx)))
         {
@@ -767,7 +936,14 @@ namespace Apache
       generic<class TKey, class TValue>
       bool LocalRegion<TKey, TValue>::IsDestroyed::get()
       {
-        return NativePtr->isDestroyed();
+        try
+        {
+          return m_nativeptr->get()->isDestroyed();
+        }
+        finally
+        {
+          GC::KeepAlive(m_nativeptr);
+        }
       }
       
       generic<class TKey, class TValue>
@@ -817,8 +993,8 @@ namespace Apache
       generic<class TKey, class TValue>
       IRegion<TKey, TValue>^ LocalRegion<TKey, TValue>::GetLocalView()
       {
-        throw gcnew System::NotSupportedException;   
+        throw gcnew System::NotSupportedException;
+      }
     }  // namespace Client
   }  // namespace Geode
 }  // namespace Apache
- } //namespace 

http://git-wip-us.apache.org/repos/asf/geode-native/blob/6027574a/src/clicache/src/LocalRegion.hpp
----------------------------------------------------------------------
diff --git a/src/clicache/src/LocalRegion.hpp b/src/clicache/src/LocalRegion.hpp
index 2954a99..aa9679d 100644
--- a/src/clicache/src/LocalRegion.hpp
+++ b/src/clicache/src/LocalRegion.hpp
@@ -18,8 +18,11 @@
 #pragma once
 
 #include "geode_defs.hpp"
+#include "begin_native.hpp"
 #include <geode/Cache.hpp>
-//#include "impl/NativeWrapper.hpp"
+#include "end_native.hpp"
+
+#include "native_shared_ptr.hpp"
 #include "IRegion.hpp"
 #include "Log.hpp"
 #include "ExceptionTypes.hpp"
@@ -35,6 +38,8 @@ namespace Apache
     namespace Client
     {
 
+      namespace native = apache::geode::client;
+
       generic<class TKey, class TValue>
       ref class RegionEntry;
 
@@ -42,7 +47,7 @@ namespace Apache
       ref class AttributesMutator;
 
       generic<class TKey, class TValue>
-			public ref class LocalRegion : public Client::Internal::SBWrap<apache::geode::client::Region>, public IRegion<TKey, TValue>  
+			public ref class LocalRegion : public IRegion<TKey, TValue>  
       {
       public:
 
@@ -226,22 +231,31 @@ namespace Apache
         /// The managed wrapper object; null if the native pointer is null.
         /// </returns>
         //generic<class TKey, class TValue>
-        inline static IRegion<TKey, TValue>^ Create( apache::geode::client::Region* nativeptr )
+        inline static IRegion<TKey, TValue>^ Create( native::RegionPtr nativeptr )
         {
-          return ( nativeptr != nullptr ?
-            gcnew LocalRegion<TKey, TValue>( nativeptr ) : nullptr );
+          return __nullptr == nativeptr ? nullptr :
+            gcnew LocalRegion<TKey, TValue>( nativeptr );
+        }
+
+        std::shared_ptr<native::Region> GetNative()
+        {
+          return m_nativeptr->get_shared_ptr();
         }
 
         /// <summary>
         /// Private constructor to wrap a native object pointer
         /// </summary>
         /// <param name="nativeptr">The native object pointer</param>
-        inline LocalRegion( apache::geode::client::Region* nativeptr )
-          : SBWrap( nativeptr ) { }
+        inline LocalRegion( native::RegionPtr nativeptr )
+				{
+          m_nativeptr = gcnew native_shared_ptr<native::Region>(nativeptr);
+        }
 
         private:        
         inline apache::geode::client::SerializablePtr getRegionEntryValue(apache::geode::client::CacheableKeyPtr& key);
         bool AreValuesEqual(apache::geode::client::CacheablePtr& val1, apache::geode::client::CacheablePtr& val2);
+
+        native_shared_ptr<native::Region>^ m_nativeptr;   
       };
     }  // namespace Client
   }  // namespace Geode

http://git-wip-us.apache.org/repos/asf/geode-native/blob/6027574a/src/clicache/src/Log.hpp
----------------------------------------------------------------------
diff --git a/src/clicache/src/Log.hpp b/src/clicache/src/Log.hpp
index 9c13d0c..ed5dd28 100644
--- a/src/clicache/src/Log.hpp
+++ b/src/clicache/src/Log.hpp
@@ -18,7 +18,10 @@
 #pragma once
 
 #include "geode_defs.hpp"
+#include "begin_native.hpp"
 #include <geode/Log.hpp>
+#include "end_native.hpp"
+
 
 
 using namespace System;

http://git-wip-us.apache.org/repos/asf/geode-native/blob/6027574a/src/clicache/src/Pool.cpp
----------------------------------------------------------------------
diff --git a/src/clicache/src/Pool.cpp b/src/clicache/src/Pool.cpp
index 3a3e68f..32921fb 100644
--- a/src/clicache/src/Pool.cpp
+++ b/src/clicache/src/Pool.cpp
@@ -35,195 +35,409 @@ namespace Apache
     namespace Client
     {
 
-      //generic<class TKey, class TValue>
-      String^ Pool/*<TKey, TValue>*/::Name::get( )
+
+      String^ Pool::Name::get( )
       {
-        return ManagedString::Get( NativePtr->getName( ) );
+        try
+        {
+          return ManagedString::Get( m_nativeptr->get()->getName( ) );
+        }
+        finally
+        {
+          GC::KeepAlive(m_nativeptr);
+        }
+
       }
 
-      //generic<class TKey, class TValue>
-      Int32 Pool/*<TKey, TValue>*/::FreeConnectionTimeout::get()
+
+      Int32 Pool::FreeConnectionTimeout::get()
       {
-        return NativePtr->getFreeConnectionTimeout();
+        try
+        {
+          return m_nativeptr->get()->getFreeConnectionTimeout();
+        }
+        finally
+        {
+          GC::KeepAlive(m_nativeptr);
+        }
+
       }
 
-      //generic<class TKey, class TValue>
-      Int32 Pool/*<TKey, TValue>*/::LoadConditioningInterval::get()
+
+      Int32 Pool::LoadConditioningInterval::get()
       {
-        return NativePtr->getLoadConditioningInterval();
+        try
+        {
+          return m_nativeptr->get()->getLoadConditioningInterval();
+        }
+        finally
+        {
+          GC::KeepAlive(m_nativeptr);
+        }
+
       }
 
-      //generic<class TKey, class TValue>
-      Int32 Pool/*<TKey, TValue>*/::SocketBufferSize::get()
+
+      Int32 Pool::SocketBufferSize::get()
       {
-        return NativePtr->getSocketBufferSize();
+        try
+        {
+          return m_nativeptr->get()->getSocketBufferSize();
+        }
+        finally
+        {
+          GC::KeepAlive(m_nativeptr);
+        }
+
       }
 
-      //generic<class TKey, class TValue>
-      Int32 Pool/*<TKey, TValue>*/::ReadTimeout::get()
+
+      Int32 Pool::ReadTimeout::get()
       {
-        return NativePtr->getReadTimeout();
+        try
+        {
+          return m_nativeptr->get()->getReadTimeout();
+        }
+        finally
+        {
+          GC::KeepAlive(m_nativeptr);
+        }
+
       }
 
-      //generic<class TKey, class TValue>
-      Int32 Pool/*<TKey, TValue>*/::MinConnections::get()
+
+      Int32 Pool::MinConnections::get()
       {
-        return NativePtr->getMinConnections();
+        try
+        {
+          return m_nativeptr->get()->getMinConnections();
+        }
+        finally
+        {
+          GC::KeepAlive(m_nativeptr);
+        }
+
       }
 
-      //generic<class TKey, class TValue>
-      Int32 Pool/*<TKey, TValue>*/::MaxConnections::get()
+
+      Int32 Pool::MaxConnections::get()
       {
-        return NativePtr->getMaxConnections();
+        try
+        {
+          return m_nativeptr->get()->getMaxConnections();
+        }
+        finally
+        {
+          GC::KeepAlive(m_nativeptr);
+        }
+
       }
 
-      //generic<class TKey, class TValue>
-      Int32 Pool/*<TKey, TValue>*/::IdleTimeout::get()
+
+      Int32 Pool::IdleTimeout::get()
       {
-        return NativePtr->getIdleTimeout();
+        try
+        {
+          return m_nativeptr->get()->getIdleTimeout();
+        }
+        finally
+        {
+          GC::KeepAlive(m_nativeptr);
+        }
+
       }
 
-      //generic<class TKey, class TValue>
-      Int32 Pool/*<TKey, TValue>*/::PingInterval::get()
+
+      Int32 Pool::PingInterval::get()
       {
-        return NativePtr->getPingInterval();
+        try
+        {
+          return m_nativeptr->get()->getPingInterval();
+        }
+        finally
+        {
+          GC::KeepAlive(m_nativeptr);
+        }
+
       }
 
-      //generic<class TKey, class TValue>
-      Int32 Pool/*<TKey, TValue>*/::UpdateLocatorListInterval::get()
+
+      Int32 Pool::UpdateLocatorListInterval::get()
       {
-        return NativePtr->getUpdateLocatorListInterval();
+        try
+        {
+          return m_nativeptr->get()->getUpdateLocatorListInterval();
+        }
+        finally
+        {
+          GC::KeepAlive(m_nativeptr);
+        }
+
       }
 
-      //generic<class TKey, class TValue>
-      Int32 Pool/*<TKey, TValue>*/::StatisticInterval::get()
+
+      Int32 Pool::StatisticInterval::get()
       {
-        return NativePtr->getStatisticInterval();
+        try
+        {
+          return m_nativeptr->get()->getStatisticInterval();
+        }
+        finally
+        {
+          GC::KeepAlive(m_nativeptr);
+        }
+
       }
 
-      //generic<class TKey, class TValue>
-      Int32 Pool/*<TKey, TValue>*/::RetryAttempts::get()
+
+      Int32 Pool::RetryAttempts::get()
       {
-        return NativePtr->getRetryAttempts();
+        try
+        {
+          return m_nativeptr->get()->getRetryAttempts();
+        }
+        finally
+        {
+          GC::KeepAlive(m_nativeptr);
+        }
+
       }
 
-      //generic<class TKey, class TValue>
-      Boolean Pool/*<TKey, TValue>*/::SubscriptionEnabled::get()
+
+      Boolean Pool::SubscriptionEnabled::get()
       {
-        return NativePtr->getSubscriptionEnabled();
+        try
+        {
+          return m_nativeptr->get()->getSubscriptionEnabled();
+        }
+        finally
+        {
+          GC::KeepAlive(m_nativeptr);
+        }
+
       }
 
-      //generic<class TKey, class TValue>
-      Boolean Pool/*<TKey, TValue>*/::PRSingleHopEnabled::get()
+
+      Boolean Pool::PRSingleHopEnabled::get()
       {
-        return NativePtr->getPRSingleHopEnabled();
+        try
+        {
+          return m_nativeptr->get()->getPRSingleHopEnabled();
+        }
+        finally
+        {
+          GC::KeepAlive(m_nativeptr);
+        }
+
       }
 
-      //generic<class TKey, class TValue>
-      Int32 Pool/*<TKey, TValue>*/::SubscriptionRedundancy::get()
+
+      Int32 Pool::SubscriptionRedundancy::get()
       {
-        return NativePtr->getSubscriptionRedundancy();
+        try
+        {
+          return m_nativeptr->get()->getSubscriptionRedundancy();
+        }
+        finally
+        {
+          GC::KeepAlive(m_nativeptr);
+        }
+
       }
 
-      //generic<class TKey, class TValue>
-      Int32 Pool/*<TKey, TValue>*/::SubscriptionMessageTrackingTimeout::get()
+
+      Int32 Pool::SubscriptionMessageTrackingTimeout::get()
       {
-        return NativePtr->getSubscriptionMessageTrackingTimeout();
+        try
+        {
+          return m_nativeptr->get()->getSubscriptionMessageTrackingTimeout();
+        }
+        finally
+        {
+          GC::KeepAlive(m_nativeptr);
+        }
+
       }
 
-      //generic<class TKey, class TValue>
-      Int32 Pool/*<TKey, TValue>*/::SubscriptionAckInterval::get()
+
+      Int32 Pool::SubscriptionAckInterval::get()
       {
-        return NativePtr->getSubscriptionAckInterval();
+        try
+        {
+          return m_nativeptr->get()->getSubscriptionAckInterval();
+        }
+        finally
+        {
+          GC::KeepAlive(m_nativeptr);
+        }
+
       }
 
-      //generic<class TKey, class TValue>
-      String^ Pool/*<TKey, TValue>*/::ServerGroup::get( )
+
+      String^ Pool::ServerGroup::get( )
       {
-        return ManagedString::Get( NativePtr->getServerGroup( ) );
+        try
+        {
+          return ManagedString::Get( m_nativeptr->get()->getServerGroup( ) );
+        }
+        finally
+        {
+          GC::KeepAlive(m_nativeptr);
+        }
+
       }
 
-      //generic<class TKey, class TValue>
-      array<String^>^ Pool/*<TKey, TValue>*/::Locators::get()
+
+      array<String^>^ Pool::Locators::get()
       {
-        apache::geode::client::CacheableStringArrayPtr locators = NativePtr->getLocators();
-        int length = locators->length();
-        if (length > 0)
+        try
         {
-          array<String^>^ result = gcnew array<String^>(length);
-          for (int item = 0; item < length; item++)
+          auto locators = m_nativeptr->get()->getLocators();
+          int length = locators->length();
+          if (length > 0)
+          {
+            array<String^>^ result = gcnew array<String^>(length);
+            for (int item = 0; item < length; item++)
+            {
+              result[item] = CacheableString::GetString((*locators)[item].get());
+            }
+            return result;
+          }
+          else
           {
-            result[item] = CacheableString::GetString(locators[item].get());
+            return nullptr;
           }
-          return result;
         }
-        else
+        finally
         {
-          return nullptr;
+          GC::KeepAlive(m_nativeptr);
         }
       }
 
-      //generic<class TKey, class TValue>
-      array<String^>^ Pool/*<TKey, TValue>*/::Servers::get()
+
+      array<String^>^ Pool::Servers::get()
       {
-        apache::geode::client::CacheableStringArrayPtr servers = NativePtr->getServers();
-        int length = servers->length();
-        if (length > 0)
+        try
         {
-          array<String^>^ result = gcnew array<String^>(length);
-          for (int item = 0; item < length; item++)
+          auto servers = m_nativeptr->get()->getServers();
+          int length = servers->length();
+          if (length > 0)
           {
-            result[item] = CacheableString::GetString(servers[item].get());
+            array<String^>^ result = gcnew array<String^>(length);
+            for (int item = 0; item < length; item++)
+            {
+              result[item] = CacheableString::GetString((*servers)[item].get());
+            }
+            return result;
+          }
+          else
+          {
+            return nullptr;
           }
-          return result;
         }
-        else
+        finally
         {
-          return nullptr;
+          GC::KeepAlive(m_nativeptr);
         }
       }
 
 	  //generic<class TKey, class TValue>
-      Boolean Pool/*<TKey, TValue>*/::ThreadLocalConnections::get()
+      Boolean Pool::ThreadLocalConnections::get()
       {
-        return NativePtr->getThreadLocalConnections();
+        try
+        {
+          return m_nativeptr->get()->getThreadLocalConnections();
+        }
+        finally
+        {
+          GC::KeepAlive(m_nativeptr);
+        }
+
       }
 
-      //generic<class TKey, class TValue>
-      bool Pool/*<TKey, TValue>*/::MultiuserAuthentication::get()
+
+      bool Pool::MultiuserAuthentication::get()
       {
-        return NativePtr->getMultiuserAuthentication();    
+        try
+        {
+          return m_nativeptr->get()->getMultiuserAuthentication();
+        }
+        finally
+        {
+          GC::KeepAlive(m_nativeptr);
+        }
+    
       }
       
-      //generic<class TKey, class TValue>
-      void Pool/*<TKey, TValue>*/::Destroy(Boolean KeepAlive)
+
+      void Pool::Destroy(Boolean KeepAlive)
       {
-        NativePtr->destroy(KeepAlive);
+        try
+        {
+          m_nativeptr->get()->destroy(KeepAlive);
+        }
+        finally
+        {
+          GC::KeepAlive(m_nativeptr);
+        }
+
       }
 
       void Pool::ReleaseThreadLocalConnection()
       {
-        NativePtr->releaseThreadLocalConnection();
+        try
+        {
+          m_nativeptr->get()->releaseThreadLocalConnection();
+        }
+        finally
+        {
+          GC::KeepAlive(m_nativeptr);
+        }
+
       }
 
-      //generic<class TKey, class TValue>
-      void Pool/*<TKey, TValue>*/::Destroy()
+
+      void Pool::Destroy()
       {
-        NativePtr->destroy();
+        try
+        {
+          m_nativeptr->get()->destroy();
+        }
+        finally
+        {
+          GC::KeepAlive(m_nativeptr);
+        }
+
       }
 
-      //generic<class TKey, class TValue>
-      Boolean Pool/*<TKey, TValue>*/::Destroyed::get()
+
+      Boolean Pool::Destroyed::get()
       {
-        return NativePtr->isDestroyed();
+        try
+        {
+          return m_nativeptr->get()->isDestroyed();
+        }
+        finally
+        {
+          GC::KeepAlive(m_nativeptr);
+        }
+
       }
 
       generic<class TKey, class TResult>
-      QueryService<TKey, TResult>^ Pool/*<TKey, TValue>*/::GetQueryService()
+      QueryService<TKey, TResult>^ Pool::GetQueryService()
       {
         _GF_MG_EXCEPTION_TRY2/* due to auto replace */
 
-          return QueryService<TKey, TResult>::Create( NativePtr->getQueryService( ).ptr( ) );
+          try
+          {
+            return QueryService<TKey, TResult>::Create(m_nativeptr->get()->getQueryService());
+          }
+          finally
+          {
+            GC::KeepAlive(m_nativeptr);
+          }
+
 
         _GF_MG_EXCEPTION_CATCH_ALL2/* due to auto replace */
       }
@@ -232,11 +446,18 @@ namespace Apache
       {
         _GF_MG_EXCEPTION_TRY2
 
-        return NativePtr->getPendingEventCount();
+          try
+          {
+            return m_nativeptr->get()->getPendingEventCount();
+          }
+          finally
+          {
+            GC::KeepAlive(m_nativeptr);
+          }
+
 
         _GF_MG_EXCEPTION_CATCH_ALL2
+      }
     }  // namespace Client
   }  // namespace Geode
 }  // namespace Apache
-
- } //namespace 

http://git-wip-us.apache.org/repos/asf/geode-native/blob/6027574a/src/clicache/src/Pool.hpp
----------------------------------------------------------------------
diff --git a/src/clicache/src/Pool.hpp b/src/clicache/src/Pool.hpp
index b1af11c..5be1cd3 100644
--- a/src/clicache/src/Pool.hpp
+++ b/src/clicache/src/Pool.hpp
@@ -18,8 +18,11 @@
 #pragma once
 
 #include "geode_defs.hpp"
+#include "begin_native.hpp"
 #include <geode/Pool.hpp>
-#include "impl/NativeWrapper.hpp"
+#include "end_native.hpp"
+
+#include "native_shared_ptr.hpp"
 
 
 using namespace System;
@@ -30,9 +33,7 @@ namespace Apache
   {
     namespace Client
     {
-
-      //generic<class TKey, class TResult>
-      //ref class Properties;
+      namespace native = apache::geode::client;
 
       generic<class TKey, class TResult>
       ref class QueryService;
@@ -47,7 +48,6 @@ namespace Apache
       /// </remarks>
       // generic<class TKey, class TValue>
       public ref class Pool sealed
-        : public Client::Internal::SBWrap<apache::geode::client::Pool>
       {
       public:
 
@@ -323,10 +323,15 @@ namespace Apache
         /// <returns>
         /// The managed wrapper object; null if the native pointer is null.
         /// </returns>
-        inline static Pool^ Create(apache::geode::client::Pool* nativeptr)
+        inline static Pool^ Create(native::PoolPtr nativeptr)
+        {
+          return __nullptr == nativeptr ? nullptr :
+            gcnew Pool( nativeptr );
+        }
+
+        std::shared_ptr<native::Pool> GetNative()
         {
-          return (nativeptr != nullptr ?
-                  gcnew Pool(nativeptr) : nullptr);
+          return m_nativeptr->get_shared_ptr();
         }
 
       private:
@@ -335,8 +340,12 @@ namespace Apache
         /// Private constructor to wrap a native object pointer
         /// </summary>
         /// <param name="nativeptr">The native object pointer</param>
-        inline Pool(apache::geode::client::Pool* nativeptr)
-          : SBWrap(nativeptr) { }
+        inline Pool(native::PoolPtr nativeptr)
+        {
+          m_nativeptr = gcnew native_shared_ptr<native::Pool>(nativeptr);
+        }
+
+        native_shared_ptr<native::Pool>^ m_nativeptr;
       };
     }  // namespace Client
   }  // namespace Geode

http://git-wip-us.apache.org/repos/asf/geode-native/blob/6027574a/src/clicache/src/PoolFactory.cpp
----------------------------------------------------------------------
diff --git a/src/clicache/src/PoolFactory.cpp b/src/clicache/src/PoolFactory.cpp
index 427453a..e17bdee 100644
--- a/src/clicache/src/PoolFactory.cpp
+++ b/src/clicache/src/PoolFactory.cpp
@@ -17,7 +17,6 @@
 
 #pragma once
 
-//#include "geode_includes.hpp"
 #include "Pool.hpp"
 #include "PoolFactory.hpp"
 
@@ -33,260 +32,419 @@ namespace Apache
     namespace Client
     {
 
-      //generic<class TKey, class TValue>
-      PoolFactory^ PoolFactory/*<TKey, TValue>*/::SetFreeConnectionTimeout( Int32 connectionTimeout )
+
+      PoolFactory^ PoolFactory::SetFreeConnectionTimeout( Int32 connectionTimeout )
 		  {
 			  _GF_MG_EXCEPTION_TRY2/* due to auto replace */
 
-			  NativePtr->setFreeConnectionTimeout( connectionTimeout );
+			  try
+			  {
+			    m_nativeptr->get()->setFreeConnectionTimeout( connectionTimeout );
+			  }
+			  finally
+			  {
+			    GC::KeepAlive(m_nativeptr);
+			  }
 
 			  _GF_MG_EXCEPTION_CATCH_ALL2/* due to auto replace */
           return this;
 		  }
 
-      //generic<class TKey, class TValue>
-		  PoolFactory^ PoolFactory/*<TKey, TValue>*/::SetLoadConditioningInterval( Int32 loadConditioningInterval )
+
+		  PoolFactory^ PoolFactory::SetLoadConditioningInterval( Int32 loadConditioningInterval )
 		  {
 			  _GF_MG_EXCEPTION_TRY2/* due to auto replace */
 
-			  NativePtr->setLoadConditioningInterval( loadConditioningInterval );
+			  try
+			  {
+			    m_nativeptr->get()->setLoadConditioningInterval( loadConditioningInterval );
+			  }
+			  finally
+			  {
+			    GC::KeepAlive(m_nativeptr);
+			  }
 
 			  _GF_MG_EXCEPTION_CATCH_ALL2/* due to auto replace */
           return this;
 		  }
 
-      //generic<class TKey, class TValue>
-		  PoolFactory^ PoolFactory/*<TKey, TValue>*/::SetSocketBufferSize( Int32 bufferSize )
+
+		  PoolFactory^ PoolFactory::SetSocketBufferSize( Int32 bufferSize )
       {
 			  _GF_MG_EXCEPTION_TRY2/* due to auto replace */
 
-			  NativePtr->setSocketBufferSize( bufferSize );
+			  try
+			  {
+			    m_nativeptr->get()->setSocketBufferSize( bufferSize );
+			  }
+			  finally
+			  {
+			    GC::KeepAlive(m_nativeptr);
+			  }
 
 			  _GF_MG_EXCEPTION_CATCH_ALL2/* due to auto replace */
           return this;
 		  }
 
-      //generic<class TKey, class TValue>
-		  PoolFactory^ PoolFactory/*<TKey, TValue>*/::SetReadTimeout( Int32 timeout )
+
+		  PoolFactory^ PoolFactory::SetReadTimeout( Int32 timeout )
       {
 			  _GF_MG_EXCEPTION_TRY2/* due to auto replace */
 
-			  NativePtr->setReadTimeout( timeout );
+			  try
+			  {
+			    m_nativeptr->get()->setReadTimeout( timeout );
+			  }
+			  finally
+			  {
+			    GC::KeepAlive(m_nativeptr);
+			  }
 
 			  _GF_MG_EXCEPTION_CATCH_ALL2/* due to auto replace */
           return this;
 		  }
 
-      //generic<class TKey, class TValue>
-		  PoolFactory^ PoolFactory/*<TKey, TValue>*/::SetMinConnections( Int32 minConnections )
+
+		  PoolFactory^ PoolFactory::SetMinConnections( Int32 minConnections )
       {
 			  _GF_MG_EXCEPTION_TRY2/* due to auto replace */
 
-			  NativePtr->setMinConnections( minConnections );
+			  try
+			  {
+			    m_nativeptr->get()->setMinConnections( minConnections );
+			  }
+			  finally
+			  {
+			    GC::KeepAlive(m_nativeptr);
+			  }
 
 			  _GF_MG_EXCEPTION_CATCH_ALL2/* due to auto replace */
           return this;
 		  }
 
-      //generic<class TKey, class TValue>
-		  PoolFactory^ PoolFactory/*<TKey, TValue>*/::SetMaxConnections( Int32 maxConnections )
+
+		  PoolFactory^ PoolFactory::SetMaxConnections( Int32 maxConnections )
       {
 			  _GF_MG_EXCEPTION_TRY2/* due to auto replace */
 
-			  NativePtr->setMaxConnections( maxConnections );
+			  try
+			  {
+			    m_nativeptr->get()->setMaxConnections( maxConnections );
+			  }
+			  finally
+			  {
+			    GC::KeepAlive(m_nativeptr);
+			  }
 
 			  _GF_MG_EXCEPTION_CATCH_ALL2/* due to auto replace */
           return this;
 		  }
 
-      //generic<class TKey, class TValue>
-		  PoolFactory^ PoolFactory/*<TKey, TValue>*/::SetIdleTimeout( Int32 idleTimeout )
+
+		  PoolFactory^ PoolFactory::SetIdleTimeout( Int32 idleTimeout )
       {
 			  _GF_MG_EXCEPTION_TRY2/* due to auto replace */
 
-			  NativePtr->setIdleTimeout( idleTimeout );
+			  try
+			  {
+			    m_nativeptr->get()->setIdleTimeout( idleTimeout );
+			  }
+			  finally
+			  {
+			    GC::KeepAlive(m_nativeptr);
+			  }
 
 			  _GF_MG_EXCEPTION_CATCH_ALL2/* due to auto replace */
           return this;
 		  }
 
-      //generic<class TKey, class TValue>
-		  PoolFactory^ PoolFactory/*<TKey, TValue>*/::SetRetryAttempts( Int32 retryAttempts )
+
+		  PoolFactory^ PoolFactory::SetRetryAttempts( Int32 retryAttempts )
       {
 			  _GF_MG_EXCEPTION_TRY2/* due to auto replace */
 
-			  NativePtr->setRetryAttempts( retryAttempts );
+			  try
+			  {
+			    m_nativeptr->get()->setRetryAttempts( retryAttempts );
+			  }
+			  finally
+			  {
+			    GC::KeepAlive(m_nativeptr);
+			  }
 
 			  _GF_MG_EXCEPTION_CATCH_ALL2/* due to auto replace */
           return this;
 		  }
 
-      //generic<class TKey, class TValue>
-		  PoolFactory^ PoolFactory/*<TKey, TValue>*/::SetPingInterval( Int32 pingInterval )
+
+		  PoolFactory^ PoolFactory::SetPingInterval( Int32 pingInterval )
       {
 			  _GF_MG_EXCEPTION_TRY2/* due to auto replace */
 
-			  NativePtr->setPingInterval( pingInterval );
+			  try
+			  {
+			    m_nativeptr->get()->setPingInterval( pingInterval );
+			  }
+			  finally
+			  {
+			    GC::KeepAlive(m_nativeptr);
+			  }
 
 			  _GF_MG_EXCEPTION_CATCH_ALL2/* due to auto replace */
           return this;
 		  }
 
-      //generic<class TKey, class TValue>
-		  PoolFactory^ PoolFactory/*<TKey, TValue>*/::SetUpdateLocatorListInterval( Int32 updateLocatorListInterval )
+
+		  PoolFactory^ PoolFactory::SetUpdateLocatorListInterval( Int32 updateLocatorListInterval )
       {
 			  _GF_MG_EXCEPTION_TRY2/* due to auto replace */
 
-			  NativePtr->setUpdateLocatorListInterval( updateLocatorListInterval );
+			  try
+			  {
+			    m_nativeptr->get()->setUpdateLocatorListInterval( updateLocatorListInterval );
+			  }
+			  finally
+			  {
+			    GC::KeepAlive(m_nativeptr);
+			  }
 
 			  _GF_MG_EXCEPTION_CATCH_ALL2/* due to auto replace */
           return this;
 		  }
 
-      //generic<class TKey, class TValue>
-      PoolFactory^ PoolFactory/*<TKey, TValue>*/::SetStatisticInterval( Int32 statisticInterval )
+
+      PoolFactory^ PoolFactory::SetStatisticInterval( Int32 statisticInterval )
       {
 			  _GF_MG_EXCEPTION_TRY2/* due to auto replace */
 
-			  NativePtr->setStatisticInterval( statisticInterval );
+			  try
+			  {
+			    m_nativeptr->get()->setStatisticInterval( statisticInterval );
+			  }
+			  finally
+			  {
+			    GC::KeepAlive(m_nativeptr);
+			  }
 
 			  _GF_MG_EXCEPTION_CATCH_ALL2/* due to auto replace */
           return this;
 		  }
 
-      //generic<class TKey, class TValue>
-      PoolFactory^ PoolFactory/*<TKey, TValue>*/::SetServerGroup( String^ group )
+
+      PoolFactory^ PoolFactory::SetServerGroup( String^ group )
       {
 			  _GF_MG_EXCEPTION_TRY2/* due to auto replace */
 
         ManagedString mg_servergroup( group );
-			  NativePtr->setServerGroup( mg_servergroup.CharPtr );
+			  try
+			  {
+			    m_nativeptr->get()->setServerGroup( mg_servergroup.CharPtr );
+			  }
+			  finally
+			  {
+			    GC::KeepAlive(m_nativeptr);
+			  }
 
 			  _GF_MG_EXCEPTION_CATCH_ALL2/* due to auto replace */
           return this;
 		  }
 
-      //generic<class TKey, class TValue>
-		  PoolFactory^ PoolFactory/*<TKey, TValue>*/::AddLocator( String^ host, Int32 port )
+
+		  PoolFactory^ PoolFactory::AddLocator( String^ host, Int32 port )
       {
 			  _GF_MG_EXCEPTION_TRY2/* due to auto replace */
 
         ManagedString mg_host( host );
-			  NativePtr->addLocator( mg_host.CharPtr, port );
+			  try
+			  {
+			    m_nativeptr->get()->addLocator( mg_host.CharPtr, port );
+			  }
+			  finally
+			  {
+			    GC::KeepAlive(m_nativeptr);
+			  }
 
 			  _GF_MG_EXCEPTION_CATCH_ALL2/* due to auto replace */
           return this;
 		  }
 
-      //generic<class TKey, class TValue>
-      PoolFactory^ PoolFactory/*<TKey, TValue>*/::AddServer( String^ host, Int32 port )
+
+      PoolFactory^ PoolFactory::AddServer( String^ host, Int32 port )
       {
 			  _GF_MG_EXCEPTION_TRY2/* due to auto replace */
 
 			  ManagedString mg_host( host );
-			  NativePtr->addServer( mg_host.CharPtr, port );
+			  try
+			  {
+			    m_nativeptr->get()->addServer( mg_host.CharPtr, port );
+			  }
+			  finally
+			  {
+			    GC::KeepAlive(m_nativeptr);
+			  }
 
 			  _GF_MG_EXCEPTION_CATCH_ALL2/* due to auto replace */
           return this;
 		  }
 
-      //generic<class TKey, class TValue>
-		  PoolFactory^ PoolFactory/*<TKey, TValue>*/::SetSubscriptionEnabled( Boolean enabled )
+
+		  PoolFactory^ PoolFactory::SetSubscriptionEnabled( Boolean enabled )
       {
 			  _GF_MG_EXCEPTION_TRY2/* due to auto replace */
 
-			  NativePtr->setSubscriptionEnabled( enabled );
+			  try
+			  {
+			    m_nativeptr->get()->setSubscriptionEnabled( enabled );
+			  }
+			  finally
+			  {
+			    GC::KeepAlive(m_nativeptr);
+			  }
 
 			  _GF_MG_EXCEPTION_CATCH_ALL2/* due to auto replace */
           return this;
 		  }
 
-      //generic<class TKey, class TValue>
-          PoolFactory^ PoolFactory/*<TKey, TValue>*/::SetPRSingleHopEnabled( Boolean enabled )
+
+          PoolFactory^ PoolFactory::SetPRSingleHopEnabled( Boolean enabled )
           {
             _GF_MG_EXCEPTION_TRY2/* due to auto replace */
 
-              NativePtr->setPRSingleHopEnabled(enabled);
+              try
+              {
+                m_nativeptr->get()->setPRSingleHopEnabled(enabled);
+              }
+              finally
+              {
+                GC::KeepAlive(m_nativeptr);
+              }
 
              _GF_MG_EXCEPTION_CATCH_ALL2/* due to auto replace */
                return this;
           }
 
-          //generic<class TKey, class TValue>
-		  PoolFactory^ PoolFactory/*<TKey, TValue>*/::SetSubscriptionRedundancy( Int32 redundancy )
+    
+		  PoolFactory^ PoolFactory::SetSubscriptionRedundancy( Int32 redundancy )
       {
 			  _GF_MG_EXCEPTION_TRY2/* due to auto replace */
 
-			  NativePtr->setSubscriptionRedundancy( redundancy );
+			  try
+			  {
+			    m_nativeptr->get()->setSubscriptionRedundancy( redundancy );
+			  }
+			  finally
+			  {
+			    GC::KeepAlive(m_nativeptr);
+			  }
 
 			  _GF_MG_EXCEPTION_CATCH_ALL2/* due to auto replace */
           return this;
 		  }
 
-      //generic<class TKey, class TValue>
-		  PoolFactory^ PoolFactory/*<TKey, TValue>*/::SetSubscriptionMessageTrackingTimeout( Int32 messageTrackingTimeout )
+
+		  PoolFactory^ PoolFactory::SetSubscriptionMessageTrackingTimeout( Int32 messageTrackingTimeout )
       {
 			  _GF_MG_EXCEPTION_TRY2/* due to auto replace */
 
-			  NativePtr->setSubscriptionMessageTrackingTimeout( messageTrackingTimeout );
+			  try
+			  {
+			    m_nativeptr->get()->setSubscriptionMessageTrackingTimeout( messageTrackingTimeout );
+			  }
+			  finally
+			  {
+			    GC::KeepAlive(m_nativeptr);
+			  }
 
 			  _GF_MG_EXCEPTION_CATCH_ALL2/* due to auto replace */
           return this;
 		  }
 
-      //generic<class TKey, class TValue>
-		  PoolFactory^ PoolFactory/*<TKey, TValue>*/::SetSubscriptionAckInterval( Int32 ackInterval )
+
+		  PoolFactory^ PoolFactory::SetSubscriptionAckInterval( Int32 ackInterval )
       {
 			  _GF_MG_EXCEPTION_TRY2/* due to auto replace */
 
-			  NativePtr->setSubscriptionAckInterval( ackInterval );
+			  try
+			  {
+			    m_nativeptr->get()->setSubscriptionAckInterval( ackInterval );
+			  }
+			  finally
+			  {
+			    GC::KeepAlive(m_nativeptr);
+			  }
 
 			  _GF_MG_EXCEPTION_CATCH_ALL2/* due to auto replace */
           return this;
 		  }
-      PoolFactory^ PoolFactory/*<TKey, TValue>*/::SetThreadLocalConnections( Boolean enabled )
+      PoolFactory^ PoolFactory::SetThreadLocalConnections( Boolean enabled )
       {
 			  _GF_MG_EXCEPTION_TRY2
 
-			  NativePtr->setThreadLocalConnections( enabled );
+			  try
+			  {
+			    m_nativeptr->get()->setThreadLocalConnections( enabled );
+			  }
+			  finally
+			  {
+			    GC::KeepAlive(m_nativeptr);
+			  }
 
 			  _GF_MG_EXCEPTION_CATCH_ALL2
           return this;
 	  }
-      //generic<class TKey, class TValue>
-      PoolFactory^ PoolFactory/*<TKey, TValue>*/::SetMultiuserAuthentication( bool multiuserAuthentication )
+
+      PoolFactory^ PoolFactory::SetMultiuserAuthentication( bool multiuserAuthentication )
       {
 			  _GF_MG_EXCEPTION_TRY2/* due to auto replace */
 
-          NativePtr->setMultiuserAuthentication( multiuserAuthentication );
+          try
+          {
+            m_nativeptr->get()->setMultiuserAuthentication( multiuserAuthentication );
+          }
+          finally
+          {
+            GC::KeepAlive(m_nativeptr);
+          }
 
 			  _GF_MG_EXCEPTION_CATCH_ALL2/* due to auto replace */
           return this;
 	   }
 
-      //generic<class TKey, class TValue>
-		  PoolFactory^ PoolFactory/*<TKey, TValue>*/::Reset()
+
+		  PoolFactory^ PoolFactory::Reset()
       {
 			  _GF_MG_EXCEPTION_TRY2/* due to auto replace */
 
-			  NativePtr->reset( );
+			  try
+			  {
+			    m_nativeptr->get()->reset( );
+			  }
+			  finally
+			  {
+			    GC::KeepAlive(m_nativeptr);
+			  }
 
 			  _GF_MG_EXCEPTION_CATCH_ALL2/* due to auto replace */
           return this;
 		  }
 
-      //generic<class TKey, class TValue>
-		  Pool/*<TKey, TValue>*/^ PoolFactory/*<TKey, TValue>*/::Create( String^ name )
-      {
-			  _GF_MG_EXCEPTION_TRY2/* due to auto replace */
 
-        ManagedString mg_name( name );
-        apache::geode::client::PoolPtr & pool = NativePtr->create(mg_name.CharPtr);
-        return Pool/*<TKey, TValue>*/::Create(pool.get());
+      Pool^ PoolFactory::Create(String^ name)
+      {
+        _GF_MG_EXCEPTION_TRY2/* due to auto replace */
 
-			  _GF_MG_EXCEPTION_CATCH_ALL2/* due to auto replace */
+          ManagedString mg_name(name);
+          try
+          {
+            return Pool::Create(m_nativeptr->get()->create(mg_name.CharPtr));
+          }
+          finally
+          {
+            GC::KeepAlive(m_nativeptr);
+          }
+        
+        _GF_MG_EXCEPTION_CATCH_ALL2/* due to auto replace */
+      }
     }  // namespace Client
   }  // namespace Geode
 }  // namespace Apache
-
- } //namespace 

http://git-wip-us.apache.org/repos/asf/geode-native/blob/6027574a/src/clicache/src/PoolFactory.hpp
----------------------------------------------------------------------
diff --git a/src/clicache/src/PoolFactory.hpp b/src/clicache/src/PoolFactory.hpp
index 4f81e57..49665bb 100644
--- a/src/clicache/src/PoolFactory.hpp
+++ b/src/clicache/src/PoolFactory.hpp
@@ -18,8 +18,11 @@
 #pragma once
 
 #include "geode_defs.hpp"
+#include "begin_native.hpp"
 #include <geode/PoolFactory.hpp>
-//#include "impl/NativeWrapper.hpp"
+#include "end_native.hpp"
+
+#include "native_shared_ptr.hpp"
 
 using namespace System;
 
@@ -29,16 +32,16 @@ namespace Apache
   {
     namespace Client
     {
+      namespace native = apache::geode::client;
+
 
-      // generic<class TKey, class TValue>
       ref class Pool;
 
       /// <summary>
       /// This interface provides for the configuration and creation of instances of Pool.
       /// </summary>
-      // generic<class TKey, class TValue>
+
       public ref class PoolFactory sealed
-        : public Internal::SBWrap<apache::geode::client::PoolFactory>
       {
       public:
 
@@ -387,7 +390,7 @@ namespace Apache
         /// throws IllegalStateException if a pool with name already exists
         /// throws IllegalStateException if a locator or server has not been added.
         /// </exception>
-        Pool/*<TKey, TValue>*/^ Create(String^ name);
+        Pool^ Create(String^ name);
 
       internal:
 
@@ -399,10 +402,10 @@ namespace Apache
         /// <returns>
         /// The managed wrapper object; null if the native pointer is null.
         /// </returns>
-        inline static PoolFactory/*<TKey, TValue>*/^ Create(apache::geode::client::PoolFactory* nativeptr)
+        inline static PoolFactory^ Create(native::PoolFactoryPtr nativeptr)
         {
-          return (nativeptr != nullptr ?
-                  gcnew PoolFactory(nativeptr) : nullptr);
+          return __nullptr == nativeptr ? nullptr :
+            gcnew PoolFactory( nativeptr );
         }
 
       private:
@@ -411,8 +414,12 @@ namespace Apache
         /// Private constructor to wrap a native object pointer
         /// </summary>
         /// <param name="nativeptr">The native object pointer</param>
-        inline PoolFactory(apache::geode::client::PoolFactory* nativeptr)
-          : SBWrap(nativeptr) { }
+        inline PoolFactory(native::PoolFactoryPtr nativeptr)
+        {
+          m_nativeptr = gcnew native_shared_ptr<native::PoolFactory>(nativeptr);
+        }
+
+        native_shared_ptr<native::PoolFactory>^ m_nativeptr;
       };
     }  // namespace Client
   }  // namespace Geode

http://git-wip-us.apache.org/repos/asf/geode-native/blob/6027574a/src/clicache/src/PoolManager.cpp
----------------------------------------------------------------------
diff --git a/src/clicache/src/PoolManager.cpp b/src/clicache/src/PoolManager.cpp
index d609860..d2aa28d 100644
--- a/src/clicache/src/PoolManager.cpp
+++ b/src/clicache/src/PoolManager.cpp
@@ -17,13 +17,11 @@
 
 #pragma once
 
-//#include "geode_includes.hpp"
 #include "Region.hpp"
 #include "Pool.hpp"
 #include "PoolManager.hpp"
 #include "PoolFactory.hpp"
 #include "CacheableString.hpp"
-#include "impl/SafeConvert.hpp"
 
 using namespace System;
 
@@ -33,55 +31,47 @@ namespace Apache
   {
     namespace Client
     {
+      namespace native = apache::geode::client;
 
-      //generic<class TKey, class TValue>
-      PoolFactory/*<TKey, TValue>*/^ PoolManager/*<TKey, TValue>*/::CreateFactory()
+      PoolFactory^ PoolManager::CreateFactory()
       {
-        return PoolFactory/*<TKey, TValue>*/::Create(apache::geode::client::PoolManager::createFactory().get());
+        return PoolFactory::Create(native::PoolManager::createFactory());
       }
 
-      //generic<class TKey, class TValue>
-      const Dictionary<String^, Pool/*<TKey, TValue>*/^>^ PoolManager/*<TKey, TValue>*/::GetAll()
+      const Dictionary<String^, Pool^>^ PoolManager::GetAll()
       {
-        apache::geode::client::HashMapOfPools pools = apache::geode::client::PoolManager::getAll();
-        Dictionary<String^, Pool/*<TKey, TValue>*/^>^ result = gcnew Dictionary<String^, Pool/*<TKey, TValue>*/^>();
-        for (apache::geode::client::HashMapOfPools::Iterator iter = pools.begin(); iter != pools.end(); ++iter)
+        auto pools = native::PoolManager::getAll();
+        auto result = gcnew Dictionary<String^, Pool^>();
+        for (native::HashMapOfPools::Iterator iter = pools.begin(); iter != pools.end(); ++iter)
         {
-          String^ key = CacheableString::GetString(iter.first().get());
-          Pool/*<TKey, TValue>*/^ val = Pool/*<TKey, TValue>*/::Create(iter.second().get());
+          auto key = CacheableString::GetString(iter.first().get());
+          auto val = Pool::Create(iter.second());
           result->Add(key, val);
         }
         return result;
       }
 
-      //generic<class TKey, class TValue>
-      Pool/*<TKey, TValue>*/^ PoolManager/*<TKey, TValue>*/::Find(String^ name)
+      Pool^ PoolManager::Find(String^ name)
       {
         ManagedString mg_name( name );
-        apache::geode::client::PoolPtr pool = apache::geode::client::PoolManager::find(mg_name.CharPtr);
-        return Pool/*<TKey, TValue>*/::Create(pool.get());
+        auto pool = native::PoolManager::find(mg_name.CharPtr);
+        return Pool::Create(pool);
       }
 
-      //generic <class TKey, class TValue>
-      Pool/*<TKey, TValue>*/^ PoolManager/*<TKey, TValue>*/::Find(Client::Region<Object^, Object^>^ region)
+      Pool^ PoolManager::Find(Client::Region<Object^, Object^>^ region)
       {
-        //return Pool::Create(apache::geode::client::PoolManager::find(apache::geode::client::RegionPtr(GetNativePtr<apache::geode::client::Region>(region))).get());
-        return Pool/*<TKey, TValue>*/::Create(apache::geode::client::PoolManager::find(apache::geode::client::RegionPtr(region->_NativePtr)).get());
+        return Pool::Create(native::PoolManager::find(region->GetNative()));
       }
 
-      //generic<class TKey, class TValue>
-      void PoolManager/*<TKey, TValue>*/::Close(Boolean KeepAlive)
+      void PoolManager::Close(Boolean KeepAlive)
       {
-        apache::geode::client::PoolManager::close(KeepAlive);
+        native::PoolManager::close(KeepAlive);
       }
 
-      //generic<class TKey, class TValue>
-      void PoolManager/*<TKey, TValue>*/::Close()
+      void PoolManager::Close()
       {
-        apache::geode::client::PoolManager::close();
+        native::PoolManager::close();
+      }
     }  // namespace Client
   }  // namespace Geode
 }  // namespace Apache
-
-
- } //namespace 

http://git-wip-us.apache.org/repos/asf/geode-native/blob/6027574a/src/clicache/src/PoolManager.hpp
----------------------------------------------------------------------
diff --git a/src/clicache/src/PoolManager.hpp b/src/clicache/src/PoolManager.hpp
index a04d1ac..f47d553 100644
--- a/src/clicache/src/PoolManager.hpp
+++ b/src/clicache/src/PoolManager.hpp
@@ -18,8 +18,11 @@
 #pragma once
 
 #include "geode_defs.hpp"
+#include "begin_native.hpp"
 #include <geode/PoolManager.hpp>
-//#include "impl/NativeWrapper.hpp"
+#include "end_native.hpp"
+
+
 
 using namespace System;
 


Mime
View raw message