Class FullSystem

java.lang.Object
com.renomad.minum.web.FullSystem

public final class FullSystem extends Object
This class is responsible for instantiating necessary classes for a valid system, in the proper order.
See Also:
  • Constructor Details

    • FullSystem

      public FullSystem(Context context)
      This constructor requires a Context object, but it is easier and recommended to use initialize() instead.
  • Method Details

    • buildContext

      public static Context buildContext()
      Builds a context object that is appropriate as a parameter to constructing a FullSystem
    • initialize

      public static FullSystem initialize()
      This is the typical entry point for system instantiation. It will build a Context object for you, and then properly instantiates the FullSystem.

      Here is an example of a simple Main file using this method:

      
         package org.example;
      
         import com.renomad.minum.web.FullSystem;
         import com.renomad.minum.web.Response;
      
         import static com.renomad.minum.web.RequestLine.Method.GET;
      
         public class Main {
      
             public static void main(String[] args) {
                 FullSystem fs = FullSystem.initialize();
                 fs.getWebFramework().registerPath(GET, "", request -> Response.htmlOk("<p>Hi there world!</p>"));
                 fs.block();
             }
         }
       
    • start

      public FullSystem start()
      This method runs the necessary methods for starting the Minum web server. It is unlikely you will want to use this, unless you require it for more control in testing.
      See Also:
    • getWebFramework

      public WebFramework getWebFramework()
    • getTheBrig

      public ITheBrig getTheBrig()
    • getContext

      public Context getContext()
    • shutdown

      public void shutdown()
    • block

      public void block()
      A blocking call for our multi-threaded application.

      This method is needed because the entire application is multi-threaded. Let me help contextualize the problem for you:

      For this application, multi-threaded means that we are wrapping our code in Thread classes and having them run using a ExecutorService. It's sort of like giving instructions to someone else to carry out the work and sending them away, trusting the work will get done, rather than doing it yourself.

      But, since our entire system is done this way, once we have sent all our threads on their way, there's nothing left for us to do! Continuing the analogy, it is like our whole job is to give other people instructions, and then just wait for them to return.

      That's the purpose of this method. It's to wait for the return.

      It's probably best to call this method as one of the last statements in the main method, so it is clear where execution is blocking.

    • toString

      public String toString()
      Intentionally return just the default object toString, this is only used to differentiate between multiple instances in memory.
      Overrides:
      toString in class Object