forked from ravendb/ravendb
/
ForwardToRavenRespondersFactory.cs
46 lines (39 loc) · 1.33 KB
/
ForwardToRavenRespondersFactory.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
//-----------------------------------------------------------------------
// <copyright file="ForwardToRavenRespondersFactory.cs" company="Hibernating Rhinos LTD">
// Copyright (c) Hibernating Rhinos LTD. All rights reserved.
// </copyright>
//-----------------------------------------------------------------------
using System.Web;
using Raven.Database;
using Raven.Database.Config;
using Raven.Database.Server;
using Raven.Http;
namespace Raven.Web
{
public class ForwardToRavenRespondersFactory : IHttpHandlerFactory
{
private static readonly object locker = new object();
static readonly RavenConfiguration ravenConfiguration = new RavenConfiguration();
static readonly DocumentDatabase database;
static readonly HttpServer server;
static ForwardToRavenRespondersFactory()
{
lock (locker)
{
if (database != null)
return;
ravenConfiguration.LoadLoggingSettings();
database = new DocumentDatabase(ravenConfiguration);
database.SpinBackgroundWorkers();
server = new RavenDbHttpServer(ravenConfiguration, database);
}
}
public IHttpHandler GetHandler(HttpContext context, string requestType, string url, string pathTranslated)
{
return new ForwardToRavenResponders(server);
}
public void ReleaseHandler(IHttpHandler handler)
{
}
}
}