directory for cache created in a corrected way and dependecy for ehcache set to provided
git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/user/databases-manager-portlet@99736 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
ea771efd64
commit
82cf7995f2
1
pom.xml
1
pom.xml
|
@ -155,6 +155,7 @@
|
|||
<groupId>net.sf.ehcache</groupId>
|
||||
<artifactId>ehcache</artifactId>
|
||||
<version>2.8.0</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
<!-- <dependency> -->
|
||||
|
|
|
@ -15,6 +15,7 @@ import java.net.URLStreamHandler;
|
|||
import javax.servlet.ServletException;
|
||||
import javax.servlet.http.HttpSession;
|
||||
|
||||
import net.didion.jwnl.data.Exc;
|
||||
import net.sf.ehcache.CacheManager;
|
||||
import net.sf.ehcache.Ehcache;
|
||||
import net.sf.ehcache.config.CacheConfiguration;
|
||||
|
@ -90,6 +91,45 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements
|
|||
// cacheManager = CacheManager.create(resourceAsStream);
|
||||
|
||||
// TODO: DA MODIFICARE LA MODALITÀ DI RECUPERO DEL FILE
|
||||
// try {
|
||||
//
|
||||
// // CacheManager cacheManager = CacheManager
|
||||
// // .newInstance("/home/loredana/workspace/databases-manager-portlet-TRUNK/configCache/encache.xml");
|
||||
//
|
||||
// // InputStream is =
|
||||
// // ClassLoader.getSystemResourceAsStream("encache.xml");
|
||||
// // CacheManager cacheManager = CacheManager.newInstance(is);
|
||||
// // is.close();
|
||||
//
|
||||
// URL url = getClass().getResource("/encache.xml");
|
||||
// CacheManager cacheManager = CacheManager.newInstance(url);
|
||||
// // getcache
|
||||
// employeeCache = cacheManager.getEhcache("DBCache");
|
||||
//
|
||||
// //set Disk Store Path in the configuration file encache.xml
|
||||
//// CacheConfiguration config = employeeCache.getCacheConfiguration();
|
||||
//// String DiskCacheFolderName="DBManagerDisk";
|
||||
////// config.setDiskStorePath(this.getServletContext().getRealPath("")+DiskCacheFolderName);
|
||||
////
|
||||
//// config.setDiskStorePath(this.getServletContext().getRealPath("")+DiskCacheFolderName);
|
||||
//
|
||||
// } catch (Exception e) {
|
||||
// // TODO: handle exception
|
||||
// e.printStackTrace();
|
||||
// throw new Exception("Failed to get cache. " + e);
|
||||
// }
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init() throws ServletException {
|
||||
|
||||
|
||||
super.init();
|
||||
|
||||
|
||||
//TODO MODIFY: SET THE NAME OF THE CACHE DISK WITH CODE AND NOT IN FILE ENCACHE.XML
|
||||
|
||||
try {
|
||||
|
||||
// CacheManager cacheManager = CacheManager
|
||||
|
@ -103,7 +143,7 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements
|
|||
URL url = getClass().getResource("/encache.xml");
|
||||
CacheManager cacheManager = CacheManager.newInstance(url);
|
||||
// getcache
|
||||
employeeCache = cacheManager.getEhcache("DBCache");
|
||||
employeeCache = cacheManager.getEhcache("DBCache");
|
||||
|
||||
//set Disk Store Path in the configuration file encache.xml
|
||||
// CacheConfiguration config = employeeCache.getCacheConfiguration();
|
||||
|
@ -112,24 +152,9 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements
|
|||
//
|
||||
// config.setDiskStorePath(this.getServletContext().getRealPath("")+DiskCacheFolderName);
|
||||
|
||||
} catch (Exception e) {
|
||||
// TODO: handle exception
|
||||
e.printStackTrace();
|
||||
throw new Exception("Failed to get cache. " + e);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init() throws ServletException {
|
||||
|
||||
|
||||
super.init();
|
||||
|
||||
|
||||
//TODO MODIFY: SET THE NAME OF THE CACHE DISK WITH CODE AND NOT IN FILE ENCACHE.XML
|
||||
|
||||
// String path = System.getenv("CATALINA_TMPDIR");
|
||||
String path = System.getenv("CATALINA_TMPDIR");
|
||||
// System.out.println("Path: " + this.getServletContext().getRealPath(""));
|
||||
|
||||
// System.out.println("Path: " + path);
|
||||
|
@ -139,11 +164,33 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements
|
|||
// String DiskCacheFolderName="DBManagerDisk";
|
||||
// File f = new File(this.getServletContext().getRealPath("")+DiskCacheFolderName);
|
||||
|
||||
// CacheConfiguration config = employeeCache.getCacheConfiguration();
|
||||
// String DiskCacheFolderName="DBManagerDisk";
|
||||
CacheConfiguration config = employeeCache.getCacheConfiguration();
|
||||
String DiskCacheFolderName="DBManagerDisk";
|
||||
// config.setDiskStorePath(this.getServletContext().getRealPath("")+DiskCacheFolderName);
|
||||
|
||||
// File f = new File(path+"/"+DiskCacheFolderName);
|
||||
|
||||
// if (!f.exists()){
|
||||
// f.mkdir();
|
||||
//
|
||||
// }
|
||||
|
||||
|
||||
|
||||
// config.setDiskStorePath(path+"/"+DiskCacheFolderName);
|
||||
config.setDiskStorePath(path);
|
||||
// config.setDiskPersistent(true);
|
||||
// config.setOverflowToDisk(true);
|
||||
|
||||
|
||||
|
||||
} catch (Exception e) {
|
||||
// TODO: handle exception
|
||||
e.printStackTrace();
|
||||
// throw new Exception("Failed to get cache. " + e);
|
||||
// Exception exc = new Exception("Failed to get cache. " + e.getMessage());
|
||||
throw e;
|
||||
}
|
||||
|
||||
// File f = new File(path+"/"+DiskCacheFolderName);
|
||||
//
|
||||
|
|
|
@ -5,8 +5,6 @@
|
|||
dynamicConfig="true">
|
||||
|
||||
|
||||
<diskStore path="/home/loredana/Desktop/DBManagerDisk"/>
|
||||
|
||||
<defaultCache
|
||||
maxEntriesLocalHeap="10000"
|
||||
eternal="false"
|
||||
|
@ -17,8 +15,7 @@
|
|||
diskExpiryThreadIntervalSeconds="120"
|
||||
memoryStoreEvictionPolicy="LRU"
|
||||
statistics="false">
|
||||
<persistence strategy="localTempSwap"/>
|
||||
</defaultCache>
|
||||
</defaultCache>
|
||||
|
||||
<cache name="DBCache"
|
||||
maxBytesLocalHeap="200m"
|
||||
|
@ -30,8 +27,8 @@
|
|||
memoryStoreEvictionPolicy="LRU"
|
||||
transactionalMode="off"
|
||||
overflowToDisk="true"
|
||||
diskPersistent="true">
|
||||
<!-- <persistence strategy="localTempSwap"/> -->
|
||||
diskPersistent="true"
|
||||
>
|
||||
</cache>
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue