Permalink
Browse files

refactoring:

  * move dispatching out of the Container into Dispatcher, it makes more sense
    for Container to only contain the list of web services defined
    in it.

  * collapse Wsdl and ActionController "routers" into
    an ActionController-specific module, no advantage
    to having them seperate as they were quite tightly
    coupled. rename to Dispatcher, to avoi
    confusion with Routing.

  * add a "_thing" suffix to concept-specific filenames. this is so that
    we don't end up with many soap.rb files, for example.

  * remove "virtual invocation" support. adds complexity, and it doesn't
    seem to add any value.


git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@679 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
  • Loading branch information...
leonbreedt committed Feb 19, 2005
1 parent e749963 commit 418d487020d24e69b528fdbedfecb20a87f99fcb
Showing with 404 additions and 551 deletions.
  1. +6 −3 actionwebservice/ChangeLog
  2. +0 −44 actionwebservice/HACKING
  3. +2 −2 actionwebservice/Rakefile
  4. +6 −7 actionwebservice/TODO
  5. +3 −3 actionwebservice/lib/action_web_service.rb
  6. +2 −2 actionwebservice/lib/action_web_service/client.rb
  7. 0 actionwebservice/lib/action_web_service/client/{soap.rb → soap_client.rb}
  8. 0 actionwebservice/lib/action_web_service/client/{xmlrpc.rb → xmlrpc_client.rb}
  9. +0 −147 actionwebservice/lib/action_web_service/container.rb
  10. +2 −0 actionwebservice/lib/action_web_service/dispatcher.rb
  11. +158 −0 actionwebservice/lib/action_web_service/dispatcher/abstract.rb
  12. +100 −9 ...onwebservice/lib/action_web_service/{router/wsdl.rb → dispatcher/action_controller_dispatcher.rb}
  13. +7 −54 actionwebservice/lib/action_web_service/invocation.rb
  14. +2 −2 actionwebservice/lib/action_web_service/protocol.rb
  15. 0 actionwebservice/lib/action_web_service/protocol/{soap.rb → soap_protocol.rb}
  16. +0 −15 actionwebservice/lib/action_web_service/protocol/{xmlrpc.rb → xmlrpc_protocol.rb}
  17. +0 −2 actionwebservice/lib/action_web_service/router.rb
  18. +0 −99 actionwebservice/lib/action_web_service/router/action_controller.rb
  19. +1 −1 actionwebservice/test/abstract_client.rb
  20. +68 −21 actionwebservice/test/{router_action_controller_test.rb → dispatcher_action_controller_test.rb}
  21. +2 −11 actionwebservice/test/invocation_test.rb
  22. +43 −17 actionwebservice/test/protocol_soap_test.rb
  23. +2 −12 actionwebservice/test/protocol_xmlrpc_test.rb
  24. +0 −100 actionwebservice/test/router_wsdl_test.rb
@@ -1,8 +1,11 @@
UNRELEASED
- * lib/*,test/*,examples/*: prefix all generic "service"
- type names with web_. update all using code as well as
- the RDoc.
+ * lib/action_service/dispatcher*: replaces "router" fragments with
+ one file for Action Controllers, moves dispatching work out of
+ the container
+ * lib/*,test/*,examples/*: rename project to
+ ActionWebService. prefix all generic "service" type names with web_.
+ update all using code as well as the RDoc.
* lib/action_service/router/wsdl.rb: ensure that #wsdl is
defined in the final container class, or the new ActionPack
filtering will exclude it
View
@@ -1,44 +0,0 @@
-== Coding Style
-
-Please try to follow Rails conventions and idioms.
-
-
-== Concepts
-
- * Service
- A service has an associated API definition, and
- implements the methods defined in the API definition
-
- * Container
- A container contains zero or more services
-
- * API
- An API definition defines a list of methods implemented by
- a service
-
- * Router
- A router takes raw wire requests, decodes them, performs the invocation on
- the service, and generates raw wire responses from the invocation result.
- A router is mixed into a container class.
-
- * Protocol
- A protocol implementation implements the unmarshaling and marshaling of
- raw wire requests and responses. Registers with router.
-
-
-== Action Pack Integration
-
-For Action Pack, the ActionController is both container and router, and also contains
-the protocol implementations.
-
-
-== Adding support for a new protocol
-
- 1. Add an ActionWebService::Protocol::YourProtocol module and any classes you need to
- perform unmarshaling/marshaling of protocol requests. See the SOAP implementation
- for an example of a complex mapping, and also see
- ActionWebService::Protocol::AbstractProtocol for the methods you need to implement.
-
- 2. Add unit tests for your new protocol. Be sure to test using a Action Pack test request
- duplicating how the real requests will arrive and verify that mapping to and from Ruby
- types works correctly.
@@ -36,7 +36,7 @@ Rake::RDocTask.new { |rdoc|
rdoc.rdoc_files.include('lib/action_web_service/api/*.rb')
rdoc.rdoc_files.include('lib/action_web_service/client/*.rb')
rdoc.rdoc_files.include('lib/action_web_service/protocol/*.rb')
- rdoc.rdoc_files.include('lib/action_web_service/router/*.rb')
+ rdoc.rdoc_files.include('lib/action_web_service/dispatcher/*.rb')
rdoc.rdoc_files.include('lib/action_web_service/support/*.rb')
}
@@ -63,7 +63,7 @@ spec = Gem::Specification.new do |s|
s.require_path = 'lib'
s.autorequire = 'action_web_service'
- s.files = [ "Rakefile", "setup.rb", "README", "TODO", "HACKING", "ChangeLog", "MIT-LICENSE" ]
+ s.files = [ "Rakefile", "setup.rb", "README", "TODO", "ChangeLog", "MIT-LICENSE" ]
s.files = s.files + Dir.glob( "examples/**/*" ).delete_if { |item| item.include?( "\.svn" ) }
s.files = s.files + Dir.glob( "lib/**/*" ).delete_if { |item| item.include?( "\.svn" ) }
s.files = s.files + Dir.glob( "test/**/*" ).delete_if { |item| item.include?( "\.svn" ) }
View
@@ -1,8 +1,11 @@
= 0.4.0 Tasks
- add ActiveRecord-like logging that includes timing information
- - rename project to 'actionwebservice', Action Web Service
= Post-0.4.0 Tasks
+ - support namespaced custom types in WSDL in a way that interoperates
+ with .NET (.NET croaks on '::' currently). perhaps a transform
+ that maps Ruby::Class to Ruby.Class and back.
+
- relax type-checking for XML-RPC, and perform casts between base types if there
are mismatches (i.e. String received when Integer expected, or vice-versa)
@@ -23,12 +26,8 @@
web_service :xmlrpc { BloggingServices.new(@request) }
end
- - supported namespaced custom types in WSDL in a way that interoperates
- with .NET (.NET croaks on '::' currently)
-
- - simplification: collapse Router::ActionController, Router::Wsdl
- and API::ActionController into Container::ActionController.
- the seperation has gained us nothing.
+ - verify that cookie support works, and add cookie-authenticated
+ service examples. test with .NET.
= Low priority tasks
- add better type mapping tests for XML-RPC
@@ -41,7 +41,7 @@
require 'action_web_service/struct'
require 'action_web_service/container'
require 'action_web_service/protocol'
-require 'action_web_service/router'
+require 'action_web_service/dispatcher'
ActionWebService::Base.class_eval do
include ActionWebService::API
@@ -55,6 +55,6 @@
include ActionWebService::Protocol::XmlRpc
include ActionWebService::API
include ActionWebService::API::ActionController
- include ActionWebService::Router::ActionController
- include ActionWebService::Router::Wsdl
+ include ActionWebService::Dispatcher
+ include ActionWebService::Dispatcher::ActionController
end
@@ -1,3 +1,3 @@
require 'action_web_service/client/base'
-require 'action_web_service/client/soap'
-require 'action_web_service/client/xmlrpc'
+require 'action_web_service/client/soap_client'
+require 'action_web_service/client/xmlrpc_client'
@@ -5,8 +5,6 @@ class ContainerError < ActionWebService::ActionWebServiceError # :nodoc:
def self.append_features(base) # :nodoc:
super
- base.class_inheritable_option(:web_service_dispatching_mode, :direct)
- base.class_inheritable_option(:web_service_exception_reporting, true)
base.extend(ClassMethods)
base.send(:include, ActionWebService::Container::InstanceMethods)
end
@@ -82,151 +80,6 @@ def web_service_object(web_service_name)
service = info[:block]
service ? instance_eval(&service) : info[:object]
end
-
- private
- def dispatch_web_service_request(protocol_request)
- case web_service_dispatching_mode
- when :direct
- dispatch_direct_web_service_request(protocol_request)
- when :delegated
- dispatch_delegated_web_service_request(protocol_request)
- else
- raise(ContainerError, "unsupported dispatching mode :#{web_service_dispatching_mode}")
- end
- end
-
- def dispatch_direct_web_service_request(protocol_request)
- public_method_name = protocol_request.public_method_name
- api = self.class.web_service_api
- method_name = api.api_method_name(public_method_name)
- block = nil
- expects = nil
- if method_name
- signature = api.api_methods[method_name]
- expects = signature[:expects]
- protocol_request.type = Protocol::CheckedMessage
- protocol_request.signature = expects
- protocol_request.return_signature = signature[:returns]
- else
- protocol_request.type = Protocol::UncheckedMessage
- system_methods = self.class.read_inheritable_attribute('default_system_methods') || {}
- protocol = protocol_request.protocol
- block = system_methods[protocol.class]
- unless block
- method_name = api.default_api_method
- unless method_name && respond_to?(method_name)
- raise(ContainerError, "no such method ##{public_method_name}")
- end
- end
- end
-
- @method_params = protocol_request.unmarshal
- @params ||= {}
- if expects
- (1..@method_params.size).each do |i|
- i -= 1
- if expects[i].is_a?(Hash)
- @params[expects[i].keys.shift.to_s] = @method_params[i]
- else
- @params["param#{i}"] = @method_params[i]
- end
- end
- end
-
- if respond_to?(:before_action)
- @params['action'] = method_name.to_s
- return protocol_request.marshal(nil) if before_action == false
- end
-
- perform_invoke = lambda do
- if block
- block.call(public_method_name, self.class, *@method_params)
- else
- send(method_name)
- end
- end
- try_default = true
- result = nil
- catch(:try_default) do
- result = perform_invoke.call
- try_default = false
- end
- if try_default
- method_name = api.default_api_method
- if method_name
- protocol_request.type = Protocol::UncheckedMessage
- else
- raise(ContainerError, "no such method ##{public_method_name}")
- end
- result = perform_invoke.call
- end
- after_action if respond_to?(:after_action)
- protocol_request.marshal(result)
- end
-
- def dispatch_delegated_web_service_request(protocol_request)
- web_service_name = protocol_request.web_service_name
- service = web_service_object(web_service_name)
- api = service.class.web_service_api
- public_method_name = protocol_request.public_method_name
- method_name = api.api_method_name(public_method_name)
-
- invocation = ActionWebService::Invocation::InvocationRequest.new(
- ActionWebService::Invocation::ConcreteInvocation,
- public_method_name,
- method_name)
-
- if method_name
- protocol_request.type = Protocol::CheckedMessage
- signature = api.api_methods[method_name]
- protocol_request.signature = signature[:expects]
- protocol_request.return_signature = signature[:returns]
- invocation.params = protocol_request.unmarshal
- else
- protocol_request.type = Protocol::UncheckedMessage
- invocation.type = ActionWebService::Invocation::VirtualInvocation
- system_methods = self.class.read_inheritable_attribute('default_system_methods') || {}
- protocol = protocol_request.protocol
- block = system_methods[protocol.class]
- if block
- invocation.block = block
- invocation.block_params << service.class
- else
- method_name = api.default_api_method
- if method_name && service.respond_to?(method_name)
- invocation.params = protocol_request.unmarshal
- invocation.method_name = method_name.to_sym
- else
- raise(ContainerError, "no such method /#{web_service_name}##{public_method_name}")
- end
- end
- end
-
- canceled_reason = nil
- canceled_block = lambda{|r| canceled_reason = r}
- perform_invoke = lambda do
- service.perform_invocation(invocation, &canceled_block)
- end
- try_default = true
- result = nil
- catch(:try_default) do
- result = perform_invoke.call
- try_default = false
- end
- if try_default
- method_name = api.default_api_method
- if method_name
- protocol_request.type = Protocol::UncheckedMessage
- invocation.params = protocol_request.unmarshal
- invocation.method_name = method_name.to_sym
- invocation.type = ActionWebService::Invocation::UnpublishedConcreteInvocation
- else
- raise(ContainerError, "no such method /#{web_service_name}##{public_method_name}")
- end
- result = perform_invoke.call
- end
- protocol_request.marshal(result)
- end
end
end
end
@@ -0,0 +1,2 @@
+require 'action_web_service/dispatcher/abstract'
+require 'action_web_service/dispatcher/action_controller_dispatcher'
Oops, something went wrong.

0 comments on commit 418d487

Please sign in to comment.