Actually,  I am attempting to use the Cache::Cache module to store the
persistant Java object  that I have created.  I have tested both
Cache::FileCache and Cache::MemoryCache.  Both of these give me a Unknown
Java object reference during the debugging.  I am using mod_perl.

Example code is like the following:

my $obj = new J::test;
$obj->setParams($A,$B,$C);
$obj->setConnect($uname,$upass,$uip,$jip);
$obj->connect();
$obj->execute($query);
Cache::FileCache->set("java_obj", $obj);  # save object in File Cache

My $new_obj = Cache::FileCache->get("java_obj");
$new_obj->execute($query2);

# this is where the code fails with Unknown Java object reference
J::test=HASH(0x10315db30)

Currently I have to reconnect with the cached object again before I can
execute another query.

Thanks,

Derek    

-----Original Message-----
From: Patrick LeBoutillier [mailto:[EMAIL PROTECTED] 
Sent: Wednesday, December 08, 2004 11:42 AM
To: Peters Derek S Contr WRALC/LGEA
Cc: [EMAIL PROTECTED]
Subject: Re: Persistant Java objects

Derek,

When you create a Java Object from Perl, that Java object is bound the Perl
reference that is returned. When that reference goes out of scope, the Java
object is "unhooked" and is free to be collected by the garbage collector.

So after each time a CGI is called, all the variables allocated during it's
lifetime are destroyed because the perl interpreter dies. Unless you are
using Apache::Registry (?) or mod_perl module or another technique to keep
your CGI persistent.

It is also possible that I'm not understanding your problem correctly.
Please provide more info on your setup (type of CGI, use of mod_perl, ...).
It possible, the (non-business part of the) code is always useful.


Cheers,

Patrick


Peters Derek S Contr WRALC/LGEA wrote:

>Hello,
> 
>I have a question about Inline::Java and keeping a object persistant.  
>I am using Inline::Java as an interface to connect to a datasource.  
>The problem is that every time I want to do a new query, I have to 
>connect again because the object that I had already created has been 
>destroyed.  Is there a way to store the object in Perl that will allow 
>me to do multiple queries from differnent cgi's.  I have been unable to 
>find any inforamtion about this process.
> 
> 
>Debugging returns
> 
>[perl][2]  creating object in java (J::jm):
>[perl][1] load done.
>[perl][2]  destroying object in java (J::jm):
> 
> 
>I am using Apache/2.0.52 (Unix) mod_perl/1.99_17 Perl/v5.8.5 and 
>Inline-0.44 and Inline::Java-0.49
> 
>Thanks,
>Derek Peters
>
>  
>


--
=====================
Patrick LeBoutillier
Laval, Quebec, Canada

Reply via email to