Package xyz.ressor

Class Ressor


  • public class Ressor
    extends java.lang.Object
    Public API of the Ressor framework.

    Ressor instances can be created using default configuration with create() or a custom one with create(RessorConfig).

    It's recommended (though not restricted) to have a single Ressor instance per running VM and re-use it everywhere.

    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      ActionsManager actions()  
      static Ressor create()  
      static Ressor create​(RessorConfig config)  
      <T> void listen​(T service)
      Starts listening the Source of the underlying service for the changes.
      <T> PollingBuilder poll​(T service)
      Starts polling the Source of the underlying service for incoming changes.
      <T> void reload​(T service)
      Forces the service to reload from the underlying data source.
      <T> void scheduleReload​(T service)
      Schedules the service reload from the underlying data source.
      <T> RessorBuilder<T,​java.lang.Object> service​(java.lang.Class<T> type)
      Creates a new service builder for the given type, which can be either interface or class.
      void shutdown()
      Shutdowns the current Ressor context.
      <T> void stop​(T service)
      Stops any periodic activity on the service (polling or listening).
      • Methods inherited from class java.lang.Object

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

      • create

        public static Ressor create()
      • service

        public <T> RessorBuilder<T,​java.lang.Object> service​(java.lang.Class<T> type)
        Creates a new service builder for the given type, which can be either interface or class.
        Type Parameters:
        T - the public service type
        Parameters:
        type - the public type of your service for which proxy instance would be generated and returned as a result
        Returns:
        service builder instance
      • listen

        public <T> void listen​(T service)
        Starts listening the Source of the underlying service for the changes. When the change event is received, the service will implicitly reload itself with the new resource. Please note that for now listening is supported only by FileSystemSource. Unless, an appropriate exception would be thrown.
        Type Parameters:
        T - service public type
        Parameters:
        service - Ressor service proxy instance
      • poll

        public <T> PollingBuilder poll​(T service)
        Starts polling the Source of the underlying service for incoming changes. When resource is detected to be changed, the service will implicitly reload itself with the new resource. Polling is supported by every Source, and have different approaches based on the implementation. Please read documentation of each source implementation.
        Type Parameters:
        T - service public type
        Parameters:
        service - Ressor service proxy instance
        Returns:
        poller builder instance
      • reload

        public <T> void reload​(T service)
        Forces the service to reload from the underlying data source. This methods blocks until the reload completion.
        Type Parameters:
        T - service public type
        Parameters:
        service - Ressor service to be reloaded
      • scheduleReload

        public <T> void scheduleReload​(T service)
        Schedules the service reload from the underlying data source. Unlike reload(Object), this method return immediately without waiting for the reload completion.
        Type Parameters:
        T - service public type
        Parameters:
        service - Ressor service to be reloaded
      • stop

        public <T> void stop​(T service)
        Stops any periodic activity on the service (polling or listening).
        Type Parameters:
        T - service public type
        Parameters:
        service - Ressor service proxy instance
      • shutdown

        public void shutdown()
        Shutdowns the current Ressor context. This includes stopping all polling, listening activities, as well as service reloads and associated actions. The internal thread pool is shutdown as well.

        This operation doesn't affect the created services itself, they will be usable until they are normally garbage collected by VM. Ressor doesn't keep any strong references to them.