NVelocity.Runtime.Resource.ResourceManagerImpl.Initialize C# (CSharp) Method

Initialize() public method

Initialize the ResourceManager.
public Initialize ( IRuntimeServices rs ) : void
rs IRuntimeServices
return void
        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.");
        }