Scala 㧠Google App Engine
Scalaã®ããã°ã©ã ã¯ï¼ããªããã®ã¾ã¾Javaã®ã¯ã©ã¹ãã¡ã¤ã«ã¨ãªãã®ã§ï¼Google App Engineã®ãµã¼ãã¬ãããScalaã§æ¸ããããããªããã¨æã£ã¦ãããï¼ãã£ã¦ã¿ããï¼ãããç°¡åã«æ¸ããï¼
æ¹æ³ã¯ï¼こちらのサイトãåèï¼Eclipseã®ãã©ã°ã¤ã³ã使ãï¼
æºå
ä¸è¨ã®æé ã§ç°å¢ãã»ããã¢ããããï¼
- Google App Engine ã®ãã©ã°ã¤ã³ãEclipseã«å°å ¥ããï¼
- Scalaã®ãã©ã°ã¤ã³ãEclipseã«å°å ¥ããï¼æ¹æ³ã¯ï¼こちらï¼
- App Engineã®ããã¸ã§ã¯ããä½æããï¼
- ããã±ã¼ã¸ã¨ã¯ã¹ããã¼ã©ã®ããã¸ã§ã¯ãåä¸ã§ï¼å³ã¯ãªãã¯ã§ã³ã³ãã¯ã¹ãã¡ãã¥ã¼ãåºãï¼Scala-> Add Scala Natureãé¸æï¼ããã«ãã£ã¦ï¼ä½æããããã¸ã§ã¯ãã§Scalaã使ããããã«ãªãï¼
ããã¾ã§ã§ï¼App Engineéçºãµã¼ãã§Scalaãå®è¡ã§ããããã«ãªãï¼ãï¼ã¯ã©ã¦ãã«ãããã¤ãã¦ãScalaã®ã©ã¤ãã©ãªãã¯ã©ã¦ãã«ã³ãã¼ãããªãããåä½ããªãï¼ã©ã¤ãã©ãªãã³ãã¼ãããããã«ããã«ã¯ï¼ä¸è¨ãå¿ è¦ï¼
- Scalaã®ã©ã¤ãã©ãªjarã war/WEB-INF/lib ã«ã³ãã¼ï¼å¾è¿°ï¼
ãµã¼ãã¬ãã
æºåãã§ãããï¼ãã¨ã¯ï¼Javaã®Servletã¯ã©ã¹ãç¶æ¿ãã¦ï¼Scalaã§ãµã¼ãã¬ãããæ¸ãã¦ããã°ããï¼ãã®ã¨ãï¼å³ã¯ãªãã¯ï¼new->class ã§ã¯ãªãï¼new -> other ã§åºã¦ããã¦ã£ã¶ã¼ãã®ãªãããï¼Scala classãé¸æããã°ï¼Scalaã®ã¯ã©ã¹ãä½æã§ããï¼
import java.io.IOException import javax.servlet.http._ class HelloServlet extends HttpServlet { override def doGet(req: HttpServletRequest, resp: HttpServletResponse) { resp.setContentType("text/plain") resp.getWriter().println("Hello world, from Scala!") } }
ç°¡åã ï¼ãã®ä¾ã ã¨ç°¡åããã¦ï¼Scalaã§æ¸ãæå³ããªã:).
ãã¨ã¯ï¼ç¹ã«ä½ãããå¿ è¦ã¯ç¡ãï¼æ®éã«éçºãµã¼ãã使ããã¨ãã§ããï¼
ã©ã¤ãã©ãªã®ã³ãã¼
åè¿°ããããã«ï¼war/WEB-INF/lib 以ä¸ã«Scalaã®ã©ã¤ãã©ãªjarãã³ãã¼ããå¿ è¦ãããï¼ã©ãããæã£ã¦ãã¦ãããã¨æããï¼pluginã«å«ã¾ãã¦ããjarã®ãã¹ãï¼ããã±ã¼ã¸ã¨ã¯ã¹ããã¼ã©ã®Scala Library ã®ä¸ã«è¦ãã¦ããã®ã§ï¼ãããã³ãã¼ããï¼ç§ã®Mac OSã§ã®ç°å¢ã®å ´åã¯ï¼ãããªæãï¼
> cp /Applications/eclipse/configuration/org.eclipse.osgi\ /bundles/354/1/.cp/lib/scala-{dbc,library,swing}.jar \ workspace/scalagae/war/WEB-INF/lib
ããã§ï¼ã¯ã©ã¦ãã«ãããã¤ãã¦å®è¡ãããã¨ãã§ããï¼
åé¡ç¹
åé¡ã¯ï¼ãã¼ã¿ã¹ãã¢ï¼æ®éGoogle App Engineã§ã¯ï¼JDO(ãJPA)ã使ã£ã¦ï¼ãã¼ã¿ã¹ãã¢ã«ã¢ã¯ã»ã¹ããã®ã ãã©ï¼JDOã§ã¯ã¢ããã¼ã·ã§ã³ã使ãï¼Scalaã§ãã¢ããã¼ã·ã§ã³ã¯ä½¿ããã¯ããªã®ã§ï¼ã¡ããã¨æ¸ãã°ä½¿ãããã ãã©ã¾ã æåãã¦ããªãï¼ãã¡ããï¼ãã¼ã¿ã®å®£è¨ã¯Javaã§ãã£ã¦ããã¦ï¼Scalaããã¯ä½¿ãã ãï¼ã¨ããæ¹æ³ã¯ç°¡åã«ã§ãããã ï¼
ææ
æå¤ã«ç°¡åã ã£ãï¼Eclipseãã©ã°ã¤ã³ã使ããã®ã§ï¼å¹ççã«éçºã§ãããï¼