diff options
| author | Matthias Radestock <matthias@lshift.net> | 2009-12-18 14:21:06 +0000 |
|---|---|---|
| committer | Matthias Radestock <matthias@lshift.net> | 2009-12-18 14:21:06 +0000 |
| commit | 6639c6d054a9f0d8421e0047fe0d6b25408d1d42 (patch) | |
| tree | 8a1b48ba9e2a5effe93fc7a7c8742384c71307d0 /src | |
| parent | 33c2260bcd4187f3c6adc70511499b37fdafc699 (diff) | |
| parent | 7a28f1b4d9b82fa3c6ad37fc9fd1574a5f22638d (diff) | |
| download | rabbitmq-server-git-6639c6d054a9f0d8421e0047fe0d6b25408d1d42.tar.gz | |
post-backout merge
Diffstat (limited to 'src')
| -rw-r--r-- | src/rabbit.erl | 1 | ||||
| -rw-r--r-- | src/rabbit_exchange.erl | 18 | ||||
| -rw-r--r-- | src/rabbit_exchange_type.erl | 107 |
3 files changed, 9 insertions, 117 deletions
diff --git a/src/rabbit.erl b/src/rabbit.erl index 3293927a48..c6dde385ce 100644 --- a/src/rabbit.erl +++ b/src/rabbit.erl @@ -134,7 +134,6 @@ start(normal, []) -> fun () -> ok = rabbit_mnesia:init() end}, {"core processes", fun () -> - ok = start_child(rabbit_exchange_type), ok = start_child(rabbit_log), ok = rabbit_hooks:start(), diff --git a/src/rabbit_exchange.erl b/src/rabbit_exchange.erl index be73e81847..09ea1e9611 100644 --- a/src/rabbit_exchange.erl +++ b/src/rabbit_exchange.erl @@ -134,18 +134,18 @@ declare(ExchangeName, Type, Durable, AutoDelete, Args) -> end end). -typename_to_plugin_module(T) -> - case rabbit_exchange_type:lookup_module(T) of - {ok, Module} -> - Module; - {error, not_found} -> +typename_to_plugin_module(T) when is_binary(T) -> + case catch list_to_existing_atom("rabbit_exchange_type_" ++ binary_to_list(T)) of + {'EXIT', {badarg, _}} -> rabbit_misc:protocol_error( - command_invalid, "invalid exchange type '~s'", [T]) + command_invalid, "invalid exchange type '~s'", [T]); + Module -> + Module end. -plugin_module_to_typename(M) -> - {ok, TypeName} = rabbit_exchange_type:lookup_name(M), - TypeName. +plugin_module_to_typename(M) when is_atom(M) -> + "rabbit_exchange_type_" ++ S = atom_to_list(M), + list_to_binary(S). check_type(T) -> Module = typename_to_plugin_module(T), diff --git a/src/rabbit_exchange_type.erl b/src/rabbit_exchange_type.erl deleted file mode 100644 index 58dcfbb6a2..0000000000 --- a/src/rabbit_exchange_type.erl +++ /dev/null @@ -1,107 +0,0 @@ -%% The contents of this file are subject to the Mozilla Public License -%% Version 1.1 (the "License"); you may not use this file except in -%% compliance with the License. You may obtain a copy of the License at -%% http://www.mozilla.org/MPL/ -%% -%% Software distributed under the License is distributed on an "AS IS" -%% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the -%% License for the specific language governing rights and limitations -%% under the License. -%% -%% The Original Code is RabbitMQ. -%% -%% The Initial Developers of the Original Code are LShift Ltd, -%% Cohesive Financial Technologies LLC, and Rabbit Technologies Ltd. -%% -%% Portions created before 22-Nov-2008 00:00:00 GMT by LShift Ltd, -%% Cohesive Financial Technologies LLC, or Rabbit Technologies Ltd -%% are Copyright (C) 2007-2008 LShift Ltd, Cohesive Financial -%% Technologies LLC, and Rabbit Technologies Ltd. -%% -%% Portions created by LShift Ltd are Copyright (C) 2007-2009 LShift -%% Ltd. Portions created by Cohesive Financial Technologies LLC are -%% Copyright (C) 2007-2009 Cohesive Financial Technologies -%% LLC. Portions created by Rabbit Technologies Ltd are Copyright -%% (C) 2007-2009 Rabbit Technologies Ltd. -%% -%% All Rights Reserved. -%% -%% Contributor(s): ______________________________________. -%% - --module(rabbit_exchange_type). - --behaviour(gen_server). - --export([start_link/0]). - --export([init/1, handle_call/3, handle_cast/2, handle_info/2, - terminate/2, code_change/3]). - --export([register/2, lookup_module/1, lookup_name/1]). - --define(SERVER, ?MODULE). - -%%--------------------------------------------------------------------------- - -start_link() -> - gen_server:start_link({local, ?SERVER}, ?MODULE, [], []). - -%%--------------------------------------------------------------------------- - -register(TypeName, ModuleName) -> - gen_server:call(?SERVER, {register, TypeName, ModuleName}). - -lookup_module(T) when is_binary(T) -> - case ets:lookup(rabbit_exchange_type_modules, T) of - [{_, Module}] -> - {ok, Module}; - [] -> - {error, not_found} - end. - -lookup_name(M) when is_atom(M) -> - [{_, TypeName}] = ets:lookup(rabbit_exchange_type_names, M), - {ok, TypeName}. - -%%--------------------------------------------------------------------------- - -internal_register(TypeName, ModuleName) - when is_binary(TypeName), is_atom(ModuleName) -> - true = ets:insert(rabbit_exchange_type_modules, {TypeName, ModuleName}), - true = ets:insert(rabbit_exchange_type_names, {ModuleName, TypeName}), - ok. - -%%--------------------------------------------------------------------------- - -init([]) -> - rabbit_exchange_type_modules = - ets:new(rabbit_exchange_type_modules, [protected, set, named_table]), - rabbit_exchange_type_names = - ets:new(rabbit_exchange_type_names, [protected, set, named_table]), - - %% TODO: split out into separate boot startup steps. - ok = internal_register(<<"direct">>, rabbit_exchange_type_direct), - ok = internal_register(<<"fanout">>, rabbit_exchange_type_fanout), - ok = internal_register(<<"headers">>, rabbit_exchange_type_headers), - ok = internal_register(<<"topic">>, rabbit_exchange_type_topic), - - {ok, none}. - -handle_call({register, TypeName, ModuleName}, _From, State) -> - ok = internal_register(TypeName, ModuleName), - {reply, ok, State}; -handle_call(Request, _From, State) -> - {stop, {unhandled_call, Request}, State}. - -handle_cast(Request, State) -> - {stop, {unhandled_cast, Request}, State}. - -handle_info(Message, State) -> - {stop, {unhandled_info, Message}, State}. - -terminate(_Reason, _State) -> - ok. - -code_change(_OldVsn, State, _Extra) -> - {ok, State}. |
