Scala 㧠Google App Engine
以åScalaã§Google App Engineã使ããªããã¨æã£ã¦ï¼試してみたï¼ãã®ã¨ãã«ã¯ï¼ãµã¼ãã¬ããã¯æ®éã«åããã©ï¼JDOã®ã¨ã³ãã³ãµãåãã¦ãããªãã¦ï¼JDOã使ããªãã£ãï¼ä»åï¼ã¡ãã£ã¨ããã£ã¦ã¿ããJDOãå«ãã¦åãããã¨ãã§ããã®ã§æ¸ãã¦ããï¼
ã³ãã³ãã©ã¤ã³ã§ã®æä½
è¦ããã«ï¼Eclipseã®å¤ã§ã¨ã³ãã³ãµã ãåããã°ããï¼ããã«ã¯ï¼SDKã«å«ã¾ãã¦ããbuild.xmlã使ãã¨ç°¡åï¼
SDKã1.3.0ã ã¨ããã¨ï¼
appengine-java-sdk-1.3.0/demos/jdoexamples/build.xml
ã«build.xmlãããï¼ãããEclipseã®ããã¸ã§ã¯ããã¼ã ãã£ã¬ã¯ããª(warã¨ãsrcããããã£ã¬ã¯ããª)ã«ã³ãã¼ãã¦ããï¼ã§ï¼ãã®ãã¡ã¤ã«ã®åé ã«ãã
<property name="sdk.dir" location="../.." />
ã®../..ã®é¨åãç·¨éãã¦ï¼èªåã®SDKãæãããã«ããï¼
ãã¨ã¯ï¼
ant
ã¨ããã ãï¼ç°¡åã ï¼JDOã®ã¢ãã«ã¯ã©ã¹ãæ¸ãç´ããã³ã«å®è¡ããªããã°ãªããªãã®ãã¡ãã£ã¨é¢åã ãï¼ï¼ï¼
Scalaã§æ¸ãJDOã®ã¢ãã«
Scalaã§æ¸ãã¨JDOã®ã¢ãã«ã¯ããªããã£ããããï¼ã¨ããã®ã¯ï¼ããã¾ãæ¬è³ªçãªè©±ãã§ã¯ãªãã¦ï¼Beanã®getter, setterãèªåçæãã¦ãããã¢ããã¼ã·ã§ã³ãããããï¼ãªãã§Javaã«ã¯ãªãã®ãï¼ãã£ã¡ã®ã»ããä¸æè°ã ãï¼
import java.util.Date import javax.jdo.annotations.IdGeneratorStrategy import javax.jdo.annotations.IdentityType import javax.jdo.annotations.PersistenceCapable import javax.jdo.annotations.Persistent import javax.jdo.annotations.PrimaryKey import com.google.appengine.api.users.User import scala.reflect.BeanProperty @PersistenceCapable{val identityType = IdentityType.APPLICATION} class Memo { @PrimaryKey @Persistent{val valueStrategy = IdGeneratorStrategy.IDENTITY} @BeanProperty private var id: java.lang.Long = null @Persistent @BeanProperty private var author: User = null @Persistent @BeanProperty private var content: String = null @Persistent @BeanProperty private var date: Date = null def this(author: User, content: String, date: Date) { this() this.author = author this.content = content this.date = date } }
PMFã¯classã§ã¯ãªãobjectã§æ¸ãã¦ããï¼ããããã·ã³ã°ã«ãã³ï¼
import javax.jdo.JDOHelper import javax.jdo.PersistenceManagerFactory object PMF { var pmfInstance: PersistenceManagerFactory = JDOHelper.getPersistenceManagerFactory("transactions-optional") def get(): PersistenceManagerFactory = pmfInstance }
ææ
App Engineä¸ã§JRubyã使ã£ã¦Ruby on Railsãªã©ãåãããããã話ããããããã ãï¼ããªã大è¦æ¨¡ãªã¯ã©ã¹ãã¼ãã«ãªãããã¹ãã³ã¢ããæéããã«ã«ãªããªãã¨èãï¼
Scalaã®å ´åã¯ï¼æå ã§classãã¡ã¤ã«ã«ãªã£ã¦ããã®ã§ï¼App Engineã®ã¹ãã³ã¢ããæéããã¾ãããããªãï¼ããããªãã ãããï¼ã©ãã ããï¼