Re: Structures in Java?
The container takes care of the majority of threading issues for you; only when multiple requests access the same data (i.e. session or application scope) does threading matter to the application developer. If you have request-level data, concurrency isn't be a concern unless you're explicitly multithreading your request. Note that instance variables of shared-scope CFC's count as cross-request data, but local variables inside CFC methods (including arguments) do not. cheers, barneyb On 10/1/06, Mark Mandel [EMAIL PROTECTED] wrote: Your probably better off with a java.util.Hashtable, as it is already syncronised (thread safe), and more often than not, where are using Hashtables in a web environment, they need to be thread safe. That being said, java.util.Collections gives you some easy to use utilities to create synchronised Maps very easily. HTH Mark -- Barney Boisvert [EMAIL PROTECTED] 360.319.6145 http://www.barneyb.com/ Got Gmail? I have 100 invites. ~| Introducing the Fusion Authority Quarterly Update. 80 pages of hard-hitting, up-to-date ColdFusion information by your peers, delivered to your door four times a year. http://www.fusionauthority.com/quarterly Archive: http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:255015 Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4
Re: Structures in Java?
Thanks Guys, that is some excellent info to keep in mind. (and that I sometimes forget to think about (e.g. worked fine in dev mode, how come it's all squirrly now?!?! ;)). Yet I went with the thread safe ajax stuff at first... just cuz... how haphazard of me. =P I vow to become a more aware coder. Vow it I say! :Denny On 10/2/06, Barney Boisvert [EMAIL PROTECTED] wrote: The container takes care of the majority of threading issues for you; only when multiple requests access the same data (i.e. session or application scope) does threading matter to the application developer. If you have request-level data, concurrency isn't be a concern unless you're explicitly multithreading your request. Note that instance variables of shared-scope CFC's count as cross-request data, but local variables inside CFC methods (including arguments) do not. cheers, barneyb On 10/1/06, Mark Mandel [EMAIL PROTECTED] wrote: Your probably better off with a java.util.Hashtable, as it is already syncronised (thread safe), and more often than not, where are using Hashtables in a web environment, they need to be thread safe. That being said, java.util.Collections gives you some easy to use utilities to create synchronised Maps very easily. HTH Mark ~| Introducing the Fusion Authority Quarterly Update. 80 pages of hard-hitting, up-to-date ColdFusion information by your peers, delivered to your door four times a year. http://www.fusionauthority.com/quarterly Archive: http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:255097 Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4
Structures in Java?
Is there anything in Java similar to Coldfusions Structures? ~| Introducing the Fusion Authority Quarterly Update. 80 pages of hard-hitting, up-to-date ColdFusion information by your peers, delivered to your door four times a year. http://www.fusionauthority.com/quarterly Archive: http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:254928 Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
Re: Structures in Java?
On 10/1/06, D F [EMAIL PROTECTED] wrote: Is there anything in Java similar to Coldfusions Structures? Remember that ColdFusion is compiled to Java, so there's always going to be a related data type between the two languages. In this case, you want a HashMap, which is what a CF structure is under the hood: http://java.sun.com/j2se/1.4.2/docs/api/java/util/HashMap.html Regards, Dave. ~| Introducing the Fusion Authority Quarterly Update. 80 pages of hard-hitting, up-to-date ColdFusion information by your peers, delivered to your door four times a year. http://www.fusionauthority.com/quarterly Archive: http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:254929 Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
Re: Structures in Java?
Thanks Dave, so presumably this HashMap object can be passed around through various methods etc? On 10/1/06, D F [EMAIL PROTECTED] wrote: Is there anything in Java similar to Coldfusions Structures? Remember that ColdFusion is compiled to Java, so there's always going to be a related data type between the two languages. In this case, you want a HashMap, which is what a CF structure is under the hood: http://java.sun.com/j2se/1.4.2/docs/api/java/util/HashMap.html Regards, Dave. ~| Introducing the Fusion Authority Quarterly Update. 80 pages of hard-hitting, up-to-date ColdFusion information by your peers, delivered to your door four times a year. http://www.fusionauthority.com/quarterly Archive: http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:254930 Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
Re: Structures in Java?
On 10/1/06, D F [EMAIL PROTECTED] wrote: Thanks Dave, so presumably this HashMap object can be passed around through various methods etc? If I'm understanding what you're trying to to do, then yes, you can pass Java objects just like you can pass CF objects around. The big difference is that, if you pass it as an argument to a cffunction call, then the cfargument tag should expect a type of any to use the Java object correctly. Regards, Dave. ~| Introducing the Fusion Authority Quarterly Update. 80 pages of hard-hitting, up-to-date ColdFusion information by your peers, delivered to your door four times a year. http://www.fusionauthority.com/quarterly Archive: http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:254931 Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
Re: Structures in Java?
On 10/1/06, D F [EMAIL PROTECTED] wrote: Thanks Dave, so presumably this HashMap object can be passed around through various methods etc? Pretty much. I think the one thing you need to keep in your head is that in java, everything starts at 0, and CF starts with 1. There is a word that I should replace everything with.. maybe indices? Eh. ** On a side note, I can't decide whether I'm dealing with a open loop, or a black hole, on another issue... anyone know how to tell the difference? Is it just taking a long time to get back to me? /me blows the dust off of some Hawking books Stupid jokes award!?! Sign me up! -Den ~| Introducing the Fusion Authority Quarterly Update. 80 pages of hard-hitting, up-to-date ColdFusion information by your peers, delivered to your door four times a year. http://www.fusionauthority.com/quarterly Archive: http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:254933 Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
Re: Structures in Java?
Your probably better off with a java.util.Hashtable, as it is already syncronised (thread safe), and more often than not, where are using Hashtables in a web environment, they need to be thread safe. That being said, java.util.Collections gives you some easy to use utilities to create synchronised Maps very easily. HTH Mark On 10/2/06, Dave Carabetta [EMAIL PROTECTED] wrote: On 10/1/06, D F [EMAIL PROTECTED] wrote: Thanks Dave, so presumably this HashMap object can be passed around through various methods etc? If I'm understanding what you're trying to to do, then yes, you can pass Java objects just like you can pass CF objects around. The big difference is that, if you pass it as an argument to a cffunction call, then the cfargument tag should expect a type of any to use the Java object correctly. Regards, Dave. ~| Introducing the Fusion Authority Quarterly Update. 80 pages of hard-hitting, up-to-date ColdFusion information by your peers, delivered to your door four times a year. http://www.fusionauthority.com/quarterly Archive: http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:254942 Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4
RE: Passing CF5 Structures to Java
I don't think you can do that in CF5, you should be able to get something like that working in CFMX though. Structures in CF5 are in C++ memory land, but in MX they are java objects, so you can pass them around to your own stuff. One workaround is to use WDDX, serialize the structure to WDDX, pass it as a string, and then in the Java class convert the WDDX into a Hashtable. Another workaround would be to create a UDF or something that converted a CF structure into a Java Hashtable by looping through the structure. This would probably perform better than the WDDX solution. _ Pete Freitag CTO, CFDEV.COM http://www.cfdev.com/ -Original Message- From: Correa, Orlando (ITSC) [mailto:Orlando.Correa;mail.ihs.gov] Sent: Wednesday, November 13, 2002 1:44 PM To: CF-Talk Subject: Passing CF5 Structures to Java We are experiencing a problem while trying to pass a ColdFusion 5 structure to a java class that was created using CreateObject. Our java code conceptually looks something similar to: public class javaTest { public static int testThis(Hashtable testVal) { return 7; } } The call in Cold Fusion is like: cfset request.o_test = CreateObject(JAVA, javaTest) cfloop from=1 to=1000 index=i cfset x = request.o_test.testThis(CFstructure) /cfloop where CFstructure is a basic structure (key/value pair) with 2 elements. We have also tried to cast the structure as a HashMap and an Object and get the same error each time. Unknown exception during conversion of a CF type to a Java type Can anyone help us with this? Thanks... Anderson, Ryan R. (ITSC) Also... we are using JRE 1.4.0 JVM ~| Archives: http://www.houseoffusion.com/cf_lists/index.cfm?forumid=4 Subscription: http://www.houseoffusion.com/cf_lists/index.cfm?method=subscribeforumid=4 FAQ: http://www.thenetprofits.co.uk/coldfusion/faq Your ad could be here. Monies from ads go to support these lists and provide more resources for the community. http://www.fusionauthority.com/ads.cfm
RE: Passing CF5 Structures to Java
Thanks Pete! For now... we were able to get away with using and passing an integer array. We haven't upgraded to CFMX yet, but are looking forward to better CF/Java integration. As an interesting side note... we found that if we called our Java object via a cfscript UDF call and looped over that... we ran into a huge bottleneck with its performance... however, calling the Java objects outside of the UDF in a loop performed about 8 times faster in our simple tests (~34 seconds to ~4 seconds). I'm not sure what's really going there, but thought someone out there might know... Thanks again... Orlando Correa IHS/ITSC -Original Message- From: Pete Freitag [mailto:pf;cfdev.com] Sent: Wednesday, November 13, 2002 12:10 PM To: CF-Talk Subject: RE: Passing CF5 Structures to Java I don't think you can do that in CF5, you should be able to get something like that working in CFMX though. Structures in CF5 are in C++ memory land, but in MX they are java objects, so you can pass them around to your own stuff. One workaround is to use WDDX, serialize the structure to WDDX, pass it as a string, and then in the Java class convert the WDDX into a Hashtable. Another workaround would be to create a UDF or something that converted a CF structure into a Java Hashtable by looping through the structure. This would probably perform better than the WDDX solution. _ Pete Freitag CTO, CFDEV.COM http://www.cfdev.com/ -Original Message- From: Correa, Orlando (ITSC) [mailto:Orlando.Correa;mail.ihs.gov] Sent: Wednesday, November 13, 2002 1:44 PM To: CF-Talk Subject: Passing CF5 Structures to Java We are experiencing a problem while trying to pass a ColdFusion 5 structure to a java class that was created using CreateObject. Our java code conceptually looks something similar to: public class javaTest { public static int testThis(Hashtable testVal) { return 7; } } The call in Cold Fusion is like: cfset request.o_test = CreateObject(JAVA, javaTest) cfloop from=1 to=1000 index=i cfset x = request.o_test.testThis(CFstructure) /cfloop where CFstructure is a basic structure (key/value pair) with 2 elements. We have also tried to cast the structure as a HashMap and an Object and get the same error each time. Unknown exception during conversion of a CF type to a Java type Can anyone help us with this? Thanks... Anderson, Ryan R. (ITSC) Also... we are using JRE 1.4.0 JVM ~| Archives: http://www.houseoffusion.com/cf_lists/index.cfm?forumid=4 Subscription: http://www.houseoffusion.com/cf_lists/index.cfm?method=subscribeforumid=4 FAQ: http://www.thenetprofits.co.uk/coldfusion/faq Your ad could be here. Monies from ads go to support these lists and provide more resources for the community. http://www.fusionauthority.com/ads.cfm