mirror of
https://github.com/sbt/sbt.git
synced 2026-09-04 16:54:29 +02:00
Launcher can now load servers in addition to regular applications.
* Add new ServerMain interface * AppProvider can now choose to load ServerMain or AppMain classes * Explicitly document what happens if something doesn't match an expected interface * Improve error message on inability to load something. * Parse new [server] section that denotes a service and is lock file * Ability to serialize launch configurations. * Attempt to look for active listening server via the lock file * Forks the launcher itself to run servers from serialized launch configuration. * Testing echo server. * Tests to detect basic server functionality will work. * Revamp all the documentation for the launcher, giving it its own section. * Full documentation on launcher configuration files. Revamp launcher documentation to be a bit more in-depth, and split bits into sections.
This commit is contained in:
@@ -1,6 +1,25 @@
|
||||
package xsbti;
|
||||
|
||||
/**
|
||||
* The main entry interface for launching applications. Classes which implement this interface
|
||||
* can be launched via the sbt launcher.
|
||||
*
|
||||
* In addition, classes can be adapted into this interface by the launcher if they have a static method
|
||||
* matching one of these signatures:
|
||||
*
|
||||
* - public static void main(String[] args)
|
||||
* - public static int main(String[] args)
|
||||
* - public static xsbti.Exit main(String[] args)
|
||||
*
|
||||
*/
|
||||
public interface AppMain
|
||||
{
|
||||
/** Run the application and return the result.
|
||||
*
|
||||
* @param configuration The configuration used to run the application. Includes arguments and access to launcher features.
|
||||
* @return
|
||||
* The result of running this app.
|
||||
* Note: the result can be things like "Please reboot this application".
|
||||
*/
|
||||
public MainResult run(AppConfiguration configuration);
|
||||
}
|
||||
@@ -3,9 +3,10 @@ package xsbti;
|
||||
import java.io.File;
|
||||
|
||||
/**
|
||||
* This represents an interface that can generate applications.
|
||||
* This represents an interface that can generate applications or servers.
|
||||
*
|
||||
* An application is somethign which will run and return an exit value.
|
||||
* This provider grants access to launcher related features associated with
|
||||
* the id.
|
||||
*/
|
||||
public interface AppProvider
|
||||
{
|
||||
@@ -33,6 +34,8 @@ public interface AppProvider
|
||||
* It is NOT guaranteed that newMain().getClass() == mainClass().
|
||||
* The sbt launcher can wrap generic static main methods. In this case, there will be a wrapper class,
|
||||
* and you must use the `entryPoint` method.
|
||||
* @throws IncompatibleClassChangeError if the configuration used for this Application does not
|
||||
* represent a launched application.
|
||||
*/
|
||||
public AppMain newMain();
|
||||
|
||||
|
||||
@@ -0,0 +1,36 @@
|
||||
package xsbti;
|
||||
|
||||
/** A running server.
|
||||
*
|
||||
* A class implementing this must:
|
||||
*
|
||||
* 1. Expose an HTTP port that clients can connect to, returned via the uri method.
|
||||
* 2. Accept HTTP HEAD requests against the returned URI. These are used as "ping" messages to ensure
|
||||
* a server is still alive, when new clients connect.
|
||||
* 3. Create a new thread to execute its service
|
||||
* 4. Block the calling thread until the server is shutdown via awaitTermination()
|
||||
*/
|
||||
public interface Server {
|
||||
/**
|
||||
* @return
|
||||
* A URI denoting the Port which clients can connect to.
|
||||
*
|
||||
* Note: we use a URI so that the server can bind to different IP addresses (even a public one) if desired.
|
||||
* Note: To verify that a server is "up", the sbt launcher will attempt to connect to
|
||||
* this URI's address and port with a socket. If the connection is accepted, the server is assumed to
|
||||
* be working.
|
||||
*/
|
||||
public java.net.URI uri();
|
||||
/**
|
||||
* This should block the calling thread until the server is shutdown.
|
||||
*
|
||||
* @return
|
||||
* The result that should occur from the server.
|
||||
* Can be:
|
||||
* - xsbti.Exit: Shutdown this launch
|
||||
* - xsbti.Reboot: Restart the server
|
||||
*
|
||||
*
|
||||
*/
|
||||
public xsbti.MainResult awaitTermination();
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
package xsbti;
|
||||
|
||||
/** The main entry point for a launched service. This allows applciations
|
||||
* to instantiate server instances.
|
||||
*/
|
||||
public interface ServerMain {
|
||||
/**
|
||||
* This method should launch one or more thread(s) which run the service. After the service has
|
||||
* been started, it should return the port/URI it is listening for connections on.
|
||||
*
|
||||
* @param configuration
|
||||
* The configuration used to launch this service.
|
||||
* @return
|
||||
* A running server.
|
||||
*/
|
||||
public Server start(AppConfiguration configuration);
|
||||
}
|
||||
Reference in New Issue
Block a user