Google App Engine Developer - Day1

902 views

Published on

Start to use Java App Engine
- Install & deploy
- First code, make a simple UI
- User login integrate

Published in: Technology
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
902
On SlideShare
0
From Embeds
0
Number of Embeds
2
Actions
Shares
0
Downloads
41
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Google App Engine Developer - Day1

  1. 1. GAE Developer - Day1 Simon @ MiCloud 2014Q1
  2. 2. ● https://developers.google.com/eclipse/docs/getting_started?hl=zh-tw Install GAE Eclipse Plugin
  3. 3. Install GAE Eclipse Plugin ● Eclipse 4.3 (Kepler) ○ https://dl.google.com/eclipse/plugin/4.3 ● Eclipse 3.8/4.2 (Juno) ○ https://dl.google.com/eclipse/plugin/4.2 ● Eclipse 3.7 (Indigo) ○ https://dl.google.com/eclipse/plugin/3.7
  4. 4. Install GAE Eclipse Plugin
  5. 5. First GAE App ● Create GAE web project ● Review project & Edit Servlet ● Deploy to GAE
  6. 6. Create GAE Web Project
  7. 7. Going to Project Detail Java source code Web source code GAE setting Servlet setting
  8. 8. Local Develop Server
  9. 9. Local Server Supports ● Jetty Servlet container ● Admin page ● Datastore - HDR ● MySQL connect
  10. 10. Local Admin Console
  11. 11. Deploy GAE to Cloud
  12. 12. Getting Start….
  13. 13. GAE預設值... ● Stateless - no session enabled ● Without app stat page ● Have JSP standard UserPrinciple object for authentication ● Cannot DB connection ● JSTL support
  14. 14. 建立簡單的UI - https://jetstrap.com
  15. 15. 整合到專案
  16. 16. Enable Session...
  17. 17. 基本設定 - Enable Session
  18. 18. Enable App State...
  19. 19. App Stats Servlet <!-- direct /appstats requests to built-in appstats tool --> <servlet> <servlet-name>appstats</servlet-name> <servlet-class>com.google.appengine.tools.appstats.AppstatsServlet</servlet-class> </servlet> <servlet-mapping> <servlet-name>appstats</servlet-name> <url-pattern>/appstats/*</url-pattern> </servlet-mapping> <!-- appstats to record statistics/metrics for each request --> <filter> <filter-name>appstats</filter-name> <filter-class>com.google.appengine.tools.appstats.AppstatsFilter</filter-class> </filter> <filter-mapping> <filter-name>appstats</filter-name> <url-pattern>/*</url-pattern> </filter-mapping>
  20. 20. http://localhost:8888/appstats/stats
  21. 21. Use User Service….
  22. 22. User Service Callback Page Result Page extends: AbstractAppEngineAuthor izationCodeServlet extends: AbstractAppEngineAuthor izationCodeCallbackServl et G 1 2 34
  23. 23. <%@ page contentType="text/html;charset=UTF-8" language="java" %> <%@ page import="java.util.List" %> <%@ page import="com.google.appengine.api.users.User" %> <%@ page import="com.google.appengine.api.users.UserService" %> <%@ page import="com.google.appengine.api.users.UserServiceFactory" %> <% UserService userService = UserServiceFactory.getUserService(); User user = userService.getCurrentUser(); if (user != null) { pageContext.setAttribute("user", user); %> <a href="<%= userService.createLogoutURL(request.getRequestURI()) %>">sign out</a>.)</p> <a href="<%= userService.createLoginURL(request.getRequestURI()) %>">Sign in</a> 整合User Service
  24. 24. Others...
  25. 25. ● 預設Datastore: com.google.api.client. extensions.appengine.auth.oauth2. AppEngineCredentialStore User service default store
  26. 26. 取得App Engine Id import com.google.apphosting.api.ApiProxy; ApiProxy.getCurrentEnvironment().getAppId();
  27. 27. Team Work - Invite Cooperate User
  28. 28. Q&A END

×