From 6ef9d4da901a346c232458317cca6268da888e2e Mon Sep 17 00:00:00 2001 From: Jeff Ames Date: Mon, 18 Aug 2008 00:39:10 +0000 Subject: Formatting cleanup. --- .../Rest/Inventory/RestHandler.cs | 65 ++++++++-------------- 1 file changed, 22 insertions(+), 43 deletions(-) (limited to 'OpenSim/ApplicationPlugins/Rest/Inventory/RestHandler.cs') diff --git a/OpenSim/ApplicationPlugins/Rest/Inventory/RestHandler.cs b/OpenSim/ApplicationPlugins/Rest/Inventory/RestHandler.cs index 7bd83c1..7f4157c 100644 --- a/OpenSim/ApplicationPlugins/Rest/Inventory/RestHandler.cs +++ b/OpenSim/ApplicationPlugins/Rest/Inventory/RestHandler.cs @@ -23,7 +23,6 @@ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * */ using System; @@ -37,7 +36,6 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory { public class RestHandler : RestPlugin, IHttpAgentHandler { - /// /// The handler delegates are not noteworthy. The allocator allows /// a given handler to optionally subclass the base RequestData @@ -66,10 +64,10 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory /// /// This static initializer scans the ASSEMBLY for classes that /// export the IRest interface and builds a list of them. These - /// are later activated by the handler. To add a new handler it + /// are later activated by the handler. To add a new handler it /// is only necessary to create a new services class that implements /// the IRest interface, and recompile the handler. This gives - /// all of the build-time flexibility of a modular approach + /// all of the build-time flexibility of a modular approach /// while not introducing yet-another module loader. Note that /// multiple assembles can still be built, each with its own set /// of handlers. Examples of services classes are RestInventoryServices @@ -78,13 +76,12 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory static RestHandler() { - Module[] mods = Assembly.GetExecutingAssembly().GetModules(); foreach (Module m in mods) { Type[] types = m.GetTypes(); - foreach (Type t in types) + foreach (Type t in types) { try { @@ -100,7 +97,6 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory } } } - } #endregion local static state @@ -109,13 +105,13 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory /// /// This routine loads all of the handlers discovered during - /// instance initialization. + /// instance initialization. /// A table of all loaded and successfully constructed handlers /// is built, and this table is then used by the constructor to /// initialize each of the handlers in turn. /// NOTE: The loading process does not automatically imply that - /// the handler has registered any kind of an interface, that - /// may be (optionally) done by the handler either during + /// the handler has registered any kind of an interface, that + /// may be (optionally) done by the handler either during /// construction, or during initialization. /// /// I was not able to make this code work within a constructor @@ -128,7 +124,6 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory { if (!handlersLoaded) { - ConstructorInfo ci; Object ht; @@ -159,8 +154,8 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory // Name is used to differentiate the message header. - public override string Name - { + public override string Name + { get { return "HANDLER"; } } @@ -173,7 +168,7 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory // We have to rename these because we want // to be able to share the values with other - // classes in our assembly and the base + // classes in our assembly and the base // names are protected. internal string MsgId @@ -203,7 +198,6 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory { try { - // This plugin will only be enabled if the broader // REST plugin mechanism is enabled. @@ -214,7 +208,7 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory // IsEnabled is implemented by the base class and // reflects an overall RestPlugin status - if (!IsEnabled) + if (!IsEnabled) { Rest.Log.WarnFormat("{0} Plugins are disabled", MsgId); return; @@ -263,15 +257,15 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory Rest.DumpLineSize); } - // Load all of the handlers present in the + // Load all of the handlers present in the // assembly // In principle, as we're an application plug-in, // most of what needs to be done could be done using - // static resources, however the Open Sim plug-in - // model makes this an instance, so that's what we + // static resources, however the Open Sim plug-in + // model makes this an instance, so that's what we // need to be. - // There is only one Communications manager per + // There is only one Communications manager per // server, and by inference, only one each of the // user, asset, and inventory servers. So we can cache // those using a static initializer. @@ -314,13 +308,12 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory { Rest.Log.ErrorFormat("{0} Plugin initialization has failed: {1}", MsgId, e.Message); } - } /// /// In the interests of efficiency, and because we cannot determine whether /// or not this instance will actually be harvested, we clobber the only - /// anchoring reference to the working state for this plug-in. What the + /// anchoring reference to the working state for this plug-in. What the /// call to close does is irrelevant to this class beyond knowing that it /// can nullify the reference when it returns. /// To make sure everything is copacetic we make sure the primary interface @@ -329,7 +322,6 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory public override void Close() { - Rest.Log.InfoFormat("{0} Plugin is terminating", MsgId); try @@ -337,12 +329,11 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory RemoveAgentHandler(Rest.Name, this); } catch (KeyNotFoundException){} - + foreach (IRest handler in handlers) { handler.Close(); } - } #endregion overriding methods @@ -380,7 +371,6 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory return true; } } - } catch (Exception e) { @@ -414,7 +404,7 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory for (int i = 0; i < request.Headers.Count; i++) { - Rest.Log.DebugFormat("{0} Header [{1}] : <{2}> = <{3}>", + Rest.Log.DebugFormat("{0} Header [{1}] : <{2}> = <{3}>", MsgId, i, request.Headers.GetKey(i), request.Headers.Get(i)); } Rest.Log.DebugFormat("{0} URI: {1}", MsgId, request.RawUrl); @@ -425,8 +415,8 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory try { - handled = ( FindPathHandler(request, response) || - FindStreamHandler(request, response) ); + handled = FindPathHandler(request, response) || + FindStreamHandler(request, response); } catch (Exception e) { @@ -440,7 +430,6 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory Rest.Log.DebugFormat("{0} EXIT", MsgId); return handled; - } #endregion interface methods @@ -488,7 +477,6 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory } return rdata.handled; - } /// @@ -501,13 +489,12 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory public void AddStreamHandler(string httpMethod, string path, RestMethod method) { - if (!IsEnabled) { return; } - if (!path.StartsWith(Rest.Prefix)) + if (!path.StartsWith(Rest.Prefix)) { path = String.Format("{0}{1}", Rest.Prefix, path); } @@ -525,7 +512,6 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory { Rest.Log.WarnFormat("{0} Ignoring duplicate handler for {1}", MsgId, path); } - } /// @@ -540,10 +526,9 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory internal bool FindPathHandler(OSHttpRequest request, OSHttpResponse response) { - RequestData rdata = null; string bestMatch = null; - + if (!IsEnabled) { return false; @@ -566,7 +551,6 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory if (!String.IsNullOrEmpty(bestMatch)) { - rdata = pathAllocators[bestMatch](request, response); Rest.Log.DebugFormat("{0} Path based REST handler matched with <{1}>", MsgId, bestMatch); @@ -575,7 +559,7 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory { pathHandlers[bestMatch](rdata); } - + // A plugin generated error indicates a request-related error // that has been handled by the plugin. @@ -583,11 +567,9 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory { Rest.Log.WarnFormat("{0} Request failed: {1}", MsgId, r.Message); } - } return (rdata == null) ? false : rdata.handled; - } /// @@ -597,7 +579,6 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory internal void AddPathHandler(RestMethodHandler mh, string path, RestMethodAllocator ra) { - if (!IsEnabled) { return; @@ -619,8 +600,6 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory pathHandlers.Add(path, mh); pathAllocators.Add(path, ra); - } } - } -- cgit v1.1