Class HandleService

All Implemented Interfaces:
CtxEventListener, ContextHandleAware, HandleAware, HandleGetter, Ready, ReadyListener

public final class HandleService extends AbstractService implements HandleGetter
System wrapper around HandleMgr, as HandleMgr should only be used by internal kOS code.
Since:
1.0
Version:
2023-03-06
  • Method Details

    • getRootHandle

      public Handle getRootHandle(String name)
      Returns a root handle with the specified name, creating the instance if needed.
    • getHandles

      public Collection<String> getHandles()
      Returns the list of handles in the cache.
    • addViewClass

      public void addViewClass(String name, Class<?> clazz)
      Add a custom view class. This can be accessed via the handles endpoint to return a custom view of any handle path bean.
      Parameters:
      name - name of the view
      clazz - the class to use for json serialization
    • removeViewClass

      public void removeViewClass(String name)
      Remove a custom view class by the view name.
    • getBean

      public <T> T getBean(String path, Class<T> clazz)
      Description copied from interface: HandleGetter
      Gets the bean of the specified type for the specified handle path.
      Specified by:
      getBean in interface HandleGetter
      Type Parameters:
      T - the expected bean type
      Parameters:
      path - the handle path of the bean
      clazz - the expected bean class
      Returns:
      the specified bean cast to the specified type
    • getBean

      public Object getBean(String path)
      Description copied from interface: HandleGetter
      Gets the bean with the specified handle path.
      Specified by:
      getBean in interface HandleGetter
      Parameters:
      path - the handle path for the bean
      Returns:
      the bean for the specified path or null
    • getBeans

      public <T> List<T> getBeans(Class<T> clazz)
      Description copied from interface: HandleGetter
      Returns a list of beans of the specified type from the cached set of beans.
      Specified by:
      getBeans in interface HandleGetter
      Parameters:
      clazz - the class of bean to return