1 / 19

A Beginners Guide to Java Integration in ColdFusion

A Beginners Guide to Java Integration in ColdFusion. Rick Root. Who Am I?. It just doesn’t seem right to have a slide with bullet points that prompt me to talk about myself. About This Session. Extend ColdFusion with “core” java Extend ColdFusion with external java libraries

johana
Télécharger la présentation

A Beginners Guide to Java Integration in ColdFusion

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. A Beginners Guide to Java Integration in ColdFusion Rick Root

  2. Who Am I? • It just doesn’t seem right to have a slide with bullet points that prompt me to talk about myself.

  3. About This Session • Extend ColdFusion with “core” java • Extend ColdFusion with external java libraries • We will not talk about JVM tuning, writing CFX Custom Tags in Java, or writing your own Java classes.

  4. Who Are You? • ColdFusion newbs • Never really used Java in ColdFusion • Just here for the networking

  5. “Networking”

  6. Using Core Java Functionality • Java Objects • Data Types • Creating and Initializing Java Objects • JavaCast() • Examples

  7. Java Objects • It all starts with java.langObject • Java objects have methods, so ColdFusion variables do to. • Example 1

  8. Data Types – Java vs. CF • Strictly typed, very picky! • Don’t assume! • Example 2

  9. Creating and Initializing Java Objects • In Java, create and initialize all at once, ie:foo = new ClassName(arguments) • In CF, use CreateObject() and init() methodfoo = CreateObject(“java”,”path.to.ClassName”); foo.init(arguments); • Multiple constructors / overloaded methods foo.init(“string”);foo.init(someint);

  10. JavaCast() • Force a ColdFusion variable to be a specific data type • Example 3 & 4

  11. String Concatenation Example • Object creation is expensive • Strings are immutable • Java StringBuffer object can help! • Example 5

  12. Using Third Party Libraries • Where to Install • Java Loader • Examples

  13. Installing Third Party Libraries • Standalone: <cfroot>/lib • Multi-server Install, all instances: <jrunroot>/servers/lib • Multi-server install, specific Instance: <jrunroot>/servers/<instancename> /cfusion.ear/cfusion.war /WEB-INF/cfusion/lib • Anywhere you want!

  14. Using JavaLoader • javaloader.cfc – Mark Mandel • Access classes without requiring them to be in the server CLASSPATH • Javaloader.riaforge.org • Example 6

  15. Examples • Generating Excel Files • Creating delimited text files • Extracting JPEG image metadata

  16. Generating Excel Files • Apache POI – API to interface with Microsoft Office files • http://poi.apache.org • Create Excel files in native format • Use more Excel features • Example 7

  17. Creating Delimited Files • JavaCSV makes it easy • Choose your delimiter • Automatic quoting when data contains your delimiter or even newlines • Example 8

  18. Extracting JPEG Image Metadata • Digital cameras store lots of metadata in captured images • Timestamp • Exposure • Camera model • Lots of stuff I don’t understand! • Example 9

  19. Wrap Up • Rick Root • rick.root@gmail.com • http://www.opensourcecf.com/

More Related