Class ScriptingService

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

    public class ScriptingService
    extends java.lang.Object
    implements de.willuhn.boot.Bootable
    Interface fuer den Scripting-Service.
    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
      class  ScriptingService.Events
      Hilfsklasse zum Mappen der Events auf die JS-Funktionen.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static java.lang.String QUEUE_ADDED
      Die Queue, die nach dem Hinzufuegen eines Scripts benachrichtigt wird.
      static java.lang.String QUEUE_REMOVED
      Die Queue, die nach dem Entfernen eines Scripts benachrichtigt wird.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void addScript​(java.io.File file)
      Fuegt ein neues Script hinzu.
      boolean contains​(java.io.File file)
      Prueft, ob das angegebene Script bereits hinzugefuegt wurde.
      java.lang.Class<de.willuhn.boot.Bootable>[] depends()  
      javax.script.ScriptEngine getEngine()
      Liefert die Script-Engine.
      java.util.List<java.lang.String> getFunction​(java.lang.String event)
      Liefert die Namen der auszufuehrenden Javascript-Funktionen fuer das Event.
      java.util.List<java.io.File> getScripts()
      Liefert die Liste der vom User registrierten Scripts.
      void init​(de.willuhn.boot.BootLoader loader, de.willuhn.boot.Bootable caller)  
      void reload()
      Startet den Scripting-Service neu, damit die Scripts neu geladen werden.
      void removeScript​(java.io.File file)
      Entfernt das Script.
      void shutdown()  
      • Methods inherited from class java.lang.Object

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

      • QUEUE_ADDED

        public static final java.lang.String QUEUE_ADDED
        Die Queue, die nach dem Hinzufuegen eines Scripts benachrichtigt wird.
        See Also:
        Constant Field Values
      • QUEUE_REMOVED

        public static final java.lang.String QUEUE_REMOVED
        Die Queue, die nach dem Entfernen eines Scripts benachrichtigt wird.
        See Also:
        Constant Field Values
    • Constructor Detail

      • ScriptingService

        public ScriptingService()
    • Method Detail

      • depends

        public java.lang.Class<de.willuhn.boot.Bootable>[] 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()
      • reload

        public void reload()
        Startet den Scripting-Service neu, damit die Scripts neu geladen werden.
      • getEngine

        public javax.script.ScriptEngine getEngine()
        Liefert die Script-Engine.
        Returns:
        die Script-Engine.
      • getFunction

        public java.util.List<java.lang.String> getFunction​(java.lang.String event)
        Liefert die Namen der auszufuehrenden Javascript-Funktionen fuer das Event.
        Parameters:
        event - das Event.
        Returns:
        die auszufuehrenden JS-Funktion oder NULL, wenn keine definiert sind.
      • getScripts

        public java.util.List<java.io.File> getScripts()
        Liefert die Liste der vom User registrierten Scripts.
        Returns:
        Liste der vom User registrierten Scripts. Niemals NULL sondern hoechstens eine leere Liste.
      • contains

        public boolean contains​(java.io.File file)
                         throws java.io.IOException
        Prueft, ob das angegebene Script bereits hinzugefuegt wurde.
        Parameters:
        file - das zu pruefende Script.
        Returns:
        true, wenn es bereits vorhanden ist.
        Throws:
        java.io.IOException
      • addScript

        public void addScript​(java.io.File file)
                       throws de.willuhn.util.ApplicationException
        Fuegt ein neues Script hinzu.
        Parameters:
        file - das hinzuzufuegende Script.
        Throws:
        de.willuhn.util.ApplicationException - wenn die Script-Datei bereits vorhanden ist.
      • removeScript

        public void removeScript​(java.io.File file)
        Entfernt das Script.
        Parameters:
        file - das zu entfernende Script.