public void Initialize(IRuntimeServices rs) { this.rsvc = rs; this.rsvc.Info("Default ResourceManager initializing. (" + base.GetType() + ")"); this.AssembleResourceLoaderInitializers(); for (int i = 0; i < this.sourceInitializerList.Count; i++) { ExtendedProperties extendedProperties = (ExtendedProperties)this.sourceInitializerList[i]; string @string = extendedProperties.GetString("class"); if (@string == null) { this.rsvc.Error("Unable to find '" + extendedProperties.GetString("_RESOURCE_LOADER_IDENTIFIER_") + ".resource.loader.class' specification in configuation. This is a critical value. Please adjust configuration."); } else { ResourceLoader loader = ResourceLoaderFactory.getLoader(this.rsvc, @string); loader.CommonInit(this.rsvc, extendedProperties); loader.Init(extendedProperties); this.resourceLoaders.Add(loader); } } this.logWhenFound = this.rsvc.GetBoolean("resource.manager.logwhenfound", true); string string2 = this.rsvc.GetString("resource.manager.cache.class"); object obj = null; if (string2 != null && string2.Length > 0) { try { Type type = Type.GetType(string2); obj = Activator.CreateInstance(type); } catch (System.Exception var_7_135) { string message = "The specified class for ResourceCache (" + string2 + ") does not exist (or is not accessible to the current classloader)."; this.rsvc.Error(message); obj = null; } if (!(obj is ResourceCache)) { string message = "The specified class for ResourceCache (" + string2 + ") does not implement NVelocity.Runtime.Resource.ResourceCache. Using default ResourceCache implementation."; this.rsvc.Error(message); obj = null; } } if (obj == null) { obj = new ResourceCacheImpl(); } this.globalCache = (ResourceCache)obj; this.globalCache.initialize(this.rsvc); this.rsvc.Info("Default ResourceManager initialization complete."); }
/// <summary> /// Initialize the ResourceManager. /// </summary> public void Initialize(IRuntimeServices rs) { runtimeServices = rs; runtimeServices.Info(string.Format("Default ResourceManager initializing. ({0})", GetType())); ResourceLoader resourceLoader; AssembleResourceLoaderInitializers(); for (int i = 0; i < sourceInitializerList.Count; i++) { ExtendedProperties configuration = (ExtendedProperties)sourceInitializerList[i]; String loaderClass = configuration.GetString("class"); if (loaderClass == null) { runtimeServices.Error( string.Format( "Unable to find '{0}.resource.loader.class' specification in configuration. This is a critical value. Please adjust configuration.", configuration.GetString(RESOURCE_LOADER_IDENTIFIER))); continue; } resourceLoader = ResourceLoaderFactory.getLoader(runtimeServices, loaderClass); resourceLoader.CommonInit(runtimeServices, configuration); resourceLoader.Init(configuration); resourceLoaders.Add(resourceLoader); } // now see if this is overridden by configuration logWhenFound = runtimeServices.GetBoolean(RuntimeConstants.RESOURCE_MANAGER_LOGWHENFOUND, true); // now, is a global cache specified? String resourceManagerCacheClassName = runtimeServices.GetString(RuntimeConstants.RESOURCE_MANAGER_CACHE_CLASS); Object o = null; if (resourceManagerCacheClassName != null && resourceManagerCacheClassName.Length > 0) { try { Type type = Type.GetType(resourceManagerCacheClassName); o = Activator.CreateInstance(type); } catch (Exception) { String err = string.Format( "The specified class for ResourceCache ({0}) does not exist (or is not accessible to the current classLoader).", resourceManagerCacheClassName); runtimeServices.Error(err); o = null; } if (!(o is ResourceCache)) { String err = string.Format( "The specified class for ResourceCache ({0}) does not implement NVelocity.Runtime.Resource.ResourceCache. Using default ResourceCache implementation.", resourceManagerCacheClassName); runtimeServices.Error(err); o = null; } } // if we didn't get through that, just use the default. if (o == null) { o = new ResourceCacheImpl(); } globalCache = (ResourceCache)o; globalCache.initialize(runtimeServices); runtimeServices.Info("Default ResourceManager initialization complete."); }
/// <summary> /// Initialize the ResourceManager. /// </summary> public void initialize(RuntimeServices rs) { rsvc = rs; rsvc.info("Default ResourceManager initializing. (" + this.GetType() + ")"); ResourceLoader resourceLoader; assembleResourceLoaderInitializers(); for (int i = 0; i < sourceInitializerList.Count; i++) { ExtendedProperties configuration = (ExtendedProperties)sourceInitializerList[i]; String loaderClass = configuration.GetString("class"); if (loaderClass == null) { rsvc.error("Unable to find '" + configuration.GetString(RESOURCE_LOADER_IDENTIFIER) + ".resource.loader.class' specification in configuation." + " This is a critical value. Please adjust configuration."); continue; } resourceLoader = ResourceLoaderFactory.getLoader(rsvc, loaderClass); resourceLoader.commonInit(rsvc, configuration); resourceLoader.init(configuration); resourceLoaders.Add(resourceLoader); } /* * now see if this is overridden by configuration */ logWhenFound = rsvc.getBoolean(RuntimeConstants_Fields.RESOURCE_MANAGER_LOGWHENFOUND, true); /* * now, is a global cache specified? */ String claz = rsvc.getString(RuntimeConstants_Fields.RESOURCE_MANAGER_CACHE_CLASS); Object o = null; if (claz != null && claz.Length > 0) { try { Type type = Type.GetType(claz); o = Activator.CreateInstance(type); } catch (Exception cnfe) { String err = "The specified class for ResourceCache (" + claz + ") does not exist (or is not accessible to the current classlaoder)."; rsvc.error(err); o = null; } if (!(o is ResourceCache)) { String err = "The specified class for ResourceCache (" + claz + ") does not implement NVelocity.Runtime.Resource.ResourceCache." + " Using default ResourceCache implementation."; rsvc.error(err); o = null; } } /* * if we didn't get through that, just use the default. */ if (o == null) { o = new ResourceCacheImpl(); } globalCache = (ResourceCache)o; globalCache.initialize(rsvc); rsvc.info("Default ResourceManager initialization complete."); }