顯示具有 GAE 標籤的文章。 顯示所有文章
顯示具有 GAE 標籤的文章。 顯示所有文章

星期二, 5月 05, 2009

GAE初體驗

今天終於拿到GAE for Java的使用許可

因為我們已經全部使用Eclipse當作開發工具, 所以透過 http://code.google.com/appengine/docs/java/tools/eclipse.html 所介紹的步驟來安裝 Google Plugin for Eclipse, 這邊不贅述.

我是使用 Eclipse 3.4 (Ganymede) for J2EE的版本. 安裝好之後工具列上會多三個小圖示


點第一個小圖示可以產生一個新的GAE project.




產生出來的專案可以馬上部屬到申請的GAE空間, 最簡單的方法是按那個長得像小飛機的按鈕.




上傳前必須填一些認證資料.




接著要設定application ID, 其實也就是申請時所設定的 http://xxx.appspot.com/ 的那個xxx. 一個人可以設定10個.




ok, 現在可以上傳了



上傳需要花一點時間, 上傳完成後就可以看看甚麼也沒做就完成的東西啦.


接著就是要找時間玩一下其他支援的功能囉. 開小飛機的初體驗還蠻有趣的 :D

星期一, 5月 04, 2009

關於GAE中用來儲存資料的兩個標準 (JDO, JPA)

話說昨天看了一下GAE的說明得知, 若要在GAE上儲存資料必須要使用JDO或JPA這兩種技術... 但是其實這兩種技術我都不會, 哈哈~ 一直都還在用很老舊的架構 Session Bean <-> DAO <-> JDBC <-> DB, 因為我喜歡使用很華麗的SQL statement來提高資料存取的速度, 曾經我也使用過Entity Bean來開發J2EE的系統, 那根本是場災難... 也造成我一直對於所謂的frameworks有點敬而遠之 (Struts, Webwork, Spring, Hibernate... etc), 且也不希望增加版本更新的困擾 (光Tomcat要不要upgrade都可以讓我考慮好幾天), 因此都只有大概看看文件, 了解一下這些frameworks存在的必要性而已.

Anyway, 在GAE上儲存資料必須要使用JDO或JPA這兩種標準, 所以我今天花了點時間研究一下, Google上是採用 Datanucleus的solution, 但這時還不曉得這個solution是甚麼, 接著上網查到 http://en.wikipedia.org/wiki/Datanucleus中有這一段: DataNucleus Access Platform is the persistence layer behind Google App Engine for Java. 原來這個 plateform同時支援JDO跟JPA兩個標準, 因此想用哪個就用哪個囉.

另外也看到Hibernate主要是JPA的實作, 因此若使用JPA可算是有摸蜆仔兼洗褲的作用. 以後若有機會使用Hibernate的話, 不妨就使用JPA來儲存資料吧.

不過看到以下那一堆unsupported features... 很多features我看不太懂是甚麼意思, 不過不能join不能aggregrate?! 不會吧~~ 那我要資料總筆數怎麼作咧... 還是說有method可以用? 看來只好等空間拿到手再來好好試用一下.

Edit 1: 剛又多研究了一下, 知道資料總筆數要用 datastore.prepare(query).countEntities()來取得, 也就是說, 基本上資料應該已經全部從資料庫給拉出來了, 這樣若有需要作報表系統的話, 效能堪慮阿...

Unsupported Features of JDO

The following features of the JDO interface are not supported by the App Engine implementation:

  • Unowned relationships. You can implement unowned relationships using explicit Key values. JDO's syntax for unowned relationships may be supported in a future release.
  • Owned many-to-many relationships.
  • contains() syntax for query filters on Collection fields. You can test that a multi-valued property (a Collection field) has a value using an equality filter: collection == "value"
  • "Join" queries. You cannot use a field of a child entity in a filter when performing a query on the parent kind. Note that you can test the parent's relationship field directly in query using a key.
  • JDOQL grouping and other aggregate queries.
  • Polymorphic queries. You cannot perform a query of a class to get instances of a subclass. Each class is represented by a separate entity kind in the datastore.
  • IdentityType.DATASTORE for the @PersistenceCapable annotation. Only IdentityType.APPLICATION is supported.
  • There is currently a bug preventing preventing persistent fields on superclasses from being saved to the datastore. This will be fixed in a future release.


Unsupported Features of JPA

The following features of the JPA interface are not supported by the App Engine implementation:

  • Owned many-to-many relationships, and unowned relationships. You can implement unowned relationships using explicit Key values, though type checking is not enforced in the API.
  • "Join" queries. You cannot use a field of a child entity in a filter when performing a query on the parent kind. Note that you can test the parent's relationship field directly in query using a key.
  • Aggregation queries (group by, having, sum, avg, max, min)
  • Polymorphic queries. You cannot perform a query of a class to get instances of a subclass. Each class is represented by a separate entity kind in the datastore.

星期六, 5月 02, 2009

看來挺有搞頭的Google App Engine

今天忙著在GWT, Ext-GWT, ZK中奮鬥,想了解到底哪一個AJAX framework比較適合我們公司使用, 目前看來是使用GWT多少可以與Android上的開發經驗相結合.

但突然想到如何與視覺化介面設計師 (據說是高級系統美工的雅稱)配合的問題, 畢竟這是web系統開發通常最痛苦的地方所在, 在網路上瀏覽資料, 似乎有還不錯的解法, 不過這不是本篇的重點, 重點是突然發現Google App Engine (GAE)這個有趣的東西, GAE剛滿周歲不久 (一年後才發現, 哈哈), 更巧的是最近剛開始開放支援Java, 也可以支援cron (scheduled tasks). 資料儲存則可以用Java Data Objects (JDO) 和 Java Persistence API (JPA), 還有其他的服務如Memcache, Expand URL FetchURL Fetch, Expand Mail, Expand Images, Expand Google Accounts, 感覺功能相當完整, 以前蠻難找到可以作Java hosting的虛擬主機, 免費的更少, GAE看來提供一個很不錯的解決方案.

使用 Android + RESTful + Google Data API + GAE 組合出有價值的服務, 看來不是夢阿!

其實覺得自己的行為還蠻像internet spider的 XD