Upload
jason-sutton
View
212
Download
0
Embed Size (px)
Citation preview
FUSIONDOX FUSIONDOX
Google App Engine and Flex
Andrew Schwabe
Chief Technology Officer – IEXP | FusionDox
www.fusiondox.com
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
FUSIONDOX FUSIONDOX
3
Terminology Disclaimer
A. We will be using terms from ColdFusion, Flex and Java
B. Google is your friend
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!
FUSIONDOX FUSIONDOX
5
What is Google App Engine (GAE)
FUSIONDOX FUSIONDOX
6
What is Google App Engine (GAE)
A. Lets you run your applications on Google's infrastructure
FUSIONDOX FUSIONDOX
7
What is Google App Engine (GAE)
A. Lets you run your applications on Google's infrastructure
B. Virtualization Technology
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
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
FUSIONDOX FUSIONDOX
10
Why bother?
FUSIONDOX FUSIONDOX
11
Why bother?
A. We can use Flex :)
B. Scalability is handled automatically by Google!
C. Open
FUSIONDOX FUSIONDOX
12
Why bother?
A. We can use Flex :)
B. Scalability is handled automatically by Google!
C. Open
FREE HOSTING
FUSIONDOX FUSIONDOX
13
FREE? But What is the catch ?
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 $$$
FUSIONDOX FUSIONDOX
15
Do I have to use Google Web Toolkit???
FUSIONDOX FUSIONDOX
16
Do I have to use Google Web Toolkit???
A. YES.
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
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
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
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
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
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
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
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)
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
FUSIONDOX FUSIONDOX
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
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
FUSIONDOX FUSIONDOX
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
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
FUSIONDOX FUSIONDOX
32
DEMO 1: Flex + XML Interface
A. Add an Entity Class (FlogEntry.java)
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 :)
FUSIONDOX FUSIONDOX
34
DEMO 1: Flex + XML Interface
A. Add an Entity Class (FlogEntry.java)
B. Add a Service Implementation (FlexServiceImpl.java)
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
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
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
FUSIONDOX FUSIONDOX
38
DEMO 1: Flex + XML Interface
A. Create the Flex App◊ All requests are managed through an HTTP
request
FUSIONDOX FUSIONDOX
39
DEMO 1: Flex + XML Interface
A. Browsing the datastore
http://localhost:8080/_ah/admin/datastore
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
FUSIONDOX FUSIONDOX
41
GET ON WITH IT !
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
FUSIONDOX FUSIONDOX
43
Publishing to Google's System
A. Right click on project → Google → Deploy
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
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
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
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