The variable that increments the "object Count Instantiation" is a "static variable".
"Static variables belong to the Class, Not to any objects created"
 
Try creating objects in a loop from a driver class or something.. and increment
the "object count in the contructor"... You can see whats happening.
 
Why do you have do this?
rbo = createObect("Java","RedBackObject").init();
 
So this doesnt call the default constructor? If it doest...what does it call?
rbo = createObect("Java","RedBackObject");
 

Joe Eugene

-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]On Behalf Of Adam Wayne Lehman
Sent: Friday, September 05, 2003 5:52 PM
To: [EMAIL PROTECTED]
Subject: RE: [CFCDev] CFObject Creation Count

I’m not familiar with redBack biz objects, but not to leave you hanging with no replies I’ll add my 2 cents.

 

I wouldn’t assume that an init() construct is called automatically. Also why is one object aware of the number of all identical objects? Is it just an inherited method? I mean, if the object is supposed to be blind to it surroundings, then getTickCount() would have to rely on asking another ‘watching’ object for that information. Right?

 

I dunno. I’m just taking stabs in the dark. Don’t listen to me.

 

But I do feel confident in saying you have to explicitly call the constructor. Somewhat.

 

Adam Wayne Lehman
Web Systems Developer
Johns Hopkins Bloomberg School of Public Health
Distance Education Division

 

-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Joe Eugene
Sent: Friday, September 05, 2003 3:24 PM
To: [EMAIL PROTECTED]
Subject: Re: [CFCDev] CFObject Creation Count

 

Repost.. Anybody?

----- Original Message -----

From: Joe Eugene

Sent: Thursday, September 04, 2003 10:29 AM

Subject: [CFCDev] CFObject Creation Count

 

I have a JavaBean API that i use to Connect to our DB via an Object Server(RedBack Business Objects)

 

The Constructor Increments a Static variable everytime an Object is Instanciated from the API.

 

private static int objCount;

public RedBackObect{

objCount++;

}

 

I am looking track DB Usage from the NO of Objects created and do some stess testing as well.

Now.. If the objects are invoked in a CFC - CFFunctions like

 

<cfset var rbo = "" />

<cfscript>

rbo = createObect("Java","RedBackObject").init(); // this should call the default contructor

//do some stuff with the rbo.

objCount = rbo.getObjectCount(); // static method in API

rbo.closeObj();

rbo="";

</cfscript>

 

objCount = 1, which is not right cause the object was instantiated several times.

 

rbo = createObect("Java","RedBackObject").init(); AND rbo = createObect("Java","RedBackObject")

Both call the default contructor right Or do you have to explicitly say "init()"?

 

If the Class gets loaded only once, then i should get the correct object count.

 

Can anybody explain whats going on in CF Object Creation?

 

Thanks,

Joe Eugene

Reply via email to