32 using System.Collections.Generic;
33 using System.Reflection;
34 using OpenSim.Framework;
35 using OpenSim.Server.Base;
36 using OpenSim.Region.Framework.Interfaces;
37 using OpenSim.Region.Framework.Scenes;
38 using OpenSim.Services.Interfaces;
40 namespace OpenSim.
Region.CoreModules.ServiceConnectorsOut.
Asset
42 [Extension(Path =
"/OpenSim/RegionModules", NodeName =
"RegionModule", Id =
"LocalAssetServicesConnector")]
45 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
51 private bool m_Enabled =
false;
53 public Type ReplaceableInterface
60 get {
return "LocalAssetServicesConnector"; }
65 IConfig moduleConfig = source.Configs[
"Modules"];
66 if (moduleConfig != null)
68 string name = moduleConfig.GetString(
"AssetServices",
"");
71 IConfig assetConfig = source.Configs[
"AssetService"];
72 if (assetConfig == null)
74 m_log.Error(
"[LOCAL ASSET SERVICES CONNECTOR]: AssetService missing from OpenSim.ini");
78 string serviceDll = assetConfig.GetString(
"LocalServiceModule", String.Empty);
80 if (serviceDll ==
String.Empty)
82 m_log.Error(
"[LOCAL ASSET SERVICES CONNECTOR]: No LocalServiceModule named in section AssetService");
87 m_log.DebugFormat(
"[LOCAL ASSET SERVICES CONNECTOR]: Loading asset service at {0}", serviceDll);
91 m_AssetService = ServerUtils.LoadPlugin<
IAssetService>(serviceDll, args);
93 if (m_AssetService == null)
95 m_log.Error(
"[LOCAL ASSET SERVICES CONNECTOR]: Can't load asset service");
99 m_log.Info(
"[LOCAL ASSET SERVICES CONNECTOR]: Local asset connector enabled");
138 "[LOCAL ASSET SERVICES CONNECTOR]: Enabled connector for region {0}", scene.RegionInfo.RegionName);
143 "[LOCAL ASSET SERVICES CONNECTOR]: Enabled asset caching for region {0}",
144 scene.RegionInfo.RegionName);
151 scene.RegisterModuleInterface<
IAssetService>(m_AssetService);
161 asset = m_Cache.Get(id);
165 asset = m_AssetService.Get(id);
166 if ((m_Cache != null) && (asset != null))
167 m_Cache.Cache(asset);
181 return m_Cache.Get(id);
190 asset = m_Cache.Get(id);
193 return asset.Metadata;
195 asset = m_AssetService.Get(id);
199 m_Cache.Cache(asset);
200 return asset.Metadata;
213 asset = m_Cache.Get(id);
218 asset = m_AssetService.Get(id);
222 m_Cache.Cache(asset);
240 o => handler(
id, sender, asset), null,
"LocalAssetServiceConnector.GotFromCacheCallback");
245 return m_AssetService.Get(id, sender, delegate (
string assetID,
Object s,
AssetBase a)
247 if ((a != null) && (m_Cache != null))
254 o => handler(assetID, s, a), null,
"LocalAssetServiceConnector.GotFromServiceCallback");
260 return m_AssetService.AssetsExist(ids);
266 m_Cache.Cache(asset);
282 return m_AssetService.Store(asset);
295 m_Cache.Cache(asset);
298 return m_AssetService.UpdateContent(id, data);
306 return m_AssetService.Delete(id);
bool UpdateContent(string id, byte[] data)
Update an asset's content
bool Get(string id, Object sender, AssetRetrieved handler)
Get an asset synchronously or asynchronously (depending on whether it is locally cached) and fire a c...
void RemoveRegion(Scene scene)
This is called whenever a Scene is removed. For shared modules, this can happen several times...
bool[] AssetsExist(string[] ids)
Check if assets exist in the database.
void Initialise(IConfigSource source)
This is called to initialize the region module. For shared modules, this is called exactly once...
AssetBase Get(string id)
Get an asset synchronously.
AssetMetadata GetMetadata(string id)
Get an asset's metadata
void RegionLoaded(Scene scene)
This will be called once for every scene loaded. In a shared module this will be multiple times in on...
void AddRegion(Scene scene)
This is called whenever a Scene is added. For shared modules, this can happen several times...
bool Local
Is this a region only asset, or does this exist on the asset server also
Asset class. All Assets are reference by this class or a class derived from this class ...
void PostInitialise()
This is called exactly once after all the shared region-modules have been instanciated and IRegionMod...
void Close()
This is the inverse to Initialise. After a Close(), this instance won't be usable anymore...
string Store(AssetBase asset)
Creates a new asset
bool Delete(string id)
Delete an asset
delegate void AssetRetrieved(string id, Object sender, AssetBase asset)
byte[] GetData(string id)
Get an asset's data, ignoring the metadata.
AssetBase GetCached(string id)
Synchronously fetches an asset from the local cache only.