Survey
* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
FUSIONDOX Google App Engine and Flex Andrew Schwabe Chief Technology Officer – IEXP | FusionDox www.fusiondox.com FUSIONDOX Who is this guy anyway? A. B. C. D. ColdFusion developer since version 3 Flex Developer since Flex 2 Betas Worked in web development for 13+ years CTO with IEXP | FusionDox, Member of Magic Industries Australia, Private consultant E. Lead Architect for: • FusionDox Document Mgt Technologies 2 FUSIONDOX Terminology Disclaimer A. We will be using terms from ColdFusion, Flex and Java B. Google is your friend 3 FUSIONDOX If you are not a Java Programmer... A. B. C. D. E. 4 Its ok :) Open your mind... Copy & Paste to get started I don't code in Java every day As a CF developer, it is good to know a little This is a crash course, not an authoritative lesson in Java coding discipline! FUSIONDOX What is Google App Engine (GAE) 5 FUSIONDOX What is Google App Engine (GAE) A. Lets you run your applications on Google's infrastructure 6 FUSIONDOX What is Google App Engine (GAE) A. Lets you run your applications on Google's infrastructure B. Virtualization Technology 7 FUSIONDOX What is Google App Engine (GAE) A. Lets you run your applications on Google's infrastructure B. Virtualization Technology C. Uses Python and Java 8 FUSIONDOX 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 9 FUSIONDOX Why bother? 10 FUSIONDOX Why bother? A. We can use Flex :) B. Scalability is handled automatically by Google! C. Open 11 FUSIONDOX Why bother? A. We can use Flex :) B. Scalability is handled automatically by Google! C. Open FREE HOSTING 12 FUSIONDOX FREE? But What is the catch ? 13 FUSIONDOX FREE? But What is the catch ? A. B. C. D. Have to use Google's Web Toolkit (GWT) Get up to 500MB of free storage Supports about 5 million page views per month Host it at myapp.appspot.com or myapp.mydomain.com (using Google Apps) E. Above 500MB/5M views costs $$$ 14 FUSIONDOX Do I have to use Google Web Toolkit??? 15 FUSIONDOX Do I have to use Google Web Toolkit??? A. YES. 16 FUSIONDOX 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 17 FUSIONDOX 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 18 FUSIONDOX Datastore A. B. C. D. 19 Kind of like a database You have to work a bit harder to relate your data Why? Not sure. Maybe b/c it is FAST and DUMB FUSIONDOX 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 20 FUSIONDOX 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 21 FUSIONDOX 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 22 FUSIONDOX 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 23 FUSIONDOX Development Environment A. Download a full Eclipse installation B. Install Google Eclipse Plugin for Java C. D. E. F. 24 http://code.google.com/eclipse/docs/download.html PyDev if you want to develop with Python Includes Google Web Toolkit (GWT) Consider some add-ons like Aptana (has a nice XML editor among other things) FUSIONDOX Starting a new GAE Java Project A. From Projects View B. New → Project → Google Web Application C. Give it a name D. Give it a package namespace (i.e. com.yourcompany.projectname) E. Keep the rest of the defaults and finish 25 FUSIONDOX FUSIONDOX Starting a new GAE Java Project A. B. It will add a lot of stuff to your project The “src” directory is where you will add your Java related code C. The “war” directory is essentially your webroot This is where your html/flex/etc. files go D. The default project adds a “greeting” app so that your app does something right away 27 FUSIONDOX Running the new GAE Java Project A. Select your project B. Run As... Web Application C. It should open the GAE window and a web browser to your default document 28 FUSIONDOX FUSIONDOX 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 30 FUSIONDOX 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 31 FUSIONDOX DEMO 1: Flex + XML Interface A. Add an Entity Class (FlogEntry.java) 32 FUSIONDOX 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 ◊ ◊ ◊ 33 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 DEMO 1: Flex + XML Interface A. Add an Entity Class (FlogEntry.java) B. Add a Service Implementation (FlexServiceImpl.java) 34 FUSIONDOX DEMO 1: Flex + XML Interface A. Add an Entity Class (FlogEntry.java) B. Add a Service Implementation (FlexServiceImpl.java) ◊ Define one function called doGet() ◊ ◊ ◊ 35 It handles multiple actions (save, delete, list) Construct XML to send back to flex via HTTP Take note of PersistenceManager FUSIONDOX DEMO 1: Flex + XML Interface A. Add an Entity Class (FlogEntry.java) B. Add a Service Implementation (FlexServiceImpl.java) C. Update web.xml 36 FUSIONDOX 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 37 FUSIONDOX DEMO 1: Flex + XML Interface A. Create the Flex App ◊ All requests are managed through an HTTP request 38 FUSIONDOX DEMO 1: Flex + XML Interface A. Browsing the datastore http://localhost:8080/_ah/admin/datastore 39 FUSIONDOX 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 40 FUSIONDOX GET ON WITH IT ! 41 FUSIONDOX 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 42 FUSIONDOX Publishing to Google's System A. Right click on project → Google → Deploy 43 FUSIONDOX 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 44 FUSIONDOX 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 45 FUSIONDOX Useful Sites http://appengine.google.com http://code.google.com/eclipse/docs/download.html http://localhost:8080/_ah/admin/datastore http://wiki.openbluedragon.org/wiki/index.php/Googl eAppEngine:Datastore 46 FUSIONDOX 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] 47