Charting with CF and Flex

47
FUSIONDOX Google App Engine and Flex Andrew Schwabe Chief Technology Officer – IEXP | FusionDox www.fusiondox.com

Transcript of Charting with CF and Flex

Page 1: Charting with CF and Flex

FUSIONDOX FUSIONDOX

Google App Engine and Flex

Andrew Schwabe

Chief Technology Officer – IEXP | FusionDox

www.fusiondox.com

Page 2: Charting with CF and Flex

FUSIONDOX FUSIONDOX

2

Who is this guy anyway?

A. ColdFusion developer since version 3

B. Flex Developer since Flex 2 Betas

C. Worked in web development for 13+ years

D. CTO with IEXP | FusionDox, Member of Magic Industries Australia,Private consultant

E. Lead Architect for:• FusionDox Document Mgt Technologies

Page 3: Charting with CF and Flex

FUSIONDOX FUSIONDOX

3

Terminology Disclaimer

A. We will be using terms from ColdFusion, Flex and Java

B. Google is your friend

Page 4: Charting with CF and Flex

FUSIONDOX FUSIONDOX

4

If you are not a Java Programmer...

A. Its ok :) Open your mind...

B. Copy & Paste to get started

C. I don't code in Java every day

D. As a CF developer, it is good to know a little

E. This is a crash course, not an authoritative lesson in Java coding discipline!

Page 5: Charting with CF and Flex

FUSIONDOX FUSIONDOX

5

What is Google App Engine (GAE)

Page 6: Charting with CF and Flex

FUSIONDOX FUSIONDOX

6

What is Google App Engine (GAE)

A. Lets you run your applications on Google's infrastructure

Page 7: Charting with CF and Flex

FUSIONDOX FUSIONDOX

7

What is Google App Engine (GAE)

A. Lets you run your applications on Google's infrastructure

B. Virtualization Technology

Page 8: Charting with CF and Flex

FUSIONDOX FUSIONDOX

8

What is Google App Engine (GAE)

A. Lets you run your applications on Google's infrastructure

B. Virtualization Technology

C. Uses Python and Java

Page 9: Charting with CF and Flex

FUSIONDOX FUSIONDOX

9

What is Google App Engine (GAE)

A. Lets you run your applications on Google's infrastructure

B. Virtualization Technology

C. Uses Python and Java

D. Its OPEN

Page 10: Charting with CF and Flex

FUSIONDOX FUSIONDOX

10

Why bother?

Page 11: Charting with CF and Flex

FUSIONDOX FUSIONDOX

11

Why bother?

A. We can use Flex :)

B. Scalability is handled automatically by Google!

C. Open

Page 12: Charting with CF and Flex

FUSIONDOX FUSIONDOX

12

Why bother?

A. We can use Flex :)

B. Scalability is handled automatically by Google!

C. Open

FREE HOSTING

Page 13: Charting with CF and Flex

FUSIONDOX FUSIONDOX

13

FREE? But What is the catch ?

Page 14: Charting with CF and Flex

FUSIONDOX FUSIONDOX

14

FREE? But What is the catch ?

A. Have to use Google's Web Toolkit (GWT)

B. Get up to 500MB of free storage

C. Supports about 5 million page views per month

D. Host it at myapp.appspot.com or myapp.mydomain.com (using Google Apps)

E. Above 500MB/5M views costs $$$

Page 15: Charting with CF and Flex

FUSIONDOX FUSIONDOX

15

Do I have to use Google Web Toolkit???

Page 16: Charting with CF and Flex

FUSIONDOX FUSIONDOX

16

Do I have to use Google Web Toolkit???

A. YES.

Page 17: Charting with CF and Flex

FUSIONDOX FUSIONDOX

17

Do I have to use Google Web Toolkit???

A. YES.

B. But its not that bad – and actually we won't be doing much with it anyway

C. And apps written with GWT can be hosted on your own server on your own JVM if you wanted

Page 18: Charting with CF and Flex

FUSIONDOX FUSIONDOX

18

From Here to There...

A. Build your app with Google's tools on your local machine

B. Publish the app to Google

C. Use Datastore for storage

D. No filesystem writing capability

Page 19: Charting with CF and Flex

FUSIONDOX FUSIONDOX

19

Datastore

A. Kind of like a database

B. You have to work a bit harder to relate your data

C. Why?

D. Not sure. Maybe b/c it is FAST and DUMB

Page 20: Charting with CF and Flex

FUSIONDOX FUSIONDOX

20

No Filesystem Writing

A. No custom logging

B. You can't easily “tweak” things once they are on the production system

C. Forces you to plan your app. (Not a bad thing)

D. Not suitable for hosting your MP3s or WaReZ

Page 21: Charting with CF and Flex

FUSIONDOX FUSIONDOX

21

Java NOT Python

A. Originally planned to use Python

B. Since the topic was chosen, Google came out with Java tools

C. I re-built all the demos using Java tools

D. CF is much closer related to CF than Python

E. Learning a little Java is a good thing

Page 22: Charting with CF and Flex

FUSIONDOX FUSIONDOX

22

Java NOT Python

A. Originally planned to use Python

B. Since the topic was chosen, Google came out with Java tools

C. I re-built all the demos using Java tools

D. CF is much closer related to CF than Python.

E. Learning a little Java is a good thing

Page 23: Charting with CF and Flex

FUSIONDOX FUSIONDOX

23

Development Environment

A. Flex Builder

B. It really does help to have Flex Builder installed as a plugin in a full Eclipse installation

C. Most developers probably will not, so we will use a standalone Flex Builder install for the demos

Page 24: Charting with CF and Flex

FUSIONDOX FUSIONDOX

24

Development Environment

A. Download a full Eclipse installation

B. Install Google Eclipse Plugin for JavaC. http://code.google.com/eclipse/docs/download.html

D. PyDev if you want to develop with Python

E. Includes Google Web Toolkit (GWT)

F. Consider some add-ons like Aptana(has a nice XML editor among other things)

Page 25: Charting with CF and Flex

FUSIONDOX FUSIONDOX

25

Starting a new GAE Java Project

A. From Projects View

B. New → Project → Google Web ApplicationC. Give it a name

D. Give it a package namespace(i.e. com.yourcompany.projectname)

E. Keep the rest of the defaults and finish

Page 26: Charting with CF and Flex

FUSIONDOX FUSIONDOX

Page 27: Charting with CF and Flex

FUSIONDOX FUSIONDOX

27

Starting a new GAE Java Project

A. It will add a lot of stuff to your project

B. The “src” directory is where you will add your Java related code

C. The “war” directory is essentially your webrootThis is where your html/flex/etc. files go

D. The default project adds a “greeting” app so that your app does something right away

Page 28: Charting with CF and Flex

FUSIONDOX FUSIONDOX

28

Running the new GAE Java Project

A. Select your project

B. Run As... Web ApplicationC. It should open the GAE window and a web browser

to your default document

Page 29: Charting with CF and Flex

FUSIONDOX FUSIONDOX

Page 30: Charting with CF and Flex

FUSIONDOX FUSIONDOX

30

Important Files

A. war/WEB-INF/web.xml– Sets the start up page for your app– Configure your servlet here

B. war/WEB-INF/appengine-web.xml– Defines the unique ID for your app– Defines the version number for your app

Page 31: Charting with CF and Flex

FUSIONDOX FUSIONDOX

31

DEMO 1: Flex + XML Interface

A. A Fast Web Log aka FLOG application

B. UI in Flex

C. Back end in Java using HTTP to send/retrieve with XML

Page 32: Charting with CF and Flex

FUSIONDOX FUSIONDOX

32

DEMO 1: Flex + XML Interface

A. Add an Entity Class (FlogEntry.java)

Page 33: Charting with CF and Flex

FUSIONDOX FUSIONDOX

33

DEMO 1: Flex + XML Interface

A. Add an Entity Class (FlogEntry.java)◊ Contains all the data we want to persist◊ Declare the class as @Persistent◊ Define private vars for each value you want to store◊ Define getters and setters for each◊ Copy/paste the rest and don't worry about it :)

Page 34: Charting with CF and Flex

FUSIONDOX FUSIONDOX

34

DEMO 1: Flex + XML Interface

A. Add an Entity Class (FlogEntry.java)

B. Add a Service Implementation (FlexServiceImpl.java)

Page 35: Charting with CF and Flex

FUSIONDOX FUSIONDOX

35

DEMO 1: Flex + XML Interface

A. Add an Entity Class (FlogEntry.java)

B. Add a Service Implementation (FlexServiceImpl.java)

◊ Define one function called doGet()◊ It handles multiple actions (save, delete, list)◊ Construct XML to send back to flex via HTTP◊ Take note of PersistenceManager

Page 36: Charting with CF and Flex

FUSIONDOX FUSIONDOX

36

DEMO 1: Flex + XML Interface

A. Add an Entity Class (FlogEntry.java)

B. Add a Service Implementation (FlexServiceImpl.java)

C. Update web.xml

Page 37: Charting with CF and Flex

FUSIONDOX FUSIONDOX

37

DEMO 1: Flex + XML Interface

A. Add an Entity Class (FlogEntry.java)

B. Add a Service Implementation (FlexServiceImpl.java)

C. Update web.xml◊ Add our servlet and servlet-mapping◊ Change the default page

Page 38: Charting with CF and Flex

FUSIONDOX FUSIONDOX

38

DEMO 1: Flex + XML Interface

A. Create the Flex App◊ All requests are managed through an HTTP

request

Page 39: Charting with CF and Flex

FUSIONDOX FUSIONDOX

39

DEMO 1: Flex + XML Interface

A. Browsing the datastore

http://localhost:8080/_ah/admin/datastore

Page 40: Charting with CF and Flex

FUSIONDOX FUSIONDOX

40

DEMO 2: Flex + BlazeDS

A. Use Spring AMF configuration (needs extra jars and xml files)

B. webAppContext.xml points to your service implementation (FlexService2)(much cleaner)

C. In Flex, create an Entity class to match your server-side one (good practice)

D. Use RemoteObject pointing to servlet-mapping we setup

Page 41: Charting with CF and Flex

FUSIONDOX FUSIONDOX

41

GET ON WITH IT !

Page 42: Charting with CF and Flex

FUSIONDOX FUSIONDOX

42

GET ON WITH IT !

A. Demo 3 – Using OpenBD!– Has trouble with WSDLs (demo uses http/xml)– Limitations with writing to local file system

B. Demo 4 – Requiring Authentication– Require google login (web.xml)– Use ajax to call servlet for auth info

Page 43: Charting with CF and Flex

FUSIONDOX FUSIONDOX

43

Publishing to Google's System

A. Right click on project → Google → Deploy

Page 44: Charting with CF and Flex

FUSIONDOX FUSIONDOX

44

Tips and Such

A. Don't forget to edit appengine-web.xml and give your app a UNIQUE id(frustration with publishing if you don't)

B. If you have multiple GAE projects in your workspace, sometimes the google VM can get confused. Use the “Compile/Browse” button to force it to rebuild

C. Consider renaming your default page/app

Page 45: Charting with CF and Flex

FUSIONDOX FUSIONDOX

45

Tips and Such

A. Since GAE can use Java, many technologies can be re-tasked to run

B. Alternatives to BlaseDS config– GraniteDS

http://blog.allurefx.com/2009/05/cloud-to-ria-accessing-google-app.html

Page 46: Charting with CF and Flex

FUSIONDOX FUSIONDOX

46

Useful Sites

http://appengine.google.com

http://code.google.com/eclipse/docs/download.html

http://localhost:8080/_ah/admin/datastorehttp://wiki.openbluedragon.org/wiki/index.php/GoogleAppEngine:Datastore

Page 47: Charting with CF and Flex

FUSIONDOX FUSIONDOX

47

Thank you!

A. All updated files will be on my blog here:

http://blog.schwabe.net

and posted on cfunited.com

B. Questions? Email me at

[email protected]