SlideShare une entreprise Scribd logo
1  sur  23
Télécharger pour lire hors ligne
Practical AtomPub Servers

                   takemaru
Outline
     What’s AtomPub?
 
          Data model
      
          Five Operations: List + CRUD
      
          Role of AtomPub servers
      


     Better choose AtomPub for your Web service?
 
          What’s the difference in RESTful services
      
          Compared with Amazon S3 (Simple Storage Service)
      
          Positioning AtomPub in RESTful services
      


     Catalyst::Controller::Atompub
 
          Makes you forcus on your task
      
          Sample Codes
      


     Summary
 
What’s AtomPub?
  What’s AtomPub?
       Defined in RFC5023
   
       One of REST instances
   
       Web API for publishing and editing Web resources
   
       Based on HTTP transfer of Atom-formatted representations
   


  Services   using AtomPub
       Google: GData, Blogger, OpenSocial
   
       Microsoft: Live Platform
   
       IBM: Lotus Connector
   
       Mixi: mixi station API
   
Data Model
                                                     Workspaces
     Members                                     
 
                                                          Group of Collections
          Web Resources in usual sense                
      
          Entry Resources or Media
      
          Resources
     Collections
 
          Sets of Members                       Members and Collections have their own URIs
      
          Retrieved in whole or in part
      


                         Collection


                                                                                 Member




                                   Workspace
Resources and Representations
                                             Examples:
                       Feed
                                              -  rticles which are
                                               A
                     Document
                                              referred to a category
                      (XML)
  Collection
                                 - mages of an event
                                               I
                     in which there are
                     several Entries


                       Entry
                                             Examples:
                     Document
                                              -  n article in a blog
                                               A
                      (XML)
                                              -  n image
                                               A
    Member              metadata
(Entry or Media)

                         substantial data

   AtomPub          Atom Format                Web Resources
  (RFC5023)
         (RFC4287)
Operations
       Five operations: List + CRUD
   
            Determined by target (URI) and HTTP method
        
                    POST: Creates a new member
                    (Member URI is assigned by the server)




                                               PUT:
                                                                        DELETE:
                                               Updates a member
                                                                        Deletes a member




                                                           GET: Retrieves a member
GET: Lists members in the collection
                                                       Operations against Members
             Operations against Collections
Operations in depth
– Entry and Media Resources
  Entry   and Media Resources
       Two sides of the same coin
   

 POST: Creates a new Member (substantial data)
                                                             PUT: Updates the Member




                                 Entry
                                          link


                                                                 Metadata MUST be updated
               Metadata:                                                   at the same time
               -  escribes attributes of the data: date, author, etc.
                D
               -  as a link to the data
                H
               -  utomatically generated as an Entry by the server
                A
Role of AtomPub Servers
     List + CRUD operations
 
          Supports publishing and editing Web resources
      
          Assigns Member URIs when they are POSTed
      



     Maintenance of metadata
 
          Generates corresponding Entries when POSTed
      
          Updates attributes when the corresponding data is PUTed or DELETEd
      



     Others
 
          Service description in Service Documents (not discussed in my talk)
      
          HTTP processings: Authentication, cache, version control, and error handling
      


      Compared with simple RESTful APIs, AtomPub servers have strong authority
Better choose AtomPub for your Web
service?
  Myths    of AtomPub
     AtomPub is a protocol just for blogging
   
    AtomPub is the best one to publish ANY type of Web
     resources


  Which    service is suited for AtomPub?
       Text-orientd services, such as blogging and SNS?
   
       File management systems including binary data?
   
       Something else?
   
AtomPub is one of REST instances
     AtomPub is one of the REST instances
 
          Don’t choose AtomPub if your service is NOT RESTful
      
          Compare AtomPub with other RESTful APIs if your service is RESTful
      



     Common features of RESTful services (in my talk)
 
          Addresses resources by URIs
      
          CRUD resources by HTTP methods: GET, POST, PUT, and DELETE
      
          Resource type is not an issue: plain-text, XML, images, videos, …
      
          Data model of dataset including several items (see figure)
      


                                                     Set
                                                                        Item
What’s the difference in RESTful APIs? 

     Metadata
 
           Which kinds of metadata are needed?
      
           Where are metadata placed?
      

     URIs
 
           Who determines resource URIs?
      

     Other options
 
           Search queries, representations, etc.
      



      Comparing AtomPub with a contrasting API, Amazon S3

                                 Matrix of metadata and URIs
          URIs  Metadata
 Simple and with data
 Rich and separated from data
          By servers
                                AtomPub
          By clients
         Amazon S3
Amazon S3 (Simple Storage Service)
     Metadata
 
                                                        /yapc.asia
          Placed in HTTP headers
      
                                                                      yapc2008.png
          Line-by-line syntax
      
          Always along with data in HTTP body
      

     URIs
 
          Determined by clients
      
          PUT is requested with a URI to create a resource
      

                                                 URI

                              PUT /yapc.asia/yapc2008.png HTTP/1.1
                              Content-Type: image/png
                 Metadata
    Date: Tue, 15 May 2008 01:23:45 GMT
                              X-Amz-Metadata: …

                     Data

                             Example of HTTP request
AtomPub
     Metadata
 
          Has its own URI and independent from data
                                                                     12345678.atom
          Written in Atom entry
      
                                                                            12345678.png
                                                  /images
     URIs
 
                                                             Entry
          Determined by servers
      




          <?xml version=“1.0” encoding=“utf-8”?>
          <entry xmlns=“http://www.w3.org/2005/Atom”>
           <link rel=“edit” 
                 href=“/images/12345678.atom”/>
           <link rel=“edit-media” 
                 href=“/images/12345678.png”/>
           <content src=“/images/12345678.png” 
                    type=“image/png”/>
           …
          </entry>

                  Metadata: /images/123456578.atom
          Data: /images/12345678.png
Embedded AtomPub
– Actually, this is AtomPub in usual sense
     Metadata
 
          Has it own URI and independent from data
      
                                                                            first_entry.atom
          Written in Atom entry
      
          Text/XML data can be embedded in metadata
      
                eg. atom:content element
            
                                                                       Entry
     URIs
 
                                                        /blog
          Determined by servers
      
          Suggested by requests with Slug header
      

                                POST /blog HTTP/1.1
          URI suggestion
       Slug: first_entry

                                <?xml version=“1.0” encoding=“utf-8”?>
                                <entry xmlns=“http://www.w3.org/2005/Atom”>
                                 <updated>2008-05-15T01:23:45Z</updated>
                 Metadata
       <author><name>yapc</name></author>
                                 …
                     Data
       <content type=“text”>This is my first entry</content>
                                </entry>
                                                                 Example of HTTP request
Positioning AtomPub in RESTful services
     Characteristics of AtomPub
 
           With rich metadata and mainly controlled by servers
      
           Can be changed by embedded content and Slug header options
      


                                 12345678.atom
                          first_entry.atom
                                       12345678.png
                        Entry
                                                                     Entry


                    AtomPub with Media resources
        Amazon S3 and embedded AtomPub
                                 Matrix of metadata and URIs
          URIs  Metadata
 Simple and with data
 Rich and separated from data
                                        embedded
          By servers
                                AtomPub
                                                          Slug header
          By clients
        Amazon S3
Better choose AtomPub for your Web
service?
  Services, which        are suited for AtomPub
       Metadata is represented in XML, especially in Atom Entries
   
          Atom standard elements are required: author, category, copyright, …
        
         Linked to other resources: eg. a blog entry including pictures
         XML vocabularies are used in the metadata: OpenSearch, RDF, …
         Complicated data model is acceptable, or don’t use media resources



       URIs are determined by servers
   
            Or determined based on clients’ suggestions
        



  I
   f you choose AtomPub, go for Catalyst::Controller::Atompub
Catalyst::Controller::Atompub
     A Catalyst controller class for processing AtomPub
 
          Why controller?
      
               AtomPub defines CONTROL flow for publishing and editing Web resources
           


          Tested in AtomPub Interop
      
               July 2007 at Tokyo
           
               Nov 2007 on the Internet
           
               Feb 2008 at Tokyo
           



          Download from CPAN
      
Catalyst::Controller::Atompub
     Makes      you focus on your task (eg. Model implementation)

           Dispatches requests based on URI and HTTP method
       
           Check cache or version of the requested resources (optional)
       
           Validates requested Entry if exists
       
           Determines a new member URI when POST
                                                         by C::C::Atompub


           Stores resources to, or retrieves them from databases
       
           Modifies the resources (optional)
                                                                  Your turn

                                                           by C::C::Atompub
           Constructs HTTP response and sends it to client
       

Can overwrite default behavior
Sample code – Creating resources
  # Attribute :Atompub(create) is required
  sub create_entry :Atompub(create) {
      my($self, $c) = @_;

      # URI of the new Entry, which was determined by C::C::Atompub
      my $uri = $self->entry_resource->uri;

      # datetime, which was assigned by C::C::Atompub
      my $edited = $self->edited;

      # POSTed Entry, an XML::Atom::Entry objcet
      my $entry = $self->entry_resource->body;

      # Creates the new Entry
      $c->model('DBIC::Entries')->create({
          uri    => $uri,
          edited => $edited->epoch,
          xml    => $entry->as_xml,
      });

      # Returns true on success
      return 1;
  }
Sample code – Listing resources
    # Attribute :Atompub(list) is required
    sub get_feed :Atompub(list) {
        my($self, $c) = @_;

         # Skeleton of the Feed, an XML::Atom::Feed objcet,
         # was prepared by C::C::Atompub
         my $feed = $self->collection_resource->body;

         # Retrieve Entries sorted in descending order
         my $rs = $c->model('DBIC::Entries')
                    ->search({}, { order_by => 'edited desc' });

         # Adds Entries to the Feed
         while (my $member = $rs->next) {
             my $entry = XML::Atom::Entry->new($member->xml);
             $feed->add_entry($entry);
         }

         # Returns true on success
         return 1;
    }
Sample code – Changing default URIs
eg. /collection/20080515-012345-123456.atom -> /collection/joe/birthday.atom

 # Changes Edit URIs, that is URIs for Member resources
 sub make_edit_uri {
     my($self, $c, @args) = @_;

      # Default URIs for Entry (and Media) resources
      my($edit_uri, $edit_media_uri) = $self−>NEXT::make_edit_uri($c, @args);

      # Modify the URIs as you like...

      # Returns modified URIs
      return ($edit_uri, $edit_media_uri);
 }

 # Changes Collection URI
 sub make_collection_uri {
     my($self, $c) = @_;

      # Constructing the new Collection URI as you like...

      # Returns the Collection URI
      return $new_uri;
 }
More…
     Many sample applications are found in samples/ directory
 
          MyAtom: Most simple AtomPub server
      
          MyBlog: Complicated server with Media resources
      
          OurBlogs: Single Collection class provides multiple Collections
      


     gihyo.jp gives detailed articles
 
          Search “gihyo.jp atompub server”
      
          Sorry, written in Japanese
      
Summary
     What’s AtomPub?
 
          Data model
      
          Five Operations: List + CRUD
      
          Role of AtomPub servers
      


     Better choose AtomPub for your Web service?
 
          What’s the difference in RESTful services
      
          Compared with Amazon S3 (Simple Storage Service)
      
          Positioning AtomPub in RESTful services
      


     Catalyst::Controller::Atompub
 
          Makes you forcus on your task
      
          Sample Codes
      


     Summary
 

Contenu connexe

Tendances

JAX-RS 2.0: RESTful Web Services
JAX-RS 2.0: RESTful Web ServicesJAX-RS 2.0: RESTful Web Services
JAX-RS 2.0: RESTful Web ServicesArun Gupta
 
The Java Content Repository
The Java Content RepositoryThe Java Content Repository
The Java Content Repositorynobby
 
Configure Your Projects with Apache Tamaya
Configure Your Projects with Apache TamayaConfigure Your Projects with Apache Tamaya
Configure Your Projects with Apache TamayaAnatole Tresch
 
04.egovFrame Runtime Environment Workshop
04.egovFrame Runtime Environment Workshop04.egovFrame Runtime Environment Workshop
04.egovFrame Runtime Environment WorkshopChuong Nguyen
 
So various polymorphism in Scala
So various polymorphism in ScalaSo various polymorphism in Scala
So various polymorphism in Scalab0ris_1
 
Owner - Java properties reinvented.
Owner - Java properties reinvented.Owner - Java properties reinvented.
Owner - Java properties reinvented.Luigi Viggiano
 
Rest with Java EE 6 , Security , Backbone.js
Rest with Java EE 6 , Security , Backbone.jsRest with Java EE 6 , Security , Backbone.js
Rest with Java EE 6 , Security , Backbone.jsCarol McDonald
 
A first Draft to Java Configuration
A first Draft to Java ConfigurationA first Draft to Java Configuration
A first Draft to Java ConfigurationAnatole Tresch
 
5050 dev nation
5050 dev nation5050 dev nation
5050 dev nationArun Gupta
 
Developing RESTful WebServices using Jersey
Developing RESTful WebServices using JerseyDeveloping RESTful WebServices using Jersey
Developing RESTful WebServices using Jerseyb_kathir
 
Cloudera Impala, updated for v1.0
Cloudera Impala, updated for v1.0Cloudera Impala, updated for v1.0
Cloudera Impala, updated for v1.0Scott Leberknight
 
Understanding
Understanding Understanding
Understanding Arun Gupta
 
Introduction to JAX-RS @ SIlicon Valley Code Camp 2010
Introduction to JAX-RS @ SIlicon Valley Code Camp 2010Introduction to JAX-RS @ SIlicon Valley Code Camp 2010
Introduction to JAX-RS @ SIlicon Valley Code Camp 2010Arun Gupta
 
Thu 1100 duncan_john_color
Thu 1100 duncan_john_colorThu 1100 duncan_john_color
Thu 1100 duncan_john_colorDATAVERSITY
 
GlassFish REST Administration Backend at JavaOne India 2012
GlassFish REST Administration Backend at JavaOne India 2012GlassFish REST Administration Backend at JavaOne India 2012
GlassFish REST Administration Backend at JavaOne India 2012Arun Gupta
 
JAX-RS 2.0: New and Noteworthy in RESTful Web services API at JAX London
JAX-RS 2.0: New and Noteworthy in RESTful Web services API at JAX LondonJAX-RS 2.0: New and Noteworthy in RESTful Web services API at JAX London
JAX-RS 2.0: New and Noteworthy in RESTful Web services API at JAX LondonArun Gupta
 
Big data: current technology scope.
Big data: current technology scope.Big data: current technology scope.
Big data: current technology scope.Roman Nikitchenko
 
PaaSing a Java EE 6 Application at Geecon 2012
PaaSing a Java EE 6 Application at Geecon 2012PaaSing a Java EE 6 Application at Geecon 2012
PaaSing a Java EE 6 Application at Geecon 2012Arun Gupta
 
Architecting virtualized infrastructure for big data presentation
Architecting virtualized infrastructure for big data presentationArchitecting virtualized infrastructure for big data presentation
Architecting virtualized infrastructure for big data presentationVlad Ponomarev
 

Tendances (20)

JAX-RS 2.0: RESTful Web Services
JAX-RS 2.0: RESTful Web ServicesJAX-RS 2.0: RESTful Web Services
JAX-RS 2.0: RESTful Web Services
 
The Java Content Repository
The Java Content RepositoryThe Java Content Repository
The Java Content Repository
 
10 jdbc
10 jdbc10 jdbc
10 jdbc
 
Configure Your Projects with Apache Tamaya
Configure Your Projects with Apache TamayaConfigure Your Projects with Apache Tamaya
Configure Your Projects with Apache Tamaya
 
04.egovFrame Runtime Environment Workshop
04.egovFrame Runtime Environment Workshop04.egovFrame Runtime Environment Workshop
04.egovFrame Runtime Environment Workshop
 
So various polymorphism in Scala
So various polymorphism in ScalaSo various polymorphism in Scala
So various polymorphism in Scala
 
Owner - Java properties reinvented.
Owner - Java properties reinvented.Owner - Java properties reinvented.
Owner - Java properties reinvented.
 
Rest with Java EE 6 , Security , Backbone.js
Rest with Java EE 6 , Security , Backbone.jsRest with Java EE 6 , Security , Backbone.js
Rest with Java EE 6 , Security , Backbone.js
 
A first Draft to Java Configuration
A first Draft to Java ConfigurationA first Draft to Java Configuration
A first Draft to Java Configuration
 
5050 dev nation
5050 dev nation5050 dev nation
5050 dev nation
 
Developing RESTful WebServices using Jersey
Developing RESTful WebServices using JerseyDeveloping RESTful WebServices using Jersey
Developing RESTful WebServices using Jersey
 
Cloudera Impala, updated for v1.0
Cloudera Impala, updated for v1.0Cloudera Impala, updated for v1.0
Cloudera Impala, updated for v1.0
 
Understanding
Understanding Understanding
Understanding
 
Introduction to JAX-RS @ SIlicon Valley Code Camp 2010
Introduction to JAX-RS @ SIlicon Valley Code Camp 2010Introduction to JAX-RS @ SIlicon Valley Code Camp 2010
Introduction to JAX-RS @ SIlicon Valley Code Camp 2010
 
Thu 1100 duncan_john_color
Thu 1100 duncan_john_colorThu 1100 duncan_john_color
Thu 1100 duncan_john_color
 
GlassFish REST Administration Backend at JavaOne India 2012
GlassFish REST Administration Backend at JavaOne India 2012GlassFish REST Administration Backend at JavaOne India 2012
GlassFish REST Administration Backend at JavaOne India 2012
 
JAX-RS 2.0: New and Noteworthy in RESTful Web services API at JAX London
JAX-RS 2.0: New and Noteworthy in RESTful Web services API at JAX LondonJAX-RS 2.0: New and Noteworthy in RESTful Web services API at JAX London
JAX-RS 2.0: New and Noteworthy in RESTful Web services API at JAX London
 
Big data: current technology scope.
Big data: current technology scope.Big data: current technology scope.
Big data: current technology scope.
 
PaaSing a Java EE 6 Application at Geecon 2012
PaaSing a Java EE 6 Application at Geecon 2012PaaSing a Java EE 6 Application at Geecon 2012
PaaSing a Java EE 6 Application at Geecon 2012
 
Architecting virtualized infrastructure for big data presentation
Architecting virtualized infrastructure for big data presentationArchitecting virtualized infrastructure for big data presentation
Architecting virtualized infrastructure for big data presentation
 

En vedette

AP1000 Reactor
AP1000 ReactorAP1000 Reactor
AP1000 Reactormyatom
 
JANTI Fukushima report part 3
JANTI Fukushima report part 3JANTI Fukushima report part 3
JANTI Fukushima report part 3myatom
 
Janti fukushima report_at
Janti fukushima report_atJanti fukushima report_at
Janti fukushima report_atmyatom
 
Temelin power uprate
Temelin power uprateTemelin power uprate
Temelin power upratemyatom
 
Updated plant costs 2010
Updated plant costs 2010Updated plant costs 2010
Updated plant costs 2010myatom
 
JANTI Fukushima report part 1 2
JANTI Fukushima report part 1 2JANTI Fukushima report part 1 2
JANTI Fukushima report part 1 2myatom
 
JANTI Fukushima report part 4 5 6
JANTI Fukushima report part 4 5 6JANTI Fukushima report part 4 5 6
JANTI Fukushima report part 4 5 6myatom
 

En vedette (7)

AP1000 Reactor
AP1000 ReactorAP1000 Reactor
AP1000 Reactor
 
JANTI Fukushima report part 3
JANTI Fukushima report part 3JANTI Fukushima report part 3
JANTI Fukushima report part 3
 
Janti fukushima report_at
Janti fukushima report_atJanti fukushima report_at
Janti fukushima report_at
 
Temelin power uprate
Temelin power uprateTemelin power uprate
Temelin power uprate
 
Updated plant costs 2010
Updated plant costs 2010Updated plant costs 2010
Updated plant costs 2010
 
JANTI Fukushima report part 1 2
JANTI Fukushima report part 1 2JANTI Fukushima report part 1 2
JANTI Fukushima report part 1 2
 
JANTI Fukushima report part 4 5 6
JANTI Fukushima report part 4 5 6JANTI Fukushima report part 4 5 6
JANTI Fukushima report part 4 5 6
 

Similaire à Practical AtomPub Servers @ YAPC::Asia 2008

RESTful Data Services with the ADO.NET Data Services Framework
RESTful Data Services with the ADO.NET Data Services FrameworkRESTful Data Services with the ADO.NET Data Services Framework
RESTful Data Services with the ADO.NET Data Services Frameworkgoodfriday
 
[DSBW Spring 2009] Unit 02: Web Technologies (1/2)
[DSBW Spring 2009] Unit 02: Web Technologies (1/2)[DSBW Spring 2009] Unit 02: Web Technologies (1/2)
[DSBW Spring 2009] Unit 02: Web Technologies (1/2)Carles Farré
 
ReST Vs SOA(P) ... Yawn
ReST Vs SOA(P) ... YawnReST Vs SOA(P) ... Yawn
ReST Vs SOA(P) ... Yawnozten
 
Data Integration with server side Mashups
Data Integration with server side MashupsData Integration with server side Mashups
Data Integration with server side Mashupsjbrendel
 
Frank Mantek Google G Data
Frank Mantek Google G DataFrank Mantek Google G Data
Frank Mantek Google G Datadeimos
 
StackMate - CloudFormation for CloudStack
StackMate - CloudFormation for CloudStackStackMate - CloudFormation for CloudStack
StackMate - CloudFormation for CloudStackChiradeep Vittal
 
Spring Boot and REST API
Spring Boot and REST APISpring Boot and REST API
Spring Boot and REST API07.pallav
 
Spring 3 - Der dritte Frühling
Spring 3 - Der dritte FrühlingSpring 3 - Der dritte Frühling
Spring 3 - Der dritte FrühlingThorsten Kamann
 
Introduction of e-Journal Local Hosting and Services - Dr. Kwang Young Kim
Introduction of e-Journal Local Hosting and Services - Dr. Kwang Young KimIntroduction of e-Journal Local Hosting and Services - Dr. Kwang Young Kim
Introduction of e-Journal Local Hosting and Services - Dr. Kwang Young Kimtulipbiru64
 
3. Sql Services 概览
3. Sql Services 概览3. Sql Services 概览
3. Sql Services 概览GaryYoung
 
Admin High Availability
Admin High AvailabilityAdmin High Availability
Admin High Availabilityrsnarayanan
 
REST and AJAX Reconciled
REST and AJAX ReconciledREST and AJAX Reconciled
REST and AJAX ReconciledLars Trieloff
 
Applications of the REST Principle
Applications of the REST PrincipleApplications of the REST Principle
Applications of the REST Principleelliando dias
 

Similaire à Practical AtomPub Servers @ YAPC::Asia 2008 (20)

RESTful Data Services with the ADO.NET Data Services Framework
RESTful Data Services with the ADO.NET Data Services FrameworkRESTful Data Services with the ADO.NET Data Services Framework
RESTful Data Services with the ADO.NET Data Services Framework
 
20080611accel
20080611accel20080611accel
20080611accel
 
[DSBW Spring 2009] Unit 02: Web Technologies (1/2)
[DSBW Spring 2009] Unit 02: Web Technologies (1/2)[DSBW Spring 2009] Unit 02: Web Technologies (1/2)
[DSBW Spring 2009] Unit 02: Web Technologies (1/2)
 
Web 2.0 101
Web 2.0 101Web 2.0 101
Web 2.0 101
 
Rest Vs Soap Yawn2289
Rest Vs Soap Yawn2289Rest Vs Soap Yawn2289
Rest Vs Soap Yawn2289
 
ReST Vs SOA(P) ... Yawn
ReST Vs SOA(P) ... YawnReST Vs SOA(P) ... Yawn
ReST Vs SOA(P) ... Yawn
 
Orcale Presentation
Orcale PresentationOrcale Presentation
Orcale Presentation
 
Data Integration with server side Mashups
Data Integration with server side MashupsData Integration with server side Mashups
Data Integration with server side Mashups
 
Frank Mantek Google G Data
Frank Mantek Google G DataFrank Mantek Google G Data
Frank Mantek Google G Data
 
20080528dublinpt1
20080528dublinpt120080528dublinpt1
20080528dublinpt1
 
StackMate - CloudFormation for CloudStack
StackMate - CloudFormation for CloudStackStackMate - CloudFormation for CloudStack
StackMate - CloudFormation for CloudStack
 
Spring Boot and REST API
Spring Boot and REST APISpring Boot and REST API
Spring Boot and REST API
 
Nuxeo JavaOne 2007
Nuxeo JavaOne 2007Nuxeo JavaOne 2007
Nuxeo JavaOne 2007
 
Spring 3 - Der dritte Frühling
Spring 3 - Der dritte FrühlingSpring 3 - Der dritte Frühling
Spring 3 - Der dritte Frühling
 
Introduction of e-Journal Local Hosting and Services - Dr. Kwang Young Kim
Introduction of e-Journal Local Hosting and Services - Dr. Kwang Young KimIntroduction of e-Journal Local Hosting and Services - Dr. Kwang Young Kim
Introduction of e-Journal Local Hosting and Services - Dr. Kwang Young Kim
 
3. Sql Services 概览
3. Sql Services 概览3. Sql Services 概览
3. Sql Services 概览
 
Admin High Availability
Admin High AvailabilityAdmin High Availability
Admin High Availability
 
REST and AJAX Reconciled
REST and AJAX ReconciledREST and AJAX Reconciled
REST and AJAX Reconciled
 
Applications of the REST Principle
Applications of the REST PrincipleApplications of the REST Principle
Applications of the REST Principle
 
Introduction to Hadoop
Introduction to HadoopIntroduction to Hadoop
Introduction to Hadoop
 

Plus de Takeru INOUE

分散ストレージに使えるかもしれないアルゴリズム
分散ストレージに使えるかもしれないアルゴリズム分散ストレージに使えるかもしれないアルゴリズム
分散ストレージに使えるかもしれないアルゴリズムTakeru INOUE
 
Rewind the last half year for Erlang
Rewind the last half year for ErlangRewind the last half year for Erlang
Rewind the last half year for ErlangTakeru INOUE
 
Kai = (Dynamo + memcache API) / Erlang
Kai = (Dynamo + memcache API) / ErlangKai = (Dynamo + memcache API) / Erlang
Kai = (Dynamo + memcache API) / ErlangTakeru INOUE
 
Process Design and Polymorphism: Lessons Learnt from Development of Kai
Process Design and Polymorphism: Lessons Learnt from Development of KaiProcess Design and Polymorphism: Lessons Learnt from Development of Kai
Process Design and Polymorphism: Lessons Learnt from Development of KaiTakeru INOUE
 
Kai – An Open Source Implementation of Amazon’s Dynamo (in Japanese)
Kai – An Open Source Implementation of Amazon’s Dynamo (in Japanese)Kai – An Open Source Implementation of Amazon’s Dynamo (in Japanese)
Kai – An Open Source Implementation of Amazon’s Dynamo (in Japanese)Takeru INOUE
 
Kai – An Open Source Implementation of Amazon’s Dynamo
Kai – An Open Source Implementation of Amazon’s DynamoKai – An Open Source Implementation of Amazon’s Dynamo
Kai – An Open Source Implementation of Amazon’s DynamoTakeru INOUE
 
Amazon's Dynamo in POE and Erlang @ YAPC::Asia 2008 LT
Amazon's Dynamo in POE and Erlang @ YAPC::Asia 2008 LTAmazon's Dynamo in POE and Erlang @ YAPC::Asia 2008 LT
Amazon's Dynamo in POE and Erlang @ YAPC::Asia 2008 LTTakeru INOUE
 

Plus de Takeru INOUE (7)

分散ストレージに使えるかもしれないアルゴリズム
分散ストレージに使えるかもしれないアルゴリズム分散ストレージに使えるかもしれないアルゴリズム
分散ストレージに使えるかもしれないアルゴリズム
 
Rewind the last half year for Erlang
Rewind the last half year for ErlangRewind the last half year for Erlang
Rewind the last half year for Erlang
 
Kai = (Dynamo + memcache API) / Erlang
Kai = (Dynamo + memcache API) / ErlangKai = (Dynamo + memcache API) / Erlang
Kai = (Dynamo + memcache API) / Erlang
 
Process Design and Polymorphism: Lessons Learnt from Development of Kai
Process Design and Polymorphism: Lessons Learnt from Development of KaiProcess Design and Polymorphism: Lessons Learnt from Development of Kai
Process Design and Polymorphism: Lessons Learnt from Development of Kai
 
Kai – An Open Source Implementation of Amazon’s Dynamo (in Japanese)
Kai – An Open Source Implementation of Amazon’s Dynamo (in Japanese)Kai – An Open Source Implementation of Amazon’s Dynamo (in Japanese)
Kai – An Open Source Implementation of Amazon’s Dynamo (in Japanese)
 
Kai – An Open Source Implementation of Amazon’s Dynamo
Kai – An Open Source Implementation of Amazon’s DynamoKai – An Open Source Implementation of Amazon’s Dynamo
Kai – An Open Source Implementation of Amazon’s Dynamo
 
Amazon's Dynamo in POE and Erlang @ YAPC::Asia 2008 LT
Amazon's Dynamo in POE and Erlang @ YAPC::Asia 2008 LTAmazon's Dynamo in POE and Erlang @ YAPC::Asia 2008 LT
Amazon's Dynamo in POE and Erlang @ YAPC::Asia 2008 LT
 

Dernier

BCE24 | Virtual Brand Ambassadors: Making Brands Personal - John Meulemans
BCE24 | Virtual Brand Ambassadors: Making Brands Personal - John MeulemansBCE24 | Virtual Brand Ambassadors: Making Brands Personal - John Meulemans
BCE24 | Virtual Brand Ambassadors: Making Brands Personal - John MeulemansBBPMedia1
 
7movierulz.uk
7movierulz.uk7movierulz.uk
7movierulz.ukaroemirsr
 
Boat Trailers Market PPT: Growth, Outlook, Demand, Keyplayer Analysis and Opp...
Boat Trailers Market PPT: Growth, Outlook, Demand, Keyplayer Analysis and Opp...Boat Trailers Market PPT: Growth, Outlook, Demand, Keyplayer Analysis and Opp...
Boat Trailers Market PPT: Growth, Outlook, Demand, Keyplayer Analysis and Opp...IMARC Group
 
Borderless Access - Global B2B Panel book-unlock 2024
Borderless Access - Global B2B Panel book-unlock 2024Borderless Access - Global B2B Panel book-unlock 2024
Borderless Access - Global B2B Panel book-unlock 2024Borderless Access
 
Graham and Doddsville - Issue 1 - Winter 2006 (1).pdf
Graham and Doddsville - Issue 1 - Winter 2006 (1).pdfGraham and Doddsville - Issue 1 - Winter 2006 (1).pdf
Graham and Doddsville - Issue 1 - Winter 2006 (1).pdfAnhNguyen97152
 
Team B Mind Map for Organizational Chg..
Team B Mind Map for Organizational Chg..Team B Mind Map for Organizational Chg..
Team B Mind Map for Organizational Chg..dlewis191
 
PDT 89 - $1.4M - Seed - Plantee Innovations.pdf
PDT 89 - $1.4M - Seed - Plantee Innovations.pdfPDT 89 - $1.4M - Seed - Plantee Innovations.pdf
PDT 89 - $1.4M - Seed - Plantee Innovations.pdfHajeJanKamps
 
Borderless Access - Global Panel book-unlock 2024
Borderless Access - Global Panel book-unlock 2024Borderless Access - Global Panel book-unlock 2024
Borderless Access - Global Panel book-unlock 2024Borderless Access
 
HELENE HECKROTTE'S PROFESSIONAL PORTFOLIO.pptx
HELENE HECKROTTE'S PROFESSIONAL PORTFOLIO.pptxHELENE HECKROTTE'S PROFESSIONAL PORTFOLIO.pptx
HELENE HECKROTTE'S PROFESSIONAL PORTFOLIO.pptxHelene Heckrotte
 
Q2 2024 APCO Geopolitical Radar - The Global Operating Environment for Business
Q2 2024 APCO Geopolitical Radar - The Global Operating Environment for BusinessQ2 2024 APCO Geopolitical Radar - The Global Operating Environment for Business
Q2 2024 APCO Geopolitical Radar - The Global Operating Environment for BusinessAPCO
 
Building Your Personal Brand on LinkedIn - Expert Planet- 2024
 Building Your Personal Brand on LinkedIn - Expert Planet-  2024 Building Your Personal Brand on LinkedIn - Expert Planet-  2024
Building Your Personal Brand on LinkedIn - Expert Planet- 2024Stephan Koning
 
Ethical stalking by Mark Williams. UpliftLive 2024
Ethical stalking by Mark Williams. UpliftLive 2024Ethical stalking by Mark Williams. UpliftLive 2024
Ethical stalking by Mark Williams. UpliftLive 2024Winbusinessin
 
Talent Management research intelligence_13 paradigm shifts_20 March 2024.pdf
Talent Management research intelligence_13 paradigm shifts_20 March 2024.pdfTalent Management research intelligence_13 paradigm shifts_20 March 2024.pdf
Talent Management research intelligence_13 paradigm shifts_20 March 2024.pdfCharles Cotter, PhD
 
Borderless Access - Global Panel book-unlock 2024
Borderless Access - Global Panel book-unlock 2024Borderless Access - Global Panel book-unlock 2024
Borderless Access - Global Panel book-unlock 2024Borderless Access
 
The Vietnam Believer Newsletter_MARCH 25, 2024_EN_Vol. 003
The Vietnam Believer Newsletter_MARCH 25, 2024_EN_Vol. 003The Vietnam Believer Newsletter_MARCH 25, 2024_EN_Vol. 003
The Vietnam Believer Newsletter_MARCH 25, 2024_EN_Vol. 003believeminhh
 
Data skills for Agile Teams- Killing story points
Data skills for Agile Teams- Killing story pointsData skills for Agile Teams- Killing story points
Data skills for Agile Teams- Killing story pointsyasinnathani
 
PDT 88 - 4 million seed - Seed - Protecto.pdf
PDT 88 - 4 million seed - Seed - Protecto.pdfPDT 88 - 4 million seed - Seed - Protecto.pdf
PDT 88 - 4 million seed - Seed - Protecto.pdfHajeJanKamps
 
To Create Your Own Wig Online To Create Your Own Wig Online
To Create Your Own Wig Online  To Create Your Own Wig OnlineTo Create Your Own Wig Online  To Create Your Own Wig Online
To Create Your Own Wig Online To Create Your Own Wig Onlinelng ths
 
Mihir Menda - Member of Supervisory Board at RMZ
Mihir Menda - Member of Supervisory Board at RMZMihir Menda - Member of Supervisory Board at RMZ
Mihir Menda - Member of Supervisory Board at RMZKanakChauhan5
 
The End of Business as Usual: Rewire the Way You Work to Succeed in the Consu...
The End of Business as Usual: Rewire the Way You Work to Succeed in the Consu...The End of Business as Usual: Rewire the Way You Work to Succeed in the Consu...
The End of Business as Usual: Rewire the Way You Work to Succeed in the Consu...Brian Solis
 

Dernier (20)

BCE24 | Virtual Brand Ambassadors: Making Brands Personal - John Meulemans
BCE24 | Virtual Brand Ambassadors: Making Brands Personal - John MeulemansBCE24 | Virtual Brand Ambassadors: Making Brands Personal - John Meulemans
BCE24 | Virtual Brand Ambassadors: Making Brands Personal - John Meulemans
 
7movierulz.uk
7movierulz.uk7movierulz.uk
7movierulz.uk
 
Boat Trailers Market PPT: Growth, Outlook, Demand, Keyplayer Analysis and Opp...
Boat Trailers Market PPT: Growth, Outlook, Demand, Keyplayer Analysis and Opp...Boat Trailers Market PPT: Growth, Outlook, Demand, Keyplayer Analysis and Opp...
Boat Trailers Market PPT: Growth, Outlook, Demand, Keyplayer Analysis and Opp...
 
Borderless Access - Global B2B Panel book-unlock 2024
Borderless Access - Global B2B Panel book-unlock 2024Borderless Access - Global B2B Panel book-unlock 2024
Borderless Access - Global B2B Panel book-unlock 2024
 
Graham and Doddsville - Issue 1 - Winter 2006 (1).pdf
Graham and Doddsville - Issue 1 - Winter 2006 (1).pdfGraham and Doddsville - Issue 1 - Winter 2006 (1).pdf
Graham and Doddsville - Issue 1 - Winter 2006 (1).pdf
 
Team B Mind Map for Organizational Chg..
Team B Mind Map for Organizational Chg..Team B Mind Map for Organizational Chg..
Team B Mind Map for Organizational Chg..
 
PDT 89 - $1.4M - Seed - Plantee Innovations.pdf
PDT 89 - $1.4M - Seed - Plantee Innovations.pdfPDT 89 - $1.4M - Seed - Plantee Innovations.pdf
PDT 89 - $1.4M - Seed - Plantee Innovations.pdf
 
Borderless Access - Global Panel book-unlock 2024
Borderless Access - Global Panel book-unlock 2024Borderless Access - Global Panel book-unlock 2024
Borderless Access - Global Panel book-unlock 2024
 
HELENE HECKROTTE'S PROFESSIONAL PORTFOLIO.pptx
HELENE HECKROTTE'S PROFESSIONAL PORTFOLIO.pptxHELENE HECKROTTE'S PROFESSIONAL PORTFOLIO.pptx
HELENE HECKROTTE'S PROFESSIONAL PORTFOLIO.pptx
 
Q2 2024 APCO Geopolitical Radar - The Global Operating Environment for Business
Q2 2024 APCO Geopolitical Radar - The Global Operating Environment for BusinessQ2 2024 APCO Geopolitical Radar - The Global Operating Environment for Business
Q2 2024 APCO Geopolitical Radar - The Global Operating Environment for Business
 
Building Your Personal Brand on LinkedIn - Expert Planet- 2024
 Building Your Personal Brand on LinkedIn - Expert Planet-  2024 Building Your Personal Brand on LinkedIn - Expert Planet-  2024
Building Your Personal Brand on LinkedIn - Expert Planet- 2024
 
Ethical stalking by Mark Williams. UpliftLive 2024
Ethical stalking by Mark Williams. UpliftLive 2024Ethical stalking by Mark Williams. UpliftLive 2024
Ethical stalking by Mark Williams. UpliftLive 2024
 
Talent Management research intelligence_13 paradigm shifts_20 March 2024.pdf
Talent Management research intelligence_13 paradigm shifts_20 March 2024.pdfTalent Management research intelligence_13 paradigm shifts_20 March 2024.pdf
Talent Management research intelligence_13 paradigm shifts_20 March 2024.pdf
 
Borderless Access - Global Panel book-unlock 2024
Borderless Access - Global Panel book-unlock 2024Borderless Access - Global Panel book-unlock 2024
Borderless Access - Global Panel book-unlock 2024
 
The Vietnam Believer Newsletter_MARCH 25, 2024_EN_Vol. 003
The Vietnam Believer Newsletter_MARCH 25, 2024_EN_Vol. 003The Vietnam Believer Newsletter_MARCH 25, 2024_EN_Vol. 003
The Vietnam Believer Newsletter_MARCH 25, 2024_EN_Vol. 003
 
Data skills for Agile Teams- Killing story points
Data skills for Agile Teams- Killing story pointsData skills for Agile Teams- Killing story points
Data skills for Agile Teams- Killing story points
 
PDT 88 - 4 million seed - Seed - Protecto.pdf
PDT 88 - 4 million seed - Seed - Protecto.pdfPDT 88 - 4 million seed - Seed - Protecto.pdf
PDT 88 - 4 million seed - Seed - Protecto.pdf
 
To Create Your Own Wig Online To Create Your Own Wig Online
To Create Your Own Wig Online  To Create Your Own Wig OnlineTo Create Your Own Wig Online  To Create Your Own Wig Online
To Create Your Own Wig Online To Create Your Own Wig Online
 
Mihir Menda - Member of Supervisory Board at RMZ
Mihir Menda - Member of Supervisory Board at RMZMihir Menda - Member of Supervisory Board at RMZ
Mihir Menda - Member of Supervisory Board at RMZ
 
The End of Business as Usual: Rewire the Way You Work to Succeed in the Consu...
The End of Business as Usual: Rewire the Way You Work to Succeed in the Consu...The End of Business as Usual: Rewire the Way You Work to Succeed in the Consu...
The End of Business as Usual: Rewire the Way You Work to Succeed in the Consu...
 

Practical AtomPub Servers @ YAPC::Asia 2008

  • 2. Outline What’s AtomPub?   Data model   Five Operations: List + CRUD   Role of AtomPub servers   Better choose AtomPub for your Web service?   What’s the difference in RESTful services   Compared with Amazon S3 (Simple Storage Service)   Positioning AtomPub in RESTful services   Catalyst::Controller::Atompub   Makes you forcus on your task   Sample Codes   Summary  
  • 3. What’s AtomPub?   What’s AtomPub? Defined in RFC5023   One of REST instances   Web API for publishing and editing Web resources   Based on HTTP transfer of Atom-formatted representations     Services using AtomPub Google: GData, Blogger, OpenSocial   Microsoft: Live Platform   IBM: Lotus Connector   Mixi: mixi station API  
  • 4. Data Model Workspaces Members     Group of Collections Web Resources in usual sense     Entry Resources or Media   Resources Collections   Sets of Members Members and Collections have their own URIs   Retrieved in whole or in part   Collection Member Workspace
  • 5. Resources and Representations Examples: Feed -  rticles which are A Document referred to a category (XML) Collection - mages of an event I in which there are several Entries Entry Examples: Document -  n article in a blog A (XML) -  n image A Member metadata (Entry or Media) substantial data AtomPub Atom Format Web Resources (RFC5023) (RFC4287)
  • 6. Operations Five operations: List + CRUD   Determined by target (URI) and HTTP method   POST: Creates a new member (Member URI is assigned by the server) PUT: DELETE: Updates a member Deletes a member GET: Retrieves a member GET: Lists members in the collection Operations against Members Operations against Collections
  • 7. Operations in depth – Entry and Media Resources   Entry and Media Resources Two sides of the same coin   POST: Creates a new Member (substantial data) PUT: Updates the Member Entry link Metadata MUST be updated Metadata: at the same time -  escribes attributes of the data: date, author, etc. D -  as a link to the data H -  utomatically generated as an Entry by the server A
  • 8. Role of AtomPub Servers List + CRUD operations   Supports publishing and editing Web resources   Assigns Member URIs when they are POSTed   Maintenance of metadata   Generates corresponding Entries when POSTed   Updates attributes when the corresponding data is PUTed or DELETEd   Others   Service description in Service Documents (not discussed in my talk)   HTTP processings: Authentication, cache, version control, and error handling    Compared with simple RESTful APIs, AtomPub servers have strong authority
  • 9. Better choose AtomPub for your Web service?   Myths of AtomPub AtomPub is a protocol just for blogging     AtomPub is the best one to publish ANY type of Web resources   Which service is suited for AtomPub? Text-orientd services, such as blogging and SNS?   File management systems including binary data?   Something else?  
  • 10. AtomPub is one of REST instances AtomPub is one of the REST instances   Don’t choose AtomPub if your service is NOT RESTful   Compare AtomPub with other RESTful APIs if your service is RESTful   Common features of RESTful services (in my talk)   Addresses resources by URIs   CRUD resources by HTTP methods: GET, POST, PUT, and DELETE   Resource type is not an issue: plain-text, XML, images, videos, …   Data model of dataset including several items (see figure)   Set Item
  • 11. What’s the difference in RESTful APIs? 
 Metadata   Which kinds of metadata are needed?   Where are metadata placed?   URIs   Who determines resource URIs?   Other options   Search queries, representations, etc.    Comparing AtomPub with a contrasting API, Amazon S3 Matrix of metadata and URIs URIs Metadata Simple and with data Rich and separated from data By servers AtomPub By clients Amazon S3
  • 12. Amazon S3 (Simple Storage Service) Metadata   /yapc.asia Placed in HTTP headers   yapc2008.png Line-by-line syntax   Always along with data in HTTP body   URIs   Determined by clients   PUT is requested with a URI to create a resource   URI PUT /yapc.asia/yapc2008.png HTTP/1.1 Content-Type: image/png Metadata Date: Tue, 15 May 2008 01:23:45 GMT X-Amz-Metadata: … Data Example of HTTP request
  • 13. AtomPub Metadata   Has its own URI and independent from data   12345678.atom Written in Atom entry   12345678.png /images URIs   Entry Determined by servers   <?xml version=“1.0” encoding=“utf-8”?> <entry xmlns=“http://www.w3.org/2005/Atom”> <link rel=“edit” href=“/images/12345678.atom”/> <link rel=“edit-media” href=“/images/12345678.png”/> <content src=“/images/12345678.png” type=“image/png”/> … </entry> Metadata: /images/123456578.atom Data: /images/12345678.png
  • 14. Embedded AtomPub – Actually, this is AtomPub in usual sense Metadata   Has it own URI and independent from data   first_entry.atom Written in Atom entry   Text/XML data can be embedded in metadata   eg. atom:content element   Entry URIs   /blog Determined by servers   Suggested by requests with Slug header   POST /blog HTTP/1.1 URI suggestion Slug: first_entry <?xml version=“1.0” encoding=“utf-8”?> <entry xmlns=“http://www.w3.org/2005/Atom”> <updated>2008-05-15T01:23:45Z</updated> Metadata <author><name>yapc</name></author> … Data <content type=“text”>This is my first entry</content> </entry> Example of HTTP request
  • 15. Positioning AtomPub in RESTful services Characteristics of AtomPub   With rich metadata and mainly controlled by servers   Can be changed by embedded content and Slug header options   12345678.atom first_entry.atom 12345678.png Entry Entry AtomPub with Media resources Amazon S3 and embedded AtomPub Matrix of metadata and URIs URIs Metadata Simple and with data Rich and separated from data embedded By servers AtomPub Slug header By clients Amazon S3
  • 16. Better choose AtomPub for your Web service?   Services, which are suited for AtomPub Metadata is represented in XML, especially in Atom Entries   Atom standard elements are required: author, category, copyright, …     Linked to other resources: eg. a blog entry including pictures   XML vocabularies are used in the metadata: OpenSearch, RDF, …   Complicated data model is acceptable, or don’t use media resources URIs are determined by servers   Or determined based on clients’ suggestions   I  f you choose AtomPub, go for Catalyst::Controller::Atompub
  • 17. Catalyst::Controller::Atompub A Catalyst controller class for processing AtomPub   Why controller?   AtomPub defines CONTROL flow for publishing and editing Web resources   Tested in AtomPub Interop   July 2007 at Tokyo   Nov 2007 on the Internet   Feb 2008 at Tokyo   Download from CPAN  
  • 18. Catalyst::Controller::Atompub   Makes you focus on your task (eg. Model implementation) Dispatches requests based on URI and HTTP method   Check cache or version of the requested resources (optional)   Validates requested Entry if exists   Determines a new member URI when POST   by C::C::Atompub Stores resources to, or retrieves them from databases   Modifies the resources (optional)   Your turn by C::C::Atompub Constructs HTTP response and sends it to client   Can overwrite default behavior
  • 19. Sample code – Creating resources # Attribute :Atompub(create) is required sub create_entry :Atompub(create) { my($self, $c) = @_; # URI of the new Entry, which was determined by C::C::Atompub my $uri = $self->entry_resource->uri; # datetime, which was assigned by C::C::Atompub my $edited = $self->edited; # POSTed Entry, an XML::Atom::Entry objcet my $entry = $self->entry_resource->body; # Creates the new Entry $c->model('DBIC::Entries')->create({ uri => $uri, edited => $edited->epoch, xml => $entry->as_xml, }); # Returns true on success return 1; }
  • 20. Sample code – Listing resources # Attribute :Atompub(list) is required sub get_feed :Atompub(list) { my($self, $c) = @_; # Skeleton of the Feed, an XML::Atom::Feed objcet, # was prepared by C::C::Atompub my $feed = $self->collection_resource->body; # Retrieve Entries sorted in descending order my $rs = $c->model('DBIC::Entries') ->search({}, { order_by => 'edited desc' }); # Adds Entries to the Feed while (my $member = $rs->next) { my $entry = XML::Atom::Entry->new($member->xml); $feed->add_entry($entry); } # Returns true on success return 1; }
  • 21. Sample code – Changing default URIs eg. /collection/20080515-012345-123456.atom -> /collection/joe/birthday.atom # Changes Edit URIs, that is URIs for Member resources sub make_edit_uri { my($self, $c, @args) = @_; # Default URIs for Entry (and Media) resources my($edit_uri, $edit_media_uri) = $self−>NEXT::make_edit_uri($c, @args); # Modify the URIs as you like... # Returns modified URIs return ($edit_uri, $edit_media_uri); } # Changes Collection URI sub make_collection_uri { my($self, $c) = @_; # Constructing the new Collection URI as you like... # Returns the Collection URI return $new_uri; }
  • 22. More… Many sample applications are found in samples/ directory   MyAtom: Most simple AtomPub server   MyBlog: Complicated server with Media resources   OurBlogs: Single Collection class provides multiple Collections   gihyo.jp gives detailed articles   Search “gihyo.jp atompub server”   Sorry, written in Japanese  
  • 23. Summary What’s AtomPub?   Data model   Five Operations: List + CRUD   Role of AtomPub servers   Better choose AtomPub for your Web service?   What’s the difference in RESTful services   Compared with Amazon S3 (Simple Storage Service)   Positioning AtomPub in RESTful services   Catalyst::Controller::Atompub   Makes you forcus on your task   Sample Codes   Summary 