Presentation is loading. Please wait.

Presentation is loading. Please wait.

© 2010 IBM Corporation RESTFul Service Modelling in Rational Software Architect April, 2011.

Similar presentations


Presentation on theme: "© 2010 IBM Corporation RESTFul Service Modelling in Rational Software Architect April, 2011."— Presentation transcript:

1 © 2010 IBM Corporation RESTFul Service Modelling in Rational Software Architect April, 2011

2 © 2010 IBM Corporation Disclaimer  The information on products is intended to outline our general product direction and it should not be relied on in making a purchasing decision. The information on products is for informational purposes only and may not be incorporated into any contract. The information on the products is not a commitment, promise, or legal obligation to deliver any material, code or functionality. The development, release, and timing of any features or functionality described for our products remains at our sole discretion.  Plans are based on best information available and may change in future.

3 © 2010 IBM Corporation REST Service Modelling  What is REST? –REST Concepts  Modelling Support for REST in RSA –RSA Profile Authoring –Sample REST Profile  JAX-RS Support –JAXRS Modelling –RSA Transformation Extensibility –Code Generation & Reverse Engineering

4 © 2010 IBM Corporation REST : Representational State Transfer (REST)  REST defines a set of architectural principles by which you can design Web services –focuses on a system's resources, including how resource states are addressed and transferred over HTTP.  First introduced in 2000 by Roy Fielding at the University of California, Irvine, in his academic dissertation, "Architectural Styles and the Design of Network-based Software Architectures,"  A simpler alternative to SOAP- and Web Services Description Language (WSDL)-based Web services  Has gained widespread acceptance across the Web –Adoption of REST by mainstream Web 2.0 service providers—including Yahoo, Google, and Facebook  REST Web service follows four basic design principles: –Use HTTP methods explicitly. –Be stateless. –Expose directory structure-like URIs. –Representation of resource state

5 © 2010 IBM Corporation REST Concepts  REST design principle establishes a one-to-one mapping between create, read, update, and delete (CRUD) operations –To create a resource on the server, use POST. –To retrieve a resource, use GET. –To change the state of a resource or to update it, use PUT. –To remove or delete a resource, use DELETE.  REST suggests the design of web services be stateless –Doesn't require the server, while processing the request, to retrieve any kind of application context or state –A client includes within the HTTP headers and body of a request all of the parameters, context, and data needed by the server-side component to generate a response  Expose directory structure-like URIs –hierarchical, rooted at a single path, and branching from it are subpaths –http://www.myservice.org/discussion/topics/{topic} –http://www.myservice.org/discussion/2008/12/10/{topic}

6 © 2010 IBM Corporation Resource URIs www.BookMarkService.com

7 © 2010 IBM Corporation Resource Representation  A resource representation typically reflects the current state of a resource  Has to do with the format of the data that the application and service exchange in the request/response payload or in the HTTP body {comment}

8 © 2010 IBM Corporation Modelling REST Domain  The key abstraction of information in REST is a RESOURCE –Any information that can be named can be a resource: a document, a home page of a weblog, or a search result –A conceptual mapping to Data Entity (or actual resource)  A Resource Path is a URI that identifies a particular resource  Uses the concepts HTTP and URIs to retrieve or modify the state of a resource –Resource can have methods to handle HTTP request GET, PUT, POST, DELETE etc  A RESOURCE can define Input/Output types –Produces/Consumes types can be specified at the individual method level as well  Path between resource specifies the navigation path form a resource to a sub-resource

9 © 2010 IBM Corporation How to extend RSA to support Modeling REST Services?

10 © 2010 IBM Corporation 10 www.wtcindia.in MDD enabled in RSA – UML Profiles  UML in itself is not broad/detailed for all domains / platforms –UML profiles allow you to customize the language for a particular domain or method  UML Profiles allow UML to be extended using –Stereotypes a type that you may apply as a property value to UML element to extend its properties and slightly alter its semantics –Tagged Values Additional properties which can be supplied E.g. Name of the Business Analyst that created that use case –Constraints Specify rules and restrictions on model elements

11 © 2010 IBM Corporation 11 www.wtcindia.in MDD enabled in RSA – UML Profiles Profile composition palette Diagrammatic Profile composition Profile tooling generation

12 © 2010 IBM Corporation MDD enabled in RSA – Deploying Custom Profile  Profile must be deployed before it can be applied to model.  Two way to deploy a profile: –File system based deployment –Plugin based deployment  In either case, it is highly recommended to have a path-map pointing to the location of the profile.

13 © 2010 IBM Corporation REST Profile Design

14 © 2010 IBM Corporation REST Domain Model

15 © 2010 IBM Corporation REST Modeling Tooling Support  Palette support for creating domain elements  Properties support for customized view

16 © 2010 IBM Corporation JAX-RS Support

17 © 2010 IBM Corporation JAX-RS Support  JAX-RS: Java API for RESTful Web Services provides Java API for creating REST Services  JAX-RS uses annotations to simplify the development and deployment of web services –@Path, specifies the relative path for a resource class. –@GET , @PUT, @POST , @DELETE, specifies the HTTP request type of a resource method. –@Produces, specifies the returned MIME media types etc –…. @Path("widgets") @Produces(“text/plain”) public class WidgetsResource { @GET @Path("offers") public WidgetList getDiscounted() { } @Path("{id}") public WidgetResource findWidget(@PathParam("id") String id) { return new WidgetResource(id); } public class WidgetResource { public WidgetResource(String id) {} @GET public Widget getDetails() {} }

18 © 2010 IBM Corporation JAX-RS Profile  REST Profile can be modified to include JAX-RS specific things –Include JAX-RS elements in REST profile if it is meant to be used in JAX-RS domain only –Create a separate profile for JAX-RS to keep REST and JAX-RS separate  Additional Concepts in JAX-RS –Sub-Resource Method –Sub-Resource Locator public class World{ @PUT public void create(){…} @Path({“continents”}) @GET public void get(){…} @Path({“continents”}) @PUT public void modify(){…} …….. } public class Res1{ @Path({“subRes”}) public SubResource getSubResource(){…} } public class SubResource{ @GET public void Operation1(){…} }

19 © 2010 IBM Corporation How do we generate Implementation code?

20 © 2010 IBM Corporation Extending Transformations  A Transformation Extension allows you to tap into and contribute to an existing Transform element in a transformation  For example, the UML-to-Java Transformation is composed of the following Transforms –Model Transform –Package Transform –Class Transform –Interface Transform –Generalization Transform –Property Transform –Operation Transform –… –You can extend any of these to customize the generated code

21 © 2010 IBM Corporation Extending Transformations  Although the functionality of RSA’s built-in code transformations is complete, you may want to extend them to include generation of custom elements or conventions or to support domain specific constructs  As with most features in Rational Software Architect, to extend existing transformations you use the normal Eclipse extension mechanisms, creating a plug-in and implementing specific extension points  Such an extension is called a Transformation Extension

22 © 2010 IBM Corporation Extending Transformations - Example  This extension looks for any UML keywords defined for this class in the Model and use them to add a new Javadoc tag associated with the class in the source code UML-to-Java Transformation Class Transform Extension

23 © 2010 IBM Corporation JAX-RS Annotation Support

24 © 2010 IBM Corporation Questions

25 © 2010 IBM Corporation Thank You!


Download ppt "© 2010 IBM Corporation RESTFul Service Modelling in Rational Software Architect April, 2011."

Similar presentations


Ads by Google