Skip to content

Commit

Permalink
refactoring:
Browse files Browse the repository at this point in the history
  * 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 418d487
Show file tree
Hide file tree
Showing 24 changed files with 404 additions and 551 deletions.
9 changes: 6 additions & 3 deletions actionwebservice/ChangeLog
@@ -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
Expand Down
44 changes: 0 additions & 44 deletions actionwebservice/HACKING

This file was deleted.

4 changes: 2 additions & 2 deletions actionwebservice/Rakefile
Expand Up @@ -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')
}

Expand All @@ -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" ) }
Expand Down
13 changes: 6 additions & 7 deletions actionwebservice/TODO
@@ -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)

Expand All @@ -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
Expand Down
6 changes: 3 additions & 3 deletions actionwebservice/lib/action_web_service.rb
Expand Up @@ -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
Expand All @@ -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
4 changes: 2 additions & 2 deletions actionwebservice/lib/action_web_service/client.rb
@@ -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'
147 changes: 0 additions & 147 deletions actionwebservice/lib/action_web_service/container.rb
Expand Up @@ -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
Expand Down Expand Up @@ -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
2 changes: 2 additions & 0 deletions actionwebservice/lib/action_web_service/dispatcher.rb
@@ -0,0 +1,2 @@
require 'action_web_service/dispatcher/abstract'
require 'action_web_service/dispatcher/action_controller_dispatcher'

0 comments on commit 418d487

Please sign in to comment.