From aec069d161e6d818c4b1d9b7448aebade62c29c5 Mon Sep 17 00:00:00 2001 From: Melanie Thielker Date: Fri, 8 May 2009 14:08:41 +0000 Subject: More additions to the nextgen reference UGAIM --- OpenSim/Servers/Asset/AssetServerConnector.cs | 44 +++++++++++ OpenSim/Servers/Asset/AssetServerMain.cs | 49 ++++++++++++ OpenSim/Services/AssetService/AssetService.cs | 94 +++++++++++++++++++++++ OpenSim/Services/AssetService/AssetServiceBase.cs | 76 ++++++++++++++++++ OpenSim/Services/Base/ServiceBase.cs | 74 ++++++++++++++++++ OpenSim/Services/Interfaces/IAssetService.cs | 53 +++++++++++++ OpenSim/Services/UserService/UserServiceBase.cs | 37 ++------- bin/OpenSim.Servers.UserServer.ini.example | 4 + prebuild.xml | 88 +++++++++++++++++++++ 9 files changed, 490 insertions(+), 29 deletions(-) create mode 100644 OpenSim/Servers/Asset/AssetServerConnector.cs create mode 100644 OpenSim/Servers/Asset/AssetServerMain.cs create mode 100644 OpenSim/Services/AssetService/AssetService.cs create mode 100644 OpenSim/Services/AssetService/AssetServiceBase.cs create mode 100644 OpenSim/Services/Base/ServiceBase.cs create mode 100644 OpenSim/Services/Interfaces/IAssetService.cs diff --git a/OpenSim/Servers/Asset/AssetServerConnector.cs b/OpenSim/Servers/Asset/AssetServerConnector.cs new file mode 100644 index 0000000..fb84211 --- /dev/null +++ b/OpenSim/Servers/Asset/AssetServerConnector.cs @@ -0,0 +1,44 @@ +/* + * Copyright (c) Contributors, http://opensimulator.org/ + * See CONTRIBUTORS.TXT for a full list of copyright holders. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the OpenSim Project nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * 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 Nini.Config; +using OpenSim.Services.Interfaces; +using OpenSim.Services.AssetService; +using OpenSim.Framework.Servers.HttpServer; + +namespace OpenSim.Servers.AssetServer +{ + public class AssetServiceConnector + { + private IAssetService m_AssetService; + + public AssetServiceConnector(IConfigSource config, IHttpServer server) + { + m_AssetService = new AssetService(config); + } + } +} diff --git a/OpenSim/Servers/Asset/AssetServerMain.cs b/OpenSim/Servers/Asset/AssetServerMain.cs new file mode 100644 index 0000000..bc738d7 --- /dev/null +++ b/OpenSim/Servers/Asset/AssetServerMain.cs @@ -0,0 +1,49 @@ +/* + * Copyright (c) Contributors, http://opensimulator.org/ + * See CONTRIBUTORS.TXT for a full list of copyright holders. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the OpenSim Project nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * 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; +using OpenSim.Servers.Base; + +namespace OpenSim.Servers.AssetServer +{ + public class AssetServer + { + protected static HttpServerBase m_Server = null; + + protected static AssetServiceConnector m_AssetServiceConnector; + + static int Main(string[] args) + { + m_Server = new HttpServerBase("Asset", args); + + m_AssetServiceConnector = new AssetServiceConnector(m_Server.Config, + m_Server.HttpServer); + + return m_Server.Run(); + } + } +} diff --git a/OpenSim/Services/AssetService/AssetService.cs b/OpenSim/Services/AssetService/AssetService.cs new file mode 100644 index 0000000..233fa62 --- /dev/null +++ b/OpenSim/Services/AssetService/AssetService.cs @@ -0,0 +1,94 @@ +/* + * Copyright (c) Contributors, http://opensimulator.org/ + * See CONTRIBUTORS.TXT for a full list of copyright holders. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the OpenSim Project nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * 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; +using System.Reflection; +using Nini.Config; +using log4net; +using OpenSim.Framework; +using OpenSim.Data; +using OpenSim.Services.Interfaces; + +namespace OpenSim.Services.AssetService +{ + public class AssetService : AssetServiceBase, IAssetService + { + private static readonly ILog m_log = + LogManager.GetLogger( + MethodBase.GetCurrentMethod().DeclaringType); + + public AssetService(IConfigSource config) : base(config) + { + if (m_AssetLoader != null) + { + IConfig assetConfig = config.Configs["AssetService"]; + if (assetConfig == null) + throw new Exception("No AssetService configuration"); + + string loaderArgs = assetConfig.GetString("AssetLoaderArgs", + String.Empty); + + m_log.InfoFormat("[ASSET]: Loading default asset set from {0}", loaderArgs); + m_AssetLoader.ForEachDefaultXmlAsset(loaderArgs, + delegate(AssetBase a) + { + Store(a); + }); + } + } + + public AssetBase Get(string id) + { + return null; + } + + public AssetMetadata GetMetadata(string id) + { + return null; + } + + public byte[] GetData(string id) + { + return null; + } + + public string Store(AssetBase asset) + { + return String.Empty; + } + + public bool UpdateContent(string id, byte[] data) + { + return false; + } + + public bool Delete(string id) + { + return false; + } + } +} diff --git a/OpenSim/Services/AssetService/AssetServiceBase.cs b/OpenSim/Services/AssetService/AssetServiceBase.cs new file mode 100644 index 0000000..4c5ba0f --- /dev/null +++ b/OpenSim/Services/AssetService/AssetServiceBase.cs @@ -0,0 +1,76 @@ +/* + * Copyright (c) Contributors, http://opensimulator.org/ + * See CONTRIBUTORS.TXT for a full list of copyright holders. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the OpenSim Project nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * 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; +using System.Reflection; +using Nini.Config; +using OpenSim.Framework; +using OpenSim.Data; +using OpenSim.Services.Interfaces; +using OpenSim.Services.Base; + +namespace OpenSim.Services.AssetService +{ + public class AssetServiceBase : ServiceBase + { + protected IAssetDataPlugin m_Database = null; + protected IAssetLoader m_AssetLoader = null; + + public AssetServiceBase(IConfigSource config) : base(config) + { + IConfig assetConfig = config.Configs["AssetService"]; + if (assetConfig == null) + throw new Exception("No AssetService configuration"); + + string dllName = assetConfig.GetString("StorageProvider", + String.Empty); + + if (dllName == String.Empty) + throw new Exception("No StorageProvider configured"); + + string connString = assetConfig.GetString("ConnectionString", + String.Empty); + + m_Database = LoadPlugin(dllName); + if (m_Database == null) + throw new Exception("Could not find a storage interface in the given module"); + + m_Database.Initialise(connString); + + string loaderName = assetConfig.GetString("DefaultAssetLoader", + String.Empty); + + if (loaderName != String.Empty) + { + m_AssetLoader = LoadPlugin(loaderName); + + if (m_AssetLoader == null) + throw new Exception("Asset loader could not be loaded"); + } + } + } +} diff --git a/OpenSim/Services/Base/ServiceBase.cs b/OpenSim/Services/Base/ServiceBase.cs new file mode 100644 index 0000000..800b172 --- /dev/null +++ b/OpenSim/Services/Base/ServiceBase.cs @@ -0,0 +1,74 @@ +/* + * Copyright (c) Contributors, http://opensimulator.org/ + * See CONTRIBUTORS.TXT for a full list of copyright holders. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the OpenSim Project nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * 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; +using System.Reflection; +using Nini.Config; +using OpenSim.Services.Interfaces; + +namespace OpenSim.Services.Base +{ + public class ServiceBase + { + public T LoadPlugin(string dllName) where T:class + { + string interfaceName = typeof(T).ToString(); + + try + { + Assembly pluginAssembly = Assembly.LoadFrom(dllName); + + foreach (Type pluginType in pluginAssembly.GetTypes()) + { + if (pluginType.IsPublic) + { + Type typeInterface = + pluginType.GetInterface(interfaceName, true); + if (typeInterface != null) + { + T plug = (T)Activator.CreateInstance( + pluginAssembly.GetType( + pluginType.ToString())); + + return plug; + } + } + } + + return null; + } + catch (Exception e) + { + return null; + } + } + + public ServiceBase(IConfigSource config) + { + } + } +} diff --git a/OpenSim/Services/Interfaces/IAssetService.cs b/OpenSim/Services/Interfaces/IAssetService.cs new file mode 100644 index 0000000..e1717d0 --- /dev/null +++ b/OpenSim/Services/Interfaces/IAssetService.cs @@ -0,0 +1,53 @@ +/* + * Copyright (c) Contributors, http://opensimulator.org/ + * See CONTRIBUTORS.TXT for a full list of copyright holders. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the OpenSimulator Project nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * 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 OpenSim.Framework; + +namespace OpenSim.Services.Interfaces +{ + public interface IAssetService + { + // Three different ways to retrieve an asset + // + AssetBase Get(string id); + AssetMetadata GetMetadata(string id); + byte[] GetData(string id); + + // Creates a new asset + // Returns a random ID if none is passed into it + // + string Store(AssetBase asset); + + // Attachments and bare scripts need this!! + // + bool UpdateContent(string id, byte[] data); + + // Kill an asset + // + bool Delete(string id); + } +} diff --git a/OpenSim/Services/UserService/UserServiceBase.cs b/OpenSim/Services/UserService/UserServiceBase.cs index 6a20670..0cf24a4 100644 --- a/OpenSim/Services/UserService/UserServiceBase.cs +++ b/OpenSim/Services/UserService/UserServiceBase.cs @@ -30,18 +30,19 @@ using System.Reflection; using Nini.Config; using OpenSim.Data; using OpenSim.Services.Interfaces; +using OpenSim.Services.Base; namespace OpenSim.Services.UserService { - public class UserServiceBase + public class UserServiceBase: ServiceBase { protected IUserDataPlugin m_Database = null; - public UserServiceBase(IConfigSource config) + public UserServiceBase(IConfigSource config) : base(config) { IConfig userConfig = config.Configs["UserService"]; if (userConfig == null) - throw new Exception("No userService configuration"); + throw new Exception("No UserService configuration"); string dllName = userConfig.GetString("StorageProvider", String.Empty); @@ -52,34 +53,12 @@ namespace OpenSim.Services.UserService string connString = userConfig.GetString("ConnectionString", String.Empty); - try - { - Assembly pluginAssembly = Assembly.LoadFrom(dllName); + m_Database = LoadPlugin(dllName); - foreach (Type pluginType in pluginAssembly.GetTypes()) - { - if (pluginType.IsPublic) - { - Type typeInterface = - pluginType.GetInterface("IUserDataPlugin", true); - if (typeInterface != null) - { - IUserDataPlugin plug = - (IUserDataPlugin)Activator.CreateInstance(pluginAssembly.GetType(pluginType.ToString())); - plug.Initialise(connString); + if (m_Database == null) + throw new Exception("Could not find a storage interface in the given module"); - m_Database = plug; - } - } - } - - if (m_Database == null) - throw new Exception("Could not find a storage interface in the given module"); - } - catch (Exception e) - { - throw new Exception("Can't open database module: "+e.Message); - } + m_Database.Initialise(connString); } } } diff --git a/bin/OpenSim.Servers.UserServer.ini.example b/bin/OpenSim.Servers.UserServer.ini.example index 2a80f27..39d0ace 100644 --- a/bin/OpenSim.Servers.UserServer.ini.example +++ b/bin/OpenSim.Servers.UserServer.ini.example @@ -1,2 +1,6 @@ [Network] port = 8002 + +[UserService] +StorageProvider = "OpenSim.Data.MySQL.dll" +ConnectionString = "Data Source=localhost;Database=opensim;User ID=opensim;Password=opensim;" diff --git a/prebuild.xml b/prebuild.xml index 2e7a59c..66a255c 100644 --- a/prebuild.xml +++ b/prebuild.xml @@ -1236,6 +1236,33 @@ + + + + ../../../bin/ + + + + + ../../../bin/ + + + + ../../../bin/ + + + + + + + + + + + + + + @@ -1256,6 +1283,37 @@ + + + + + + + + + + + + + + ../../../bin/ + + + + + ../../../bin/ + + + + ../../../bin/ + + + + + + + + @@ -1323,6 +1381,36 @@ + + + + ../../../bin/ + + + + + ../../../bin/ + + + + ../../../bin/ + + + + + + + + + + + + + + + + + -- cgit v1.1