Class VelocityService

  • All Implemented Interfaces:
    de.willuhn.boot.Bootable

    public class VelocityService
    extends java.lang.Object
    implements de.willuhn.boot.Bootable
    Resource-Loader von Velocity.
    • Constructor Summary

      Constructors 
      Constructor Description
      VelocityService()  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.lang.Class[] depends()  
      org.apache.velocity.app.VelocityEngine getEngine​(java.lang.String plugin)
      Liefert die Velocity-Engine fuer das angegebene Plugin.
      void init​(de.willuhn.boot.BootLoader loader, de.willuhn.boot.Bootable caller)  
      java.lang.String merge​(java.lang.String source, java.util.Map<java.lang.String,​java.lang.Object> context)
      Interpretiert das Velocity-Template im String "source" und nimmt alle Ersetzungen gemaess dem Context.
      void shutdown()  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • VelocityService

        public VelocityService()
    • Method Detail

      • depends

        public java.lang.Class[] depends()
        Specified by:
        depends in interface de.willuhn.boot.Bootable
        See Also:
        Bootable.depends()
      • init

        public void init​(de.willuhn.boot.BootLoader loader,
                         de.willuhn.boot.Bootable caller)
                  throws de.willuhn.boot.SkipServiceException
        Specified by:
        init in interface de.willuhn.boot.Bootable
        Throws:
        de.willuhn.boot.SkipServiceException
        See Also:
        Bootable.init(de.willuhn.boot.BootLoader, de.willuhn.boot.Bootable)
      • shutdown

        public void shutdown()
        Specified by:
        shutdown in interface de.willuhn.boot.Bootable
        See Also:
        Bootable.shutdown()
      • getEngine

        public org.apache.velocity.app.VelocityEngine getEngine​(java.lang.String plugin)
        Liefert die Velocity-Engine fuer das angegebene Plugin.
        Parameters:
        plugin - Name des Plugins oder Name der Plugin-Klasse.
        Returns:
        die Velocity-Engine oder die Default-Velocity-Engine von Jameica selbst wenn keine Plugin-spezifische gefunden wurde.
      • merge

        public java.lang.String merge​(java.lang.String source,
                                      java.util.Map<java.lang.String,​java.lang.Object> context)
                               throws java.io.IOException
        Interpretiert das Velocity-Template im String "source" und nimmt alle Ersetzungen gemaess dem Context. Das ist eine bequeme "Convenience"-Funktion, um mal schnell was in einem String zu ersetzen, ohne erst manuell eine ganze VelocityEngine samt Readern und Writern programmieren zu muessen.
        Parameters:
        source - Der Text mit den Velocity-Platzhaltern.
        context - Map mit den Velocity-Parametern.
        Returns:
        der verarbeitete Text.
        Throws:
        java.io.IOException