1 / 21

MCS 270 Spring 2014

MCS 270 Spring 2014. Object-Oriented Software Development. MCS 270 Object-Oriented Software Development. Today ’ s schedule. Google Web Toolkit Domain Analysis/Application Analysis. MCS 270 Object-Oriented Software Development. Google Web Toolkit Features.

tulia
Download Presentation

MCS 270 Spring 2014

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. MCS 270 Spring 2014 Object-Oriented Software Development

  2. MCS 270 Object-Oriented Software Development Today’s schedule Google Web Toolkit Domain Analysis/Application Analysis

  3. MCS 270 Object-Oriented Software Development Google Web Toolkit Features Communication between client and server using Java objects. GWT applications do not need to fetch new HTML pages as they execute. Uses Remote Procedure Call (RPC) for interaction with the server across a network. GWT compiles client-side Java code into JavaScript code that is then inserted into the HTML page and used to run app JavaScript client implementation -> runs on multiple browsers.

  4. MCS 270 Object-Oriented Software Development Google Web Toolkit Client Side Programming Client-side code includes: Core (non-GUI) Java classes GWT UI widgets – buttons, menus, panels, etc RPC Servlet InterfaceDefinitions (including Async)

  5. MCS 270 Object-Oriented Software Development Google Web Toolkit Server Side Programming Server-side code includes: Core (non-GUI) Java classes RPC Servlet ImplementationClasses

  6. MCS 270 Object-Oriented Software Development Google Web Toolkit Shared Programming Shared code includes: Core (non-GUI) Java classes that are used by both server and client. Note: These should not contain GUI components or RPC components.

  7. MCS 270 Object-Oriented Software Development Client <-> Server Communication RPC - The mechanism for exchanging data with a server across a network. The server-side code that gets invoked from the client is often referred to as a service The act of making a remote procedure call is sometimes referred to as invoking a service.

  8. MCS 270 Object-Oriented Software Development RPC architecture

  9. MCS 270 Object-Oriented Software Development Example – Client Side Interface Definition package com.example.foo.client; import com.google.gwt.user.client.rpc.RemoteService; import com.google.gwt.user.client.rpc.RemoteServiceRelativePath; @RemoteServiceRelativePath(”myservicetarget") public interface MyService extends RemoteService { public List getEmployeeList(String department); public String getEmployeeTitle(int employeeID); }

  10. MCS 270 Object-Oriented Software Development Example – Client Side Interface Definition – Async package com.example.foo.client; import com.google.gwt.user.client.rpc.AsyncCallback; interface MyServiceAsync { public void getEmployeeList (String department, AsyncCallback<List> callback); public void getEmployeeTitle(int employeeID, AsyncCallback<String> callback); }

  11. MCS 270 Object-Oriented Software Development Example – Server Side Implementation package com.example.foo.server; import com.google.gwt.user.server.rpc.RemoteServiceServlet; import com.example.client.MyService; public class MyServiceImpl extends RemoteServiceServlet implements MyService { public List getEmployeeList (String department) { // construct List list from database return list; } public String getEmployeeTitle(int employeeID){ return “title”; } }

  12. MCS 270 Object-Oriented Software Development Example – web.xml servlet – module definition <servlet> <servlet-name>myServiceImpl</servlet-name> <servlet-class>com.example.foo.server.MyServiceImpl</servlet-class> </servlet> <servlet-mapping> <servlet-name>myServiceImpl</servlet-name> <url-pattern>/foo/myservicetarget</url-pattern> </servlet-mapping>

  13. MCS 270 Object-Oriented Software Development Serialization Data that is transferred from client to sevrer (or vice-versa) needs to be serializable. (List in last example) For an object to be serialized, every parameter and return type must be serializable.

  14. MCS 270 Object-Oriented Software Development Serialization For a type to be serializable it must satisfy at least one of the following requirements. It is a primitive type (int, char, boolean, etc.) It is an array of serializable types It is a serializable class

  15. MCS 270 Object-Oriented Software Development Serialization A serializable class must satisfy all of following: It implements either Java Serializable or GWT’s ‘IsSerializable’ interface or derives from a superclass that does. It’s non-final, non-transient instance fields are themselves serializable. It has a default (zero argument) constructor with any access modifier (e.g. private Foo(){} will work).

  16. MCS 270 Object-Oriented Software Development Example public class PostData implements IsSerializable { private String title="no title”; private String description="empty”; private double price=0.0; private Seller seller=null; private Buyer buyer=null; // GWT serializable Objects need a no=argument constructor public PostData() {} public PostData(String t, String d, double p, Seller s, Buyer b){ title = t; description = d; price = p; seller = s; buyer = b; } }

  17. MCS 270 Object-Oriented Software Development Client-Side Service Callback For each operation of the service interface we define a class to specify how to handle the returned result of the operation. Class must implement the AsyncCallback<T> interface, which specifies two operations: void onFailure(Throwable caught) void onSuccess(T t).

  18. MCS 270 Object-Oriented Software Development Client-Side Service Callback onFailure(Throwable caught): called when the procedure fails or an exception occurred; exception is passed to the procedure as a parameter. onSuccess(T t): called when the procedure successfully returns a result of type T, and the result is passed to the operation as a parameter. T must be the same data type of the return of the service operation.

  19. MCS 270 Object-Oriented Software Development Client-Side Service Callback Example private final PostDataServiceAsync postDataService = GWT.create(PostDataService.class); public void handlePostSubmit(PostData post) { submitPostService.submitPostToServer(post, new AsyncCallback<String>() { public void onFailure(Throwable caught) { return; } public void onSuccess(String result) { System.out.println(result); } }); }

  20. MCS 270 Object-Oriented Software Development Domain Model Exercise • Groups of 3-4: Create a Domain Model analysis of “GusList” – an on-line classified ad service for the Gustavus community. • Task: Identify • Classes • Associations • Attributes • Assumptions: We will use the MVC architecture • Assignment: By next Thursday (March 6), prepare (group) a Domain Model Class Diagram with all associations and attributes, plus a Data Dictionary.

  21. MCS 270 Object-Oriented Software Development Assignments Monday – Work on GWT Project: Homework: GusList Domain Class Model Due: Thursday, March 6

More Related