Representational State Transfer
> Skochel
Google App Engine + JDO + Spring MVC, CRUD example. See following code snippets to perform CRUD on GAE datastore, using Java Data Objects(JDO).
Just annotate the Customer with JDO annotation and perform the CRUD via PersistenceManager. Add Customer c = new Customer(); c.setName(name); PersistenceManager pm = PMF.get().getPersistenceManager(); try { pm.makePersistent(c); } finally { pm.close(); } Search Search “Customer” where name == “mkyong”. PersistenceManager pm = PMF.get().getPersistenceManager(); Query q = pm.newQuery(Customer.class); q.setFilter("name == nameParameter"); q.setOrdering("date desc"); q.declareParameters("String nameParameter"); try { List<Customer> results = (List<Customer>) q.execute("mkyong"); //... } finally { q.closeAll(); pm.close(); } Search “Customer” where name == “mkyong” and email ==”test@gmail.com”. Return list of customer records. Update To update, get existing object and modify it.
Delete GAE + Spring MVC + CRUD example. Google App Engine + Spring MVC, CRUD example with datastore low level api. See following code snippets to perform CRUD for Google App Engine datastore, Java, using low-level API.
Add Store a customer into datastore, with “name” as the key. Key customerKey = KeyFactory.createKey("Customer", "your name"); Entity customer = new Entity("Customer", customerKey); customer.setProperty("name", "your name"); customer.setProperty("email", "your email"); DatastoreService datastore = DatastoreServiceFactory.getDatastoreService(); datastore.put(customer); //save it Search Return 10 customers as a List.
DatastoreService datastore = DatastoreServiceFactory.getDatastoreService(); Query query = new Query("Customer").addSort("date", Query.SortDirection.DESCENDING); List<Entity> customers = datastore.prepare(query).asList(FetchOptions.Builder.withLimit(10)); Find and returned a customer with matched filter.
Query query = new Query("Customer"); query.addFilter("name", FilterOperator.EQUAL, "your name"); PreparedQuery pq = datastore.prepare(query); Entity customer = pq.asSingleEntity();
Fielding Dissertation: CHAPTER 5: Representational State Transfer (REST)
[Top] [Prev] [Next] This chapter introduces and elaborates the Representational State Transfer (REST) architectural style for distributed hypermedia systems, describing the software engineering principles guiding REST and the interaction constraints chosen to retain those principles, while contrasting them to the constraints of other architectural styles.
REST is a hybrid style derived from several of the network-based architectural styles described in Chapter 3 and combined with additional constraints that define a uniform connector interface. The software architecture framework of Chapter 1 is used to define the architectural elements of REST and examine sample process, connector, and data views of prototypical architectures. 5.1 Deriving REST The design rationale behind the Web architecture can be described by an architectural style consisting of the set of constraints applied to elements within the architecture. 5.1.1 Starting with the Null Style 5.1.2 Client-Server 5.1.3 Stateless. Representational state transfer.
Representational State Transfer (REST) is a software architecture style consisting of guidelines and best practices for creating scalable web services.[1][2] REST is a coordinated set of constraints applied to the design of components in a distributed hypermedia system that can lead to a more performant and maintainable architecture.[3] REST has gained widespread acceptance across the Web[citation needed] as a simpler alternative to SOAP and WSDL-based Web services.
RESTful systems typically, but not always, communicate over the Hypertext Transfer Protocol with the same HTTP verbs (GET, POST, PUT, DELETE, etc.) used by web browsers to retrieve web pages and send data to remote servers.[3] The REST architectural style was developed by W3C Technical Architecture Group (TAG) in parallel with HTTP 1.1, based on the existing design of HTTP 1.0.[4] The World Wide Web represents the largest implementation of a system conforming to the REST architectural style. Architectural properties[edit]