Sean,

> basic feature of how Java works. Normally, you don't have multiple
> class loaders of course so you never notice.

I dont think the above is correct for J2EE Environment. Once the Class
loads, its stays loaded...I think this is why we have "HOT LOAD" features
to "RE LOAD" classes in development environment.

> loaders. Why does it use multiple class loaders? Because we want CF to
> dynamically recompile and reload classes.

I think there might be some mis-understanding above...
I am just using CFMX as an interface... The manipulation in done in the Java
Class.
Again this works in Regular CF Page, am only having problems when i move
the code to a CFC.

Here is a simple test.

Java Class - compile and drop *.class in WEB-INF\Classes
public class ObjectCount{
 private static int i;
 public ObjectCount(){
 i++;
 }
 public static int getObjectCount(){
 return i;
 }
}//end Object Count

Create 2 simple pages.

obj1.cfm
<cfscript>
xobj = createObject("Java","ObjectCount").init();
</cfscript>
<cfoutput>
object Count : #xobj.getObjectCount()#<br>
</cfoutput>

obj2.cfm
<cfscript>
xobj1 = createObject("Java","ObjectCount").init();
</cfscript>
<cfoutput>
object Count : #xobj1.getObjectCount()#<br>
</cfoutput>

Load both pages in 2 Browser Windows and click refresh in alternate
browsers.
You can see the object count gets reported correctly.

The problem is when the code gets moved into a CFC Or i am missing something
else.

Joe Eugene


> -----Original Message-----
> From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
> Behalf Of Sean A Corfield
> Sent: Saturday, September 06, 2003 3:08 PM
> To: [EMAIL PROTECTED]
> Subject: Re: [CFCDev] CFObject Creation Count
>
>
> On Friday, Sep 5, 2003, at 12:23 US/Pacific, Joe Eugene wrote:
> > If the Class gets loaded only once, then i should get the correct
> > object count.
>
> Yes, sort of. If you have multiple class loaders active, a class can be
> loaded more than once and new static variables are created each time
> (so your objectCount is correct per-loader, not per-JVM). This is a
> basic feature of how Java works. Normally, you don't have multiple
> class loaders of course so you never notice.
>
> Why do you get 'strange' behavior in CF? Because it uses multiple class
> loaders. Why does it use multiple class loaders? Because we want CF to
> dynamically recompile and reload classes. You can't unload an old
> version of a class without unloading the class loader that created it -
> and you can't unload a class loader until all instances of all classes
> that it loaded have become 'unreachable' (i.e., ready for garbage
> collection). If you have a CFC instance in a shared scope, it won't
> become unreachable and so you can't unload the class loader and
> therefore you can't load a new version of the CFC unless you create a
> new class loader.
>
> BTW, I just had my wife read this (she's not a programmer) to make sure
> it's clear... and she understood it!
>
> Sean A Corfield -- http://www.corfield.org/blog/
>
> "If you're not annoying somebody, you're not really alive."
> -- Margaret Atwood
>
> ----------------------------------------------------------
> You are subscribed to cfcdev. To unsubscribe, send an email
> to [EMAIL PROTECTED] with the word 'unsubscribe cfcdev'
> in the message of the email.
>
> CFCDev is run by CFCZone (www.cfczone.org) and supported
> by Mindtool, Corporation (www.mindtool.com).
>
> An archive of the CFCDev list is available at
> www.mail-archive.com/[EMAIL PROTECTED]

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Archives: http://www.houseoffusion.com/lists.cfm?link=t:4
Subscription: http://www.houseoffusion.com/lists.cfm?link=s:4
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4

Get the mailserver that powers this list at 
http://www.coolfusion.com

Reply via email to