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>
<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....
- "name" invalid attribute! perhaps meant displayname?
- 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. - 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
Post a Comment