本文档主要介绍了如何在 Spring 框架中实现远程服务接口(RMI、Hessian 和 Burlap),通过示例代码演示了服务的配置、部署与调用。介绍包括如何定义接口,配置 Spring bean,启动 RMI 服务器,并通过客户端调用远程服务。详细讨论了不同远程调用技术的优势与使用场景,提供了相关配置文件示例。
文档介绍了Spring Web MVC框架的使用及其架构,强调了控制器(controller)在请求处理中的作用。它包括了使用Eclipse Web Tools Platform进行开发的基本步骤,并提供了创建和配置Spring Web MVC应用程序的示例代码。文档还探讨了在web.xml中配置DispatcherServlet和视图解析器的具体内容。
The document outlines the advantages of using Vim for PHP development, emphasizing its speed, cross-platform capability, and consistent environment. It details various Vim modes, commands for navigation, text editing, search and replace functionality, buffer and window management, and configuration options. The document also mentions available plugins and a charitable organization called HeadNorth for spinal cord injury support.
This document provides instructions for building a Rails API and discusses related topics. It recommends using Rails 3.1 and Ruby 1.9.2 to build the API. It provides steps to generate a MessagesController to handle API requests for messages. It discusses testing the API with curl and rspec tests. It also covers building a namespaced and versioned API, authentication, caching responses, hosting on DotCloud, and running background jobs with Delayed Job.
The document discusses various iOS development topics, particularly focusing on image handling techniques using UIImagePickerController and UIImage functionalities. It includes references to memory management, design patterns in software engineering, and tools for resizing images in iOS applications. Additionally, the document provides code snippets and links to further resources related to iOS programming.
The document describes the implementation of user authentication in a Rails application, detailing user signup, login/logout features, and relevant model and controller structures. It includes examples of migrations for user and message relations, as well as various validation techniques used for user input. Additionally, it outlines deployment steps to Heroku and contains references to testing methods for the application.
This document discusses using WebSockets and EventMachine to build a real-time Twitter stream application. It introduces key concepts like HTML5 WebSockets, EventMachine, and the Twitter Streaming API. It provides code examples for creating a WebSocket connection in the browser, and using EventMachine to build a WebSocket server that subscribes to the Twitter stream and publishes tweets to connected clients over WebSockets.
This document discusses Rack, a web server interface for Ruby web applications. It explains that Rack provides a standard interface between web servers and web frameworks, allowing frameworks to focus on application logic instead of communication details. It also outlines the components of a Rack application, including status code, headers, and body in the response. Finally, it lists some common Rack web servers and middleware libraries that can be used to handle requests and add functionality.
This document discusses Rails engines and gems. It explains that engines allow extracting common functionality into reusable modules. Engines use the Rails::Engine class and Railtie to integrate with Rails applications. The document also covers creating gems, testing engines, mounting engines to host apps, and overriding engine classes and views.
This document introduces a Namespace Less Engine that allows projects to reuse code from other projects without worrying about namespaces. Some key points:
- It allows reusing an entire project (CMS, news system, etc.) rather than just parts of code. Everything can be inherited and overridden.
- Models, controllers and other code can be written without namespaces. Placeholder files define inline namespaces.
- Views cannot be directly inherited but can be overridden. Helpers can also be included.
- The engine gem is included in the Gemfile. Migrations and other setup is installed via rake tasks.
- Tips include using the engine as a submodule instead of gem, and generating models/controllers
The document outlines the advantages of using Vim for PHP development, emphasizing its speed, cross-platform capability, and consistent environment. It details various Vim modes, commands for navigation, text editing, search and replace functionality, buffer and window management, and configuration options. The document also mentions available plugins and a charitable organization called HeadNorth for spinal cord injury support.
This document provides instructions for building a Rails API and discusses related topics. It recommends using Rails 3.1 and Ruby 1.9.2 to build the API. It provides steps to generate a MessagesController to handle API requests for messages. It discusses testing the API with curl and rspec tests. It also covers building a namespaced and versioned API, authentication, caching responses, hosting on DotCloud, and running background jobs with Delayed Job.
The document discusses various iOS development topics, particularly focusing on image handling techniques using UIImagePickerController and UIImage functionalities. It includes references to memory management, design patterns in software engineering, and tools for resizing images in iOS applications. Additionally, the document provides code snippets and links to further resources related to iOS programming.
The document describes the implementation of user authentication in a Rails application, detailing user signup, login/logout features, and relevant model and controller structures. It includes examples of migrations for user and message relations, as well as various validation techniques used for user input. Additionally, it outlines deployment steps to Heroku and contains references to testing methods for the application.
This document discusses using WebSockets and EventMachine to build a real-time Twitter stream application. It introduces key concepts like HTML5 WebSockets, EventMachine, and the Twitter Streaming API. It provides code examples for creating a WebSocket connection in the browser, and using EventMachine to build a WebSocket server that subscribes to the Twitter stream and publishes tweets to connected clients over WebSockets.
This document discusses Rack, a web server interface for Ruby web applications. It explains that Rack provides a standard interface between web servers and web frameworks, allowing frameworks to focus on application logic instead of communication details. It also outlines the components of a Rack application, including status code, headers, and body in the response. Finally, it lists some common Rack web servers and middleware libraries that can be used to handle requests and add functionality.
This document discusses Rails engines and gems. It explains that engines allow extracting common functionality into reusable modules. Engines use the Rails::Engine class and Railtie to integrate with Rails applications. The document also covers creating gems, testing engines, mounting engines to host apps, and overriding engine classes and views.
This document introduces a Namespace Less Engine that allows projects to reuse code from other projects without worrying about namespaces. Some key points:
- It allows reusing an entire project (CMS, news system, etc.) rather than just parts of code. Everything can be inherited and overridden.
- Models, controllers and other code can be written without namespaces. Placeholder files define inline namespaces.
- Views cannot be directly inherited but can be overridden. Helpers can also be included.
- The engine gem is included in the Gemfile. Migrations and other setup is installed via rake tasks.
- Tips include using the engine as a submodule instead of gem, and generating models/controllers
4. 我将要分享的…… REST—— 标准、架构或者理念? Resource CRUD HTTP Verb Ruby on Rails RESTful Login & Search? Twitter & Facebook API Tips Q & A
5. REST Re presentational S tate T ransfer Client-server Stateless 无状态 Cacheable 可缓存 Layered system 负载均衡、共享内存 Code on Demand* 临时扩展客户端功能 Uniform interface 简化、去耦
6. 一种抽象的概念、架构蓝图 Just an Architecture, Not a Standard or Protocol 描述基于互联网的分布式系统 Describe Internet Based Remote System
7. R emote P rocedure C alls 一种分布式函数调用接口 SOAP <?xml version=“1.0” encoding=“UTF-8”?> <soap:Envelope xmlns:soap=“http://schemas.xmlsoap.org/soap/envelope/”> <soap:Body> <gs:doGoogleSearch xmlns:gs=“urn:GoogleSearch”> <q>REST</q> </gs:doGoogleSearch> </soap:Body> </soap:Envelope> Facebook API 、 Flickr API 、淘宝 API http://api.flickr.com/services/rest/?method= flickr.photos.search http://gw.api.tbsandbox.com/router/rest?method= taobao.taobaoke.items.get
8. REST vs RPC RPC 允许定义任意的程序接口 getUsers() getNewUsersSince(date) savePurchaseOrder() … 大多数通过 POST 进行通讯 忽略 HTTP 现有功能 Authentication Caching Content type SOAP 一种基于 HTTP 的通讯协议 REST 接口局限于现有的、标准的 HTTP 操作 GET POST PUT DELETE 一种架构,而非协议 充分利用 HTTP 协议 交互的核心是 Stateful Resources ,而非 Messages 或者 Operations
13. Ruby on Rails 基于动态编程语言 Ruby MVC 架构 M odel- V iew- C ontroller 专注于 Web Application 的开发框架 从 v1.2.x 起支持 REST 架构 v3 beta 可能在 1 月底发布!
14. REST Ruby on Rails 7 个 Controller 的 Action : Index Show New Edit Create Update Destroy 4 个 HTTP Verb : GET POST PUT DELETE
15. POST /projects/create create /projects POST POST /projects/update/1 update /projects/1 PUT GET /projects/destroy/1 destroy /projects/1 DELETE GET /projects/show/1 show /projects/1 GET URL without REST Action URL with REST HTTP Verb
16. class UsersController < ApplicationController # GET /users/1 def show() end # POST /users def create() end # PUT /users/1 def update() end # DELETE /users/1 def destroy() end end
17. class UsersController < ApplicationController # GET /users/new def new ; end # GET /users/1/edit def edit ; end # GET /users def index ; end # GET /users/1 def show ; end # POST /users def create ; end # PUT /users/1 def update ; end # DELETE /users/1 def destroy ; end end
19. 数据表结构 User 拥有很多 Groups Group 拥有很多 Users Users UsersGroups Groups 1 N N 1
20. class Group < ActiveRecord::Base has_many :users_groups has_many :users , :through => :users_groups end class User < ActiveRecord::Base has_many :users_groups has_many :groups , :through => :users_groups end class UsersGroups < ActiveRecord::Base belongs_to :groups belongs_to :users end
22. UsersController join_group() # POST /users/1/join_group?group_id=2 leave_group() # POST /users/1/leave_group?group_id=2 GroupsController add_user() # POST /groups/1/add_user?user_id=2 remove_user() # POST /groups/1/remove_user?user_id=2
24. class Group < ActiveRecord::Base has_many :memberships has_many :users, :through => :memberships end class User < ActiveRecord::Base has_many :memberships has_many :groups, :through => :memberships end class Membership < ActiveRecord::Base belongs_to :groups belongs_to :users end
25. MembershipsController create() # INSERT INTO "memberships" ("group_id", "user_id") VALUES(2, 1) # POST /memberships?user_id=1&group_id=2 destroy() # DELETE FROM "memberships" WHERE "id" = 1 # DELETE /memberships/3
26. mine types class UsersController < ApplicationController # GET /users # GET /users.xml def index @users = User.all respond_to do |format| format.html # index.html.erb format.js { render :json => @users } format.xml { render :xml => @users } fomrat.atom do render :action => “atom”, :content_type => Mine::ATOM end end end end
27. GET /users => HTML GET /users.xml => XML Accept: text/javascript GET /users => json Accept: text/html GET /users.xml => XML
28. Nested Resrouce GET /groups GET /groups/1 DELETE /groups/1 POST /groups GET /users GET /users/2 DELETE /users/2 POST /users 只是想对某个 Group 中的 Users 进行操作呢?
29. map.resources :groups do |groups| groups.resources :users end GET /groups/1/users GET /groups/1/users/2 DELETE /groups/1/users/2 POST /groups/1/users
33. 你如何实现 Login ? POST /login?user=shaokun&password=*** POST /signin?user=shaokun&password=*** https://reg.163.com/logins.jsp http://ptlogin2.qq.com/login
35. class SessionsController < ApplicationController # GET /sessions def new end # POST /sessions def create end # DELETE /sessions # logout def destroy end end
44. http://twitter.com/statuses/destroy/statusid.format DELETE/ POST 删除一个 Status http://twitter.com/statuses/update.format POST 创建一个新的 Status http://twitter.com/statues/show/statusid.format GET 获取特定用户的某一个 Status http://twitter.com/statues/user_timeline/userid.format GET 获取特定用户的 Statuses http://twitter.com/statuses/public_timeline GET 获取所有用户的 Statuses URL HTTP Verb 操作
46. 完全的 RESTful Twitter API /users/{user_id}/statuses/{status_id}.format PUT 更新一个 Status /users/{user_id}/statuses/{status_id}.format DELETE 删除一个 Status /users/{user_id}/statuses.format POST 创建一个新的 Status /users/{user_id}/statues/{status_id}.format GET 获取特定用户的某一个 Status /users/{user_id}/statuses.format GET 获取特定用户的 Statuses /statuses.format GET 获取所有用户的 Statuses URL HTTP Verb 操作
47. Facebook API Facebook 是怎么描述它的 API 的: The API uses a REST-like interface. This means that our Facebook method calls are made over the internet by sending HTTP GET or POST requests to the Facebook API REST server (http://api.facebook.com/restserver.php). Nearly any computer language can be used to communicate over HTTP with the REST server.
53. User A 创建 Bookmark A # POST /bookmarks User X 评论 Bookmark A # POST /bookmarks/1/comments User A 将某一个评论标为 Spam # PUT /bookmarks/1/comments/2/mark_spam
55. I am creating a SPAM resource! POST /bookmarks/1/comments/2/spam
56. map.resources :users do |users| users.resources :bookmarks do |bookmarks| bookmarks.resources :comments do |comments| comments.resource :spam end end end
57. Your genius API for your team GET /users/1/bookmarks/2/comments GET /users/1/bookmarks/2/comments/3 POST /users/1/bookmarks/2/comments POST /users/1/bookmarks/2/comments/3/spams
59. 是否容易被团队成员接受? Accept by your team 是否存在于团队常用用例中的词汇? Common vocabulary 是否有助于将其开放为 API ? Help expose as a API 是否为开发人员建立更简单的、可遵循的规则? Simple rules, could be followed by your team 与现存的、有用的插件是否兼容? Work with the existing great plugin