Exemple #1
0
            internal VelocimacroProxy CreateVelocimacro(String ns)
            {
                VelocimacroProxy velocimacroProxy = new VelocimacroProxy();

                velocimacroProxy.Name      = macroName;
                velocimacroProxy.ArgArray  = argumentArray;
                velocimacroProxy.MacroBody = macroBody;
                velocimacroProxy.NodeTree  = nodeTree;
                velocimacroProxy.Namespace = ns;
                return(velocimacroProxy);
            }
Exemple #2
0
            internal VelocimacroProxy createVelocimacro(String namespace_Renamed)
            {
                VelocimacroProxy vp = new VelocimacroProxy();

                vp.Name      = this.macroname;
                vp.ArgArray  = this.argarray;
                vp.Macrobody = this.macrobody;
                vp.NodeTree  = this.nodeTree;
                vp.Namespace = namespace_Renamed;
                return(vp);
            }
            internal MacroEntry(string vmName, INode macro, string[] argArray, string sourceTemplate)
            {
                this.vmName         = vmName;
                this.argArray       = argArray;
                this.nodeTree       = (SimpleNode)macro;
                this.sourceTemplate = sourceTemplate;

                vp = new VelocimacroProxy();
                vp.SetName(this.vmName);
                vp.ArgArray = this.argArray;
                vp.NodeTree = this.nodeTree;
            }
        public Directive.Directive GetVelocimacro(string vmName, string sourceTemplate)
        {
            VelocimacroProxy velocimacroProxy = null;

            lock (this)
            {
                velocimacroProxy = this.vmManager.get(vmName, sourceTemplate);
                if (velocimacroProxy != null && this.Autoload)
                {
                    string libraryName = this.vmManager.GetLibraryName(vmName, sourceTemplate);
                    if (libraryName != null)
                    {
                        try
                        {
                            VelocimacroFactory.Twonk twonk = (VelocimacroFactory.Twonk) this.libModMap[libraryName];
                            if (twonk != null)
                            {
                                Template template         = twonk.template;
                                long     modificationTime = twonk.modificationTime;
                                long     lastModified     = template.ResourceLoader.GetLastModified(template);
                                if (lastModified > modificationTime)
                                {
                                    this.LogVMMessageInfo("Velocimacro : autoload reload for VMs from VM library template : " + libraryName);
                                    twonk.modificationTime = lastModified;
                                    template               = this.rsvc.GetTemplate(libraryName);
                                    twonk.template         = template;
                                    twonk.modificationTime = template.LastModified;
                                }
                            }
                        }
                        catch (System.Exception ex)
                        {
                            this.LogVMMessageInfo(string.Concat(new object[]
                            {
                                "Velocimacro : error using  VM library template ",
                                libraryName,
                                " : ",
                                ex
                            }));
                        }
                        velocimacroProxy = this.vmManager.get(vmName, sourceTemplate);
                    }
                }
            }
            return(velocimacroProxy);
        }
Exemple #5
0
        /// <summary>  actual factory : creates a Directive that will
        /// behave correctly wrt getting the framework to
        /// dig out the correct # of args
        /// </summary>
        public Directive.Directive GetVelocimacro(String vmName, String sourceTemplate)
        {
            VelocimacroProxy velocimacroProxy = null;

            lock (this)
            {
                /*
                 *  don't ask - do
                 */

                velocimacroProxy = velocimacroManager.get(vmName, sourceTemplate);

                /*
                 *  if this exists, and autoload is on, we need to check
                 *  where this VM came from
                 */

                if (velocimacroProxy != null && Autoload)
                {
                    /*
                     *  see if this VM came from a library.  Need to pass sourceTemplate
                     *  in the event namespaces are set, as it could be masked by local
                     */

                    String lib = velocimacroManager.GetLibraryName(vmName, sourceTemplate);

                    if (lib != null)
                    {
                        try
                        {
                            /*
                             *  get the template from our map
                             */

                            Twonk twonk = (Twonk)libModMap[lib];

                            if (twonk != null)
                            {
                                Template template = twonk.template;

                                /*
                                 *  now, compare the last modified time of the resource
                                 *  with the last modified time of the template
                                 *  if the file has changed, then reload. Otherwise, we should
                                 *  be ok.
                                 */

                                long tt = twonk.modificationTime;
                                long ft = template.ResourceLoader.GetLastModified(template)
                                ;

                                if (ft > tt)
                                {
                                    LogVMMessageInfo(string.Format("Velocimacro : autoload reload for VMs from VM library template : {0}", lib));

                                    /*
                                     *  when there are VMs in a library that invoke each other,
                                     *  there are calls into getVelocimacro() from the init()
                                     *  process of the VM directive.  To stop the infinite loop
                                     *  we save the current time reported by the resource loader
                                     *  and then be honest when the reload is complete
                                     */

                                    twonk.modificationTime = ft;

                                    template = runtimeServices.GetTemplate(lib)
                                    ;

                                    /*
                                     * and now we be honest
                                     */

                                    twonk.template         = template;
                                    twonk.modificationTime = template.LastModified;

                                    /*
                                     *  note that we don't need to put this twonk back
                                     *  into the map, as we can just use the same reference
                                     *  and this block is synchronized
                                     */
                                }
                            }
                        }
                        catch (System.Exception e)
                        {
                            LogVMMessageInfo(string.Format("Velocimacro : error using  VM library template {0} : {1}", lib, e));
                        }

                        /*
                         *  and get again
                         */
                        velocimacroProxy = velocimacroManager.get(vmName, sourceTemplate);
                    }
                }
            }

            return(velocimacroProxy);
        }
        /// <since> 1.6
        /// </since>
        public virtual Directive.Directive GetVelocimacro(string vmName, string sourceTemplate, string renderingTemplate)
        {
            VelocimacroProxy vp = null;

            vp = vmManager.Get(vmName, sourceTemplate, renderingTemplate);

            /*
             * if this exists, and autoload is on, we need to check where this VM came from
             */

            if (vp != null && autoReloadLibrary)
            {
                lock (this)
                {
                    /*
                     * see if this VM came from a library. Need to pass sourceTemplate in the event
                     * namespaces are set, as it could be masked by local
                     */

                    string lib = vmManager.GetLibraryName(vmName, sourceTemplate);

                    if (lib != null)
                    {
                        try
                        {
                            /*
                             * Get the template from our map
                             */


                            if (libModMap.ContainsKey(lib))
                            {
                                Twonk tw = libModMap[lib];

                                Template template = tw.template;

                                /*
                                 * now, Compare the last modified time of the resource with the last
                                 * modified time of the template if the file has changed, then reload.
                                 * Otherwise, we should be ok.
                                 */

                                long tt = tw.modificationTime;
                                long ft = template.ResourceLoader.GetLastModified(template);

                                if (ft > tt)
                                {
                                    log.Debug("auto-reloading VMs from VM library : " + lib);

                                    /*
                                     * when there are VMs in a library that invoke each other, there are
                                     * calls into getVelocimacro() from the Init() process of the VM
                                     * directive. To stop the infinite loop we save the current time
                                     * reported by the resource loader and then be honest when the
                                     * reload is complete
                                     */

                                    tw.modificationTime = ft;

                                    template = rsvc.GetTemplate(lib);

                                    /*
                                     * and now we be honest
                                     */

                                    tw.template         = template;
                                    tw.modificationTime = template.LastModified;

                                    /*
                                     * note that we don't need to Put this twonk
                                     * back into the map, as we can just use the
                                     * same reference and this block is synchronized
                                     */
                                }
                            }
                        }
                        catch (System.Exception e)
                        {
                            string msg = "Velocimacro : Error using VM library : " + lib;
                            //Log.Error(true, msg, e);
                            throw new VelocityException(msg, e);
                        }

                        vp = vmManager.Get(vmName, sourceTemplate, renderingTemplate);
                    }
                }
            }

            return(vp);
        }
			internal VelocimacroProxy CreateVelocimacro(String ns)
			{
				VelocimacroProxy vp = new VelocimacroProxy();
				vp.Name = macroname;
				vp.ArgArray = argarray;
				vp.Macrobody = macrobody;
				vp.NodeTree = nodeTree;
				vp.Namespace = ns;
				return vp;
			}
 internal VelocimacroProxy CreateVelocimacro(String ns)
 {
     VelocimacroProxy velocimacroProxy = new VelocimacroProxy();
     velocimacroProxy.Name = macroName;
     velocimacroProxy.ArgArray = argumentArray;
     velocimacroProxy.MacroBody = macroBody;
     velocimacroProxy.NodeTree = nodeTree;
     velocimacroProxy.Namespace = ns;
     return velocimacroProxy;
 }