åè Slim3 JSON æ©è½ã®èª¬æ(éå ¬å¼) GAE + Slim3 㧠JSON åºå Model ã§ã®è¨è¿°ä¾ã åºæ¬çã«ã¯ JSON ãå©ç¨ããã®ã«æ¢åã® Model ããã®ã¾ã¾ä½¿ããã ããããJSON ã¢ããã¼ã·ã§ã³ã§ Model ãä¿æããã¨ã³ãã£ãã£å ã®ããããã£ãæä½ãããå ´åã¯ãä¸è¨ã®ããã«ãorg.slim3.datastore.json.Jsonããå¿ è¦ã«ãªãã import org.slim3.datastore.Attribute; import org.slim3.datastore.Model; // JSON ã¢ããã¼ã·ã§ã³ãå©ç¨ããå ´åã« import ãã import org.slim3.datastore.json.Json; @Model(schemaVersion = 1) public class Article implements Ser
(2/7æ´æ°) (2/26æ´æ°) (12/22æ´æ° @Jsonã¯ãã£ã¼ã«ãç´æ¥æå®ã«ãªãã¾ãã) Slim3 JSONæ©è½ã®ããã¥ã¡ã³ããæ¸ãå§ãã¾ãããã¾ã éå ¬å¼ãªãã®ã§ãããã²ã¨éãæ¸ãçµãã£ããå ¬å¼ã¸ã®ãã¼ã¸ãææ¡ããäºå®ã§ããã§ããå ¬å¼ã¯è±èªãªãã§ããããã©ããããã®ããã¾ãããããªãä¸æãªè±èªã§æ¸ããããã¾ãã¯æ¥æ¬èªã§ã¡ããã¨æ¸ããã»ããè¯ãã¯ãã ã¨ããããã§ãä¸è¨ããã¥ã¡ã³ãã®èæ¡ã§ããè¥å¹²æ¹è¡ãå¤ã§ãããevernoteã«æ¸ããªãã£ã¦exportãããã®ãè²¼ã£ã¤ãã¦ãããã ã¨æãã¾ããããã«ãã¨JSONå ¥åºåã®ã«ã¹ã¿ãã¤ãºæ¹æ³ãæ¸ãã¦ä¸æ®µè½ã¨ããäºå®ã§ãã(æ¸ãã¾ãã!) æ¦è¦ãSlim3ã®JSONæ©è½ã¯ãã¢ãã«(@org.slim3.datastore.Modelã¢ããã¼ã·ã§ã³ãä»å ãããã¯ã©ã¹)ã®JSONå¤ææ©è½ãæä¾ãã¾ããJSONå¤æã¯ãorg.slim3.data
ä¾ãã°ã渡ãããå¤ãä¸æã§ãã®å¤ã Key ã¨ãã¦å©ç¨ãããå ´åããã¿ã¤ã ã¹ã¿ã³ãã Java ã§å©ç¨ã§ããããªç§åä½ã«å¤æãããå ´åãªã©ã§ãBeanUtil ã§å¦çãããåã«ä¸åº¦å¥ã®å¦çãè¡ãããã¨ãã«ä½¿ãã public class ItemService { private ItemMeta a = new ItemMeta(); public Item post(Map<String, Object> input) { Item Item = new Item(); // exclude ã«å¦ç対象å¤ã«ãããå¤æ°åãè¨å ¥ãã // See at http://slim3.googlecode.com/svn/trunk/slim3/javadoc/org/slim3/util/CopyOptions.html BeanUtil.copy(input, Item, new CopyO
CoolãªURIã§JSONãè¿ãURLã¯ã©ã表ç¾ããã å é¨çã«ã¯ã/user/get?id=12345&type=jsonãã¨ãªããããªURIï¼idã12345ã®ã¦ã¼ã¶æ å ±ã®JSONå½¢å¼ï¼ããCool URIã§ã¯ã©ã®ããã«è¡¨ç¾ããã®ãé©åãæ©ãã§ãããã/user/json/12345ããã/user/12345/jsonãã¯ãªããéãæ°ããããã ãããããWebãæ¯ããæè¡ -HTTPãURIãHTMLãããã¦REST (WEB+DB PRESSãã©ã¹ã·ãªã¼ãº)ãã«ãã®çããæ¸ãã¦ãã£ãã ä¾ãã°ï¼ã¤ã®ãªã½ã¼ã¹ãHTMLã¨ããã¹ãã¨JSONã§è¡¨ç¾ã§ããå ´åã«ã¯ãããããã.htmlãã.txtãã.jsonãã¨ããæ¡å¼µåãä»ãã¦ããã®è¡¨ç¾ãåããã¨è¯ãã§ãããã ãWebãæ¯ããæè¡ã p.062 å è¿°ã®ä¾ã§è¨ãã°ãã/user/12345.jsonãã¨ãªãããªãã»ã©ç¢ºãã«ããã¯ãã£
slim3ã§ã¯GAEã®ç°å¢ã«ä¾åãããããªåä½ãã¹ããããªãç°¡åã«è¡ãäºãã§ãã¾ããä¾ãã°ãBigtableã¸ã®ã¢ã¯ã»ã¹ã¯ãã¹ãã®å®è¡æ¯ã«ãªã»ããããããã°ãã¼ãã«ãã©ã³ã¶ã¯ã·ã§ã³ã«å¯¾å¿ãªã©è³ããã¤ãããã§ãã ã¨ããããç»åãå å·¥ãã¦ãµã ãã¤ã«ãä½ãæãªã©ã«ä½¿ç¨ãã ImagesServiceã§ããããããåä½ãã¹ãã§å®è¡ãããã¨ããã¨ä¾å¤ãçºçãã¾ããå é¨çã«ã¯ãç»åã®ä½æãä¸é¨ã®è»½ãå¦çã¯Implã§è¡ã£ã¦ããããã§ãããæ¡å¤§ç¸®å°ãªã©ã®å¤æå¦çã¯åã¢ããªã§ããã®ã§ã¯ãªããå¤é¨ãµã¼ãã¹ã¨ãã¦å¼ã³åºãã¦ããããã§ãããããã®ãã¹ãç°å¢ã§ã®ã¨ãã¥ã¬ã¼ãã¯ãorg.slim3.tester.AppEngineTesterã®makeSyncCallã§è¡ã£ã¦ãã¾ãã®ã§ããããå°ãã«ã¹ã¿ãã¤ãºãããã¨ã§ImagesServiceãã¨ãã¥ã¬ã¼ãã§ããããã«ãªãã¾ãã 以ä¸ãç°¡åãªãµã³ãã«ã«ãªãã¾ãã
ãã¼ã«ã«ã®ã¦ããããã¹ãã§ãcom.google.appengine.api.users.Userã®ã¤ã³ã¹ã¿ã³ã¹ãåå¾ãããã¨ãã¦ããããã©ã«ãã»ã³ã³ã¹ãã©ã¯ã¿ã¯ãã©ã¤ãã¼ãã§ããããUserServiceã®getCurrentUser()ã¡ã½ãããnullãè¿ããããç°¡åã§ã¯ãªãã 以ä¸ã®ãªã³ã¯ãåèã«ããã°ãgetCurrentUser()ã¡ã½ããã§ä»»æã®userIdãæã¤Userã®ã¤ã³ã¹ã¿ã³ã¹ãåå¾ãããã¨ãå¯è½ã Local Unit Testing with UserService: userId==null problem ã¾ããslim3ãå©ç¨ããå ´åã¯ãä¸è¨ã®ããã«tester.environmentããorg.slim3.tester.TestEnvironmentãå©ç¨ãããããã public class UserTest extends AppEngineTestC
ãã¡ãã®ãã¼ã¸ã¯ç§»è»¢ãã¾ããã ãã®åº¦ãæ§ä¼ç¤¾åã·ã¢ãã«ã³ã³ãµã«ãã£ã³ã°æ ªå¼ä¼ç¤¾ããï¼ï¼¥ï¼´ï¼¡ï¼´ï¼¥ï¼¡ï¼æ ªå¼ä¼ç¤¾ã¸ã¨ç¤¾åå¤æ´ããã³ãå¼ç¤¾ã³ã¼ãã¬ã¼ããµã¤ãããªãã¥ã¼ã¢ã«ãããã¾ããã ãã®ãã¼ã¸ã¯5ç§å¾ã«ãæ°ããã³ã¼ãã¬ã¼ããµã¤ãã«èªå転éããã¾ãã é·ç§»ããªãå ´åã¯ãã¡ãã
ãã®ä»ããã©ã³ã¯ããã¸ã§ã¯ãã®å ¥æã«æ¸ãã¦ããè¨å®ãè¡ãã ããã¸ã§ã¯ããå®è¡ï¼ãå®è¡ãâãWebã¢ããªã±ã¼ã·ã§ã³ãï¼ããã¨ããDevelopment Modeãã¨ãããã¥ã¼ãéãã ããã«è¡¨ç¤ºããã¦ãããhttp://127.0.0.1:8888/index.html?gwt.codesvr=127.0.0.1:9997ãããã©ã¦ã¶ã¼ã§éãã¨ãæåã«ãGoogle Web Toolkit Developer Pluginãã®ã¤ã³ã¹ãã¼ã«ãè¦æ±ãããã GwtDevPluginSetup.exeããã¦ã³ãã¼ããã¦å®è¡ãã¦ã¤ã³ã¹ãã¼ã«ããã å度ãhttp://127.0.0.1:8888/index.html?gwt.codesvr=127.0.0.1:9997ããéãã¨ããã©ã¦ã¶ã¼ä¸ã¯çã£ç½ã®ç»é¢ã表示ãããã ããï¼GwtDevPluginã®ActiveXã®å®è¡ã¯è¨±å¯ãã¦ããï¼ Ecli
AppEngineã¯ãã¢ã¯ã»ã¹ããã£ãã¨ãã«ã¢ããªã±ã¼ã·ã§ã³ãèµ·åãããã°ããã¢ã¯ã»ã¹ãç¡ããã°ã¢ããªã±ã¼ã·ã§ã³ãçµäºãããã¾ã次ã®ãªã¯ã¨ã¹ãã§åèµ·åããã¨ããä»çµã¿ãå°å ¥ãã¦ãã¾ãã ãã®ãããã¢ããªã±ã¼ã·ã§ã³ãèµ·å(spin-up)ããæéãã¨ã¦ãéè¦ã«ãªã£ã¦ãã¾ãããã®spin-upã®æéã¯python(webapp)ã§60cpu_ms以ä¸ã(cpu_msã¯cpuã使ãä»®æ³çãªæéã§ããmsã¨åãæãã§æãã¦ããã£ã¦ãã¨ããããã¯å¤§ä¸å¤«ã§ã)Javaã®Servletã ã¨600cpu_msãããã§ããPythonã§ãDjangoãããªå¤§ããªãã¬ã¼ã ã¯ã¼ã¯ã ã¨1000cpu_msããã(ã¢ããªã«ãã)ãããã¾ããã許容ç¯å²å ãJavaã ã¨Slim3ã§1300cpu_msãSpringã ã¨æ©ãã¦7000cpu_msã¨ããæãã§ãSlim3ãã®ãªã®ãªè¨±å®¹ç¯å²å ã§ãããããã»ãã¨ãã¯ã1000
ãªãªã¼ã¹ãé害æ å ±ãªã©ã®ãµã¼ãã¹ã®ãç¥ãã
ææ°ã®äººæ°ã¨ã³ããªã¼ã®é ä¿¡
å¦çãå®è¡ä¸ã§ã
j次ã®ããã¯ãã¼ã¯
kåã®ããã¯ãã¼ã¯
lãã¨ã§èªã
eã³ã¡ã³ãä¸è¦§ãéã
oãã¼ã¸ãéã
{{#tags}}- {{label}}
{{/tags}}