Jetty deployers - Webapp Deploy Management component
—
Core deployment orchestration functionality providing centralized control over application lifecycles, provider management, and state coordination. The DeploymentManager serves as the main entry point for all deployment operations.
The central orchestrator that manages the complete deployment lifecycle of applications, coordinating between providers, managing state transitions, and maintaining deployed context handlers.
/**
* Main deployment manager responsible for tracking apps, managing providers,
* and executing lifecycle operations
*/
public class DeploymentManager extends ContainerLifeCycle {
/** Creates a new deployment manager with default configuration */
public DeploymentManager();
/** Receives an app for processing and lifecycle management */
public void addApp(App app);
/** Gets an app by its unique identifier */
public App getApp(String appId);
/** Gets an app by its origin path */
public App getApp(Path path);
/** Returns all currently managed apps */
public Collection<App> getApps();
/** Returns all apps currently in the specified node state */
public Collection<App> getApps(String nodeName);
/** Returns apps with the same context path as the given app */
public List<App> getAppsWithSameContext(App app);
/** Adds an application provider for automatic app discovery */
public void addAppProvider(AppProvider provider);
/** Removes an application provider */
public void removeAppProvider(AppProvider provider);
/** Returns all configured application providers */
public Collection<AppProvider> getAppProviders();
/** Sets the collection of application providers */
public void setAppProviders(Collection<AppProvider> providers);
/** Checks if a provider exists for the specified environment */
public boolean hasAppProviderFor(String environmentName);
/** Moves an app through the lifecycle to the desired node state */
public void requestAppGoal(App app, String nodeName);
/** Moves an app through the lifecycle by app ID (JMX operation) */
public void requestAppGoal(String appId, String nodeName);
/** Removes app from deployment tracking */
public void removeApp(App app);
/** Undeploys all currently deployed applications */
public void undeployAll();
/** Returns the deployment lifecycle state machine */
public AppLifeCycle getLifeCycle();
/** Gets the default lifecycle goal for new applications */
public String getDefaultLifeCycleGoal();
/** Sets the default lifecycle goal for new applications */
public void setDefaultLifeCycleGoal(String defaultLifeCycleState);
/** Gets default environment name for deployed applications */
public String getDefaultEnvironmentName();
/** Returns the context handler collection for deployed apps */
public ContextHandlerCollection getContexts();
/** Sets the context handler collection for deployed apps */
public void setContexts(ContextHandlerCollection contexts);
/** Returns the associated Jetty server */
public Server getServer();
/** Returns all app entries with their lifecycle information */
public Collection<AppEntry> getAppEntries();
/** Returns all lifecycle nodes from the state machine */
public Collection<Node> getNodes();
/** Adds a lifecycle binding for state transitions */
public void addLifeCycleBinding(AppLifeCycle.Binding binding);
/** Sets the collection of lifecycle bindings */
public void setLifeCycleBindings(Collection<AppLifeCycle.Binding> bindings);
/** Returns all configured lifecycle bindings */
public Collection<AppLifeCycle.Binding> getLifeCycleBindings();
/** Returns if standard bindings are used */
public boolean isUseStandardBindings();
/** Sets whether to use standard deployment bindings */
public void setUseStandardBindings(boolean useStandardBindings);
/** Inserts a new lifecycle node between existing nodes */
public void insertLifeCycleNode(String existingFromNodeName, String existingToNodeName, String insertedNodeName);
}Usage Examples:
import org.eclipse.jetty.deploy.DeploymentManager;
import org.eclipse.jetty.deploy.providers.ContextProvider;
import org.eclipse.jetty.server.Server;
import org.eclipse.jetty.server.handler.ContextHandlerCollection;
// Basic setup
DeploymentManager deploymentManager = new DeploymentManager();
deploymentManager.setContexts(new ContextHandlerCollection());
// Add providers for different deployment sources
ContextProvider webappsProvider = new ContextProvider();
webappsProvider.setMonitoredDirName("webapps");
deploymentManager.addAppProvider(webappsProvider);
// Configure lifecycle
deploymentManager.setDefaultLifeCycleGoal("started");
deploymentManager.setUseStandardBindings(true);
// Integrate with server
Server server = new Server(8080);
server.addBean(deploymentManager);
// Manual app management
App myApp = deploymentManager.getApp("/path/to/my-app.war");
if (myApp != null) {
deploymentManager.requestAppGoal(myApp, "started");
}
// Undeploy all apps during shutdown
deploymentManager.undeployAll();Represents information about an application managed by the DeploymentManager, including its origin, provider, and runtime state.
/**
* Represents information about an application managed by the DeploymentManager
*/
public class App {
/** Creates a new app with the specified manager, provider, and origin path */
public App(DeploymentManager manager, AppProvider provider, Path path);
/** Returns the deployment manager that manages this app */
public DeploymentManager getDeploymentManager();
/** Returns the app provider that created this app */
public AppProvider getAppProvider();
/** Returns the origin path of this app */
public Path getPath();
/** Returns the context path for the app */
public String getContextPath();
/** Returns the environment name if set */
public String getEnvironmentName();
/** Returns the context handler, creating if needed */
public ContextHandler getContextHandler() throws Exception;
/** Returns application properties */
public Map<String, String> getProperties();
/** Returns string representation of the app */
public String toString();
}Provides tracking information for an app including its current lifecycle state and state history.
/**
* Nested class providing tracking information for deployed applications
*/
public static class DeploymentManager.AppEntry {
/** Returns the tracked app */
public App getApp();
/** Returns current lifecycle node */
public Node getLifecyleNode();
/** Returns timestamps for each state transition */
public Map<Node, Long> getStateTimestamps();
/** Returns app version number */
public int getVersion();
}Usage Examples:
// Query deployment status
Collection<DeploymentManager.AppEntry> entries = deploymentManager.getAppEntries();
for (DeploymentManager.AppEntry entry : entries) {
App app = entry.getApp();
Node currentState = entry.getLifecyleNode();
System.out.println("App: " + app.getPath());
System.out.println("State: " + currentState.getName());
System.out.println("Context Path: " + app.getContextPath());
// Get state transition history
Map<Node, Long> timestamps = entry.getStateTimestamps();
for (Map.Entry<Node, Long> stateTime : timestamps.entrySet()) {
System.out.println("State " + stateTime.getKey().getName() +
" at " + new Date(stateTime.getValue()));
}
}
// Work with app properties
App app = deploymentManager.getApp("my-app");
Map<String, String> props = app.getProperties();
props.put("my.custom.property", "value");
// Access context handler
ContextHandler handler = app.getContextHandler();
handler.setDisplayName("My Application");Install with Tessl CLI
npx tessl i tessl/maven-org-eclipse-jetty--jetty-deploy