- See Also:
-
Constructor Summary
ConstructorDescriptionFullSystem
(Context context) This constructor requires aContext
object, but it is easier and recommended to useinitialize()
instead. -
Method Summary
Modifier and TypeMethodDescriptionvoid
block()
A blocking call for our multi-threaded application.static Context
Builds a context object that is appropriate as a parameter to constructing aFullSystem
static FullSystem
This is the typical entry point for system instantiation.void
shutdown()
start()
This method runs the necessary methods for starting the Minum web server.toString()
Intentionally return just the default object toString, this is only used to differentiate between multiple instances in memory.
-
Constructor Details
-
FullSystem
This constructor requires aContext
object, but it is easier and recommended to useinitialize()
instead.
-
-
Method Details
-
buildContext
Builds a context object that is appropriate as a parameter to constructing aFullSystem
-
initialize
This is the typical entry point for system instantiation. It will build aContext
object for you, and then properly instantiates theFullSystem
.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
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
-
getTheBrig
-
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 aExecutorService
. 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
Intentionally return just the default object toString, this is only used to differentiate between multiple instances in memory.
-