Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / December 2005

Tip: Looking for answers? Try searching our database.

Tomcat + TreeCache + disappearing values

Thread view: 
Maciej Boniewicz - 01 Dec 2005 13:29 GMT
Hello! I have problem with TreeCache. I wrote simpe class to Caching values
based on TreeCache, and it works, but very often
it looses values(there are ie empty Strings as values (no null values!!!)).
Thanks for any help. Here is my cache class:

package utils;

import java.util.*;

import org.jboss.cache.*;
import org.apache.log4j.*;

public class Cache {
static Logger logger = Logger.getLogger(Cache.class);

private static HashMap lastAccesses = new HashMap();

private static int life_time=0;
private static TreeCache jtr = null;

private static void init()
{
 if(jtr==null)
 {
  ResourceBundle data;
  String xml_path="";
  try
  {
            data = ResourceBundle.getBundle("Consts");
            xml_path=data.getString("cache_xml_path");
   life_time=Integer.parseInt(data.getString("cache_life_time"))*1000;
   jtr = new TreeCache();
   org.jboss.cache.PropertyConfigurator config = new
org.jboss.cache.PropertyConfigurator();
   config.configure(jtr, xml_path);
   jtr.startService();
  }catch(Exception e)
  {
   logger.debug(e.toString());
  }
 }
}

public static Object getObject(String object_name)
{
 init();
 if(lastAccesses.containsKey(object_name))
 {
  if(new
Date().getTime()-((Date)lastAccesses.get(object_name)).getTime()>=life_time)
   return null;
 }else
  return null;

 try
 {
  if(jtr.exists("/",(Object)object_name))
   return (Object)jtr.get("/",(Object)object_name);
  else
   return null;
 }catch(Exception e)
 {
  logger.debug(e.toString());
 }
 return null;
}
public static void setObject(String object_name,Object obj)
{
 Object oldobj;
 init();
 try
 {
  oldobj=jtr.put("/",(Object)object_name,obj);
  if(oldobj!=null)
   oldobj=null;
  oldobj=lastAccesses.put(object_name,(Object)new Date());
  if(oldobj!=null)
   oldobj=null;
 }catch(Exception e)
 {
  logger.debug(e.toString());
 }
}
}
cbroussard@liquiddatainc.com - 01 Dec 2005 17:48 GMT
Have you tried the jboss.org forums.  That might be a good place to
post and try to get an answer.

hope that helps,

http://www.binaryfrost.com
Maciej Boniewicz - 02 Dec 2005 07:53 GMT
I think it's very good idea :) Thanks for help :)

> Have you tried the jboss.org forums.  That might be a good place to
> post and try to get an answer.
>
> hope that helps,
>
> http://www.binaryfrost.com


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.