diff options
author | Mike Mazur | 2009-02-16 02:25:25 +0000 |
---|---|---|
committer | Mike Mazur | 2009-02-16 02:25:25 +0000 |
commit | 8d304725518424131fa42dce1515137e0bb1eada (patch) | |
tree | 69ba204f2560971b385332e5bd689cbc3a8fbff9 /OpenSim/Grid/AssetInventoryServer/Extensions/DBConnString.cs | |
parent | - add OpenSim.Grid.AssetServer.Plugins.OpenSim as a dependency for OpenSim.Da... (diff) | |
download | opensim-SC_OLD-8d304725518424131fa42dce1515137e0bb1eada.zip opensim-SC_OLD-8d304725518424131fa42dce1515137e0bb1eada.tar.gz opensim-SC_OLD-8d304725518424131fa42dce1515137e0bb1eada.tar.bz2 opensim-SC_OLD-8d304725518424131fa42dce1515137e0bb1eada.tar.xz |
Rename NewAssetServer AssetInventoryServer and fully qualify with
OpenSim.Grid.AssetInventoryServer.
Diffstat (limited to 'OpenSim/Grid/AssetInventoryServer/Extensions/DBConnString.cs')
-rw-r--r-- | OpenSim/Grid/AssetInventoryServer/Extensions/DBConnString.cs | 78 |
1 files changed, 78 insertions, 0 deletions
diff --git a/OpenSim/Grid/AssetInventoryServer/Extensions/DBConnString.cs b/OpenSim/Grid/AssetInventoryServer/Extensions/DBConnString.cs new file mode 100644 index 0000000..58054d6 --- /dev/null +++ b/OpenSim/Grid/AssetInventoryServer/Extensions/DBConnString.cs | |||
@@ -0,0 +1,78 @@ | |||
1 | /* | ||
2 | * Copyright (c) 2008 Intel Corporation | ||
3 | * All rights reserved. | ||
4 | * Redistribution and use in source and binary forms, with or without | ||
5 | * modification, are permitted provided that the following conditions | ||
6 | * are met: | ||
7 | * | ||
8 | * -- Redistributions of source code must retain the above copyright | ||
9 | * notice, this list of conditions and the following disclaimer. | ||
10 | * -- Redistributions in binary form must reproduce the above copyright | ||
11 | * notice, this list of conditions and the following disclaimer in the | ||
12 | * documentation and/or other materials provided with the distribution. | ||
13 | * -- Neither the name of the Intel Corporation nor the names of its | ||
14 | * contributors may be used to endorse or promote products derived from | ||
15 | * this software without specific prior written permission. | ||
16 | * | ||
17 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | ||
18 | * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | ||
19 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A | ||
20 | * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE INTEL OR ITS | ||
21 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, | ||
22 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, | ||
23 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR | ||
24 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF | ||
25 | * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING | ||
26 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
27 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
28 | */ | ||
29 | |||
30 | using System; | ||
31 | using System.Xml; | ||
32 | using ExtensionLoader.Config; | ||
33 | using MySql.Data.MySqlClient; | ||
34 | |||
35 | namespace OpenSim.Grid.AssetInventoryServer.Extensions | ||
36 | { | ||
37 | public static class DBConnString | ||
38 | { | ||
39 | private static string connectionString; | ||
40 | |||
41 | /// <summary> | ||
42 | /// Parses the MySQL connection string out of either the asset server | ||
43 | /// .ini or a OpenSim-style .xml file and caches the result for future | ||
44 | /// requests | ||
45 | /// </summary> | ||
46 | public static string GetConnectionString(IniConfigSource configFile) | ||
47 | { | ||
48 | if (connectionString == null) | ||
49 | { | ||
50 | // Try parsing from the ini file | ||
51 | try | ||
52 | { | ||
53 | // Load the extension list (and ordering) from our config file | ||
54 | IConfig extensionConfig = configFile.Configs["MySQL"]; | ||
55 | connectionString = extensionConfig.GetString("database_connect", null); | ||
56 | } | ||
57 | catch (Exception) { } | ||
58 | |||
59 | if (connectionString != null) | ||
60 | { | ||
61 | // Force MySQL's broken connection pooling off | ||
62 | MySqlConnectionStringBuilder builder = new MySqlConnectionStringBuilder(connectionString); | ||
63 | builder.Pooling = false; | ||
64 | if (String.IsNullOrEmpty(builder.Database)) | ||
65 | Logger.Log.Error("No database selected in the connectionString: " + connectionString); | ||
66 | connectionString = builder.ToString(); | ||
67 | } | ||
68 | else | ||
69 | { | ||
70 | Logger.Log.Error("Database connection string is missing, check that the database_connect line is " + | ||
71 | "correct and uncommented in AssetInventoryServer.ini"); | ||
72 | } | ||
73 | } | ||
74 | |||
75 | return connectionString; | ||
76 | } | ||
77 | } | ||
78 | } | ||