Proper code?


all, working on making facade java functions need used. want make doubly sure there no chance of memory leaks using type of code. can tell using facade interface java component add methods it. please please let me know if code safe.

<cfcomponent name="testcomponent" output="false">

<cffunction name="init" returntype="any">

<cfscript>

variables.objccc = createobject("java","com.ablecommerce.ac5.product.category");
objccc.init();

return this;
</cfscript>

</cffunction>

<cffunction name="load">

<cfargument name="token" type="any">
<cfargument name="categoryid" type="numeric">

<cfscript>

return objccc.load(arguments.token, javacast("long",arguments.categoryid));

</cfscript>

</cffunction>

a few potential gotchas, other that, it's ok....
  1. "name" invalid attribute! perhaps meant displayname?
  2. be careful "variables" scope in components. declare these outside cffunction if meant whole object.
    use "this" scope meant public (not idea).
    use "var" qualifier variables declared inside functions.
  3. if java uses shared resource or spawns asynchronous threads, there might trouble. use locking if needed , monitor thread state if applicable.



More discussions in Advanced Techniques


adobe

Comments

Popular posts from this blog

Connecting Raspberry Pi 2 to P10(1R)-V706 LED Dot Matrix - Raspberry Pi Forums

TypeError: <unknown> is not a numpy array - Raspberry Pi Forums

datso and removing imagetitle - Joomla! Forum - community, help and support