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>
|
<groupId>net.sf.ehcache</groupId>
|
||||||
<artifactId>ehcache</artifactId>
|
<artifactId>ehcache</artifactId>
|
||||||
<version>2.8.0</version>
|
<version>2.8.0</version>
|
||||||
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!-- <dependency> -->
|
<!-- <dependency> -->
|
||||||
|
|
|
@ -15,6 +15,7 @@ import java.net.URLStreamHandler;
|
||||||
import javax.servlet.ServletException;
|
import javax.servlet.ServletException;
|
||||||
import javax.servlet.http.HttpSession;
|
import javax.servlet.http.HttpSession;
|
||||||
|
|
||||||
|
import net.didion.jwnl.data.Exc;
|
||||||
import net.sf.ehcache.CacheManager;
|
import net.sf.ehcache.CacheManager;
|
||||||
import net.sf.ehcache.Ehcache;
|
import net.sf.ehcache.Ehcache;
|
||||||
import net.sf.ehcache.config.CacheConfiguration;
|
import net.sf.ehcache.config.CacheConfiguration;
|
||||||
|
@ -90,6 +91,45 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements
|
||||||
// cacheManager = CacheManager.create(resourceAsStream);
|
// cacheManager = CacheManager.create(resourceAsStream);
|
||||||
|
|
||||||
// TODO: DA MODIFICARE LA MODALITÀ DI RECUPERO DEL FILE
|
// 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 {
|
try {
|
||||||
|
|
||||||
// CacheManager cacheManager = CacheManager
|
// CacheManager cacheManager = CacheManager
|
||||||
|
@ -112,24 +152,9 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements
|
||||||
//
|
//
|
||||||
// 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();
|
String path = System.getenv("CATALINA_TMPDIR");
|
||||||
|
|
||||||
|
|
||||||
//TODO MODIFY: SET THE NAME OF THE CACHE DISK WITH CODE AND NOT IN FILE ENCACHE.XML
|
|
||||||
|
|
||||||
// String path = System.getenv("CATALINA_TMPDIR");
|
|
||||||
// System.out.println("Path: " + this.getServletContext().getRealPath(""));
|
// System.out.println("Path: " + this.getServletContext().getRealPath(""));
|
||||||
|
|
||||||
// System.out.println("Path: " + path);
|
// System.out.println("Path: " + path);
|
||||||
|
@ -139,11 +164,33 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements
|
||||||
// String DiskCacheFolderName="DBManagerDisk";
|
// String DiskCacheFolderName="DBManagerDisk";
|
||||||
// File f = new File(this.getServletContext().getRealPath("")+DiskCacheFolderName);
|
// File f = new File(this.getServletContext().getRealPath("")+DiskCacheFolderName);
|
||||||
|
|
||||||
// CacheConfiguration config = employeeCache.getCacheConfiguration();
|
CacheConfiguration config = employeeCache.getCacheConfiguration();
|
||||||
// String DiskCacheFolderName="DBManagerDisk";
|
String DiskCacheFolderName="DBManagerDisk";
|
||||||
// config.setDiskStorePath(this.getServletContext().getRealPath("")+DiskCacheFolderName);
|
// config.setDiskStorePath(this.getServletContext().getRealPath("")+DiskCacheFolderName);
|
||||||
|
|
||||||
|
// File f = new File(path+"/"+DiskCacheFolderName);
|
||||||
|
|
||||||
|
// if (!f.exists()){
|
||||||
|
// f.mkdir();
|
||||||
|
//
|
||||||
|
// }
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// config.setDiskStorePath(path+"/"+DiskCacheFolderName);
|
// 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);
|
// File f = new File(path+"/"+DiskCacheFolderName);
|
||||||
//
|
//
|
||||||
|
|
|
@ -5,8 +5,6 @@
|
||||||
dynamicConfig="true">
|
dynamicConfig="true">
|
||||||
|
|
||||||
|
|
||||||
<diskStore path="/home/loredana/Desktop/DBManagerDisk"/>
|
|
||||||
|
|
||||||
<defaultCache
|
<defaultCache
|
||||||
maxEntriesLocalHeap="10000"
|
maxEntriesLocalHeap="10000"
|
||||||
eternal="false"
|
eternal="false"
|
||||||
|
@ -17,7 +15,6 @@
|
||||||
diskExpiryThreadIntervalSeconds="120"
|
diskExpiryThreadIntervalSeconds="120"
|
||||||
memoryStoreEvictionPolicy="LRU"
|
memoryStoreEvictionPolicy="LRU"
|
||||||
statistics="false">
|
statistics="false">
|
||||||
<persistence strategy="localTempSwap"/>
|
|
||||||
</defaultCache>
|
</defaultCache>
|
||||||
|
|
||||||
<cache name="DBCache"
|
<cache name="DBCache"
|
||||||
|
@ -30,8 +27,8 @@
|
||||||
memoryStoreEvictionPolicy="LRU"
|
memoryStoreEvictionPolicy="LRU"
|
||||||
transactionalMode="off"
|
transactionalMode="off"
|
||||||
overflowToDisk="true"
|
overflowToDisk="true"
|
||||||
diskPersistent="true">
|
diskPersistent="true"
|
||||||
<!-- <persistence strategy="localTempSwap"/> -->
|
>
|
||||||
</cache>
|
</cache>
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue