SlideShare a Scribd company logo
1 of 60
Download to read offline
Google App
Engine for Java
       Java




 shin1ogawa@
...shin1ogawa
Google, Java, Eclipse, AppEngine,
Wicket, Maven, Hudson,        ...
                       Java
•               OSS

    •   [SF.jp]Jiemamy...

    •   [SF.jp]gae-j-samples...GAE/J          GAE/J/Maven

    •   [SF.jp]asclipse...Amateras AIR GEAR   AS3

    •   java-ja, wicket-ja, BOTTUKU...

                             (http://www.topgate.co.jp)
         GoogleAppEngine          GoogleApps
• Platform
    •
    •

•
•
• Datastore
    •
    •
•
Platform

•


    •    Disk

•
    •   AppEngine



• Google Apps       Apps
Platform

• Google


• Google
•
Platform

•
    •
                          JVM                            …

•                         Platform
    •   AWS-EC2         ”Amazon Cloud Watch(     )”             (
            )                   ”Auto Scaling”        ”Elastic Load
        Balancing”
    •
                Relational Database


        •         KVS   SimpleDB(     )
Platform

•                          WebContainer
• static              Container
•
 • DatastoreService
 • MailService
 • URLFetchService
 • ImageService...
• cron
Platform

•



     /            , CPU
         , DISK
    , API         ,
                      ...
Platform
“                        ”
• 1
                                         1
    •                        ”release”
            ”snapshot”       …
        •   http://myappid.appspot.com/ ...
        •   http://snapthot.latest.myappid.appspot.com/ ...

•


        •   datastore
        •                           python         java
Platform
Web
• JVM           JDK1.6      Hotspot Client VM
• Jetty


    •   Jetty       JEE           App Engine


    •   Jetty   Comet       (30                stream         )

•                       =           JVM


    •              static

•                                       https           off
Platform
Web                   /
• appengine-web.xml               sessions enabled=true


•                                  Datastore


    •   _ah_session       Kind

• Application
                                 SessionCleanupServlet


    •       Servlet              web.xml
Platform

•
    • Disk
•
• API
• Java




     : http://code.google.com/intl/ja/appengine/docs/quotas.html
Platform

• Disk
    •                   3000
    • Datastore         1GB
•                 250
    • ...


                  appengine
Platform

•
        30
•                /           10MB
•                    2000
•        API          7000
• ...        ,   /
Platform
API
• Datastore                      1MB
• MemcacheService     Key
           1MB
• URLFetchService          10


• Datasotre                     1000
 •   JDO      1000   ...

• ...
Platform
Java
•
• Thread
• Socket
• JDK                  class
    •   white-list                class              -> http://
        code.google.com/intl/ja/appengine/docs/java/jrewhitelist.html
•               GC
• ...
1
•          : Google
•
    •   Best practices for writing scalable applications
• Google Group
    •   Google App Engine for Java
    •   Google App Engine
    •   Google-App-Engine-Japan

• Google Code
    •   googleappengine
    •   datanucleus-appengine
2
•             1,   3               IRC                  Office Hour
    •   irc://irc.freenode.net/#appengine
    •   Google Calendar: delevepoer-calendar@google.com

• Google App Engine Blog
• AppEngine Cookbook
• Under the covers of the Google App Engine
  Datastore
•                           tips
• shin1ogawa
    •                          (     maven plugin   )
    •                  Google App Engine
3




• https://sites.google.com/a/topgate.co.jp/


         : AppEngineSDK
                      Hackathon   Googler
• Google Plugins for Eclipse(SDK                               )
 •                                               Eclipse
 •   AppEngine

• Ant(SDK                           )
 •   dev_appserver
 •   app_cfg         AppEngine

• Python          SDK(JavaSDK                                          )
 •   index   vacuum(Index   Error                          )
 •   bulkloader(Datastore               Export/Import)

• NetBeans         IntelliJ IDEA                plugin             …
• war/WEB-INF/
  • appengine-web.xml
   ...appengine

 • datastore-indexes.xml
   ...             index

 • cron.xml       ...cron

 • appegnine-generated/
   • datastore-indexes-auto.xml
     ...             index

   • local_db.bin           ...Datastore
•
• SDK
                                     local_db.bin(
                )    SDK
    •                 local_db.bin      AppID, versionId
                         local_db.bin              k

• Maven
    •   mvnsearch             appengine
    •   shin1ogawa   Maven   SDK          plugin
•


•                     java.util.logging


    •   war/WEB-INF/appengine-web.xml   logging.properties



• RemoteApiServlet                                 SDK
appengine-web.xml
•              on/off
• https    on/off
•                       static


•


• logging.properties
•          web.xml
Datastore

• Kind...RDB
• Entity...RDB
• Property...RDB
• Index...RDB
• Key...RDB          Entity
• Filter...SQL     Where
 • equality filter...          ”=”    Filter
  • inequality filter...”>”, “>=”, “<=”, “<“
• Entity Group...                 Entity
Datastore

• BigTable
 • ...

• RDB
 •    (     =         key                   )
     • [0]id=1, name=”Hoge”
     • [1]id=2, height=170.5, weight=65.5
     • [2]id=3, tag=[“Apple”, “Java”]
 •
Datastore

•
    •         Entity     80ms/1
    • RDB     Index
•               Entity


•
    • Query
                           (      )
    •
Datastore

•
    •         Entity     80ms/1
    • RDB     Index
•               Entity


•
    • Query
                           (      )
    •
Datastore
Entity Group
•                               Entity
    • RDB               Relation
    • Java
    •       )
        •           Kind:Entity:id=1
            •         Kind:Entity:id=2
                •       Kind:Entity:id=3
        •           Kind:Entity:id=4
            •         Kind:Entity:id=5
Datastore
Key
• Entity                          Property
 • Long    (id)    String    (name)   Key    Id


• EntityGroup                                     Entity   Key
       Entity
 •    Entity: Kind=Parent, id=1
 •    Entity: Kind=Child, name=“hoge@fuga.com”
 •                Entity    Key
     • Parent(1)/Child(“hoge@fuga.com”)
Datastore
Property
• Entity
• java.lang
 • String          500
• Text
 • 500            String
• Blob
 •
• List Property
 • List    Set
Datastore
Index
• Property
• Kind Index
 • Kind Key                        Index
• Single Property Index
 •        Property                Index
• Composite Index
 •      Property                 Index
• Text     Blob       Index

             (index explosion)             Composite
Property          Index
Datastore
Transaction
•                    ACID
    •
        • JDO
        •
•               Transaction   EntityGroup
        Entity
    •
Datastore
Query
•                   ’<‘, ‘<=’, ‘==’, ‘>=’, ‘>’
• Like                      (startsWith())
•             And
• Java      ‘IN’, ‘!=’
•        Property
     inequality filter                           Property


• max()     min()
• Join
Datastore
Query
• Index
                                 → Index


 • Kind Index, Single Property Index
            Datastore


 • Composite Index   datastore-indexes.xml
Datastore
NG
•
    •
        ID
    •                            1,2,3,1001,1002...

•
    •                  1000
        •    JDO          1000



        Google                                        tips
                   ”      ”
Datastore

•
    •
    •
•                             Kind
•           EntityGroup       (
    Transaction           )
    •   Transaction
•
Datastore
                     /
                                         =


•
    • ID,          ShardingNo
    •       “ID,          ShardingNo)”




•
Datastore
                            /
                        1         2      ...


• offset/limit
•                      +1
                                Filter
    •                                          Filter
                   k

•
    •   property            property
Datastore

• JDO, JPA, Low-level API      3
 •           JPA
 • JDO                                  ORM


     •             Datastore
 •                                 Low-level API
     • JDO         Low-level API
     JEE                                           ...


                               Low-level API
Datastore
JDO/Entity
@PersistenceCapable(identityType = IdentityType.APPLICATION
  , detachable = "true")
@Version(strategy = VersionStrategy.VERSION_NUMBER)
public class Entity {
  @Persistent
  @PrimaryKey(valueStrategy = IdGeneratorStrategy.IDENTITY)
  Key id;

    @Persistent String value;

    @Persistent(defaultFetchGroup = “true”) Text text;
}

                       Fetch            Fetch
@Version       JDO                        (OPT_VERSION   property
           )
Datastore
JDO/Owned Relationship
public class Parent {
  ...
  @Persistent(defaultFetchGroup = “true”)
  List<Child> children;
}

public class Child {
  @Persistent
  @PrimaryKey(valueStrategy = IdGeneratorStrategy.IDENTITY)
  Key id;
  ...
}


Child   Key   (    encoded-pk   String   )
Datastore
JDO/Owned Relationship(Key                             )
public class Parent {
  ...
}

public class Child {
  ...
  @Persistent
  @Extension(vendorName="datanucleus",
    key="gae.parent-pk", value="true")
  Key parentKey;
  ...
}

   Entity                                      Child
parentKey    Entity     Key          EntityGroup
   Ancestor Key
Datastore
JDO/Owned Relationship(                     )
public class Parent {
  ...
  @Persistent(defaultFetchGroup = “true”)
  List<Child> children;
}

public class Child {
  ...
  @Persistent(mappedBy = “children”)
  Parent parent;
  ...
}


mappedBy                   property
Datastore
JDO/Unowned Relationship
@PersistenceCapable(identityType = IdentityType.APPLICATION)
public class Entity {
  @Persistent
  @PrimaryKey(valueStrategy = IdGeneratorStrategy.IDENTITY)
  Key id;

    @Persistent
    String value;

    @Persistent
    Sey<Key> otherEntityRefs;
}
Datastore
JDO/
PersistentManager pm = ... // PersistentManager        ;
Parent parent = new Parent();
parent.set......
List<Child> children = new ArrayList<Child>();
children.add(child1);
parent.setChildren(children);

try {
  Transaction transaction = pm.currentTransaction();
  transaction.begin();
  pm.makePersistent(parent);
  transaction.commit();
} finally {
  if (transaction.isActive())
    transaction.rollback();
}
Datastore
JDO/
PersistentManager pm = ... // PersistentManager             ;
Query query = pm.newQuery(Entity.class);
query.setFilter(“name == param”);
query.declareParameters(“java.lang.String param”);
query.setOrdering(“name asc, key desc”);
@SuppressWarnings("unchecked")
List<Entity> list = (List<Entity>) query.execute(“hoge”);
...

Key key = KeyFactory.createKey(“Entity”, “keyName”);
Entity entity = pm.getObjectById(Entity.class, key);

Key key = entity.getOtherEntityKey();
OtherEntity otherEntity = pm.getObjectById(OtherEntity.class, key);
Datastore
JDO/
PersistentManager pm = ... // PersistentManager             ;
Query query = pm.newQuery(Entity.class);
query.setFilter(“name == param”);
query.declareParameters(“java.lang.String param”);
query.setResult(“count(this)”);
@SuppressWarnings("unchecked")
Integer count = (Integer) query.execute(“hoge”);
...

query.setResult(“key”);
List<Entity> list = (List<Entity>) query.execute(“hoge”);


           ”count(this)”
           ”key”            Key
Datastore
JDO/
•
    • transient, hollow, persistent/detached
    • JDOHelper#getObjectState()
• PersistenceManager
    InstanceLifecycleListener
• PersistenceManager#execute()       List
    serialize
• PersistenceManager#retrieve[All]()           Property
           fetch
Datastore
Low-level API/
Entity entity = new Entity(“Kind”); // Low-level API   Entity
entity.setProperty(“name”, “hoge”);
entity.setProperty(“height”, 170.5);

DatastoreService service =
  DatastoreServiceFactory.getDatastoreService();
service.put(entity);

Entity[] entities = ....
service.put(entities);


                     Entity
Datastore
Low-level API/
Query query = new Query(“Entity”);
query
  .addFilter(“name”, FilterOperator.GREATER_THAN_OR_EQUAL, “hoge”)
  .addSort("name", SortDirection.ASCENDING)
  .addSort("__key__", SortDirection.ASCENDING);

DatastoreService service =
  DatastoreServiceFactory.getDatastoreService();
List<Entity> entities = service.prepare(query).asList(
  FetchOptions.Builder.withOffset(0));

Key key = KeyFactory.createKey(“Entity”, “keyName”);
Entity entity = service.get(key);


             property   ”__key__”
Datastore
Low-level API/
Query query = new Query(“Entity”);
query
  .addFilter(“name”, FilterOperator.GREATER_THAN_OR_EQUAL, “hoge”)
  .addSort("name", SortDirection.ASCENDING)
  .addSort("__key__", SortDirection.ASCENDING).setKeysOnly();

DatastoreService service =
  DatastoreServiceFactory.getDatastoreService();
int count = service.prepare(query).countEntities();

Entity entity = service. prepare(query).asSingleResult();


setKeysOnly()
asSingleResult()   0   null   1       Entity   2      Exception
MemcacheService
•
    •           (                  )
    •

• cache
•            JCache(javax.cache), Low-level API      2


    MemcacheService service =
      MemcacheServiceFactory.getMemcacheService();
    service.put("key", list);
    Object cachedObject = service.get("key");
    service.delete("key");
URLFetchService
•         URL
•                API   java.net.URLConnection   Low-level
    API   2
    •         commons-httpclient


URLFetchService service =
  URLFetchServiceFactory.getURLFetchService();
HTTPResponse response =
  service.fetch(new HTTPRequest(new URL(“”)));
if (response.getResponseCode() != 200)
  throw new RuntimeException();
byte[] bytes = response.getContent();
cron
•
    •                URL                     Filter/Servlet
•
•
    <?xml version="1.0" encoding="UTF-8"?>
    <cronentries>
      <cron>
        <url>/cron/fetch?name=jiemamy-sf</url>
        <description>fetch the jiemamy SF.jp timeline.</description>
        <schedule>every 1 minutes</schedule>
      </cron>
    </cronentries>
• MailService
 •          JavaMail(javax.mail), Low-level API   2
 •

• ImageService
 •   low-level API
 •              ...
       •

• UserService
 •   Google Account
 •           Google
                           appengine-java ML
ApiProxy
• com.google.apphosting.api.ApiProxy
 •                                       Proxy
• com.google.apphosting.api.ApiProxy.Delegate
 •
• com.google.appengine.tools.development.ApiProxyL
  ocal
 •      Delegate

           ApiProxyLocal
Delegate#makeSyncCall()
• public byte[] makeSyncCall(
  Environment environment,
  String packageName, // service
  String methodName, // service
  byte[] requestBytes) throws ApiProxyException

byte[]           ProtocolBuffer                   byte


   SDK       RemoteApiServlet
 http        makeSyncCall()             Servlet
         [         |            YO]
UI


•        UI                             …
                                    …


•


        Google App Engine   ”   ”           ”
    ”
shin1ogawa@

More Related Content

What's hot

Windows Azure: Lessons From the Field
Windows Azure: Lessons From the FieldWindows Azure: Lessons From the Field
Windows Azure: Lessons From the FieldMichael Collier
 
OpenStack Horizon: Controlling the Cloud using Django
OpenStack Horizon: Controlling the Cloud using DjangoOpenStack Horizon: Controlling the Cloud using Django
OpenStack Horizon: Controlling the Cloud using DjangoDavid Lapsley
 
Stratalux Cloud Formation and Chef Integration Presentation
Stratalux Cloud Formation and Chef Integration PresentationStratalux Cloud Formation and Chef Integration Presentation
Stratalux Cloud Formation and Chef Integration PresentationJeremy Przygode
 
SEC303 Top 10 AWS Identity and Access Management Best Practices - AWS re:Inve...
SEC303 Top 10 AWS Identity and Access Management Best Practices - AWS re:Inve...SEC303 Top 10 AWS Identity and Access Management Best Practices - AWS re:Inve...
SEC303 Top 10 AWS Identity and Access Management Best Practices - AWS re:Inve...Amazon Web Services
 
OSGi and Spring Data for simple (Web) Application Development - Christian Bar...
OSGi and Spring Data for simple (Web) Application Development - Christian Bar...OSGi and Spring Data for simple (Web) Application Development - Christian Bar...
OSGi and Spring Data for simple (Web) Application Development - Christian Bar...mfrancis
 
Automating Your Microsoft Azure Environment (DevLink 2014)
Automating Your Microsoft Azure Environment (DevLink 2014)Automating Your Microsoft Azure Environment (DevLink 2014)
Automating Your Microsoft Azure Environment (DevLink 2014)Michael Collier
 
Automating Your Azure Environment
Automating Your Azure EnvironmentAutomating Your Azure Environment
Automating Your Azure EnvironmentMichael Collier
 
More Cache for Less Cash (DevLink 2014)
More Cache for Less Cash (DevLink 2014)More Cache for Less Cash (DevLink 2014)
More Cache for Less Cash (DevLink 2014)Michael Collier
 
JavaScript!
JavaScript!JavaScript!
JavaScript!RTigger
 
FI MUNI 2012 - iOS Basics
FI MUNI 2012 - iOS BasicsFI MUNI 2012 - iOS Basics
FI MUNI 2012 - iOS BasicsPetr Dvorak
 
Zero to Sixty: AWS CloudFormation (DMG201) | AWS re:Invent 2013
Zero to Sixty: AWS CloudFormation (DMG201) | AWS re:Invent 2013Zero to Sixty: AWS CloudFormation (DMG201) | AWS re:Invent 2013
Zero to Sixty: AWS CloudFormation (DMG201) | AWS re:Invent 2013Amazon Web Services
 
Azure Day Reloaded 2019 - ARM Template workshop
Azure Day Reloaded 2019 - ARM Template workshopAzure Day Reloaded 2019 - ARM Template workshop
Azure Day Reloaded 2019 - ARM Template workshopMarco Obinu
 
All your data belong to us - The Active Objects Plugin
All your data belong to us - The Active Objects PluginAll your data belong to us - The Active Objects Plugin
All your data belong to us - The Active Objects PluginSamuel Le Berrigaud
 

What's hot (17)

Windows Azure: Lessons From the Field
Windows Azure: Lessons From the FieldWindows Azure: Lessons From the Field
Windows Azure: Lessons From the Field
 
OpenStack Horizon: Controlling the Cloud using Django
OpenStack Horizon: Controlling the Cloud using DjangoOpenStack Horizon: Controlling the Cloud using Django
OpenStack Horizon: Controlling the Cloud using Django
 
Stratalux Cloud Formation and Chef Integration Presentation
Stratalux Cloud Formation and Chef Integration PresentationStratalux Cloud Formation and Chef Integration Presentation
Stratalux Cloud Formation and Chef Integration Presentation
 
SEC303 Top 10 AWS Identity and Access Management Best Practices - AWS re:Inve...
SEC303 Top 10 AWS Identity and Access Management Best Practices - AWS re:Inve...SEC303 Top 10 AWS Identity and Access Management Best Practices - AWS re:Inve...
SEC303 Top 10 AWS Identity and Access Management Best Practices - AWS re:Inve...
 
OSGi and Spring Data for simple (Web) Application Development - Christian Bar...
OSGi and Spring Data for simple (Web) Application Development - Christian Bar...OSGi and Spring Data for simple (Web) Application Development - Christian Bar...
OSGi and Spring Data for simple (Web) Application Development - Christian Bar...
 
iOS 7 SDK特訓班
iOS 7 SDK特訓班iOS 7 SDK特訓班
iOS 7 SDK特訓班
 
Automating Your Microsoft Azure Environment (DevLink 2014)
Automating Your Microsoft Azure Environment (DevLink 2014)Automating Your Microsoft Azure Environment (DevLink 2014)
Automating Your Microsoft Azure Environment (DevLink 2014)
 
Automating Your Azure Environment
Automating Your Azure EnvironmentAutomating Your Azure Environment
Automating Your Azure Environment
 
Oak Lucene Indexes
Oak Lucene IndexesOak Lucene Indexes
Oak Lucene Indexes
 
More Cache for Less Cash (DevLink 2014)
More Cache for Less Cash (DevLink 2014)More Cache for Less Cash (DevLink 2014)
More Cache for Less Cash (DevLink 2014)
 
J query module1
J query module1J query module1
J query module1
 
JavaScript!
JavaScript!JavaScript!
JavaScript!
 
FI MUNI 2012 - iOS Basics
FI MUNI 2012 - iOS BasicsFI MUNI 2012 - iOS Basics
FI MUNI 2012 - iOS Basics
 
Zero to Sixty: AWS CloudFormation (DMG201) | AWS re:Invent 2013
Zero to Sixty: AWS CloudFormation (DMG201) | AWS re:Invent 2013Zero to Sixty: AWS CloudFormation (DMG201) | AWS re:Invent 2013
Zero to Sixty: AWS CloudFormation (DMG201) | AWS re:Invent 2013
 
Azure Day Reloaded 2019 - ARM Template workshop
Azure Day Reloaded 2019 - ARM Template workshopAzure Day Reloaded 2019 - ARM Template workshop
Azure Day Reloaded 2019 - ARM Template workshop
 
Terraform & Azure
Terraform & AzureTerraform & Azure
Terraform & Azure
 
All your data belong to us - The Active Objects Plugin
All your data belong to us - The Active Objects PluginAll your data belong to us - The Active Objects Plugin
All your data belong to us - The Active Objects Plugin
 

Similar to 初心者向けGAE/Java説明資料

Android lessons you won't learn in school
Android lessons you won't learn in schoolAndroid lessons you won't learn in school
Android lessons you won't learn in schoolMichael Galpin
 
Client-side MVC with Backbone.js
Client-side MVC with Backbone.js Client-side MVC with Backbone.js
Client-side MVC with Backbone.js iloveigloo
 
How to Contribute to Apache Usergrid
How to Contribute to Apache UsergridHow to Contribute to Apache Usergrid
How to Contribute to Apache UsergridDavid M. Johnson
 
Play Framework and Activator
Play Framework and ActivatorPlay Framework and Activator
Play Framework and ActivatorKevin Webber
 
Django Overview
Django OverviewDjango Overview
Django OverviewBrian Tol
 
Building APIs in an easy way using API Platform
Building APIs in an easy way using API PlatformBuilding APIs in an easy way using API Platform
Building APIs in an easy way using API PlatformAntonio Peric-Mazar
 
dotNet Miami - May 17th, 2012: Will Tartak: Designing for Mobile Development
dotNet Miami - May 17th, 2012: Will Tartak: Designing for Mobile DevelopmentdotNet Miami - May 17th, 2012: Will Tartak: Designing for Mobile Development
dotNet Miami - May 17th, 2012: Will Tartak: Designing for Mobile DevelopmentdotNet Miami
 
In-browser storage and me
In-browser storage and meIn-browser storage and me
In-browser storage and meJason Casden
 
Building APIs in an easy way using API Platform
Building APIs in an easy way using API PlatformBuilding APIs in an easy way using API Platform
Building APIs in an easy way using API PlatformAntonio Peric-Mazar
 
System insight without Interference
System insight without InterferenceSystem insight without Interference
System insight without InterferenceTony Tam
 
コードで学ぶドメイン駆動設計入門
コードで学ぶドメイン駆動設計入門コードで学ぶドメイン駆動設計入門
コードで学ぶドメイン駆動設計入門潤一 加藤
 
Google Developer Days Brazil 2009 - Java Appengine
Google Developer Days Brazil 2009 -  Java AppengineGoogle Developer Days Brazil 2009 -  Java Appengine
Google Developer Days Brazil 2009 - Java AppenginePatrick Chanezon
 
Web Development using Ruby on Rails
Web Development using Ruby on RailsWeb Development using Ruby on Rails
Web Development using Ruby on RailsAvi Kedar
 
Python - A Comprehensive Programming Language
Python - A Comprehensive Programming LanguagePython - A Comprehensive Programming Language
Python - A Comprehensive Programming LanguageTsungWei Hu
 
CTO Night & Days 2015 Winter - AWS Mobile Development
CTO Night & Days 2015 Winter - AWS Mobile DevelopmentCTO Night & Days 2015 Winter - AWS Mobile Development
CTO Night & Days 2015 Winter - AWS Mobile Development崇之 清水
 
Android development - the basics, MFF UK, 2014
Android development - the basics, MFF UK, 2014Android development - the basics, MFF UK, 2014
Android development - the basics, MFF UK, 2014Tomáš Kypta
 

Similar to 初心者向けGAE/Java説明資料 (20)

Android lessons you won't learn in school
Android lessons you won't learn in schoolAndroid lessons you won't learn in school
Android lessons you won't learn in school
 
Client-side MVC with Backbone.js
Client-side MVC with Backbone.js Client-side MVC with Backbone.js
Client-side MVC with Backbone.js
 
How to Contribute to Apache Usergrid
How to Contribute to Apache UsergridHow to Contribute to Apache Usergrid
How to Contribute to Apache Usergrid
 
Play Framework and Activator
Play Framework and ActivatorPlay Framework and Activator
Play Framework and Activator
 
Django Overview
Django OverviewDjango Overview
Django Overview
 
Building APIs in an easy way using API Platform
Building APIs in an easy way using API PlatformBuilding APIs in an easy way using API Platform
Building APIs in an easy way using API Platform
 
dotNet Miami - May 17th, 2012: Will Tartak: Designing for Mobile Development
dotNet Miami - May 17th, 2012: Will Tartak: Designing for Mobile DevelopmentdotNet Miami - May 17th, 2012: Will Tartak: Designing for Mobile Development
dotNet Miami - May 17th, 2012: Will Tartak: Designing for Mobile Development
 
In-browser storage and me
In-browser storage and meIn-browser storage and me
In-browser storage and me
 
Building APIs in an easy way using API Platform
Building APIs in an easy way using API PlatformBuilding APIs in an easy way using API Platform
Building APIs in an easy way using API Platform
 
System insight without Interference
System insight without InterferenceSystem insight without Interference
System insight without Interference
 
REST easy with API Platform
REST easy with API PlatformREST easy with API Platform
REST easy with API Platform
 
コードで学ぶドメイン駆動設計入門
コードで学ぶドメイン駆動設計入門コードで学ぶドメイン駆動設計入門
コードで学ぶドメイン駆動設計入門
 
HTML5: Introduction
HTML5: IntroductionHTML5: Introduction
HTML5: Introduction
 
Google Developer Days Brazil 2009 - Java Appengine
Google Developer Days Brazil 2009 -  Java AppengineGoogle Developer Days Brazil 2009 -  Java Appengine
Google Developer Days Brazil 2009 - Java Appengine
 
Extjs + Gears
Extjs + GearsExtjs + Gears
Extjs + Gears
 
Web Development using Ruby on Rails
Web Development using Ruby on RailsWeb Development using Ruby on Rails
Web Development using Ruby on Rails
 
DOTNET8.pptx
DOTNET8.pptxDOTNET8.pptx
DOTNET8.pptx
 
Python - A Comprehensive Programming Language
Python - A Comprehensive Programming LanguagePython - A Comprehensive Programming Language
Python - A Comprehensive Programming Language
 
CTO Night & Days 2015 Winter - AWS Mobile Development
CTO Night & Days 2015 Winter - AWS Mobile DevelopmentCTO Night & Days 2015 Winter - AWS Mobile Development
CTO Night & Days 2015 Winter - AWS Mobile Development
 
Android development - the basics, MFF UK, 2014
Android development - the basics, MFF UK, 2014Android development - the basics, MFF UK, 2014
Android development - the basics, MFF UK, 2014
 

More from Shinichi Ogawa

2011 12-07 ragtech2011
2011 12-07 ragtech20112011 12-07 ragtech2011
2011 12-07 ragtech2011Shinichi Ogawa
 
Appengine ja-night#13bt
Appengine ja-night#13btAppengine ja-night#13bt
Appengine ja-night#13btShinichi Ogawa
 
Devlove hangar flight-wintersortie-shin1ogawa
Devlove hangar flight-wintersortie-shin1ogawaDevlove hangar flight-wintersortie-shin1ogawa
Devlove hangar flight-wintersortie-shin1ogawaShinichi Ogawa
 
Appengine ja-night-sapporo#1 bt
Appengine ja-night-sapporo#1 btAppengine ja-night-sapporo#1 bt
Appengine ja-night-sapporo#1 btShinichi Ogawa
 
Appengine ja-night-sapporo#1
Appengine ja-night-sapporo#1Appengine ja-night-sapporo#1
Appengine ja-night-sapporo#1Shinichi Ogawa
 
Java cloud-meeting-2010tokyo-shin1ogawa
Java cloud-meeting-2010tokyo-shin1ogawaJava cloud-meeting-2010tokyo-shin1ogawa
Java cloud-meeting-2010tokyo-shin1ogawaShinichi Ogawa
 
Java Cloud Meeting Fukuoka 2010
Java Cloud Meeting Fukuoka 2010Java Cloud Meeting Fukuoka 2010
Java Cloud Meeting Fukuoka 2010Shinichi Ogawa
 
Appengine Java Night #2 LT
Appengine Java Night #2 LTAppengine Java Night #2 LT
Appengine Java Night #2 LTShinichi Ogawa
 
Appengine Java Night #2a
Appengine Java Night #2aAppengine Java Night #2a
Appengine Java Night #2aShinichi Ogawa
 
Appengine Java Night #2 Lt
Appengine Java Night #2 LtAppengine Java Night #2 Lt
Appengine Java Night #2 LtShinichi Ogawa
 
Appengine Java Night #2b
Appengine Java Night #2bAppengine Java Night #2b
Appengine Java Night #2bShinichi Ogawa
 
appengine java night #1
appengine java night #1appengine java night #1
appengine java night #1Shinichi Ogawa
 

More from Shinichi Ogawa (12)

2011 12-07 ragtech2011
2011 12-07 ragtech20112011 12-07 ragtech2011
2011 12-07 ragtech2011
 
Appengine ja-night#13bt
Appengine ja-night#13btAppengine ja-night#13bt
Appengine ja-night#13bt
 
Devlove hangar flight-wintersortie-shin1ogawa
Devlove hangar flight-wintersortie-shin1ogawaDevlove hangar flight-wintersortie-shin1ogawa
Devlove hangar flight-wintersortie-shin1ogawa
 
Appengine ja-night-sapporo#1 bt
Appengine ja-night-sapporo#1 btAppengine ja-night-sapporo#1 bt
Appengine ja-night-sapporo#1 bt
 
Appengine ja-night-sapporo#1
Appengine ja-night-sapporo#1Appengine ja-night-sapporo#1
Appengine ja-night-sapporo#1
 
Java cloud-meeting-2010tokyo-shin1ogawa
Java cloud-meeting-2010tokyo-shin1ogawaJava cloud-meeting-2010tokyo-shin1ogawa
Java cloud-meeting-2010tokyo-shin1ogawa
 
Java Cloud Meeting Fukuoka 2010
Java Cloud Meeting Fukuoka 2010Java Cloud Meeting Fukuoka 2010
Java Cloud Meeting Fukuoka 2010
 
Appengine Java Night #2 LT
Appengine Java Night #2 LTAppengine Java Night #2 LT
Appengine Java Night #2 LT
 
Appengine Java Night #2a
Appengine Java Night #2aAppengine Java Night #2a
Appengine Java Night #2a
 
Appengine Java Night #2 Lt
Appengine Java Night #2 LtAppengine Java Night #2 Lt
Appengine Java Night #2 Lt
 
Appengine Java Night #2b
Appengine Java Night #2bAppengine Java Night #2b
Appengine Java Night #2b
 
appengine java night #1
appengine java night #1appengine java night #1
appengine java night #1
 

Recently uploaded

Artificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning eraArtificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning eraDeakin University
 
costume and set research powerpoint presentation
costume and set research powerpoint presentationcostume and set research powerpoint presentation
costume and set research powerpoint presentationphoebematthew05
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024Lorenzo Miniero
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsMark Billinghurst
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsRizwan Syed
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitecturePixlogix Infotech
 
Key Features Of Token Development (1).pptx
Key  Features Of Token  Development (1).pptxKey  Features Of Token  Development (1).pptx
Key Features Of Token Development (1).pptxLBM Solutions
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfAlex Barbosa Coqueiro
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfAddepto
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024Scott Keck-Warren
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 3652toLead Limited
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticscarlostorres15106
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Mattias Andersson
 
My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024The Digital Insurer
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Enterprise Knowledge
 
Science&tech:THE INFORMATION AGE STS.pdf
Science&tech:THE INFORMATION AGE STS.pdfScience&tech:THE INFORMATION AGE STS.pdf
Science&tech:THE INFORMATION AGE STS.pdfjimielynbastida
 
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)Wonjun Hwang
 

Recently uploaded (20)

Artificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning eraArtificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning era
 
costume and set research powerpoint presentation
costume and set research powerpoint presentationcostume and set research powerpoint presentation
costume and set research powerpoint presentation
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR Systems
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL Certs
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC Architecture
 
Key Features Of Token Development (1).pptx
Key  Features Of Token  Development (1).pptxKey  Features Of Token  Development (1).pptx
Key Features Of Token Development (1).pptx
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdf
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdf
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024
 
Hot Sexy call girls in Panjabi Bagh 🔝 9953056974 🔝 Delhi escort Service
Hot Sexy call girls in Panjabi Bagh 🔝 9953056974 🔝 Delhi escort ServiceHot Sexy call girls in Panjabi Bagh 🔝 9953056974 🔝 Delhi escort Service
Hot Sexy call girls in Panjabi Bagh 🔝 9953056974 🔝 Delhi escort Service
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
 
DMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special EditionDMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special Edition
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?
 
My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024
 
Science&tech:THE INFORMATION AGE STS.pdf
Science&tech:THE INFORMATION AGE STS.pdfScience&tech:THE INFORMATION AGE STS.pdf
Science&tech:THE INFORMATION AGE STS.pdf
 
Vulnerability_Management_GRC_by Sohang Sengupta.pptx
Vulnerability_Management_GRC_by Sohang Sengupta.pptxVulnerability_Management_GRC_by Sohang Sengupta.pptx
Vulnerability_Management_GRC_by Sohang Sengupta.pptx
 
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
 

初心者向けGAE/Java説明資料

  • 1. Google App Engine for Java Java shin1ogawa@
  • 2. ...shin1ogawa Google, Java, Eclipse, AppEngine, Wicket, Maven, Hudson, ... Java • OSS • [SF.jp]Jiemamy... • [SF.jp]gae-j-samples...GAE/J GAE/J/Maven • [SF.jp]asclipse...Amateras AIR GEAR AS3 • java-ja, wicket-ja, BOTTUKU... (http://www.topgate.co.jp) GoogleAppEngine GoogleApps
  • 3. • Platform • • • • • Datastore • • •
  • 4. Platform • • Disk • • AppEngine • Google Apps Apps
  • 6. Platform • • JVM … • Platform • AWS-EC2 ”Amazon Cloud Watch( )” ( ) ”Auto Scaling” ”Elastic Load Balancing” • Relational Database • KVS SimpleDB( )
  • 7. Platform • WebContainer • static Container • • DatastoreService • MailService • URLFetchService • ImageService... • cron
  • 8. Platform • / , CPU , DISK , API , ...
  • 9. Platform “ ” • 1 1 • ”release” ”snapshot” … • http://myappid.appspot.com/ ... • http://snapthot.latest.myappid.appspot.com/ ... • • datastore • python java
  • 10. Platform Web • JVM JDK1.6 Hotspot Client VM • Jetty • Jetty JEE App Engine • Jetty Comet (30 stream ) • = JVM • static • https off
  • 11. Platform Web / • appengine-web.xml sessions enabled=true • Datastore • _ah_session Kind • Application SessionCleanupServlet • Servlet web.xml
  • 12. Platform • • Disk • • API • Java : http://code.google.com/intl/ja/appengine/docs/quotas.html
  • 13. Platform • Disk • 3000 • Datastore 1GB • 250 • ... appengine
  • 14. Platform • 30 • / 10MB • 2000 • API 7000 • ... , /
  • 15. Platform API • Datastore 1MB • MemcacheService Key 1MB • URLFetchService 10 • Datasotre 1000 • JDO 1000 ... • ...
  • 16. Platform Java • • Thread • Socket • JDK class • white-list class -> http:// code.google.com/intl/ja/appengine/docs/java/jrewhitelist.html • GC • ...
  • 17. 1 • : Google • • Best practices for writing scalable applications • Google Group • Google App Engine for Java • Google App Engine • Google-App-Engine-Japan • Google Code • googleappengine • datanucleus-appengine
  • 18. 2 • 1, 3 IRC Office Hour • irc://irc.freenode.net/#appengine • Google Calendar: delevepoer-calendar@google.com • Google App Engine Blog • AppEngine Cookbook • Under the covers of the Google App Engine Datastore • tips • shin1ogawa • ( maven plugin ) • Google App Engine
  • 19. 3 • https://sites.google.com/a/topgate.co.jp/ : AppEngineSDK Hackathon Googler
  • 20. • Google Plugins for Eclipse(SDK ) • Eclipse • AppEngine • Ant(SDK ) • dev_appserver • app_cfg AppEngine • Python SDK(JavaSDK ) • index vacuum(Index Error ) • bulkloader(Datastore Export/Import) • NetBeans IntelliJ IDEA plugin …
  • 21. • war/WEB-INF/ • appengine-web.xml ...appengine • datastore-indexes.xml ... index • cron.xml ...cron • appegnine-generated/ • datastore-indexes-auto.xml ... index • local_db.bin ...Datastore
  • 22. • • SDK local_db.bin( ) SDK • local_db.bin AppID, versionId local_db.bin k • Maven • mvnsearch appengine • shin1ogawa Maven SDK plugin
  • 23. • • java.util.logging • war/WEB-INF/appengine-web.xml logging.properties • RemoteApiServlet SDK
  • 24. appengine-web.xml • on/off • https on/off • static • • logging.properties • web.xml
  • 25. Datastore • Kind...RDB • Entity...RDB • Property...RDB • Index...RDB • Key...RDB Entity • Filter...SQL Where • equality filter... ”=” Filter • inequality filter...”>”, “>=”, “<=”, “<“ • Entity Group... Entity
  • 26. Datastore • BigTable • ... • RDB • ( = key ) • [0]id=1, name=”Hoge” • [1]id=2, height=170.5, weight=65.5 • [2]id=3, tag=[“Apple”, “Java”] •
  • 27. Datastore • • Entity 80ms/1 • RDB Index • Entity • • Query ( ) •
  • 28. Datastore • • Entity 80ms/1 • RDB Index • Entity • • Query ( ) •
  • 29. Datastore Entity Group • Entity • RDB Relation • Java • ) • Kind:Entity:id=1 • Kind:Entity:id=2 • Kind:Entity:id=3 • Kind:Entity:id=4 • Kind:Entity:id=5
  • 30. Datastore Key • Entity Property • Long (id) String (name) Key Id • EntityGroup Entity Key Entity • Entity: Kind=Parent, id=1 • Entity: Kind=Child, name=“hoge@fuga.com” • Entity Key • Parent(1)/Child(“hoge@fuga.com”)
  • 31. Datastore Property • Entity • java.lang • String 500 • Text • 500 String • Blob • • List Property • List Set
  • 32. Datastore Index • Property • Kind Index • Kind Key Index • Single Property Index • Property Index • Composite Index • Property Index • Text Blob Index (index explosion) Composite Property Index
  • 33. Datastore Transaction • ACID • • JDO • • Transaction EntityGroup Entity •
  • 34. Datastore Query • ’<‘, ‘<=’, ‘==’, ‘>=’, ‘>’ • Like (startsWith()) • And • Java ‘IN’, ‘!=’ • Property inequality filter Property • max() min() • Join
  • 35. Datastore Query • Index → Index • Kind Index, Single Property Index Datastore • Composite Index datastore-indexes.xml
  • 36. Datastore NG • • ID • 1,2,3,1001,1002... • • 1000 • JDO 1000 Google tips ” ”
  • 37. Datastore • • • • Kind • EntityGroup ( Transaction ) • Transaction •
  • 38. Datastore / = • • ID, ShardingNo • “ID, ShardingNo)” •
  • 39. Datastore / 1 2 ... • offset/limit • +1 Filter • Filter k • • property property
  • 40. Datastore • JDO, JPA, Low-level API 3 • JPA • JDO ORM • Datastore • Low-level API • JDO Low-level API JEE ... Low-level API
  • 41. Datastore JDO/Entity @PersistenceCapable(identityType = IdentityType.APPLICATION , detachable = "true") @Version(strategy = VersionStrategy.VERSION_NUMBER) public class Entity { @Persistent @PrimaryKey(valueStrategy = IdGeneratorStrategy.IDENTITY) Key id; @Persistent String value; @Persistent(defaultFetchGroup = “true”) Text text; } Fetch Fetch @Version JDO (OPT_VERSION property )
  • 42. Datastore JDO/Owned Relationship public class Parent { ... @Persistent(defaultFetchGroup = “true”) List<Child> children; } public class Child { @Persistent @PrimaryKey(valueStrategy = IdGeneratorStrategy.IDENTITY) Key id; ... } Child Key ( encoded-pk String )
  • 43. Datastore JDO/Owned Relationship(Key ) public class Parent { ... } public class Child { ... @Persistent @Extension(vendorName="datanucleus", key="gae.parent-pk", value="true") Key parentKey; ... } Entity Child parentKey Entity Key EntityGroup Ancestor Key
  • 44. Datastore JDO/Owned Relationship( ) public class Parent { ... @Persistent(defaultFetchGroup = “true”) List<Child> children; } public class Child { ... @Persistent(mappedBy = “children”) Parent parent; ... } mappedBy property
  • 45. Datastore JDO/Unowned Relationship @PersistenceCapable(identityType = IdentityType.APPLICATION) public class Entity { @Persistent @PrimaryKey(valueStrategy = IdGeneratorStrategy.IDENTITY) Key id; @Persistent String value; @Persistent Sey<Key> otherEntityRefs; }
  • 46. Datastore JDO/ PersistentManager pm = ... // PersistentManager ; Parent parent = new Parent(); parent.set...... List<Child> children = new ArrayList<Child>(); children.add(child1); parent.setChildren(children); try { Transaction transaction = pm.currentTransaction(); transaction.begin(); pm.makePersistent(parent); transaction.commit(); } finally { if (transaction.isActive()) transaction.rollback(); }
  • 47. Datastore JDO/ PersistentManager pm = ... // PersistentManager ; Query query = pm.newQuery(Entity.class); query.setFilter(“name == param”); query.declareParameters(“java.lang.String param”); query.setOrdering(“name asc, key desc”); @SuppressWarnings("unchecked") List<Entity> list = (List<Entity>) query.execute(“hoge”); ... Key key = KeyFactory.createKey(“Entity”, “keyName”); Entity entity = pm.getObjectById(Entity.class, key); Key key = entity.getOtherEntityKey(); OtherEntity otherEntity = pm.getObjectById(OtherEntity.class, key);
  • 48. Datastore JDO/ PersistentManager pm = ... // PersistentManager ; Query query = pm.newQuery(Entity.class); query.setFilter(“name == param”); query.declareParameters(“java.lang.String param”); query.setResult(“count(this)”); @SuppressWarnings("unchecked") Integer count = (Integer) query.execute(“hoge”); ... query.setResult(“key”); List<Entity> list = (List<Entity>) query.execute(“hoge”); ”count(this)” ”key” Key
  • 49. Datastore JDO/ • • transient, hollow, persistent/detached • JDOHelper#getObjectState() • PersistenceManager InstanceLifecycleListener • PersistenceManager#execute() List serialize • PersistenceManager#retrieve[All]() Property fetch
  • 50. Datastore Low-level API/ Entity entity = new Entity(“Kind”); // Low-level API Entity entity.setProperty(“name”, “hoge”); entity.setProperty(“height”, 170.5); DatastoreService service = DatastoreServiceFactory.getDatastoreService(); service.put(entity); Entity[] entities = .... service.put(entities); Entity
  • 51. Datastore Low-level API/ Query query = new Query(“Entity”); query .addFilter(“name”, FilterOperator.GREATER_THAN_OR_EQUAL, “hoge”) .addSort("name", SortDirection.ASCENDING) .addSort("__key__", SortDirection.ASCENDING); DatastoreService service = DatastoreServiceFactory.getDatastoreService(); List<Entity> entities = service.prepare(query).asList( FetchOptions.Builder.withOffset(0)); Key key = KeyFactory.createKey(“Entity”, “keyName”); Entity entity = service.get(key); property ”__key__”
  • 52. Datastore Low-level API/ Query query = new Query(“Entity”); query .addFilter(“name”, FilterOperator.GREATER_THAN_OR_EQUAL, “hoge”) .addSort("name", SortDirection.ASCENDING) .addSort("__key__", SortDirection.ASCENDING).setKeysOnly(); DatastoreService service = DatastoreServiceFactory.getDatastoreService(); int count = service.prepare(query).countEntities(); Entity entity = service. prepare(query).asSingleResult(); setKeysOnly() asSingleResult() 0 null 1 Entity 2 Exception
  • 53. MemcacheService • • ( ) • • cache • JCache(javax.cache), Low-level API 2 MemcacheService service = MemcacheServiceFactory.getMemcacheService(); service.put("key", list); Object cachedObject = service.get("key"); service.delete("key");
  • 54. URLFetchService • URL • API java.net.URLConnection Low-level API 2 • commons-httpclient URLFetchService service = URLFetchServiceFactory.getURLFetchService(); HTTPResponse response = service.fetch(new HTTPRequest(new URL(“”))); if (response.getResponseCode() != 200) throw new RuntimeException(); byte[] bytes = response.getContent();
  • 55. cron • • URL Filter/Servlet • • <?xml version="1.0" encoding="UTF-8"?> <cronentries> <cron> <url>/cron/fetch?name=jiemamy-sf</url> <description>fetch the jiemamy SF.jp timeline.</description> <schedule>every 1 minutes</schedule> </cron> </cronentries>
  • 56. • MailService • JavaMail(javax.mail), Low-level API 2 • • ImageService • low-level API • ... • • UserService • Google Account • Google appengine-java ML
  • 57. ApiProxy • com.google.apphosting.api.ApiProxy • Proxy • com.google.apphosting.api.ApiProxy.Delegate • • com.google.appengine.tools.development.ApiProxyL ocal • Delegate ApiProxyLocal
  • 58. Delegate#makeSyncCall() • public byte[] makeSyncCall( Environment environment, String packageName, // service String methodName, // service byte[] requestBytes) throws ApiProxyException byte[] ProtocolBuffer byte SDK RemoteApiServlet http makeSyncCall() Servlet [ | YO]
  • 59. UI • UI … … • Google App Engine ” ” ” ”