[mapguide-commits] r8770 - in trunk/MgDev: Common/MapGuideCommon/System Server/src/Common/Cache Server/src/Common/Manager Server/src/Core Server/src/Services/Mapping Server/src/Services/Rendering

svn_mapguide at osgeo.org svn_mapguide at osgeo.org
Wed Oct 7 23:35:59 PDT 2015


Author: hubu
Date: 2015-10-07 23:35:59 -0700 (Wed, 07 Oct 2015)
New Revision: 8770

Added:
   trunk/MgDev/Server/src/Common/Cache/ResourceLayerDefinitionCacheItem.cpp
   trunk/MgDev/Server/src/Common/Cache/ResourceLayerDefinitionCacheItem.h
   trunk/MgDev/Server/src/Common/Cache/ResourceServiceCache.cpp
   trunk/MgDev/Server/src/Common/Cache/ResourceServiceCache.h
   trunk/MgDev/Server/src/Common/Cache/ResourceServiceCacheEntry.cpp
   trunk/MgDev/Server/src/Common/Cache/ResourceServiceCacheEntry.h
   trunk/MgDev/Server/src/Core/ResourceServiceCacheTimeLimitEventHandler.cpp
   trunk/MgDev/Server/src/Core/ResourceServiceCacheTimeLimitEventHandler.h
Modified:
   trunk/MgDev/Common/MapGuideCommon/System/ConfigProperties.cpp
   trunk/MgDev/Common/MapGuideCommon/System/ConfigProperties.h
   trunk/MgDev/Server/src/Common/Cache/Makefile.am
   trunk/MgDev/Server/src/Common/Cache/ServerCache.vcxproj
   trunk/MgDev/Server/src/Common/Cache/ServerCacheBuild.cpp
   trunk/MgDev/Server/src/Common/Manager/CacheManager.cpp
   trunk/MgDev/Server/src/Common/Manager/CacheManager.h
   trunk/MgDev/Server/src/Common/Manager/FdoConnectionManager.cpp
   trunk/MgDev/Server/src/Core/EventTimer.h
   trunk/MgDev/Server/src/Core/Makefile.am
   trunk/MgDev/Server/src/Core/ServerCore.vcxproj
   trunk/MgDev/Server/src/Core/ServerCore.vcxproj.filters
   trunk/MgDev/Server/src/Core/ServerCoreBuild.cpp
   trunk/MgDev/Server/src/Core/TimedEvent.h
   trunk/MgDev/Server/src/Core/TimedEventHandler.cpp
   trunk/MgDev/Server/src/Services/Mapping/Makefile.am
   trunk/MgDev/Server/src/Services/Mapping/MappingUtil.cpp
   trunk/MgDev/Server/src/Services/Mapping/ServerMappingService.vcxproj
   trunk/MgDev/Server/src/Services/Rendering/Makefile.am
   trunk/MgDev/Server/src/Services/Rendering/ServerRenderingService.cpp
   trunk/MgDev/Server/src/Services/Rendering/ServerRenderingService.vcxproj
Log:
RFC 151: Add Layer Definition Cache. http://trac.osgeo.org/mapguide/wiki/MapGuideRfc151


Modified: trunk/MgDev/Common/MapGuideCommon/System/ConfigProperties.cpp
===================================================================
--- trunk/MgDev/Common/MapGuideCommon/System/ConfigProperties.cpp	2015-10-03 05:45:30 UTC (rev 8769)
+++ trunk/MgDev/Common/MapGuideCommon/System/ConfigProperties.cpp	2015-10-08 06:35:59 UTC (rev 8770)
@@ -367,6 +367,12 @@
 const STRING MgConfigProperties::DefaultResourceServicePropertySessionRepositoriesConfig        = L"FilePerSession";
 const STRING MgConfigProperties::ResourceServicePropertySessionRepositoriesLimit                = L"SessionRepositoriesLimit";
 const INT32  MgConfigProperties::DefaultResourceServicePropertySessionRepositoriesLimit         = 200;
+const STRING MgConfigProperties::ResourceServicePropertyCacheSize                               = L"CacheSize";
+const INT32  MgConfigProperties::DefaultResourceServicePropertyCacheSize                        = 500;
+const STRING MgConfigProperties::ResourceServicePropertyCacheTimeLimit                          = L"CacheTimeLimit";
+const INT32  MgConfigProperties::DefaultResourceServicePropertyCacheTimeLimit                   = 86400;
+const STRING MgConfigProperties::ResourceServicePropertyCacheTimerInterval                      = L"CacheTimerInterval";
+const INT32  MgConfigProperties::DefaultResourceServicePropertyCacheTimerInterval               = 3600;
 
 // ******************************************************************
 // Site Service Properties
@@ -701,6 +707,9 @@
     { MgConfigProperties::ResourceServicePropertyRetryAttempts                      , MgPropertyType::Int32     , 0                                     , 1000                                  , L""                                       },
     { MgConfigProperties::ResourceServicePropertyRetryInterval                      , MgPropertyType::Int32     , 0                                     , 60000                                 , L""                                       },
     { MgConfigProperties::ResourceServicePropertySessionRepositoriesLimit           , MgPropertyType::Int32     , 0                                     , 60000                                 , L""                                       },
+    { MgConfigProperties::ResourceServicePropertyCacheSize                          , MgPropertyType::Int32     , MG_CONFIG_MIN_CACHE_SIZE              , MG_CONFIG_MAX_CACHE_SIZE              , L""                                       },
+    { MgConfigProperties::ResourceServicePropertyCacheTimeLimit                     , MgPropertyType::Int32     , 0                                     , MG_CONFIG_MAX_INT32                   , L""                                       },
+    { MgConfigProperties::ResourceServicePropertyCacheTimerInterval                 , MgPropertyType::Int32     , MG_CONFIG_MIN_TIMER_INTERVAL          , MG_CONFIG_MAX_TIMER_INTERVAL          , L""                                       },
     { L""                                                                           , 0                         , 0.0                                   , 0.0                                   , L""                                       }
 };
 

Modified: trunk/MgDev/Common/MapGuideCommon/System/ConfigProperties.h
===================================================================
--- trunk/MgDev/Common/MapGuideCommon/System/ConfigProperties.h	2015-10-03 05:45:30 UTC (rev 8769)
+++ trunk/MgDev/Common/MapGuideCommon/System/ConfigProperties.h	2015-10-08 06:35:59 UTC (rev 8770)
@@ -489,6 +489,18 @@
     static const STRING ResourceServicePropertySessionRepositoriesLimit;        /// value("SessionRepositoriesLimit")
     static const INT32 DefaultResourceServicePropertySessionRepositoriesLimit;  /// value(200)
 
+    // Sets the maximum number of internal resource service data objects to cache
+    static const STRING ResourceServicePropertyCacheSize;                       /// value("CacheSize")
+    static const INT32 DefaultResourceServicePropertyCacheSize;                 /// value(500)
+
+    /// Sets the maximum amount of time (in seconds) to cache the internal resource service data objects
+    static const STRING ResourceServicePropertyCacheTimeLimit;                  /// value("CacheTimeLimit")
+    static const INT32 DefaultResourceServicePropertyCacheTimeLimit;            /// value(86400)
+
+    /// Sets the time duration (in seconds) between internal resource service cache timelimit checks
+    static const STRING ResourceServicePropertyCacheTimerInterval;              /// value("CacheTimerInterval")
+    static const INT32 DefaultResourceServicePropertyCacheTimerInterval;        /// value(3600)
+
 EXTERNAL_API:
 
     /// Sets the root of the session repository

Modified: trunk/MgDev/Server/src/Common/Cache/Makefile.am
===================================================================
--- trunk/MgDev/Server/src/Common/Cache/Makefile.am	2015-10-03 05:45:30 UTC (rev 8769)
+++ trunk/MgDev/Server/src/Common/Cache/Makefile.am	2015-10-08 06:35:59 UTC (rev 8770)
@@ -27,7 +27,10 @@
   FeatureServiceCache.cpp \
   FeatureServiceCacheEntry.cpp \
   FeatureSourceCacheItem.cpp \
-  SpatialContextCacheItem.cpp
+  SpatialContextCacheItem.cpp \
+  ResourceLayerDefinitionCacheItem.cpp \
+  ResourceServiceCache.cpp \
+  ResourceServiceCacheEntry.cpp
 
 noinst_HEADERS = $(include_SOURCES) \
   ServerCache.h \
@@ -39,6 +42,9 @@
   FeatureServiceCache.h \
   FeatureServiceCacheEntry.h \
   FeatureSourceCacheItem.h \
-  SpatialContextCacheItem.h
+  SpatialContextCacheItem.h \
+  ResourceLayerDefinitionCacheItem.h \
+  ResourceServiceCache.h \
+  ResourceServiceCacheEntry.h
 
 libMgServerCache_la_LDFLAGS = -release $(PACKAGE_VERSION)

Added: trunk/MgDev/Server/src/Common/Cache/ResourceLayerDefinitionCacheItem.cpp
===================================================================
--- trunk/MgDev/Server/src/Common/Cache/ResourceLayerDefinitionCacheItem.cpp	                        (rev 0)
+++ trunk/MgDev/Server/src/Common/Cache/ResourceLayerDefinitionCacheItem.cpp	2015-10-08 06:35:59 UTC (rev 8770)
@@ -0,0 +1,53 @@
+//
+//  Copyright (C) 2004-2015 by Autodesk, Inc.
+//
+//  This library is free software; you can redistribute it and/or
+//  modify it under the terms of version 2.1 of the GNU Lesser
+//  General Public License as published by the Free Software Foundation.
+//
+//  This library is distributed in the hope that it will be useful,
+//  but WITHOUT ANY WARRANTY; without even the implied warranty of
+//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+//  Lesser General Public License for more details.
+//
+//  You should have received a copy of the GNU Lesser General Public
+//  License along with this library; if not, write to the Free Software
+//  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+//
+
+#include "MapGuideCommon.h"
+#include "ResourceLayerDefinitionCacheItem.h"
+
+///////////////////////////////////////////////////////////////////////////////
+/// \brief
+/// Construct the object.
+///
+MgResourceLayerDefinitionCacheItem::MgResourceLayerDefinitionCacheItem()
+{
+}
+
+///////////////////////////////////////////////////////////////////////////////
+/// \brief
+/// Construct the object.
+///
+MgResourceLayerDefinitionCacheItem::MgResourceLayerDefinitionCacheItem(MdfModel::LayerDefinition* layerDefinition)
+{
+    Set(layerDefinition);
+}
+
+///////////////////////////////////////////////////////////////////////////////
+/// \brief
+/// Destruct the object.
+///
+MgResourceLayerDefinitionCacheItem::~MgResourceLayerDefinitionCacheItem()
+{
+}
+
+///////////////////////////////////////////////////////////////////////////////
+/// \brief
+/// Set the layer definition.
+///
+void MgResourceLayerDefinitionCacheItem::Set(MdfModel::LayerDefinition* layerDefinition)
+{
+    m_layerDefinition.reset(layerDefinition);
+}

Added: trunk/MgDev/Server/src/Common/Cache/ResourceLayerDefinitionCacheItem.h
===================================================================
--- trunk/MgDev/Server/src/Common/Cache/ResourceLayerDefinitionCacheItem.h	                        (rev 0)
+++ trunk/MgDev/Server/src/Common/Cache/ResourceLayerDefinitionCacheItem.h	2015-10-08 06:35:59 UTC (rev 8770)
@@ -0,0 +1,63 @@
+//
+//  Copyright (C) 2004-2015 by Autodesk, Inc.
+//
+//  This library is free software; you can redistribute it and/or
+//  modify it under the terms of version 2.1 of the GNU Lesser
+//  General Public License as published by the Free Software Foundation.
+//
+//  This library is distributed in the hope that it will be useful,
+//  but WITHOUT ANY WARRANTY; without even the implied warranty of
+//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+//  Lesser General Public License for more details.
+//
+//  You should have received a copy of the GNU Lesser General Public
+//  License along with this library; if not, write to the Free Software
+//  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+//
+
+#ifndef MG_RESOURCE_LAYER_DEFINITION_CACHE_ITEM_H_
+#define MG_RESOURCE_LAYER_DEFINITION_CACHE_ITEM_H_
+
+#include "ServerCacheItem.h"
+#include "LayerDefinition.h"
+#include <memory>
+
+using namespace std;
+
+class MG_SERVER_CACHE_API MgResourceLayerDefinitionCacheItem : public MgServerCacheItem
+{
+/// Constructors/Destructor
+
+public:
+    MgResourceLayerDefinitionCacheItem(void);
+    explicit MgResourceLayerDefinitionCacheItem(MdfModel::LayerDefinition* LayerDefinition);
+    virtual ~MgResourceLayerDefinitionCacheItem(void);
+
+private:
+
+    // Unimplemented copy constructor and assignment operator.
+    MgResourceLayerDefinitionCacheItem(const MgResourceLayerDefinitionCacheItem&);
+    MgResourceLayerDefinitionCacheItem& operator=(const MgResourceLayerDefinitionCacheItem&);
+
+/// Methods
+
+public:
+
+    MdfModel::LayerDefinition* Get();
+    void Set(MdfModel::LayerDefinition* layerDefinition);
+
+/// Data Members
+
+private:
+
+    auto_ptr<MdfModel::LayerDefinition> m_layerDefinition;
+};
+
+/// Inline Methods
+
+inline MdfModel::LayerDefinition* MgResourceLayerDefinitionCacheItem::Get()
+{
+    return m_layerDefinition.get();
+}
+
+#endif

Added: trunk/MgDev/Server/src/Common/Cache/ResourceServiceCache.cpp
===================================================================
--- trunk/MgDev/Server/src/Common/Cache/ResourceServiceCache.cpp	                        (rev 0)
+++ trunk/MgDev/Server/src/Common/Cache/ResourceServiceCache.cpp	2015-10-08 06:35:59 UTC (rev 8770)
@@ -0,0 +1,314 @@
+//
+//  Copyright (C) 2004-2015 by Autodesk, Inc.
+//
+//  This library is free software; you can redistribute it and/or
+//  modify it under the terms of version 2.1 of the GNU Lesser
+//  General Public License as published by the Free Software Foundation.
+//
+//  This library is distributed in the hope that it will be useful,
+//  but WITHOUT ANY WARRANTY; without even the implied warranty of
+//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+//  Lesser General Public License for more details.
+//
+//  You should have received a copy of the GNU Lesser General Public
+//  License along with this library; if not, write to the Free Software
+//  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+//
+
+#include "MapGuideCommon.h"
+#include "ResourceServiceCache.h"
+
+///////////////////////////////////////////////////////////////////////////////
+/// \brief
+/// Construct the object.
+///
+MgResourceServiceCache::MgResourceServiceCache() :
+    m_nDroppedEntries(0)
+{
+    Initialize(MgConfigProperties::DefaultResourceServicePropertyCacheSize,
+        MgConfigProperties::DefaultResourceServicePropertyCacheTimeLimit);
+}
+
+///////////////////////////////////////////////////////////////////////////////
+/// \brief
+/// Destruct the object.
+///
+MgResourceServiceCache::~MgResourceServiceCache()
+{
+    MG_TRY()
+
+    ACE_DEBUG((LM_DEBUG, ACE_TEXT("(%t) MgResourceServiceCache::~MgResourceServiceCache()\n")));
+
+    Clear();
+
+    MG_CATCH_AND_RELEASE()
+}
+
+///////////////////////////////////////////////////////////////////////////////
+/// \brief
+/// Clear the cache.
+///
+void MgResourceServiceCache::Clear()
+{
+    ACE_MT(ACE_GUARD(ACE_Recursive_Thread_Mutex, ace_mon, m_mutex));
+
+    for (MgResourceServiceCacheEntries::iterator i = m_resourceServiceCacheEntries.begin();
+        i != m_resourceServiceCacheEntries.end(); ++i)
+    {
+#ifdef _DEBUG
+        ACE_ASSERT(NULL != i->second);
+
+        if (NULL != i->second && 1 != i->second->GetRefCount())
+        {
+            ACE_DEBUG((LM_DEBUG, ACE_TEXT("(%t) MgFeatureServiceCache::Clear() - Reference Count of '%W': %d\n"),
+                i->first.c_str(), i->second->GetRefCount()));
+        }
+#endif
+        SAFE_RELEASE(i->second);
+    }
+
+    m_resourceServiceCacheEntries.clear();
+}
+
+///////////////////////////////////////////////////////////////////////////////
+/// \brief
+/// Compact the cache.
+///
+void MgResourceServiceCache::Compact()
+{
+    ACE_MT(ACE_GUARD(ACE_Recursive_Thread_Mutex, ace_mon, m_mutex));
+
+    INT32 size = (INT32)m_resourceServiceCacheEntries.size();
+
+    if (size >= m_size)
+    {
+        RemoveOldEntry();
+    }
+}
+
+///////////////////////////////////////////////////////////////////////////////
+/// \brief
+/// Return an existing entry from this cache or a newly created one
+/// if it does not exist.
+///
+MgResourceServiceCacheEntry* MgResourceServiceCache::SetEntry(MgResourceIdentifier* resource)
+{
+    ACE_MT(ACE_GUARD_RETURN(ACE_Recursive_Thread_Mutex, ace_mon, m_mutex, NULL));
+
+    Ptr<MgResourceServiceCacheEntry> entry = GetEntry(resource);
+
+    if (NULL == entry.p)
+    {
+        Compact();
+
+        entry = new MgResourceServiceCacheEntry();
+        m_resourceServiceCacheEntries.insert(MgResourceServiceCacheEntries::value_type(
+            resource->ToString(), SAFE_ADDREF(entry.p)));
+    }
+
+    return entry.Detach();
+}
+
+///////////////////////////////////////////////////////////////////////////////
+/// \brief
+/// Return an existing entry from this cache.
+///
+MgResourceServiceCacheEntry* MgResourceServiceCache::GetEntry(MgResourceIdentifier* resource)
+{
+    if (NULL == resource)
+    {
+        throw new MgNullArgumentException(
+            L"MgResourceServiceCache.GetEntry",
+            __LINE__, __WFILE__, NULL, L"", NULL);
+    }
+
+    resource->Validate();
+
+    if (!resource->IsResourceTypeOf(MgResourceType::LayerDefinition))
+    {
+        throw new MgInvalidResourceTypeException(
+            L"MgResourceServiceCache.GetEntry",
+            __LINE__, __WFILE__, NULL, L"", NULL);
+    }
+
+    ACE_MT(ACE_GUARD_RETURN(ACE_Recursive_Thread_Mutex, ace_mon, m_mutex, NULL));
+
+    Ptr<MgResourceServiceCacheEntry> entry;
+    MgResourceServiceCacheEntries::iterator i =
+        m_resourceServiceCacheEntries.find(resource->ToString());
+
+    if (m_resourceServiceCacheEntries.end() != i)
+    {
+        entry = SAFE_ADDREF(i->second);
+        entry->UpdateTimestamp();
+    }
+
+    return entry.Detach();
+}
+
+///////////////////////////////////////////////////////////////////////////////
+/// \brief
+/// Remove an entry from the cache.
+///
+void MgResourceServiceCache::RemoveEntry(CREFSTRING resource)
+{
+    ACE_MT(ACE_GUARD(ACE_Recursive_Thread_Mutex, ace_mon, m_mutex));
+
+    MgResourceServiceCacheEntries::iterator i =
+        m_resourceServiceCacheEntries.find(resource);
+
+    if (m_resourceServiceCacheEntries.end() != i)
+    {
+        SAFE_RELEASE(i->second);
+        m_resourceServiceCacheEntries.erase(i);
+    }
+}
+
+///////////////////////////////////////////////////////////////////////////////
+/// \brief
+/// Remove an entry from the cache.
+///
+void MgResourceServiceCache::RemoveEntry(MgResourceIdentifier* resource)
+{
+    if (NULL != resource)
+    {
+        RemoveEntry(resource->ToString());
+    }
+}
+
+///////////////////////////////////////////////////////////////////////////////
+/// \brief
+/// Remove the first oldest entry from the cache.
+///
+void MgResourceServiceCache::RemoveOldEntry()
+{
+    ACE_MT(ACE_GUARD(ACE_Recursive_Thread_Mutex, ace_mon, m_mutex));
+
+    MgResourceServiceCacheEntries::iterator currIter, prevIter, oldEntry;
+
+    currIter = prevIter = oldEntry = m_resourceServiceCacheEntries.begin();
+
+    while (m_resourceServiceCacheEntries.end() != currIter)
+    {
+        if (NULL == currIter->second)
+        {
+            oldEntry = currIter;
+            break;
+        }
+
+        if (currIter->second->GetTimestamp() < oldEntry->second->GetTimestamp())
+        {
+            oldEntry = currIter;
+        }
+
+        if (currIter->second->GetTimestamp() < prevIter->second->GetTimestamp())
+        {
+            break;
+        }
+        else
+        {
+            prevIter = currIter;
+        }
+
+        ++currIter;
+    }
+
+    if (m_resourceServiceCacheEntries.end() != oldEntry)
+    {
+        SAFE_RELEASE(oldEntry->second);
+        m_resourceServiceCacheEntries.erase(oldEntry);
+        m_nDroppedEntries++;
+    }
+}
+
+///////////////////////////////////////////////////////////////////////////////
+/// \brief
+/// Remove expired entries from the cache.
+///
+void MgResourceServiceCache::RemoveExpiredEntries()
+{
+    ACE_MT(ACE_GUARD(ACE_Recursive_Thread_Mutex, ace_mon, m_mutex));
+
+    ACE_Time_Value currTime = ACE_High_Res_Timer::gettimeofday();
+    MgResourceServiceCacheEntries::iterator i = m_resourceServiceCacheEntries.begin();
+
+    while (m_resourceServiceCacheEntries.end() != i)
+    {
+        if (NULL == i->second)
+        {
+            m_resourceServiceCacheEntries.erase(i++);
+        }
+        else
+        {
+            ACE_Time_Value idleTimeout = currTime - i->second->GetTimestamp();
+
+            if (idleTimeout > m_timeLimit) // entry has been expired
+            {
+                SAFE_RELEASE(i->second);
+                m_resourceServiceCacheEntries.erase(i++);
+            }
+            else
+            {
+                ++i;
+            }
+        }
+    }
+}
+
+///////////////////////////////////////////////////////////////////////////////
+/// \brief
+/// Methods to manage cache entries.
+///
+void MgResourceServiceCache::SetLayerDefinition(MgResourceIdentifier* resource, MgResourceLayerDefinitionCacheItem* layerDefinition)
+{
+    ACE_MT(ACE_GUARD(ACE_Recursive_Thread_Mutex, ace_mon, m_mutex));
+
+    Ptr<MgResourceServiceCacheEntry> entry = SetEntry(resource);
+
+    entry->SetLayerDefinition(layerDefinition);
+}
+
+MgResourceLayerDefinitionCacheItem* MgResourceServiceCache::GetLayerDefinition(MgResourceIdentifier* resource)
+{
+    ACE_MT(ACE_GUARD_RETURN(ACE_Recursive_Thread_Mutex, ace_mon, m_mutex, NULL));
+
+    Ptr<MgResourceLayerDefinitionCacheItem> data;
+    Ptr<MgResourceServiceCacheEntry> entry = GetEntry(resource);
+
+    if (NULL != entry.p)
+    {
+        data = entry->GetLayerDefinition();
+
+        // Make sure this cached data is only used by one thread at a time.
+        if (NULL != data.p && data->GetRefCount() > 2)
+        {
+            data = NULL;
+        }
+    }
+
+    return data.Detach();
+}
+
+///////////////////////////////////////////////////////////////////////////////
+/// \brief
+/// Returns the size of the cache.
+///
+INT32 MgResourceServiceCache::GetCacheSize()
+{
+    ACE_MT(ACE_GUARD_RETURN(ACE_Recursive_Thread_Mutex, ace_mon, m_mutex, -1));
+
+    INT32 size = (INT32)m_resourceServiceCacheEntries.size();
+    return size;
+}
+
+///////////////////////////////////////////////////////////////////////////////
+/// \brief
+/// Returns the # of dropped cache entries.
+///
+INT32 MgResourceServiceCache::GetDroppedEntriesCount()
+{
+    ACE_MT(ACE_GUARD_RETURN(ACE_Recursive_Thread_Mutex, ace_mon, m_mutex, -1));
+
+    return m_nDroppedEntries;
+}
+

Added: trunk/MgDev/Server/src/Common/Cache/ResourceServiceCache.h
===================================================================
--- trunk/MgDev/Server/src/Common/Cache/ResourceServiceCache.h	                        (rev 0)
+++ trunk/MgDev/Server/src/Common/Cache/ResourceServiceCache.h	2015-10-08 06:35:59 UTC (rev 8770)
@@ -0,0 +1,76 @@
+//
+//  Copyright (C) 2004-2015 by Autodesk, Inc.
+//
+//  This library is free software; you can redistribute it and/or
+//  modify it under the terms of version 2.1 of the GNU Lesser
+//  General Public License as published by the Free Software Foundation.
+//
+//  This library is distributed in the hope that it will be useful,
+//  but WITHOUT ANY WARRANTY; without even the implied warranty of
+//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+//  Lesser General Public License for more details.
+//
+//  You should have received a copy of the GNU Lesser General Public
+//  License along with this library; if not, write to the Free Software
+//  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+//
+
+#ifndef MG_RESOURCE_SERVICE_CACHE_H_
+#define MG_RESOURCE_SERVICE_CACHE_H_
+
+#include "ServerCache.h"
+#include "ResourceServiceCacheEntry.h"
+
+class MG_SERVER_CACHE_API MgResourceServiceCache : public MgServerCache
+{
+    DECLARE_CLASSNAME(MgResourceServiceCache)
+
+/// Constructors/Destructor
+
+public:
+    MgResourceServiceCache(void);
+    ~MgResourceServiceCache(void);
+
+private:
+
+    // Unimplemented copy constructor and assignment operator.
+    MgResourceServiceCache(const MgResourceServiceCache&);
+    MgResourceServiceCache& operator=(const MgResourceServiceCache&);
+
+/// Methods
+
+public:
+
+    virtual void Clear();
+
+    void RemoveEntry(CREFSTRING resource);
+    void RemoveEntry(MgResourceIdentifier* resource);
+    void RemoveExpiredEntries();
+
+    // gets/sets layer definitions
+    void SetLayerDefinition(MgResourceIdentifier* resource, MgResourceLayerDefinitionCacheItem* layerDefinition);
+    MgResourceLayerDefinitionCacheItem* GetLayerDefinition(MgResourceIdentifier* source);
+
+    INT32 GetCacheSize();
+    INT32 GetDroppedEntriesCount();
+
+protected:
+
+    void Compact();
+
+    MgResourceServiceCacheEntry* SetEntry(MgResourceIdentifier* resource);
+    MgResourceServiceCacheEntry* GetEntry(MgResourceIdentifier* resource);
+    void RemoveOldEntry();
+
+/// Data Members
+
+private:
+
+    friend class MgCacheManager;
+
+    typedef std::map<STRING, MgResourceServiceCacheEntry*> MgResourceServiceCacheEntries;
+    MgResourceServiceCacheEntries m_resourceServiceCacheEntries;
+    INT32 m_nDroppedEntries;
+};
+
+#endif

Added: trunk/MgDev/Server/src/Common/Cache/ResourceServiceCacheEntry.cpp
===================================================================
--- trunk/MgDev/Server/src/Common/Cache/ResourceServiceCacheEntry.cpp	                        (rev 0)
+++ trunk/MgDev/Server/src/Common/Cache/ResourceServiceCacheEntry.cpp	2015-10-08 06:35:59 UTC (rev 8770)
@@ -0,0 +1,53 @@
+//
+//  Copyright (C) 2004-2015 by Autodesk, Inc.
+//
+//  This library is free software; you can redistribute it and/or
+//  modify it under the terms of version 2.1 of the GNU Lesser
+//  General Public License as published by the Free Software Foundation.
+//
+//  This library is distributed in the hope that it will be useful,
+//  but WITHOUT ANY WARRANTY; without even the implied warranty of
+//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+//  Lesser General Public License for more details.
+//
+//  You should have received a copy of the GNU Lesser General Public
+//  License along with this library; if not, write to the Free Software
+//  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+//
+
+#include "MapGuideCommon.h"
+#include "ResourceServiceCacheEntry.h"
+
+#include <set>
+
+///////////////////////////////////////////////////////////////////////////////
+/// \brief
+/// Construct the object.
+///
+MgResourceServiceCacheEntry::MgResourceServiceCacheEntry()
+{
+}
+
+///////////////////////////////////////////////////////////////////////////////
+/// \brief
+/// Destruct the object.
+///
+MgResourceServiceCacheEntry::~MgResourceServiceCacheEntry()
+{
+
+}
+
+///////////////////////////////////////////////////////////////////////////////
+/// \brief
+/// Methods to manage cache items.
+///
+void MgResourceServiceCacheEntry::SetLayerDefinition(MgResourceLayerDefinitionCacheItem* layerDefinition)
+{
+    m_layerDefinition = SAFE_ADDREF(layerDefinition);
+}
+
+MgResourceLayerDefinitionCacheItem* MgResourceServiceCacheEntry::GetLayerDefinition()
+{
+    return SAFE_ADDREF(m_layerDefinition.p);
+}
+

Added: trunk/MgDev/Server/src/Common/Cache/ResourceServiceCacheEntry.h
===================================================================
--- trunk/MgDev/Server/src/Common/Cache/ResourceServiceCacheEntry.h	                        (rev 0)
+++ trunk/MgDev/Server/src/Common/Cache/ResourceServiceCacheEntry.h	2015-10-08 06:35:59 UTC (rev 8770)
@@ -0,0 +1,47 @@
+//
+//  Copyright (C) 2004-2015 by Autodesk, Inc.
+//
+//  This library is free software; you can redistribute it and/or
+//  modify it under the terms of version 2.1 of the GNU Lesser
+//  General Public License as published by the Free Software Foundation.
+//
+//  This library is distributed in the hope that it will be useful,
+//  but WITHOUT ANY WARRANTY; without even the implied warranty of
+//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+//  Lesser General Public License for more details.
+//
+//  You should have received a copy of the GNU Lesser General Public
+//  License along with this library; if not, write to the Free Software
+//  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+//
+
+#ifndef MG_RESOURCE_SERVICE_CACHE_ENTRY_H_
+#define MG_RESOURCE_SERVICE_CACHE_ENTRY_H_
+
+#include "ServerCacheEntry.h"
+#include "ResourceLayerDefinitionCacheItem.h"
+
+class MG_SERVER_CACHE_API MgResourceServiceCacheEntry : public MgServerCacheEntry
+{
+/// Constructors/Destructor
+public:
+    MgResourceServiceCacheEntry(void);
+    virtual ~MgResourceServiceCacheEntry(void);
+
+private:
+
+    // Unimplemented copy constructor and assignment operator.
+    MgResourceServiceCacheEntry(const MgResourceServiceCacheEntry&);
+    MgResourceServiceCacheEntry& operator=(const MgResourceServiceCacheEntry&);
+
+/// Methods
+
+public:
+    void SetLayerDefinition(MgResourceLayerDefinitionCacheItem* layerDefinition);
+    MgResourceLayerDefinitionCacheItem* GetLayerDefinition();
+
+private:
+    Ptr<MgResourceLayerDefinitionCacheItem> m_layerDefinition;
+};
+
+#endif

Modified: trunk/MgDev/Server/src/Common/Cache/ServerCache.vcxproj
===================================================================
--- trunk/MgDev/Server/src/Common/Cache/ServerCache.vcxproj	2015-10-03 05:45:30 UTC (rev 8769)
+++ trunk/MgDev/Server/src/Common/Cache/ServerCache.vcxproj	2015-10-08 06:35:59 UTC (rev 8770)
@@ -224,6 +224,24 @@
       <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
       <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
     </ClCompile>
+    <ClCompile Include="ResourceLayerDefinitionCacheItem.cpp">
+      <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
+      <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
+      <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
+      <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
+    </ClCompile>
+    <ClCompile Include="ResourceServiceCache.cpp">
+      <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
+      <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
+      <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
+      <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
+    </ClCompile>
+    <ClCompile Include="ResourceServiceCacheEntry.cpp">
+      <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
+      <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
+      <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
+      <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
+    </ClCompile>
     <ClCompile Include="ServerCache.cpp">
       <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
       <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
@@ -256,6 +274,9 @@
     <ClInclude Include="FeatureServiceCache.h" />
     <ClInclude Include="FeatureServiceCacheEntry.h" />
     <ClInclude Include="FeatureSourceCacheItem.h" />
+    <ClInclude Include="ResourceLayerDefinitionCacheItem.h" />
+    <ClInclude Include="ResourceServiceCache.h" />
+    <ClInclude Include="ResourceServiceCacheEntry.h" />
     <ClInclude Include="ServerCache.h" />
     <ClInclude Include="ServerCacheDllExport.h" />
     <ClInclude Include="ServerCacheEntry.h" />

Modified: trunk/MgDev/Server/src/Common/Cache/ServerCacheBuild.cpp
===================================================================
--- trunk/MgDev/Server/src/Common/Cache/ServerCacheBuild.cpp	2015-10-03 05:45:30 UTC (rev 8769)
+++ trunk/MgDev/Server/src/Common/Cache/ServerCacheBuild.cpp	2015-10-08 06:35:59 UTC (rev 8770)
@@ -24,3 +24,6 @@
 #include "FeatureServiceCacheEntry.cpp"
 #include "FeatureSourceCacheItem.cpp"
 #include "SpatialContextCacheItem.cpp"
+#include "ResourceServiceCache.cpp"
+#include "ResourceServiceCacheEntry.cpp"
+#include "ResourceLayerDefinitionCacheItem.cpp"

Modified: trunk/MgDev/Server/src/Common/Manager/CacheManager.cpp
===================================================================
--- trunk/MgDev/Server/src/Common/Manager/CacheManager.cpp	2015-10-03 05:45:30 UTC (rev 8769)
+++ trunk/MgDev/Server/src/Common/Manager/CacheManager.cpp	2015-10-08 06:35:59 UTC (rev 8770)
@@ -108,6 +108,21 @@
         MgConfigProperties::DefaultFeatureServicePropertyCacheTimeLimit);
 
     m_featureServiceCache.Initialize(cacheSize, cacheTimeLimit);
+
+    // Initialize resource service cache
+    configuration->GetIntValue(
+        MgConfigProperties::ResourceServicePropertiesSection,
+        MgConfigProperties::ResourceServicePropertyCacheSize,
+        cacheSize,
+        MgConfigProperties::DefaultResourceServicePropertyCacheSize);
+
+    configuration->GetIntValue(
+        MgConfigProperties::ResourceServicePropertiesSection,
+        MgConfigProperties::ResourceServicePropertyCacheTimeLimit,
+        cacheTimeLimit,
+        MgConfigProperties::DefaultResourceServicePropertyCacheTimeLimit);
+
+    m_resourceServiceCache.Initialize(cacheSize, cacheTimeLimit);
 }
 
 ///////////////////////////////////////////////////////////////////////////////
@@ -124,6 +139,7 @@
 
         m_fdoConnectionManager->ClearCache();
         m_featureServiceCache.Clear();
+        m_resourceServiceCache.Clear();
     }
 }
 
@@ -168,6 +184,11 @@
             m_featureServiceCache.RemoveEntry(resource);
         }
     }
+    if (STRING::npos != resource.rfind(MgResourceType::LayerDefinition))
+    {
+        ACE_MT(ACE_GUARD(ACE_Recursive_Thread_Mutex, ace_mon, m_resourceServiceCache.m_mutex));
+        m_resourceServiceCache.RemoveEntry(resource);
+    }
 }
 
 ///////////////////////////////////////////////////////////////////////////////
@@ -176,17 +197,25 @@
 ///
 void MgCacheManager::NotifyResourceChanged(MgResourceIdentifier* resource)
 {
-    if (NULL != resource && resource->IsResourceTypeOf(MgResourceType::FeatureSource))
+    if (NULL != resource)
     {
-        // The mutex usage and the method call order here are important
-        // because they ensure all the caches are in sync.
-       ACE_MT(ACE_GUARD(ACE_Recursive_Thread_Mutex, ace_mon, m_fdoConnectionManager->sm_mutex));
+        if (resource->IsResourceTypeOf(MgResourceType::FeatureSource))
         {
-            ACE_MT(ACE_GUARD(ACE_Recursive_Thread_Mutex, ace_mon, m_featureServiceCache.m_mutex));
+            // The mutex usage and the method call order here are important
+            // because they ensure all the caches are in sync.
+            ACE_MT(ACE_GUARD(ACE_Recursive_Thread_Mutex, ace_mon, m_fdoConnectionManager->sm_mutex));
+            {
+                ACE_MT(ACE_GUARD(ACE_Recursive_Thread_Mutex, ace_mon, m_featureServiceCache.m_mutex));
 
-            m_fdoConnectionManager->RemoveCachedFdoConnection(resource);
-            m_featureServiceCache.RemoveEntry(resource);
+                m_fdoConnectionManager->RemoveCachedFdoConnection(resource);
+                m_featureServiceCache.RemoveEntry(resource);
+            }
         }
+        else if (resource->IsResourceTypeOf(MgResourceType::LayerDefinition))
+        {
+            ACE_MT(ACE_GUARD(ACE_Recursive_Thread_Mutex, ace_mon, m_resourceServiceCache.m_mutex));
+            m_resourceServiceCache.RemoveEntry(resource);
+        }
     }
 }
 
@@ -367,3 +396,49 @@
 
     return notificationNeeded;
 }
+
+MgResourceLayerDefinitionCacheItem* MgCacheManager::GetResourceLayerDefinitionCacheItem(MgResourceIdentifier* resource)
+{
+    Ptr<MgResourceLayerDefinitionCacheItem> cacheItem;
+
+    MG_TRY()
+
+    cacheItem = m_resourceServiceCache.GetLayerDefinition(resource);
+
+    if (NULL == cacheItem.p)
+    {
+        // Get the Resource Service.
+        Ptr<MgResourceService> resourceService = dynamic_cast<MgResourceService*>(
+            m_serviceManager->RequestService(MgServiceType::ResourceService));
+        ACE_ASSERT(NULL != resourceService.p);
+
+        auto_ptr<MdfModel::LayerDefinition> layerDefinition;
+        layerDefinition.reset(MgLayerBase::GetLayerDefinition(resourceService, resource));
+
+        if (NULL == layerDefinition.get())
+        {
+            MgResources* resources = MgResources::GetInstance();
+            ACE_ASSERT(NULL != resources);
+            STRING message = resources->GetResourceMessage(MgResources::ResourceService,
+                L"MgInvalidLayerDefinition", NULL);
+            MgStringCollection arguments;
+            arguments.Add(message);
+
+            throw new MgInvalidFeatureSourceException(
+                L"MgCacheManager.GetResourceLayerDefinitionCacheItem",
+                __LINE__, __WFILE__, &arguments, L"", NULL);
+        }
+
+        cacheItem = new MgResourceLayerDefinitionCacheItem(layerDefinition.release());
+        m_resourceServiceCache.SetLayerDefinition(resource, cacheItem.p);
+    }
+    else
+    {
+        CheckPermission(resource, MgResourcePermission::ReadOnly);
+    }
+
+    MG_CATCH_AND_THROW(L"MgCacheManager.GetResourceLayerDefinitionCacheItem")
+
+    return cacheItem.Detach();
+}
+

Modified: trunk/MgDev/Server/src/Common/Manager/CacheManager.h
===================================================================
--- trunk/MgDev/Server/src/Common/Manager/CacheManager.h	2015-10-03 05:45:30 UTC (rev 8769)
+++ trunk/MgDev/Server/src/Common/Manager/CacheManager.h	2015-10-08 06:35:59 UTC (rev 8770)
@@ -20,6 +20,7 @@
 
 #include "ServerManager.h"
 #include "FeatureServiceCache.h"
+#include "ResourceServiceCache.h"
 
 class MgServiceManager;
 class MgFdoConnectionManager;
@@ -62,6 +63,9 @@
     MgFeatureSourceCacheItem* GetFeatureSourceCacheItem(MgResourceIdentifier* resource);
     MgSpatialContextCacheItem* GetSpatialContextCacheItem(MgResourceIdentifier* resource);
 
+    MgResourceServiceCache* GetResourceServiceCache();
+    MgResourceLayerDefinitionCacheItem* GetResourceLayerDefinitionCacheItem(MgResourceIdentifier* resource);
+
     bool IsResourceChangeNotificationNeeded(MgResourceIdentifier* resource);
 
 /// Data Members
@@ -74,6 +78,7 @@
     MgFdoConnectionManager* m_fdoConnectionManager;
 
     MgFeatureServiceCache m_featureServiceCache;
+    MgResourceServiceCache m_resourceServiceCache;
 };
 
 /// Inline Methods
@@ -83,4 +88,9 @@
     return &m_featureServiceCache;
 }
 
+inline MgResourceServiceCache* MgCacheManager::GetResourceServiceCache()
+{
+    return &m_resourceServiceCache;
+}
+
 #endif

Modified: trunk/MgDev/Server/src/Common/Manager/FdoConnectionManager.cpp
===================================================================
--- trunk/MgDev/Server/src/Common/Manager/FdoConnectionManager.cpp	2015-10-03 05:45:30 UTC (rev 8769)
+++ trunk/MgDev/Server/src/Common/Manager/FdoConnectionManager.cpp	2015-10-08 06:35:59 UTC (rev 8770)
@@ -735,7 +735,7 @@
                             {
                                 // We have a long transaction name match
                                 INT32 useLimit = providerInfo->GetUseLimit();
-                                if (useLimit == -1 || pFdoConnectionCacheEntry->nUseTotal <= useLimit)
+                                if (useLimit == -1 || pFdoConnectionCacheEntry->nUseCount <= useLimit)
                                 {
                                     // If the provider is a PerCommandThreaded/MultiThreaded provider, reuse existing 
                                     // connection only when reuseOnly is true (current connections count == pool size). 

Modified: trunk/MgDev/Server/src/Core/EventTimer.h
===================================================================
--- trunk/MgDev/Server/src/Core/EventTimer.h	2015-10-03 05:45:30 UTC (rev 8769)
+++ trunk/MgDev/Server/src/Core/EventTimer.h	2015-10-08 06:35:59 UTC (rev 8770)
@@ -39,6 +39,7 @@
         FeatureServiceCacheTimeLimit        = 6,
         DataTransactionTimeout              = 7,
         PerformanceLogging                  = 8,
+        ResourceServiceCacheTimeLimit       = 9,
     };
 
 /// Constructors/Destructor

Modified: trunk/MgDev/Server/src/Core/Makefile.am
===================================================================
--- trunk/MgDev/Server/src/Core/Makefile.am	2015-10-03 05:45:30 UTC (rev 8769)
+++ trunk/MgDev/Server/src/Core/Makefile.am	2015-10-08 06:35:59 UTC (rev 8770)
@@ -60,6 +60,7 @@
   PerformanceLoggingEventHandler.cpp \
   RepositoryCheckpointEventHandler.cpp \
   ResourceChangeEventHandler.cpp \
+  ResourceServiceCacheTimeLimitEventHandler.cpp \
   Server.cpp \
   ServerFactory.cpp \
   ServiceHandlerFactory.cpp \
@@ -81,6 +82,7 @@
   PerformanceLoggingEventHandler.h \
   RepositoryCheckpointEventHandler.h \
   ResourceChangeEventHandler.h \
+  ResourceServiceCacheTimeLimitEventHandler.h \
   Server.h \
   ServiceHandlerFactory.h \
   ServiceRegistrationEventHandler.h \

Added: trunk/MgDev/Server/src/Core/ResourceServiceCacheTimeLimitEventHandler.cpp
===================================================================
--- trunk/MgDev/Server/src/Core/ResourceServiceCacheTimeLimitEventHandler.cpp	                        (rev 0)
+++ trunk/MgDev/Server/src/Core/ResourceServiceCacheTimeLimitEventHandler.cpp	2015-10-08 06:35:59 UTC (rev 8770)
@@ -0,0 +1,87 @@
+//
+//  Copyright (C) 2004-2011 by Autodesk, Inc.
+//
+//  This library is free software; you can redistribute it and/or
+//  modify it under the terms of version 2.1 of the GNU Lesser
+//  General Public License as published by the Free Software Foundation.
+//
+//  This library is distributed in the hope that it will be useful,
+//  but WITHOUT ANY WARRANTY; without even the implied warranty of
+//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+//  Lesser General Public License for more details.
+//
+//  You should have received a copy of the GNU Lesser General Public
+//  License along with this library; if not, write to the Free Software
+//  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+//
+
+#include "MapGuideCommon.h"
+#include "ResourceServiceCacheTimeLimitEventHandler.h"
+#include "CacheManager.h"
+
+///////////////////////////////////////////////////////////////////////////////
+/// \brief
+/// Constructs the object.
+///
+MgResourceServiceCacheTimeLimitEventHandler::MgResourceServiceCacheTimeLimitEventHandler(MgEventTimer& timer) :
+    MgTimedEventHandler(timer)
+{
+    MgConfiguration* configuration = MgConfiguration::GetInstance();
+    ACE_ASSERT(NULL != configuration);
+    INT32 timeout = MgConfigProperties::DefaultResourceServicePropertyCacheTimeLimit;
+    INT32 interval = MgConfigProperties::DefaultResourceServicePropertyCacheTimerInterval;
+
+    if (NULL != configuration)
+    {
+        configuration->GetIntValue(
+            MgConfigProperties::ResourceServicePropertiesSection,
+            MgConfigProperties::ResourceServicePropertyCacheTimeLimit,
+            timeout,
+            MgConfigProperties::DefaultResourceServicePropertyCacheTimeLimit);
+
+        configuration->GetIntValue(
+            MgConfigProperties::ResourceServicePropertiesSection,
+            MgConfigProperties::ResourceServicePropertyCacheTimerInterval,
+            interval,
+            MgConfigProperties::DefaultResourceServicePropertyCacheTimerInterval);
+    }
+
+    m_timer.SetInterval(interval);
+    m_event.SetTimeout(timeout);
+    m_event.SetId(MgTimedEvent::ResourceServiceCacheTimeLimit);
+}
+
+///////////////////////////////////////////////////////////////////////////////
+/// \brief
+/// Destructs the object.
+///
+MgResourceServiceCacheTimeLimitEventHandler::~MgResourceServiceCacheTimeLimitEventHandler()
+{
+}
+
+///////////////////////////////////////////////////////////////////////////////
+/// \brief
+/// Handles the specified event.
+///
+void MgResourceServiceCacheTimeLimitEventHandler::HandleEvent(long eventId)
+{
+    MG_TRY()
+
+    //ACE_DEBUG((LM_DEBUG, ACE_TEXT("Expired Resource Service cache entries handled by thread %t\n")));
+
+    // Clean up resource service cache.
+    if (MgTimedEvent::ResourceServiceCacheTimeLimit == eventId)
+    {
+        Ptr<MgUserInformation> userInfo = new MgUserInformation(
+            MgUser::Administrator, L"");
+
+        MgUserInformation::SetCurrentUserInfo(userInfo);
+
+        MgResourceServiceCache* resourceServiceCache = MgCacheManager::GetInstance()->GetResourceServiceCache();
+        resourceServiceCache->RemoveExpiredEntries();
+
+        MgUserInformation::SetCurrentUserInfo(NULL);
+    }
+
+    MG_CATCH_AND_THROW(L"MgResourceServiceCacheTimeLimitEventHandler.HandleEvent")
+}

Added: trunk/MgDev/Server/src/Core/ResourceServiceCacheTimeLimitEventHandler.h
===================================================================
--- trunk/MgDev/Server/src/Core/ResourceServiceCacheTimeLimitEventHandler.h	                        (rev 0)
+++ trunk/MgDev/Server/src/Core/ResourceServiceCacheTimeLimitEventHandler.h	2015-10-08 06:35:59 UTC (rev 8770)
@@ -0,0 +1,58 @@
+//
+//  Copyright (C) 2004-2015 by Autodesk, Inc.
+//
+//  This library is free software; you can redistribute it and/or
+//  modify it under the terms of version 2.1 of the GNU Lesser
+//  General Public License as published by the Free Software Foundation.
+//
+//  This library is distributed in the hope that it will be useful,
+//  but WITHOUT ANY WARRANTY; without even the implied warranty of
+//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+//  Lesser General Public License for more details.
+//
+//  You should have received a copy of the GNU Lesser General Public
+//  License along with this library; if not, write to the Free Software
+//  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+//
+
+#ifndef MG_RESOURCE_SERVICE_CACHE_TIMEOUT_EVENT_HANDLER_H_
+#define MG_RESOURCE_SERVICE_CACHE_TIMEOUT_EVENT_HANDLER_H_
+
+#include "TimedEventHandler.h"
+
+///////////////////////////////////////////////////////////////////////////////
+/// \brief
+/// Derived Event Handler class to clean up inactive resource service cache items.
+///
+class MgResourceServiceCacheTimeLimitEventHandler : public MgTimedEventHandler
+{
+/// Constructors/Destructor
+
+public:
+
+    MgResourceServiceCacheTimeLimitEventHandler(MgEventTimer& timer);
+    virtual ~MgResourceServiceCacheTimeLimitEventHandler();
+
+private:
+
+    // Unimplemented Constructors/Methods
+
+    MgResourceServiceCacheTimeLimitEventHandler();
+    MgResourceServiceCacheTimeLimitEventHandler(const MgResourceServiceCacheTimeLimitEventHandler&);
+    MgResourceServiceCacheTimeLimitEventHandler& operator=(const MgResourceServiceCacheTimeLimitEventHandler&);
+
+/// Methods
+
+protected:
+
+    virtual void HandleEvent(long eventId);
+
+/// Data Members
+
+private:
+
+};
+
+/// Inline Methods
+
+#endif

Modified: trunk/MgDev/Server/src/Core/ServerCore.vcxproj
===================================================================
--- trunk/MgDev/Server/src/Core/ServerCore.vcxproj	2015-10-03 05:45:30 UTC (rev 8769)
+++ trunk/MgDev/Server/src/Core/ServerCore.vcxproj	2015-10-08 06:35:59 UTC (rev 8770)
@@ -267,6 +267,12 @@
       <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
       <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
     </ClCompile>
+    <ClCompile Include="ResourceServiceCacheTimeLimitEventHandler.cpp">
+      <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
+      <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
+      <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
+      <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
+    </ClCompile>
     <ClCompile Include="ServiceRegistrationEventHandler.cpp">
       <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
       <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
@@ -345,6 +351,7 @@
     <ClInclude Include="PerformanceLoggingEventHandler.h" />
     <ClInclude Include="RepositoryCheckpointEventHandler.h" />
     <ClInclude Include="ResourceChangeEventHandler.h" />
+    <ClInclude Include="ResourceServiceCacheTimeLimitEventHandler.h" />
     <ClInclude Include="ServiceRegistrationEventHandler.h" />
     <ClInclude Include="SessionTimeoutEventHandler.h" />
     <ClInclude Include="TimedEvent.h" />

Modified: trunk/MgDev/Server/src/Core/ServerCore.vcxproj.filters
===================================================================
--- trunk/MgDev/Server/src/Core/ServerCore.vcxproj.filters	2015-10-03 05:45:30 UTC (rev 8769)
+++ trunk/MgDev/Server/src/Core/ServerCore.vcxproj.filters	2015-10-08 06:35:59 UTC (rev 8770)
@@ -53,6 +53,9 @@
     <ClCompile Include="ServerFactory.cpp" />
     <ClCompile Include="ServiceHandlerFactory.cpp" />
     <ClCompile Include="SignalHandler.cpp" />
+    <ClCompile Include="ResourceServiceCacheTimeLimitEventHandler.cpp">
+      <Filter>TimedEventHandlers</Filter>
+    </ClCompile>
   </ItemGroup>
   <ItemGroup>
     <ClInclude Include="ConnectionTimeoutEventHandler.h">
@@ -99,6 +102,9 @@
     <ClInclude Include="Server.h" />
     <ClInclude Include="ServiceHandlerFactory.h" />
     <ClInclude Include="SignalHandler.h" />
+    <ClInclude Include="ResourceServiceCacheTimeLimitEventHandler.h">
+      <Filter>TimedEventHandlers</Filter>
+    </ClInclude>
   </ItemGroup>
   <ItemGroup>
     <ResourceCompile Include="ServerCore.rc" />

Modified: trunk/MgDev/Server/src/Core/ServerCoreBuild.cpp
===================================================================
--- trunk/MgDev/Server/src/Core/ServerCoreBuild.cpp	2015-10-03 05:45:30 UTC (rev 8769)
+++ trunk/MgDev/Server/src/Core/ServerCoreBuild.cpp	2015-10-08 06:35:59 UTC (rev 8770)
@@ -27,6 +27,7 @@
 #include "PerformanceLoggingEventHandler.cpp"
 #include "RepositoryCheckpointEventHandler.cpp"
 #include "ResourceChangeEventHandler.cpp"
+#include "ResourceServiceCacheTimeLimitEventHandler.cpp"
 #include "Server.cpp"
 #include "ServiceHandlerFactory.cpp"
 #include "ServiceRegistrationEventHandler.cpp"

Modified: trunk/MgDev/Server/src/Core/TimedEvent.h
===================================================================
--- trunk/MgDev/Server/src/Core/TimedEvent.h	2015-10-03 05:45:30 UTC (rev 8769)
+++ trunk/MgDev/Server/src/Core/TimedEvent.h	2015-10-08 06:35:59 UTC (rev 8770)
@@ -35,6 +35,7 @@
         FeatureServiceCacheTimeLimit        = 70,
         DataTransactionTimeout              = 80,
         PerformanceLogging                  = 90,
+        ResourceServiceCacheTimeLimit       = 100,
     };
 
 /// Constructors/Destructor

Modified: trunk/MgDev/Server/src/Core/TimedEventHandler.cpp
===================================================================
--- trunk/MgDev/Server/src/Core/TimedEventHandler.cpp	2015-10-03 05:45:30 UTC (rev 8769)
+++ trunk/MgDev/Server/src/Core/TimedEventHandler.cpp	2015-10-08 06:35:59 UTC (rev 8770)
@@ -90,6 +90,10 @@
             eventHandler.reset(new MgPerformanceLoggingEventHandler(timer));
             break;
 
+        case MgEventTimer::ResourceServiceCacheTimeLimit:
+            eventHandler.reset(new MgResourceServiceCacheTimeLimitEventHandler(timer));
+            break;
+
         default:
             throw new MgInvalidArgumentException(
                 L"MgTimedEventHandler.Create", __LINE__, __WFILE__, NULL, L"", NULL);

Modified: trunk/MgDev/Server/src/Services/Mapping/Makefile.am
===================================================================
--- trunk/MgDev/Server/src/Services/Mapping/Makefile.am	2015-10-03 05:45:30 UTC (rev 8769)
+++ trunk/MgDev/Server/src/Services/Mapping/Makefile.am	2015-10-08 06:35:59 UTC (rev 8770)
@@ -11,6 +11,7 @@
   -I../../Common \
   -I../../Common/Base \
   -I../../Common/Manager \
+  -I../../Common/Cache \
   -I../../../../Common/MdfModel \
   -I../../../../Common/MdfParser \
   -I$(map_fdo_include) \

Modified: trunk/MgDev/Server/src/Services/Mapping/MappingUtil.cpp
===================================================================
--- trunk/MgDev/Server/src/Services/Mapping/MappingUtil.cpp	2015-10-03 05:45:30 UTC (rev 8769)
+++ trunk/MgDev/Server/src/Services/Mapping/MappingUtil.cpp	2015-10-08 06:35:59 UTC (rev 8770)
@@ -31,6 +31,7 @@
 #include "SymbolVisitor.h"
 #include "SymbolDefinition.h"
 #include "TransformCache.h"
+#include "CacheManager.h"
 
 #include <algorithm>
 
@@ -383,7 +384,6 @@
     // Get the layers' resource content in a single request by adding them to a collection
     for (int i = layers->GetCount()-1; i >= 0; i--)
     {
-        auto_ptr<MdfModel::LayerDefinition> ldf;
         RSMgFeatureReader* rsReader = NULL;
 
         Ptr<MgLayerBase> mapLayer = layers->GetItem(i);
@@ -433,7 +433,9 @@
 
             //get layer definition
             Ptr<MgResourceIdentifier> layerid = mapLayer->GetLayerDefinition();
-            ldf.reset(MgLayerBase::GetLayerDefinition(svcResource, layerid));
+            MgCacheManager* cacheManager = MgCacheManager::GetInstance();
+            Ptr<MgResourceLayerDefinitionCacheItem> cacheItem = cacheManager->GetResourceLayerDefinitionCacheItem(layerid);
+            MdfModel::LayerDefinition* layerDefinition = cacheItem->Get();
 
             Ptr<MgLayerGroup> group = mapLayer->GetGroup();
 
@@ -463,9 +465,9 @@
                                      -mapLayer->GetDisplayOrder(),
                                       uig);
 
-            MdfModel::VectorLayerDefinition* vl = dynamic_cast<MdfModel::VectorLayerDefinition*>(ldf.get());
-            MdfModel::DrawingLayerDefinition* dl = dynamic_cast<MdfModel::DrawingLayerDefinition*>(ldf.get());
-            MdfModel::GridLayerDefinition* gl = dynamic_cast<MdfModel::GridLayerDefinition*>(ldf.get());
+            MdfModel::VectorLayerDefinition* vl = dynamic_cast<MdfModel::VectorLayerDefinition*>(layerDefinition);
+            MdfModel::DrawingLayerDefinition* dl = dynamic_cast<MdfModel::DrawingLayerDefinition*>(layerDefinition);
+            MdfModel::GridLayerDefinition* gl = dynamic_cast<MdfModel::GridLayerDefinition*>(layerDefinition);
 
             if (vl) //############################################################################ vector layer
             {

Modified: trunk/MgDev/Server/src/Services/Mapping/ServerMappingService.vcxproj
===================================================================
--- trunk/MgDev/Server/src/Services/Mapping/ServerMappingService.vcxproj	2015-10-03 05:45:30 UTC (rev 8769)
+++ trunk/MgDev/Server/src/Services/Mapping/ServerMappingService.vcxproj	2015-10-08 06:35:59 UTC (rev 8770)
@@ -94,7 +94,7 @@
   <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
     <ClCompile>
       <Optimization>Disabled</Optimization>
-      <AdditionalIncludeDirectories>..\..\Common;..\..\Common\Base;..\..\Common\Manager;..\Feature;..\..\..\..\Common\Foundation;..\..\..\..\Common\Geometry;..\..\..\..\Common\PlatformBase;..\..\..\..\Common\MapGuideCommon;..\..\..\..\Common\MdfModel;..\..\..\..\Common\MdfParser;..\..\..\..\Common\Renderers;..\..\..\..\Common\Stylization;..\..\..\..\Oem\ACE\ACE_wrappers;..\..\..\..\Oem\dbxml\xerces-c-src\src;..\..\..\..\Oem\FDO\inc;..\..\..\..\Oem\FDO\inc\ExpressionEngine;..\..\Gws\Include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+      <AdditionalIncludeDirectories>..\..\Common;..\..\Common\Base;..\..\Common\Cache;..\..\Common\Manager;..\Feature;..\..\..\..\Common\Foundation;..\..\..\..\Common\Geometry;..\..\..\..\Common\PlatformBase;..\..\..\..\Common\MapGuideCommon;..\..\..\..\Common\MdfModel;..\..\..\..\Common\MdfParser;..\..\..\..\Common\Renderers;..\..\..\..\Common\Stylization;..\..\..\..\Oem\ACE\ACE_wrappers;..\..\..\..\Oem\dbxml\xerces-c-src\src;..\..\..\..\Oem\FDO\inc;..\..\..\..\Oem\FDO\inc\ExpressionEngine;..\..\Gws\Include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
       <PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;_USRDLL;MG_SERVER_MAPPING_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
       <ExceptionHandling>Async</ExceptionHandling>
       <BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
@@ -121,7 +121,7 @@
   <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
     <ClCompile>
       <Optimization>Disabled</Optimization>
-      <AdditionalIncludeDirectories>..\..\Common;..\..\Common\Base;..\..\Common\Manager;..\Feature;..\..\..\..\Common\Foundation;..\..\..\..\Common\Geometry;..\..\..\..\Common\PlatformBase;..\..\..\..\Common\MapGuideCommon;..\..\..\..\Common\MdfModel;..\..\..\..\Common\MdfParser;..\..\..\..\Common\Renderers;..\..\..\..\Common\Stylization;..\..\..\..\Oem\ACE\ACE_wrappers;..\..\..\..\Oem\dbxml\xerces-c-src\src;..\..\..\..\Oem\FDO\inc;..\..\..\..\Oem\FDO\inc\ExpressionEngine;..\..\Gws\Include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+      <AdditionalIncludeDirectories>..\..\Common;..\..\Common\Base;..\..\Common\Cache;..\..\Common\Manager;..\Feature;..\..\..\..\Common\Foundation;..\..\..\..\Common\Geometry;..\..\..\..\Common\PlatformBase;..\..\..\..\Common\MapGuideCommon;..\..\..\..\Common\MdfModel;..\..\..\..\Common\MdfParser;..\..\..\..\Common\Renderers;..\..\..\..\Common\Stylization;..\..\..\..\Oem\ACE\ACE_wrappers;..\..\..\..\Oem\dbxml\xerces-c-src\src;..\..\..\..\Oem\FDO\inc;..\..\..\..\Oem\FDO\inc\ExpressionEngine;..\..\Gws\Include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
       <PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;_USRDLL;MG_SERVER_MAPPING_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
       <ExceptionHandling>Async</ExceptionHandling>
       <BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
@@ -148,7 +148,7 @@
   <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
     <ClCompile>
       <Optimization>MaxSpeed</Optimization>
-      <AdditionalIncludeDirectories>..\..\Common;..\..\Common\Base;..\..\Common\Manager;..\Feature;..\..\..\..\Common\Foundation;..\..\..\..\Common\Geometry;..\..\..\..\Common\PlatformBase;..\..\..\..\Common\MapGuideCommon;..\..\..\..\Common\MdfModel;..\..\..\..\Common\MdfParser;..\..\..\..\Common\Renderers;..\..\..\..\Common\Stylization;..\..\..\..\Oem\ACE\ACE_wrappers;..\..\..\..\Oem\dbxml\xerces-c-src\src;..\..\..\..\Oem\FDO\inc;..\..\..\..\Oem\FDO\inc\ExpressionEngine;..\..\Gws\Include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+      <AdditionalIncludeDirectories>..\..\Common;..\..\Common\Base;..\..\Common\Cache;..\..\Common\Manager;..\Feature;..\..\..\..\Common\Foundation;..\..\..\..\Common\Geometry;..\..\..\..\Common\PlatformBase;..\..\..\..\Common\MapGuideCommon;..\..\..\..\Common\MdfModel;..\..\..\..\Common\MdfParser;..\..\..\..\Common\Renderers;..\..\..\..\Common\Stylization;..\..\..\..\Oem\ACE\ACE_wrappers;..\..\..\..\Oem\dbxml\xerces-c-src\src;..\..\..\..\Oem\FDO\inc;..\..\..\..\Oem\FDO\inc\ExpressionEngine;..\..\Gws\Include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
       <PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;_USRDLL;MG_SERVER_MAPPING_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
       <ExceptionHandling>Async</ExceptionHandling>
       <RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
@@ -176,7 +176,7 @@
   <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
     <ClCompile>
       <Optimization>MaxSpeed</Optimization>
-      <AdditionalIncludeDirectories>..\..\Common;..\..\Common\Base;..\..\Common\Manager;..\Feature;..\..\..\..\Common\Foundation;..\..\..\..\Common\Geometry;..\..\..\..\Common\PlatformBase;..\..\..\..\Common\MapGuideCommon;..\..\..\..\Common\MdfModel;..\..\..\..\Common\MdfParser;..\..\..\..\Common\Renderers;..\..\..\..\Common\Stylization;..\..\..\..\Oem\ACE\ACE_wrappers;..\..\..\..\Oem\dbxml\xerces-c-src\src;..\..\..\..\Oem\FDO\inc;..\..\..\..\Oem\FDO\inc\ExpressionEngine;..\..\Gws\Include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+      <AdditionalIncludeDirectories>..\..\Common;..\..\Common\Base;..\..\Common\Cache;..\..\Common\Manager;..\Feature;..\..\..\..\Common\Foundation;..\..\..\..\Common\Geometry;..\..\..\..\Common\PlatformBase;..\..\..\..\Common\MapGuideCommon;..\..\..\..\Common\MdfModel;..\..\..\..\Common\MdfParser;..\..\..\..\Common\Renderers;..\..\..\..\Common\Stylization;..\..\..\..\Oem\ACE\ACE_wrappers;..\..\..\..\Oem\dbxml\xerces-c-src\src;..\..\..\..\Oem\FDO\inc;..\..\..\..\Oem\FDO\inc\ExpressionEngine;..\..\Gws\Include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
       <PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;_USRDLL;MG_SERVER_MAPPING_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
       <ExceptionHandling>Async</ExceptionHandling>
       <RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
@@ -382,6 +382,14 @@
       <Project>{a4f7f6b2-0e74-4dfd-b283-c7e380bd6f58}</Project>
       <ReferenceOutputAssembly>false</ReferenceOutputAssembly>
     </ProjectReference>
+    <ProjectReference Include="..\..\Common\Cache\ServerCache.vcxproj">
+      <Project>{531778c6-c340-40f2-b403-9b58b8121aab}</Project>
+      <Private>false</Private>
+      <ReferenceOutputAssembly>false</ReferenceOutputAssembly>
+      <CopyLocalSatelliteAssemblies>false</CopyLocalSatelliteAssemblies>
+      <LinkLibraryDependencies>true</LinkLibraryDependencies>
+      <UseLibraryDependencyInputs>false</UseLibraryDependencyInputs>
+    </ProjectReference>
     <ProjectReference Include="..\..\Common\Manager\ServerManager.vcxproj">
       <Project>{adbf25e2-c629-4832-b315-f12abde05632}</Project>
       <ReferenceOutputAssembly>false</ReferenceOutputAssembly>

Modified: trunk/MgDev/Server/src/Services/Rendering/Makefile.am
===================================================================
--- trunk/MgDev/Server/src/Services/Rendering/Makefile.am	2015-10-03 05:45:30 UTC (rev 8769)
+++ trunk/MgDev/Server/src/Services/Rendering/Makefile.am	2015-10-08 06:35:59 UTC (rev 8770)
@@ -15,6 +15,7 @@
   -I../../../../Common/MapGuideCommon \
   -I../../Common \
   -I../../Common/Base \
+  -I../../Common/Cache \
   -I../../Common/Manager \
   -I../../../../Common/MdfModel \
   -I../../../../Common/Stylization \

Modified: trunk/MgDev/Server/src/Services/Rendering/ServerRenderingService.cpp
===================================================================
--- trunk/MgDev/Server/src/Services/Rendering/ServerRenderingService.cpp	2015-10-03 05:45:30 UTC (rev 8769)
+++ trunk/MgDev/Server/src/Services/Rendering/ServerRenderingService.cpp	2015-10-08 06:35:59 UTC (rev 8770)
@@ -28,6 +28,7 @@
 #include "MappingUtil.h"
 #include "LegendPlotUtil.h"
 #include "TransformCache.h"
+#include "CacheManager.h"
 #include "Box2D.h"
 #include <cmath>
 
@@ -1575,9 +1576,12 @@
 
         //get the MDF layer definition
         Ptr<MgResourceIdentifier> layerResId = layer->GetLayerDefinition();
-        auto_ptr<MdfModel::LayerDefinition> ldf(MgLayerBase::GetLayerDefinition(m_svcResource, layerResId));
-        MdfModel::VectorLayerDefinition* vl = dynamic_cast<MdfModel::VectorLayerDefinition*>(ldf.get());
+        MgCacheManager* cacheManager = MgCacheManager::GetInstance();
+        Ptr<MgResourceLayerDefinitionCacheItem> cacheItem = cacheManager->GetResourceLayerDefinitionCacheItem(layerResId);
+        MdfModel::LayerDefinition* layerDefinition = cacheItem->Get();
 
+        MdfModel::VectorLayerDefinition* vl = dynamic_cast<MdfModel::VectorLayerDefinition*>(layerDefinition);
+
         //we can only do geometric query selection for vector layers
         if (vl)
         {
@@ -2039,9 +2043,11 @@
             continue;
 
         Ptr<MgResourceIdentifier> layerid = mapLayer->GetLayerDefinition();
-        ldf.reset(MgLayerBase::GetLayerDefinition(m_svcResource, layerid));
+        MgCacheManager* cacheManager = MgCacheManager::GetInstance();
+        Ptr<MgResourceLayerDefinitionCacheItem> cacheItem = cacheManager->GetResourceLayerDefinitionCacheItem(layerid);
+        MdfModel::LayerDefinition* layerDefinition = cacheItem->Get();
 
-        WatermarkInstanceCollection* layerWatermarks = ldf->GetWatermarks();
+        WatermarkInstanceCollection* layerWatermarks = layerDefinition->GetWatermarks();
         for (int j=layerWatermarks->GetCount()-1; j>=0; j--)
             tempWatermarkInstances.Adopt(layerWatermarks->OrphanAt(j));
         for (int j=tempWatermarkInstances.GetCount()-1; j>=0; j--)

Modified: trunk/MgDev/Server/src/Services/Rendering/ServerRenderingService.vcxproj
===================================================================
--- trunk/MgDev/Server/src/Services/Rendering/ServerRenderingService.vcxproj	2015-10-03 05:45:30 UTC (rev 8769)
+++ trunk/MgDev/Server/src/Services/Rendering/ServerRenderingService.vcxproj	2015-10-08 06:35:59 UTC (rev 8770)
@@ -94,7 +94,7 @@
   <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
     <ClCompile>
       <Optimization>Disabled</Optimization>
-      <AdditionalIncludeDirectories>..\..\Common;..\..\Common\Base;..\..\Common\Manager;..\Feature;..\Mapping;..\..\..\..\Common\Foundation;..\..\..\..\Common\Geometry;..\..\..\..\Common\PlatformBase;..\..\..\..\Common\MapGuideCommon;..\..\..\..\Common\MdfModel;..\..\..\..\Common\Renderers;..\..\..\..\Common\Stylization;..\..\..\..\Oem\ACE\ACE_wrappers;..\..\..\..\Oem\dbxml\xerces-c-src\src;..\..\..\..\Oem\FDO\inc;..\..\..\..\Oem\FDO\inc\ExpressionEngine;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+      <AdditionalIncludeDirectories>..\..\Common;..\..\Common\Base;..\..\Common\Cache;..\..\Common\Manager;..\Feature;..\Mapping;..\..\..\..\Common\Foundation;..\..\..\..\Common\Geometry;..\..\..\..\Common\PlatformBase;..\..\..\..\Common\MapGuideCommon;..\..\..\..\Common\MdfModel;..\..\..\..\Common\Renderers;..\..\..\..\Common\Stylization;..\..\..\..\Oem\ACE\ACE_wrappers;..\..\..\..\Oem\dbxml\xerces-c-src\src;..\..\..\..\Oem\FDO\inc;..\..\..\..\Oem\FDO\inc\ExpressionEngine;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
       <PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;_USRDLL;MG_SERVER_RENDERING_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
       <ExceptionHandling>Async</ExceptionHandling>
       <BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
@@ -120,7 +120,7 @@
   <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
     <ClCompile>
       <Optimization>Disabled</Optimization>
-      <AdditionalIncludeDirectories>..\..\Common;..\..\Common\Base;..\..\Common\Manager;..\Feature;..\Mapping;..\..\..\..\Common\Foundation;..\..\..\..\Common\Geometry;..\..\..\..\Common\PlatformBase;..\..\..\..\Common\MapGuideCommon;..\..\..\..\Common\MdfModel;..\..\..\..\Common\Renderers;..\..\..\..\Common\Stylization;..\..\..\..\Oem\ACE\ACE_wrappers;..\..\..\..\Oem\dbxml\xerces-c-src\src;..\..\..\..\Oem\FDO\inc;..\..\..\..\Oem\FDO\inc\ExpressionEngine;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+      <AdditionalIncludeDirectories>..\..\Common;..\..\Common\Base;..\..\Common\Cache;..\..\Common\Manager;..\Feature;..\Mapping;..\..\..\..\Common\Foundation;..\..\..\..\Common\Geometry;..\..\..\..\Common\PlatformBase;..\..\..\..\Common\MapGuideCommon;..\..\..\..\Common\MdfModel;..\..\..\..\Common\Renderers;..\..\..\..\Common\Stylization;..\..\..\..\Oem\ACE\ACE_wrappers;..\..\..\..\Oem\dbxml\xerces-c-src\src;..\..\..\..\Oem\FDO\inc;..\..\..\..\Oem\FDO\inc\ExpressionEngine;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
       <PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;_USRDLL;MG_SERVER_RENDERING_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
       <ExceptionHandling>Async</ExceptionHandling>
       <BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
@@ -146,7 +146,7 @@
   <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
     <ClCompile>
       <Optimization>MaxSpeed</Optimization>
-      <AdditionalIncludeDirectories>..\..\Common;..\..\Common\Base;..\..\Common\Manager;..\Feature;..\Mapping;..\..\..\..\Common\Foundation;..\..\..\..\Common\Geometry;..\..\..\..\Common\PlatformBase;..\..\..\..\Common\MapGuideCommon;..\..\..\..\Common\MdfModel;..\..\..\..\Common\Renderers;..\..\..\..\Common\Stylization;..\..\..\..\Oem\ACE\ACE_wrappers;..\..\..\..\Oem\dbxml\xerces-c-src\src;..\..\..\..\Oem\FDO\inc;..\..\..\..\Oem\FDO\inc\ExpressionEngine;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+      <AdditionalIncludeDirectories>..\..\Common;..\..\Common\Base;..\..\Common\Cache;..\..\Common\Manager;..\Feature;..\Mapping;..\..\..\..\Common\Foundation;..\..\..\..\Common\Geometry;..\..\..\..\Common\PlatformBase;..\..\..\..\Common\MapGuideCommon;..\..\..\..\Common\MdfModel;..\..\..\..\Common\Renderers;..\..\..\..\Common\Stylization;..\..\..\..\Oem\ACE\ACE_wrappers;..\..\..\..\Oem\dbxml\xerces-c-src\src;..\..\..\..\Oem\FDO\inc;..\..\..\..\Oem\FDO\inc\ExpressionEngine;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
       <PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;_USRDLL;MG_SERVER_RENDERING_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
       <ExceptionHandling>Async</ExceptionHandling>
       <RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
@@ -173,7 +173,7 @@
   <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
     <ClCompile>
       <Optimization>MaxSpeed</Optimization>
-      <AdditionalIncludeDirectories>..\..\Common;..\..\Common\Base;..\..\Common\Manager;..\Feature;..\Mapping;..\..\..\..\Common\Foundation;..\..\..\..\Common\Geometry;..\..\..\..\Common\PlatformBase;..\..\..\..\Common\MapGuideCommon;..\..\..\..\Common\MdfModel;..\..\..\..\Common\Renderers;..\..\..\..\Common\Stylization;..\..\..\..\Oem\ACE\ACE_wrappers;..\..\..\..\Oem\dbxml\xerces-c-src\src;..\..\..\..\Oem\FDO\inc;..\..\..\..\Oem\FDO\inc\ExpressionEngine;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+      <AdditionalIncludeDirectories>..\..\Common;..\..\Common\Base;..\..\Common\Cache;..\..\Common\Manager;..\Feature;..\Mapping;..\..\..\..\Common\Foundation;..\..\..\..\Common\Geometry;..\..\..\..\Common\PlatformBase;..\..\..\..\Common\MapGuideCommon;..\..\..\..\Common\MdfModel;..\..\..\..\Common\Renderers;..\..\..\..\Common\Stylization;..\..\..\..\Oem\ACE\ACE_wrappers;..\..\..\..\Oem\dbxml\xerces-c-src\src;..\..\..\..\Oem\FDO\inc;..\..\..\..\Oem\FDO\inc\ExpressionEngine;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
       <PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;_USRDLL;MG_SERVER_RENDERING_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
       <ExceptionHandling>Async</ExceptionHandling>
       <RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
@@ -337,6 +337,14 @@
       <Project>{a4f7f6b2-0e74-4dfd-b283-c7e380bd6f58}</Project>
       <ReferenceOutputAssembly>false</ReferenceOutputAssembly>
     </ProjectReference>
+    <ProjectReference Include="..\..\Common\Cache\ServerCache.vcxproj">
+      <Project>{531778c6-c340-40f2-b403-9b58b8121aab}</Project>
+      <Private>false</Private>
+      <ReferenceOutputAssembly>false</ReferenceOutputAssembly>
+      <CopyLocalSatelliteAssemblies>false</CopyLocalSatelliteAssemblies>
+      <LinkLibraryDependencies>true</LinkLibraryDependencies>
+      <UseLibraryDependencyInputs>false</UseLibraryDependencyInputs>
+    </ProjectReference>
     <ProjectReference Include="..\..\Common\Manager\ServerManager.vcxproj">
       <Project>{adbf25e2-c629-4832-b315-f12abde05632}</Project>
       <ReferenceOutputAssembly>false</ReferenceOutputAssembly>



More information about the mapguide-commits mailing list