Author: [email protected]
Date: Mon Jan 16 17:17:02 2012
New Revision: 1915
Log:
[AMDATUOPENSOCIAL-143] Disabled ehCache by default in the config and replaced
the ehCache.xml with the default file from shindig. ehCache can be enabled by
passing the config file to the shindig.cache.ehcache.config entry in
org.amdatu.opensocial.shindig.cfg
Modified:
trunk/amdatu-opensocial/config/src/main/resources/org.amdatu.opensocial.shindig.cfg
trunk/amdatu-opensocial/opensocial-shindig/src/main/java/org/amdatu/opensocial/shindig/module/ConfigurationAdminGuiceModule.java
trunk/amdatu-opensocial/opensocial-shindig/src/main/java/org/amdatu/opensocial/shindig/service/GuiceInjectorServletImpl.java
trunk/amdatu-opensocial/opensocial-shindig/src/main/resources/conf/ehcacheConfig.xml
Modified:
trunk/amdatu-opensocial/config/src/main/resources/org.amdatu.opensocial.shindig.cfg
==============================================================================
---
trunk/amdatu-opensocial/config/src/main/resources/org.amdatu.opensocial.shindig.cfg
(original)
+++
trunk/amdatu-opensocial/config/src/main/resources/org.amdatu.opensocial.shindig.cfg
Mon Jan 16 17:17:02 2012
@@ -98,7 +98,9 @@
shindig.cache.lru.httpResponses.capacity=10000
# The location of the EhCache configuration file.
-shindig.cache.ehcache.config=res://org/apache/shindig/common/cache/ehcache/ehcacheConfig.xml
+# Leave this entry empty to completely disable the ehcache, otherwise enter:
+# res://org/apache/shindig/common/cache/ehcache/ehcacheConfig.xml
+shindig.cache.ehcache.config=
# True to enable JMX integration with cache stats
shindig.cache.ehcache.jmx.enabled=true
Modified:
trunk/amdatu-opensocial/opensocial-shindig/src/main/java/org/amdatu/opensocial/shindig/module/ConfigurationAdminGuiceModule.java
==============================================================================
---
trunk/amdatu-opensocial/opensocial-shindig/src/main/java/org/amdatu/opensocial/shindig/module/ConfigurationAdminGuiceModule.java
(original)
+++
trunk/amdatu-opensocial/opensocial-shindig/src/main/java/org/amdatu/opensocial/shindig/module/ConfigurationAdminGuiceModule.java
Mon Jan 16 17:17:02 2012
@@ -113,5 +113,9 @@
else {
return file;
}
+ }
+
+ public Properties getProperties() {
+ return m_properties;
}
}
Modified:
trunk/amdatu-opensocial/opensocial-shindig/src/main/java/org/amdatu/opensocial/shindig/service/GuiceInjectorServletImpl.java
==============================================================================
---
trunk/amdatu-opensocial/opensocial-shindig/src/main/java/org/amdatu/opensocial/shindig/service/GuiceInjectorServletImpl.java
(original)
+++
trunk/amdatu-opensocial/opensocial-shindig/src/main/java/org/amdatu/opensocial/shindig/service/GuiceInjectorServletImpl.java
Mon Jan 16 17:17:02 2012
@@ -79,10 +79,10 @@
// Instance variables
private boolean m_jmxInitialized;
private Component m_serviceComponent;
-
+
public GuiceInjectorServletImpl() {
}
-
+
public ServletConfig getServletConfig() {
return null;
}
@@ -103,9 +103,9 @@
// does not register the service with the GuiceInjectorServlet
interface since we want
// postpone the availability of the service until the Guice injector
is initialized.
m_serviceComponent = m_dependencyManager.createComponent()
- .setInterface(GuiceInjectorServlet.class.getName(), null)
- .setImplementation(this)
- .setCallbacks("_init", "start", "stop", "_destroy");
+ .setInterface(GuiceInjectorServlet.class.getName(),
null)
+ .setImplementation(this)
+ .setCallbacks("_init", "start", "stop", "_destroy");
m_dependencyManager.add(m_serviceComponent);
}
@@ -124,12 +124,17 @@
* @return a newly created Guice injector which is shared between all
Shindig servlets using a common HttpContext
*/
private Injector createGuiceInjector() {
- String[] moduleNames = getGuiceModules();
+ List<String> moduleNames = getGuiceModules();
List<Module> modules = new ArrayList<Module>();
if (moduleNames != null) {
// First add the properties module
modules.add(m_shindigConfigurationModule);
-
+
+ // Add the ehCache module, but only if it is enabled
+ if (isEhCacheEnabled()) {
+
moduleNames.add("org.apache.shindig.common.cache.ehcache.EhCacheModule");
+ }
+
// Now add all Guice-injected modules
for (String moduleName : moduleNames) {
try {
@@ -174,10 +179,15 @@
return injector;
}
- private String[] getGuiceModules() {
- return new String[] {
- "org.apache.shindig.gadgets.DefaultGuiceModule",
- "org.apache.shindig.extras.ShindigExtrasGuiceModule",
- "org.apache.shindig.common.cache.ehcache.EhCacheModule"};
- }
+ private List<String> getGuiceModules() {
+ List<String> modules = new ArrayList<String>();
+ modules.add("org.apache.shindig.gadgets.DefaultGuiceModule");
+ modules.add("org.apache.shindig.extras.ShindigExtrasGuiceModule");
+ return modules;
+ }
+
+ private boolean isEhCacheEnabled() {
+ Object ehCache =
m_shindigConfigurationModule.getProperties().get("shindig.cache.ehcache.config");
+ return ehCache != null && !ehCache.toString().trim().isEmpty();
+ }
}
Modified:
trunk/amdatu-opensocial/opensocial-shindig/src/main/resources/conf/ehcacheConfig.xml
==============================================================================
---
trunk/amdatu-opensocial/opensocial-shindig/src/main/resources/conf/ehcacheConfig.xml
(original)
+++
trunk/amdatu-opensocial/opensocial-shindig/src/main/resources/conf/ehcacheConfig.xml
Mon Jan 16 17:17:02 2012
@@ -23,14 +23,14 @@
<!--
Mandatory Default Cache configuration. These settings will be applied to
caches
created programmatically using CacheManager.add(String cacheName).
-
+
The defaultCache has an implicit name "default" which is a reserved cache
name.
-->
<defaultCache
- maxElementsInMemory="0"
+ maxElementsInMemory="1000"
eternal="false"
- timeToIdleSeconds="1"
- timeToLiveSeconds="1"
+ timeToIdleSeconds="300"
+ timeToLiveSeconds="600"
overflowToDisk="false"
diskPersistent="false"
memoryStoreEvictionPolicy="LFU"/>
@@ -40,14 +40,14 @@
allow us to cache the objects indefinitely when using an LFU or LRU cache.
-->
<cache name="gadgetSpecs"
- maxElementsInMemory="0"
+ maxElementsInMemory="1000"
eternal="true"
overflowToDisk="false"
diskPersistent="false"
memoryStoreEvictionPolicy="LFU"/>
<cache name="messageBundles"
- maxElementsInMemory="0"
+ maxElementsInMemory="1000"
eternal="true"
overflowToDisk="false"
diskPersistent="false"
@@ -55,7 +55,7 @@
<!-- Used to cache parsed HTML DOMs based on their content -->
<cache name="parsedDocuments"
- maxElementsInMemory="0"
+ maxElementsInMemory="1000"
eternal="true"
overflowToDisk="false"
diskPersistent="false"
@@ -63,18 +63,18 @@
<!-- Used to cache parsed CSS DOMs based on their content -->
<cache name="parsedCss"
- maxElementsInMemory="0"
+ maxElementsInMemory="1000"
eternal="true"
overflowToDisk="false"
diskPersistent="false"
memoryStoreEvictionPolicy="LFU"/>
- <!--
+ <!--
This configuration is only suitable for a modest sized HTTP cache.
You should configure a shared cache for production use.
-->
<cache name="httpResponses"
- maxElementsInMemory="0"
+ maxElementsInMemory="10000"
eternal="true"
overflowToDisk="false"
diskPersistent="false"
@@ -82,9 +82,19 @@
<!-- Used to cache parsed expressions based on their content -->
<cache name="expressions"
- maxElementsInMemory="0"
+ maxElementsInMemory="1000"
eternal="true"
overflowToDisk="false"
diskPersistent="false"
memoryStoreEvictionPolicy="LFU"/>
+
+ <!-- Used to cache cajoled documents based on their content -->
+ <cache name="cajoledDocuments"
+ maxElementsInMemory="1000"
+ eternal="false"
+ timeToIdleSeconds="300"
+ timeToLiveSeconds="600"
+ overflowToDisk="false"
+ diskPersistent="false"
+ memoryStoreEvictionPolicy="LFU"/>
</ehcache>
_______________________________________________
Amdatu-commits mailing list
[email protected]
http://lists.amdatu.org/mailman/listinfo/amdatu-commits