SlideShare a Scribd company logo
1 of 48
Download to read offline
REZA LESMANA
                               Universitas Gunadarma




Saturday, February 5, 2011
REST
                             Using Restlet Framework
Saturday, February 5, 2011
REST
                    Representational State Transfer



Saturday, February 5, 2011
WHAT IS REST?
               GAYA ARSITEKTUR SOFTWARE UNTUK ARSITEKTUR
                        APLIKASI BERBASIS JARINGAN

                                      BASICALLY
                             WEB SERVICES ARCHITECTURE



Saturday, February 5, 2011
WHY USE REST?
                             UNIFORM INTERFACE




    SEMUA KOMPONEN APLIKASI DALAM WEB SERVICES
       BERINTERAKSI DENGAN CARA YANG SAMA


Saturday, February 5, 2011
UNIFORM INTERFACE
                                one of the feature of REST




Saturday, February 5, 2011
UNIFORM INTERFACE
                             Resource Identification [1]

                                   RESOURCE
                informasi yang dibutuhkan oleh user untuk
                menjalankan proses bisnis dari suatu aplikasi


Saturday, February 5, 2011
UNIFORM INTERFACE
                             Resource Identification [2]

                   Uniform Resource Identifier
                             (URI)
                                  Contoh : HTTP URL


Saturday, February 5, 2011
UNIFORM INTERFACE
                              Resource Identification [3]
                                        URI Template

                             http://contohaja.com/message/{index}



Saturday, February 5, 2011
RESTLET FRAMEWORK
                                 application building block




Saturday, February 5, 2011
RESTLET FRAMEWORK
                                   servlet configuration (web.xml)
                              <!-- Application class name -->
                              <context-param>
                                 <param-name>org.restlet.application</param-name>
                                 <param-value>
                                     com.helloworld.main.MainApplication
                                 </param-value>
                              </context-param>

                              <!-- Restlet adapter -->
                              <servlet>
                                 <servlet-name>RestletServlet</servlet-name>
                                 <servlet-class>
                                     org.restlet.ext.servlet.ServerServlet
                                 </servlet-class>
                              </servlet>

                              <!-- Catch all requests -->
                              <servlet-mapping>
                                 <servlet-name>RestletServlet</servlet-name>
                                 <url-pattern>/*</url-pattern>
                              </servlet-mapping>



Saturday, February 5, 2011
UNIFORM INTERFACE
                              Resource Identification [4]
                                 aplikasi penyimpanan pesan dalam stack


    • Daftar                 Pesan --->   • “/” --->   MessagesResource

    • Top           of Stack --->         • “/message/    ---> MessageResource

    • Pesan Tunggal                --->   • “/message/{index}   ---> MessageResource



Saturday, February 5, 2011
RESTLET FRAMEWORK
                              MainApplication
       public class MainApplication extends Application {

       	      public MainApplication(Context parentContext) {
       	      	 super(parentContext);		
       	      }
       	
       	      @Override
       	      public synchronized Restlet createInboundRoot() {
       	      	 Router router = new Router(getContext());
       	      	
       	      	 router.attach("/", MessagesResource.class);
       	      	 router.attach("/message/", MessageResource.class);
       	      	 router.attach("/message/{messageIndex}", MessageResource.class);
       	      	
       	      	 return router;
       	      }
       }

Saturday, February 5, 2011
UNIFORM INTERFACE
      Manipulation Through Representation [1]

                                REPRESENTATION

                             representasi dari resource


Saturday, February 5, 2011
RESTLET FRAMEWORK
                                 application building block




Saturday, February 5, 2011
UNIFORM INTERFACE
      Manipulation Through Representation [2]
                              HTTP METHOD as Popular Practices


   • HTTP                POST ---> • membuat Resource baru (Create)

   • HTTP                GET --->    • mendapatkan   Resource (Read)

   • HTTP                PUT --->    • mengubah   Resource (Update)

   • HTTP                DELETE ---> • menghapus Resource (Delete)


Saturday, February 5, 2011
UNIFORM INTERFACE
      Manipulation Through Representation [3]
                                        Another Protocol?


    • Gunakan     standar protokol komunikasi sesuai dengan
        spesifikasinya

    • Perhatikan             Safety dan Idempotency dari method

              • Safety       : tidak menghasilkan “efek samping” pada resource

              • Idempotency         : dilakukan berulang-ulang hasilnya sama

Saturday, February 5, 2011
UNIFORM INTERFACE
      Manipulation Through Representation [4]
                       Standardized Document Structure as Representation


                             • XHTML        • MPEG

                             • XML          • MP3

                             • Atom   Pub   • AVI

                             • OData        • Text/Audio/Video   Streaming


Saturday, February 5, 2011
UNIFORM INTERFACE
      Manipulation Through Representation [5]
                                      Not Only HTTP


                             TEXT/AUDIO/VIDEO STREAMING
                                     Contoh : VoIP

                                   Using SIP or XMPP



Saturday, February 5, 2011
RESTLET FRAMEWORK
                              MainApplication
       public class MainApplication extends Application {

       	      public MainApplication(Context parentContext) {
       	      	 super(parentContext);		
       	      }
       	
       	      @Override
       	      public synchronized Restlet createInboundRoot() {
       	      	 Router router = new Router(getContext());
       	      	
       	      	 router.attach("/", MessagesResource.class);
       	      	 router.attach("/message/", MessageResource.class);
       	      	 router.attach("/message/{messageIndex}", MessageResource.class);
       	      	
       	      	 return router;
       	      }
       }

Saturday, February 5, 2011
RESTLET FRAMEWORK
      Manipulation Through Representation [1]
                       public class MessageResource extends ServerResource {
                       	
                       	 @Post
                       	 public Representation addMessage(Representation entity) {
                       	 	 StringRepresentation representation = null;
                       	 	
                       	 	 String result = "";
                       	 	 try {
                       	 	 	 result = HelloBusiness.create(entity.getText());
                       	 	 } catch (IOException e) {
                       	 	 	 setStatus(Status.SERVER_ERROR_INTERNAL );
                       	 	 }
                       	 	
                       	 	 representation = new StringRepresentation
                       	 	 	 (result, MediaType.APPLICATION_XML);
                       	 	
                       	 	 return representation;	
                       	 }

Saturday, February 5, 2011
RESTLET FRAMEWORK
      Manipulation Through Representation [2]
                  @Get("xml")
           	      public Representation get(){
           	      	 String index = (String)getRequest().getAttributes().get("messageIndex");
           	      	 StringRepresentation representation = null;
           	      	 String result = "";
           	      	 try{
           	      	 	 if(index != "" && index != null){
           	      	 	 	 result = HelloBusiness.get(Integer.parseInt(index));
           	      	 	 }else{
           	      	 	 	 result = HelloBusiness.get();
           	      	 	 }
           	      	 	 representation = new StringRepresentation
           	      	 	 	 	 	 	 (result, MediaType.APPLICATION_XML);
           	      	 	 return representation;
           	      	 }catch(Exception e){
           	      	 	 setStatus(Status.CLIENT_ERROR_NOT_FOUND);
           	      	 	 representation = new StringRepresentation
           	      	 	 	 	 	 	 ("no item found", MediaType.TEXT_PLAIN);
           	      	 	 return representation;	 	
           	      	 }
           	      }

Saturday, February 5, 2011
RESTLET FRAMEWORK
      Manipulation Through Representation [3]
                       	     @Put
                       	     public Representation put(Representation entity){
                       	     	 StringRepresentation representation = null;
                       	     	
                       	     	 String result = "";
                       	     	 try {
                       	     	 	
                       	     	 	 result = HelloBusiness.update(entity.getText());
                       	     	 	
                       	     	 } catch (IOException e) {
                       	     	 	 setStatus(Status.SERVER_ERROR_INTERNAL );
                       	     	 }
                       	     	
                       	     	 representation = new StringRepresentation
                       	     	 	 	 	 	 	 (result, MediaType.APPLICATION_XML);
                       	     	
                       	     	 return representation;
                       	     }
Saturday, February 5, 2011
RESTLET FRAMEWORK
      Manipulation Through Representation [4]
            	     @Delete
            	     public Representation delete(){
            	     	 StringRepresentation representation = null;
            	     	 String result = "";
            	     	 try {
            	     	 	 result = HelloBusiness.delete();
            	     	 }catch(NoMoreItemException ne){
            	     	 	 setStatus(Status.CLIENT_ERROR_FORBIDDEN);
            	     	 	 representation = new StringRepresentation
            	     	 	 	 	 ("Tidak boleh, udah kosong", MediaType.TEXT_PLAIN);
            	     	 	 return representation;
            	     	 }
            	     	 representation = new StringRepresentation
            	     	 	 	 	 	 	 (result, MediaType.APPLICATION_XML);
            	     	 return representation;
            	     }


Saturday, February 5, 2011
UNIFORM INTERFACE
                             Self-Descriptive Messages [1]

                                    TWO FACTORS

                            The Protocol Message
                    The Media Type (Type of Representation)

Saturday, February 5, 2011
UNIFORM INTERFACE
                             Self-Descriptive Messages [2]
                                  The Protocol Message

    • HTTP                   Header --> Content Negotiation
              •    Contoh :        Accept : application/xml

    • Status                 Respon :
         •   Contoh :            HTTP 1.1 / 200 OK ,HTTP 1.1 / 403 FORBIDDEN


Saturday, February 5, 2011
UNIFORM INTERFACE
                             Self-Descriptive Messages [3]
                                       The Media Type
         • Struktur             Dokumen Bisa Mudah Diolah
         • Contoh              :
                    • XML       (application/xml)
                    • Atom         Pub (application/atom+xml)
Saturday, February 5, 2011
Contoh MediaType XML
            <messages>
              <message>
                     <messageid>120</messageid>
                     <author>Reza</author>
                     <created>2011/02/04 08:20:12</created>
                     <value>Hello, World!</value>
                     <link>/message/120</link>
              <message>
              ........
              ........
            <messages>

Saturday, February 5, 2011
Contoh MediaType Atom
 <entry>
    <id>urn:uuid:95506d98-aae9-4d34-a8f4-1ff30bece80c</id>
    <title type=ʹ′ʹ′textʹ′ʹ′>product created</title>
    <updated>2009-07-05T10:25:00Z</updated>
    <link rel=ʹ′ʹ′selfʹ′ʹ′ href=ʹ′ʹ′http://starbucks.com/products/notifications/95506d98-aae9-4d34-
    a8f4-1ff30bece80cʹ′ʹ′/>
    <link rel=ʹ′ʹ′relatedʹ′ʹ′ href=ʹ′ʹ′http://starbucks.com/products/527ʹ′ʹ′/>
    <category scheme=ʹ′ʹ′http://starbucks.com/products/categories/typeʹ′ʹ′ term=ʹ′ʹ′productʹ′ʹ′/>
    <category scheme=ʹ′ʹ′http://starbucks.com/products/categories/statusʹ′ʹ′ term=ʹ′ʹ′newʹ′ʹ′/>
    <content type=ʹ′ʹ′application/vnd.starbucks+xmlʹ′ʹ′>
        <product xmlns=ʹ′ʹ′http://schemas.starbucks.com/productʹ′ʹ′
                       href=ʹ′ʹ′http://starbucks.com/products/527ʹ′ʹ′>
        <name>Fairtrade Roma Coffee Beans</name>
        <size>1kg</size>
        <price>10</price>
        <currency>$</currency>
        </product>
    </content>
 </entry>

Saturday, February 5, 2011
RESTLET FRAMEWORK
                             Self-Descriptive Message [1]
           @Get("xml")
           	 public Representation get(){
           	 	 String index = (String)getRequest().getAttributes().get("messageIndex");
           	 	 StringRepresentation representation = null;
           	 	 String result = "";
           	 	 try{
           	 	 	 if(index != "" && index != null){
           	 	 	 	 result = HelloBusiness.get(Integer.parseInt(index));
           	 	 	 }else{
           	 	 	 	 result = HelloBusiness.get();
           	 	 	 }
           	 	 	 representation = new StringRepresentation
           	 	 	 	 	 	 	 (result, MediaType.APPLICATION_XML);
           	 	 	 return representation;
           	 	 }catch(NotFoundException e){
           	 	 	 setStatus(Status.CLIENT_ERROR_NOT_FOUND);
           	 	 	 representation = new StringRepresentation
           	 	 	 	 	 	 	 ("no item found", MediaType.TEXT_PLAIN);
           	 	 	 return representation;	 	
           	 	 }
           	 }

Saturday, February 5, 2011
RESTLET FRAMEWORK
                             Self-Descriptive Message [2]
                                 <messages>
                                 <request>GET : ALL</request>
                                 <message>
                                 	 <request>GET</request>
                                 	 <value>Hello, World!</value>
                                 	 <link>/message/0</link>
                                 </message>
                                 <message>
                                 	 <request>GET</request>
                                 	 <value>Halo, Dunia!</value>
                                 	 <link>/message/1</link>
                                 </message>
                                 <message>
                                 	 <request>GET</request>
                                 	 <value>Apa Kabar?</value>
                                 	 <link>/message/2</link>
                                 </message>
                                 </messages>

Saturday, February 5, 2011
Saturday, February 5, 2011
UNIFORM INTERFACE
      Hypermedia as The Engine of Application
             State (HATEOAS) [1]

                                     or
                             Hypermedia constraints



Saturday, February 5, 2011
UNIFORM INTERFACE
                             Hypermedia Constraint [1]


    • Inti          dari Representational State Transfer
    • Menyatukan     informasi proses bisnis dalam
        representasi resource



Saturday, February 5, 2011
UNIFORM INTERFACE
                             Hypermedia Constraint [2]
                    explains why named as “representational state transfer”




Saturday, February 5, 2011
UNIFORM INTERFACE
                             Hypermedia Constraint [3]
                                 execution of business process


                    “Consumers in a hypermedia system cause state
                    transitions by visiting and manipulating resource
                    state. Interestingly, the application state changes that
                    result from a consumer driving a hypermedia system
                    resemble the execution of a business process. This
                    suggests that our services can advertise workflows
                    using hypermedia.” - Jim Webber - REST In Practice




Saturday, February 5, 2011
UNIFORM INTERFACE
                             Hypermedia Constraint [3]
                                        Best Practices



    • Menambahkan       informasi possible next states
        langsung di dalam Representation
    • Caranya                (untuk saat ini) :
                    • possible   next states ----> hyperlinks


Saturday, February 5, 2011
UNIFORM INTERFACE
                             Hypermedia Constraint [4]
                                                      examples
                              <entry>
                              <order xmlns=ʹ′ʹ′http://schemas.starbucks.comʹ′ʹ′>
                              <location>takeAway</location>
                              <item>
                                  <name>latte</name>
                                  <quantity>1</quantity>
                                  <milk>whole</milk>
                                  <size>small</size>
                              </item>
                              <cost>2.0</cost>
                              <status>payment-expected</status>
                              <link rel=ʹ′ʹ′http://relations.restbucks.com/paymentʹ′ʹ′
                                      href=ʹ′ʹ′https://restbucks.com/payment/1234ʹ′ʹ′/>
                              <link rel=ʹ′ʹ′http://relations.restbucks.com/special-offerʹ′ʹ′
                                      href=ʹ′ʹ′http://restbucks.com/offers/cookie/1234ʹ′ʹ′/>
                              </entry>

Saturday, February 5, 2011
UNIFORM INTERFACE
                             Hypermedia Constraint [5]
                               hypermedia support in MediaType

    • Lebih baik jangan gunakan MediaType XML untuk
        menambahkan hyperlinks di dalamnya.
        •   Tidak ada dukungan langsung (native link tag) untuk hyperlinks

    • Gunakan                 Hypermedia Types (-Mike Amundsen)
                    • Contoh     : Atom
                    • http://amundsen.com/hypermedia/
Saturday, February 5, 2011
RESTLET FRAMEWORK
                             Hypermedia Constraints [1]

    • Native    support untuk mempermudah manajemen
        hypermedia constraints terdapat pada Restlet
        versi 2.1 (dalam pengembangan)
    • Solusi                 : Tambahkan secara manual !     :D
    • Solusi                 : Pakai versi 2.1 dengan resiko sendiri


Saturday, February 5, 2011
CONTOH APLIKASI LAIN
                                  SOCIAL COMMERCE [1]


    • Indeks Aplikasi              Memuat :

              • Daftar Toko         Online (dengan link masing-masing)

              • Link         ke User Profile

              • Link         ke Pengaturan Toko Online milik user




Saturday, February 5, 2011
CONTOH APLIKASI LAIN
                                    SOCIAL COMMERCE [2]


    • Masuk                  ke salah satu Toko Online (melalui link). Memuat :

              • Profil          singkat penjual (dengan link ke profil lengkap)

              • Daftar   Deskripsi Singkat Produk (dengan link masing-
                   masing untuk deskripsi lengkap)

              • Link          ke Indeks


Saturday, February 5, 2011
CONTOH APLIKASI LAIN
                                  SOCIAL COMMERCE [3]



    • Lihat            deskripsi lengkap produk (melalui link). Memuat :

              • Informasi        produk

              • Link         untuk memesan

              • Link         kembali ke Toko Online



Saturday, February 5, 2011
CONTOH APLIKASI LAIN
                             SOCIAL COMMERCE [4]




Saturday, February 5, 2011
CONTOH APLIKASI LAIN
                             SOCIAL COMMERCE [5]




Saturday, February 5, 2011
CONTOH APLIKASI LAIN
                             SOCIAL COMMERCE [6]




Saturday, February 5, 2011
CONTOH APLIKASI LAIN
                             SOCIAL COMMERCE [7]




Saturday, February 5, 2011
THANK YOU !

                             QUESTION?




Saturday, February 5, 2011

More Related Content

What's hot

Mule ESB SMTP Connector Integration
Mule ESB SMTP Connector  IntegrationMule ESB SMTP Connector  Integration
Mule ESB SMTP Connector IntegrationAnilKumar Etagowni
 
09 Managing Dependencies
09 Managing Dependencies09 Managing Dependencies
09 Managing Dependenciesrehaniltifat
 
Mule Esb Data Weave
Mule Esb Data WeaveMule Esb Data Weave
Mule Esb Data WeaveMohammed246
 
Junit in mule demo
Junit in mule demoJunit in mule demo
Junit in mule demoSudha Ch
 
Baocao Web Tech Java Mail
Baocao Web Tech Java MailBaocao Web Tech Java Mail
Baocao Web Tech Java Mailxicot
 
11 Understanding and Influencing the PL/SQL Compilar
11 Understanding and Influencing the PL/SQL Compilar11 Understanding and Influencing the PL/SQL Compilar
11 Understanding and Influencing the PL/SQL Compilarrehaniltifat
 
PHP Oracle Web Applications by Kuassi Mensah
PHP Oracle Web Applications by Kuassi MensahPHP Oracle Web Applications by Kuassi Mensah
PHP Oracle Web Applications by Kuassi MensahPHP Barcelona Conference
 
Using SP Metal for faster share point development
Using SP Metal for faster share point developmentUsing SP Metal for faster share point development
Using SP Metal for faster share point developmentPranav Sharma
 
Mule system properties
Mule system propertiesMule system properties
Mule system propertiesGandham38
 
Mule testing
Mule   testingMule   testing
Mule testingSindhu VL
 
Php Applications with Oracle by Kuassi Mensah
Php Applications with Oracle by Kuassi MensahPhp Applications with Oracle by Kuassi Mensah
Php Applications with Oracle by Kuassi MensahPHP Barcelona Conference
 
Mule Collection Splitter
Mule Collection SplitterMule Collection Splitter
Mule Collection SplitterAnkush Sharma
 
Oracle sql & plsql
Oracle sql & plsqlOracle sql & plsql
Oracle sql & plsqlSid Xing
 
RestFull Webservices with JAX-RS
RestFull Webservices with JAX-RSRestFull Webservices with JAX-RS
RestFull Webservices with JAX-RSNeil Ghosh
 
Force.com migration utility
Force.com migration utilityForce.com migration utility
Force.com migration utilityAmit Sharma
 

What's hot (18)

Mule ESB SMTP Connector Integration
Mule ESB SMTP Connector  IntegrationMule ESB SMTP Connector  Integration
Mule ESB SMTP Connector Integration
 
09 Managing Dependencies
09 Managing Dependencies09 Managing Dependencies
09 Managing Dependencies
 
Mule Esb Data Weave
Mule Esb Data WeaveMule Esb Data Weave
Mule Esb Data Weave
 
Junit in mule demo
Junit in mule demoJunit in mule demo
Junit in mule demo
 
Baocao Web Tech Java Mail
Baocao Web Tech Java MailBaocao Web Tech Java Mail
Baocao Web Tech Java Mail
 
11 Understanding and Influencing the PL/SQL Compilar
11 Understanding and Influencing the PL/SQL Compilar11 Understanding and Influencing the PL/SQL Compilar
11 Understanding and Influencing the PL/SQL Compilar
 
Lecture11 b
Lecture11 bLecture11 b
Lecture11 b
 
PHP Oracle Web Applications by Kuassi Mensah
PHP Oracle Web Applications by Kuassi MensahPHP Oracle Web Applications by Kuassi Mensah
PHP Oracle Web Applications by Kuassi Mensah
 
Using SP Metal for faster share point development
Using SP Metal for faster share point developmentUsing SP Metal for faster share point development
Using SP Metal for faster share point development
 
Jersey and JAX-RS
Jersey and JAX-RSJersey and JAX-RS
Jersey and JAX-RS
 
Getting modular with OSGI
Getting modular with OSGIGetting modular with OSGI
Getting modular with OSGI
 
Mule system properties
Mule system propertiesMule system properties
Mule system properties
 
Mule testing
Mule   testingMule   testing
Mule testing
 
Php Applications with Oracle by Kuassi Mensah
Php Applications with Oracle by Kuassi MensahPhp Applications with Oracle by Kuassi Mensah
Php Applications with Oracle by Kuassi Mensah
 
Mule Collection Splitter
Mule Collection SplitterMule Collection Splitter
Mule Collection Splitter
 
Oracle sql & plsql
Oracle sql & plsqlOracle sql & plsql
Oracle sql & plsql
 
RestFull Webservices with JAX-RS
RestFull Webservices with JAX-RSRestFull Webservices with JAX-RS
RestFull Webservices with JAX-RS
 
Force.com migration utility
Force.com migration utilityForce.com migration utility
Force.com migration utility
 

Viewers also liked

Sistem Informasi & Aplikasinya
Sistem Informasi & AplikasinyaSistem Informasi & Aplikasinya
Sistem Informasi & AplikasinyaPrizka Airianiain
 
Sistem informasi dalam organisasi
Sistem informasi dalam organisasiSistem informasi dalam organisasi
Sistem informasi dalam organisasiyy rahmat
 
Asking and getting permission
Asking and getting permissionAsking and getting permission
Asking and getting permissionHaruko Shinagawa
 
Penulisan rujukan mengikut format apa contoh (1)
Penulisan rujukan mengikut format apa   contoh (1)Penulisan rujukan mengikut format apa   contoh (1)
Penulisan rujukan mengikut format apa contoh (1)Mohd Fadzil Ambok
 
The philosophical foundations of education
The philosophical foundations of educationThe philosophical foundations of education
The philosophical foundations of educationLo-Ann Placido
 
Education at a Glance 2014 - Key Findings
Education at a Glance 2014 - Key FindingsEducation at a Glance 2014 - Key Findings
Education at a Glance 2014 - Key FindingsEduSkills OECD
 

Viewers also liked (7)

Sistem Informasi & Aplikasinya
Sistem Informasi & AplikasinyaSistem Informasi & Aplikasinya
Sistem Informasi & Aplikasinya
 
Sistem informasi dalam organisasi
Sistem informasi dalam organisasiSistem informasi dalam organisasi
Sistem informasi dalam organisasi
 
Revolusi mental dan konsep visi serta misi jokowi jusuf kalla 2014
Revolusi mental dan konsep visi serta misi jokowi jusuf kalla 2014Revolusi mental dan konsep visi serta misi jokowi jusuf kalla 2014
Revolusi mental dan konsep visi serta misi jokowi jusuf kalla 2014
 
Asking and getting permission
Asking and getting permissionAsking and getting permission
Asking and getting permission
 
Penulisan rujukan mengikut format apa contoh (1)
Penulisan rujukan mengikut format apa   contoh (1)Penulisan rujukan mengikut format apa   contoh (1)
Penulisan rujukan mengikut format apa contoh (1)
 
The philosophical foundations of education
The philosophical foundations of educationThe philosophical foundations of education
The philosophical foundations of education
 
Education at a Glance 2014 - Key Findings
Education at a Glance 2014 - Key FindingsEducation at a Glance 2014 - Key Findings
Education at a Glance 2014 - Key Findings
 

Similar to Rest dengan restlet

JAX-RS 2.0 and OData
JAX-RS 2.0 and ODataJAX-RS 2.0 and OData
JAX-RS 2.0 and ODataAnil Allewar
 
Introduction to Wildfly 8 - Marchioni
Introduction to Wildfly 8 -  MarchioniIntroduction to Wildfly 8 -  Marchioni
Introduction to Wildfly 8 - MarchioniCodemotion
 
JavaOne 2009 - TS-5276 - RESTful Protocol Buffers
JavaOne 2009 - TS-5276 - RESTful  Protocol BuffersJavaOne 2009 - TS-5276 - RESTful  Protocol Buffers
JavaOne 2009 - TS-5276 - RESTful Protocol BuffersMatt O'Keefe
 
03.eGovFrame Runtime Environment Training Book Supplement
03.eGovFrame Runtime Environment Training Book Supplement03.eGovFrame Runtime Environment Training Book Supplement
03.eGovFrame Runtime Environment Training Book SupplementChuong Nguyen
 
Building RESTful Services with WCF 4.0
Building RESTful Services with WCF 4.0Building RESTful Services with WCF 4.0
Building RESTful Services with WCF 4.0Saltmarch Media
 
Philly Spring UG Roo Overview
Philly Spring UG Roo OverviewPhilly Spring UG Roo Overview
Philly Spring UG Roo Overviewkrimple
 
XML-RPC (XML Remote Procedure Call)
XML-RPC (XML Remote Procedure Call)XML-RPC (XML Remote Procedure Call)
XML-RPC (XML Remote Procedure Call)Peter R. Egli
 
The Solar Framework for PHP
The Solar Framework for PHPThe Solar Framework for PHP
The Solar Framework for PHPConFoo
 
The NuGram approach to dynamic grammars
The NuGram approach to dynamic grammarsThe NuGram approach to dynamic grammars
The NuGram approach to dynamic grammarsNu Echo Inc.
 
Native REST Web Services with Oracle 11g
Native REST Web Services with Oracle 11gNative REST Web Services with Oracle 11g
Native REST Web Services with Oracle 11gMarcelo Ochoa
 
Introduction to java servlet 3.0 api javaone 2008
Introduction to java servlet 3.0 api javaone 2008Introduction to java servlet 3.0 api javaone 2008
Introduction to java servlet 3.0 api javaone 2008JavaEE Trainers
 
Java Enterprise Edition 6 Overview
Java Enterprise Edition 6 OverviewJava Enterprise Edition 6 Overview
Java Enterprise Edition 6 OverviewEugene Bogaart
 
CDI, Seam & RESTEasy: You haven't seen REST yet!
CDI, Seam & RESTEasy: You haven't seen REST yet!CDI, Seam & RESTEasy: You haven't seen REST yet!
CDI, Seam & RESTEasy: You haven't seen REST yet!Dan Allen
 
04.egovFrame Runtime Environment Workshop
04.egovFrame Runtime Environment Workshop04.egovFrame Runtime Environment Workshop
04.egovFrame Runtime Environment WorkshopChuong Nguyen
 
Java EE 6 & GlassFish v3 at Vancouver JUG, Jan 26, 2010
Java EE 6 & GlassFish v3 at Vancouver JUG, Jan 26, 2010Java EE 6 & GlassFish v3 at Vancouver JUG, Jan 26, 2010
Java EE 6 & GlassFish v3 at Vancouver JUG, Jan 26, 2010Arun Gupta
 
Network Device Database Management with REST using Jersey
Network Device Database Management with REST using JerseyNetwork Device Database Management with REST using Jersey
Network Device Database Management with REST using JerseyPayal Jain
 
Overview of RESTful web services
Overview of RESTful web servicesOverview of RESTful web services
Overview of RESTful web servicesnbuddharaju
 
JavaOne India 2011 - Servlets 3.0
JavaOne India 2011 - Servlets 3.0JavaOne India 2011 - Servlets 3.0
JavaOne India 2011 - Servlets 3.0Arun Gupta
 

Similar to Rest dengan restlet (20)

JAX-RS 2.0 and OData
JAX-RS 2.0 and ODataJAX-RS 2.0 and OData
JAX-RS 2.0 and OData
 
Introduction to Wildfly 8 - Marchioni
Introduction to Wildfly 8 -  MarchioniIntroduction to Wildfly 8 -  Marchioni
Introduction to Wildfly 8 - Marchioni
 
JavaOne 2009 - TS-5276 - RESTful Protocol Buffers
JavaOne 2009 - TS-5276 - RESTful  Protocol BuffersJavaOne 2009 - TS-5276 - RESTful  Protocol Buffers
JavaOne 2009 - TS-5276 - RESTful Protocol Buffers
 
Why Laravel?
Why Laravel?Why Laravel?
Why Laravel?
 
03.eGovFrame Runtime Environment Training Book Supplement
03.eGovFrame Runtime Environment Training Book Supplement03.eGovFrame Runtime Environment Training Book Supplement
03.eGovFrame Runtime Environment Training Book Supplement
 
Building RESTful Services with WCF 4.0
Building RESTful Services with WCF 4.0Building RESTful Services with WCF 4.0
Building RESTful Services with WCF 4.0
 
Philly Spring UG Roo Overview
Philly Spring UG Roo OverviewPhilly Spring UG Roo Overview
Philly Spring UG Roo Overview
 
XML-RPC (XML Remote Procedure Call)
XML-RPC (XML Remote Procedure Call)XML-RPC (XML Remote Procedure Call)
XML-RPC (XML Remote Procedure Call)
 
The Solar Framework for PHP
The Solar Framework for PHPThe Solar Framework for PHP
The Solar Framework for PHP
 
The NuGram approach to dynamic grammars
The NuGram approach to dynamic grammarsThe NuGram approach to dynamic grammars
The NuGram approach to dynamic grammars
 
Native REST Web Services with Oracle 11g
Native REST Web Services with Oracle 11gNative REST Web Services with Oracle 11g
Native REST Web Services with Oracle 11g
 
JavaEE6 my way
JavaEE6 my wayJavaEE6 my way
JavaEE6 my way
 
Introduction to java servlet 3.0 api javaone 2008
Introduction to java servlet 3.0 api javaone 2008Introduction to java servlet 3.0 api javaone 2008
Introduction to java servlet 3.0 api javaone 2008
 
Java Enterprise Edition 6 Overview
Java Enterprise Edition 6 OverviewJava Enterprise Edition 6 Overview
Java Enterprise Edition 6 Overview
 
CDI, Seam & RESTEasy: You haven't seen REST yet!
CDI, Seam & RESTEasy: You haven't seen REST yet!CDI, Seam & RESTEasy: You haven't seen REST yet!
CDI, Seam & RESTEasy: You haven't seen REST yet!
 
04.egovFrame Runtime Environment Workshop
04.egovFrame Runtime Environment Workshop04.egovFrame Runtime Environment Workshop
04.egovFrame Runtime Environment Workshop
 
Java EE 6 & GlassFish v3 at Vancouver JUG, Jan 26, 2010
Java EE 6 & GlassFish v3 at Vancouver JUG, Jan 26, 2010Java EE 6 & GlassFish v3 at Vancouver JUG, Jan 26, 2010
Java EE 6 & GlassFish v3 at Vancouver JUG, Jan 26, 2010
 
Network Device Database Management with REST using Jersey
Network Device Database Management with REST using JerseyNetwork Device Database Management with REST using Jersey
Network Device Database Management with REST using Jersey
 
Overview of RESTful web services
Overview of RESTful web servicesOverview of RESTful web services
Overview of RESTful web services
 
JavaOne India 2011 - Servlets 3.0
JavaOne India 2011 - Servlets 3.0JavaOne India 2011 - Servlets 3.0
JavaOne India 2011 - Servlets 3.0
 

Recently uploaded

A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxA Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxLoriGlavin3
 
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxLoriGlavin3
 
Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...
Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...
Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...panagenda
 
Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...
Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...
Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...Scott Andery
 
Data governance with Unity Catalog Presentation
Data governance with Unity Catalog PresentationData governance with Unity Catalog Presentation
Data governance with Unity Catalog PresentationKnoldus Inc.
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc
 
The State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxThe State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxLoriGlavin3
 
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024BookNet Canada
 
Manual 508 Accessibility Compliance Audit
Manual 508 Accessibility Compliance AuditManual 508 Accessibility Compliance Audit
Manual 508 Accessibility Compliance AuditSkynet Technologies
 
Decarbonising Buildings: Making a net-zero built environment a reality
Decarbonising Buildings: Making a net-zero built environment a realityDecarbonising Buildings: Making a net-zero built environment a reality
Decarbonising Buildings: Making a net-zero built environment a realityIES VE
 
2024 April Patch Tuesday
2024 April Patch Tuesday2024 April Patch Tuesday
2024 April Patch TuesdayIvanti
 
Long journey of Ruby standard library at RubyConf AU 2024
Long journey of Ruby standard library at RubyConf AU 2024Long journey of Ruby standard library at RubyConf AU 2024
Long journey of Ruby standard library at RubyConf AU 2024Hiroshi SHIBATA
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity PlanDatabarracks
 
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxPasskey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxLoriGlavin3
 
Genislab builds better products and faster go-to-market with Lean project man...
Genislab builds better products and faster go-to-market with Lean project man...Genislab builds better products and faster go-to-market with Lean project man...
Genislab builds better products and faster go-to-market with Lean project man...Farhan Tariq
 
Generative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersGenerative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersRaghuram Pandurangan
 
Time Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directionsTime Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directionsNathaniel Shimoni
 
Emixa Mendix Meetup 11 April 2024 about Mendix Native development
Emixa Mendix Meetup 11 April 2024 about Mendix Native developmentEmixa Mendix Meetup 11 April 2024 about Mendix Native development
Emixa Mendix Meetup 11 April 2024 about Mendix Native developmentPim van der Noll
 
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...Alkin Tezuysal
 
A Framework for Development in the AI Age
A Framework for Development in the AI AgeA Framework for Development in the AI Age
A Framework for Development in the AI AgeCprime
 

Recently uploaded (20)

A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxA Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
 
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
 
Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...
Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...
Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...
 
Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...
Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...
Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...
 
Data governance with Unity Catalog Presentation
Data governance with Unity Catalog PresentationData governance with Unity Catalog Presentation
Data governance with Unity Catalog Presentation
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
 
The State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxThe State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptx
 
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
 
Manual 508 Accessibility Compliance Audit
Manual 508 Accessibility Compliance AuditManual 508 Accessibility Compliance Audit
Manual 508 Accessibility Compliance Audit
 
Decarbonising Buildings: Making a net-zero built environment a reality
Decarbonising Buildings: Making a net-zero built environment a realityDecarbonising Buildings: Making a net-zero built environment a reality
Decarbonising Buildings: Making a net-zero built environment a reality
 
2024 April Patch Tuesday
2024 April Patch Tuesday2024 April Patch Tuesday
2024 April Patch Tuesday
 
Long journey of Ruby standard library at RubyConf AU 2024
Long journey of Ruby standard library at RubyConf AU 2024Long journey of Ruby standard library at RubyConf AU 2024
Long journey of Ruby standard library at RubyConf AU 2024
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity Plan
 
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxPasskey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
 
Genislab builds better products and faster go-to-market with Lean project man...
Genislab builds better products and faster go-to-market with Lean project man...Genislab builds better products and faster go-to-market with Lean project man...
Genislab builds better products and faster go-to-market with Lean project man...
 
Generative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersGenerative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information Developers
 
Time Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directionsTime Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directions
 
Emixa Mendix Meetup 11 April 2024 about Mendix Native development
Emixa Mendix Meetup 11 April 2024 about Mendix Native developmentEmixa Mendix Meetup 11 April 2024 about Mendix Native development
Emixa Mendix Meetup 11 April 2024 about Mendix Native development
 
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
 
A Framework for Development in the AI Age
A Framework for Development in the AI AgeA Framework for Development in the AI Age
A Framework for Development in the AI Age
 

Rest dengan restlet

  • 1. REZA LESMANA Universitas Gunadarma Saturday, February 5, 2011
  • 2. REST Using Restlet Framework Saturday, February 5, 2011
  • 3. REST Representational State Transfer Saturday, February 5, 2011
  • 4. WHAT IS REST? GAYA ARSITEKTUR SOFTWARE UNTUK ARSITEKTUR APLIKASI BERBASIS JARINGAN BASICALLY WEB SERVICES ARCHITECTURE Saturday, February 5, 2011
  • 5. WHY USE REST? UNIFORM INTERFACE SEMUA KOMPONEN APLIKASI DALAM WEB SERVICES BERINTERAKSI DENGAN CARA YANG SAMA Saturday, February 5, 2011
  • 6. UNIFORM INTERFACE one of the feature of REST Saturday, February 5, 2011
  • 7. UNIFORM INTERFACE Resource Identification [1] RESOURCE informasi yang dibutuhkan oleh user untuk menjalankan proses bisnis dari suatu aplikasi Saturday, February 5, 2011
  • 8. UNIFORM INTERFACE Resource Identification [2] Uniform Resource Identifier (URI) Contoh : HTTP URL Saturday, February 5, 2011
  • 9. UNIFORM INTERFACE Resource Identification [3] URI Template http://contohaja.com/message/{index} Saturday, February 5, 2011
  • 10. RESTLET FRAMEWORK application building block Saturday, February 5, 2011
  • 11. RESTLET FRAMEWORK servlet configuration (web.xml) <!-- Application class name --> <context-param> <param-name>org.restlet.application</param-name> <param-value> com.helloworld.main.MainApplication </param-value> </context-param> <!-- Restlet adapter --> <servlet> <servlet-name>RestletServlet</servlet-name> <servlet-class> org.restlet.ext.servlet.ServerServlet </servlet-class> </servlet> <!-- Catch all requests --> <servlet-mapping> <servlet-name>RestletServlet</servlet-name> <url-pattern>/*</url-pattern> </servlet-mapping> Saturday, February 5, 2011
  • 12. UNIFORM INTERFACE Resource Identification [4] aplikasi penyimpanan pesan dalam stack • Daftar Pesan ---> • “/” ---> MessagesResource • Top of Stack ---> • “/message/ ---> MessageResource • Pesan Tunggal ---> • “/message/{index} ---> MessageResource Saturday, February 5, 2011
  • 13. RESTLET FRAMEWORK MainApplication public class MainApplication extends Application { public MainApplication(Context parentContext) { super(parentContext); } @Override public synchronized Restlet createInboundRoot() { Router router = new Router(getContext()); router.attach("/", MessagesResource.class); router.attach("/message/", MessageResource.class); router.attach("/message/{messageIndex}", MessageResource.class); return router; } } Saturday, February 5, 2011
  • 14. UNIFORM INTERFACE Manipulation Through Representation [1] REPRESENTATION representasi dari resource Saturday, February 5, 2011
  • 15. RESTLET FRAMEWORK application building block Saturday, February 5, 2011
  • 16. UNIFORM INTERFACE Manipulation Through Representation [2] HTTP METHOD as Popular Practices • HTTP POST ---> • membuat Resource baru (Create) • HTTP GET ---> • mendapatkan Resource (Read) • HTTP PUT ---> • mengubah Resource (Update) • HTTP DELETE ---> • menghapus Resource (Delete) Saturday, February 5, 2011
  • 17. UNIFORM INTERFACE Manipulation Through Representation [3] Another Protocol? • Gunakan standar protokol komunikasi sesuai dengan spesifikasinya • Perhatikan Safety dan Idempotency dari method • Safety : tidak menghasilkan “efek samping” pada resource • Idempotency : dilakukan berulang-ulang hasilnya sama Saturday, February 5, 2011
  • 18. UNIFORM INTERFACE Manipulation Through Representation [4] Standardized Document Structure as Representation • XHTML • MPEG • XML • MP3 • Atom Pub • AVI • OData • Text/Audio/Video Streaming Saturday, February 5, 2011
  • 19. UNIFORM INTERFACE Manipulation Through Representation [5] Not Only HTTP TEXT/AUDIO/VIDEO STREAMING Contoh : VoIP Using SIP or XMPP Saturday, February 5, 2011
  • 20. RESTLET FRAMEWORK MainApplication public class MainApplication extends Application { public MainApplication(Context parentContext) { super(parentContext); } @Override public synchronized Restlet createInboundRoot() { Router router = new Router(getContext()); router.attach("/", MessagesResource.class); router.attach("/message/", MessageResource.class); router.attach("/message/{messageIndex}", MessageResource.class); return router; } } Saturday, February 5, 2011
  • 21. RESTLET FRAMEWORK Manipulation Through Representation [1] public class MessageResource extends ServerResource { @Post public Representation addMessage(Representation entity) { StringRepresentation representation = null; String result = ""; try { result = HelloBusiness.create(entity.getText()); } catch (IOException e) { setStatus(Status.SERVER_ERROR_INTERNAL ); } representation = new StringRepresentation (result, MediaType.APPLICATION_XML); return representation; } Saturday, February 5, 2011
  • 22. RESTLET FRAMEWORK Manipulation Through Representation [2] @Get("xml") public Representation get(){ String index = (String)getRequest().getAttributes().get("messageIndex"); StringRepresentation representation = null; String result = ""; try{ if(index != "" && index != null){ result = HelloBusiness.get(Integer.parseInt(index)); }else{ result = HelloBusiness.get(); } representation = new StringRepresentation (result, MediaType.APPLICATION_XML); return representation; }catch(Exception e){ setStatus(Status.CLIENT_ERROR_NOT_FOUND); representation = new StringRepresentation ("no item found", MediaType.TEXT_PLAIN); return representation; } } Saturday, February 5, 2011
  • 23. RESTLET FRAMEWORK Manipulation Through Representation [3] @Put public Representation put(Representation entity){ StringRepresentation representation = null; String result = ""; try { result = HelloBusiness.update(entity.getText()); } catch (IOException e) { setStatus(Status.SERVER_ERROR_INTERNAL ); } representation = new StringRepresentation (result, MediaType.APPLICATION_XML); return representation; } Saturday, February 5, 2011
  • 24. RESTLET FRAMEWORK Manipulation Through Representation [4] @Delete public Representation delete(){ StringRepresentation representation = null; String result = ""; try { result = HelloBusiness.delete(); }catch(NoMoreItemException ne){ setStatus(Status.CLIENT_ERROR_FORBIDDEN); representation = new StringRepresentation ("Tidak boleh, udah kosong", MediaType.TEXT_PLAIN); return representation; } representation = new StringRepresentation (result, MediaType.APPLICATION_XML); return representation; } Saturday, February 5, 2011
  • 25. UNIFORM INTERFACE Self-Descriptive Messages [1] TWO FACTORS The Protocol Message The Media Type (Type of Representation) Saturday, February 5, 2011
  • 26. UNIFORM INTERFACE Self-Descriptive Messages [2] The Protocol Message • HTTP Header --> Content Negotiation • Contoh : Accept : application/xml • Status Respon : • Contoh : HTTP 1.1 / 200 OK ,HTTP 1.1 / 403 FORBIDDEN Saturday, February 5, 2011
  • 27. UNIFORM INTERFACE Self-Descriptive Messages [3] The Media Type • Struktur Dokumen Bisa Mudah Diolah • Contoh : • XML (application/xml) • Atom Pub (application/atom+xml) Saturday, February 5, 2011
  • 28. Contoh MediaType XML <messages> <message> <messageid>120</messageid> <author>Reza</author> <created>2011/02/04 08:20:12</created> <value>Hello, World!</value> <link>/message/120</link> <message> ........ ........ <messages> Saturday, February 5, 2011
  • 29. Contoh MediaType Atom <entry> <id>urn:uuid:95506d98-aae9-4d34-a8f4-1ff30bece80c</id> <title type=ʹ′ʹ′textʹ′ʹ′>product created</title> <updated>2009-07-05T10:25:00Z</updated> <link rel=ʹ′ʹ′selfʹ′ʹ′ href=ʹ′ʹ′http://starbucks.com/products/notifications/95506d98-aae9-4d34- a8f4-1ff30bece80cʹ′ʹ′/> <link rel=ʹ′ʹ′relatedʹ′ʹ′ href=ʹ′ʹ′http://starbucks.com/products/527ʹ′ʹ′/> <category scheme=ʹ′ʹ′http://starbucks.com/products/categories/typeʹ′ʹ′ term=ʹ′ʹ′productʹ′ʹ′/> <category scheme=ʹ′ʹ′http://starbucks.com/products/categories/statusʹ′ʹ′ term=ʹ′ʹ′newʹ′ʹ′/> <content type=ʹ′ʹ′application/vnd.starbucks+xmlʹ′ʹ′> <product xmlns=ʹ′ʹ′http://schemas.starbucks.com/productʹ′ʹ′ href=ʹ′ʹ′http://starbucks.com/products/527ʹ′ʹ′> <name>Fairtrade Roma Coffee Beans</name> <size>1kg</size> <price>10</price> <currency>$</currency> </product> </content> </entry> Saturday, February 5, 2011
  • 30. RESTLET FRAMEWORK Self-Descriptive Message [1] @Get("xml") public Representation get(){ String index = (String)getRequest().getAttributes().get("messageIndex"); StringRepresentation representation = null; String result = ""; try{ if(index != "" && index != null){ result = HelloBusiness.get(Integer.parseInt(index)); }else{ result = HelloBusiness.get(); } representation = new StringRepresentation (result, MediaType.APPLICATION_XML); return representation; }catch(NotFoundException e){ setStatus(Status.CLIENT_ERROR_NOT_FOUND); representation = new StringRepresentation ("no item found", MediaType.TEXT_PLAIN); return representation; } } Saturday, February 5, 2011
  • 31. RESTLET FRAMEWORK Self-Descriptive Message [2] <messages> <request>GET : ALL</request> <message> <request>GET</request> <value>Hello, World!</value> <link>/message/0</link> </message> <message> <request>GET</request> <value>Halo, Dunia!</value> <link>/message/1</link> </message> <message> <request>GET</request> <value>Apa Kabar?</value> <link>/message/2</link> </message> </messages> Saturday, February 5, 2011
  • 33. UNIFORM INTERFACE Hypermedia as The Engine of Application State (HATEOAS) [1] or Hypermedia constraints Saturday, February 5, 2011
  • 34. UNIFORM INTERFACE Hypermedia Constraint [1] • Inti dari Representational State Transfer • Menyatukan informasi proses bisnis dalam representasi resource Saturday, February 5, 2011
  • 35. UNIFORM INTERFACE Hypermedia Constraint [2] explains why named as “representational state transfer” Saturday, February 5, 2011
  • 36. UNIFORM INTERFACE Hypermedia Constraint [3] execution of business process “Consumers in a hypermedia system cause state transitions by visiting and manipulating resource state. Interestingly, the application state changes that result from a consumer driving a hypermedia system resemble the execution of a business process. This suggests that our services can advertise workflows using hypermedia.” - Jim Webber - REST In Practice Saturday, February 5, 2011
  • 37. UNIFORM INTERFACE Hypermedia Constraint [3] Best Practices • Menambahkan informasi possible next states langsung di dalam Representation • Caranya (untuk saat ini) : • possible next states ----> hyperlinks Saturday, February 5, 2011
  • 38. UNIFORM INTERFACE Hypermedia Constraint [4] examples <entry> <order xmlns=ʹ′ʹ′http://schemas.starbucks.comʹ′ʹ′> <location>takeAway</location> <item> <name>latte</name> <quantity>1</quantity> <milk>whole</milk> <size>small</size> </item> <cost>2.0</cost> <status>payment-expected</status> <link rel=ʹ′ʹ′http://relations.restbucks.com/paymentʹ′ʹ′ href=ʹ′ʹ′https://restbucks.com/payment/1234ʹ′ʹ′/> <link rel=ʹ′ʹ′http://relations.restbucks.com/special-offerʹ′ʹ′ href=ʹ′ʹ′http://restbucks.com/offers/cookie/1234ʹ′ʹ′/> </entry> Saturday, February 5, 2011
  • 39. UNIFORM INTERFACE Hypermedia Constraint [5] hypermedia support in MediaType • Lebih baik jangan gunakan MediaType XML untuk menambahkan hyperlinks di dalamnya. • Tidak ada dukungan langsung (native link tag) untuk hyperlinks • Gunakan Hypermedia Types (-Mike Amundsen) • Contoh : Atom • http://amundsen.com/hypermedia/ Saturday, February 5, 2011
  • 40. RESTLET FRAMEWORK Hypermedia Constraints [1] • Native support untuk mempermudah manajemen hypermedia constraints terdapat pada Restlet versi 2.1 (dalam pengembangan) • Solusi : Tambahkan secara manual ! :D • Solusi : Pakai versi 2.1 dengan resiko sendiri Saturday, February 5, 2011
  • 41. CONTOH APLIKASI LAIN SOCIAL COMMERCE [1] • Indeks Aplikasi Memuat : • Daftar Toko Online (dengan link masing-masing) • Link ke User Profile • Link ke Pengaturan Toko Online milik user Saturday, February 5, 2011
  • 42. CONTOH APLIKASI LAIN SOCIAL COMMERCE [2] • Masuk ke salah satu Toko Online (melalui link). Memuat : • Profil singkat penjual (dengan link ke profil lengkap) • Daftar Deskripsi Singkat Produk (dengan link masing- masing untuk deskripsi lengkap) • Link ke Indeks Saturday, February 5, 2011
  • 43. CONTOH APLIKASI LAIN SOCIAL COMMERCE [3] • Lihat deskripsi lengkap produk (melalui link). Memuat : • Informasi produk • Link untuk memesan • Link kembali ke Toko Online Saturday, February 5, 2011
  • 44. CONTOH APLIKASI LAIN SOCIAL COMMERCE [4] Saturday, February 5, 2011
  • 45. CONTOH APLIKASI LAIN SOCIAL COMMERCE [5] Saturday, February 5, 2011
  • 46. CONTOH APLIKASI LAIN SOCIAL COMMERCE [6] Saturday, February 5, 2011
  • 47. CONTOH APLIKASI LAIN SOCIAL COMMERCE [7] Saturday, February 5, 2011
  • 48. THANK YOU ! QUESTION? Saturday, February 5, 2011