예제 #1
0
        /// <summary>
        /// Initializes Velocity.
        /// </summary>
        /// <param name="config">servlet configuration parameters
        /// </param>
        protected override void InitVelocity()
        {
            // Try reading Velocity configuration
            try {
                ExtendedProperties p = base.LoadConfiguration();
                Velocity.ExtendedProperties = ExtendedProperties.ConvertProperties(p);
            } catch (System.Exception e) {
                Velocity.Error("Unable to read Velocity configuration file: " + e);
                Velocity.Info("Using default Velocity configuration.");
            }

            // load resources with webapp resource loader
            WebappLoaderAppContext wlac = new WebappLoaderAppContext(this.context);

            Velocity.SetApplicationAttribute("NVelocity.Http.Resource.Loader.WebappLoader", wlac);
            Velocity.SetProperty("resource.loader", "webapp");
            Velocity.SetProperty("webapp.resource.loader.class", @"NVelocity.Http.Resource.Loader.WebappLoader\,NVelocity.Http");

            // now all is ready - init Velocity
            try {
                Velocity.Init();
            } catch (System.Exception e) {
                Velocity.Error("VELOCITY PANIC : unable to init() : " + e);
                throw new HttpException("VELOCITY PANIC : unable to init()", e);
            }
        }
예제 #2
0
 /// <summary>
 /// Initialize the Velocity Runtime with a Properties
 /// object.
 /// </summary>
 /// <param name="p">Properties</param>
 public void Init(ExtendedProperties p)
 {
     overridingProperties = ExtendedProperties.ConvertProperties(p);
     Init();
 }
예제 #3
0
 /// <summary> Initialize the Velocity Runtime with a Properties
 /// object.
 /// *
 /// </summary>
 /// <param name="">Properties
 ///
 /// </param>
 public virtual void init(ExtendedProperties p)
 {
     overridingProperties = ExtendedProperties.ConvertProperties(p);
     init();
 }