or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

Files

docs

application-providers.mddeployment-management.mdgraph-system.mdindex.mdlifecycle-management.md

deployment-management.mddocs/

0

# Deployment Management

1

2

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.

3

4

## Capabilities

5

6

### DeploymentManager

7

8

The central orchestrator that manages the complete deployment lifecycle of applications, coordinating between providers, managing state transitions, and maintaining deployed context handlers.

9

10

```java { .api }

11

/**

12

* Main deployment manager responsible for tracking apps, managing providers,

13

* and executing lifecycle operations

14

*/

15

public class DeploymentManager extends ContainerLifeCycle {

16

/** Creates a new deployment manager with default configuration */

17

public DeploymentManager();

18

19

/** Receives an app for processing and lifecycle management */

20

public void addApp(App app);

21

22

/** Gets an app by its unique identifier */

23

public App getApp(String appId);

24

25

/** Gets an app by its origin path */

26

public App getApp(Path path);

27

28

/** Returns all currently managed apps */

29

public Collection<App> getApps();

30

31

/** Returns all apps currently in the specified node state */

32

public Collection<App> getApps(String nodeName);

33

34

/** Returns apps with the same context path as the given app */

35

public List<App> getAppsWithSameContext(App app);

36

37

/** Adds an application provider for automatic app discovery */

38

public void addAppProvider(AppProvider provider);

39

40

/** Removes an application provider */

41

public void removeAppProvider(AppProvider provider);

42

43

/** Returns all configured application providers */

44

public Collection<AppProvider> getAppProviders();

45

46

/** Sets the collection of application providers */

47

public void setAppProviders(Collection<AppProvider> providers);

48

49

/** Checks if a provider exists for the specified environment */

50

public boolean hasAppProviderFor(String environmentName);

51

52

/** Moves an app through the lifecycle to the desired node state */

53

public void requestAppGoal(App app, String nodeName);

54

55

/** Moves an app through the lifecycle by app ID (JMX operation) */

56

public void requestAppGoal(String appId, String nodeName);

57

58

/** Removes app from deployment tracking */

59

public void removeApp(App app);

60

61

/** Undeploys all currently deployed applications */

62

public void undeployAll();

63

64

/** Returns the deployment lifecycle state machine */

65

public AppLifeCycle getLifeCycle();

66

67

/** Gets the default lifecycle goal for new applications */

68

public String getDefaultLifeCycleGoal();

69

70

/** Sets the default lifecycle goal for new applications */

71

public void setDefaultLifeCycleGoal(String defaultLifeCycleState);

72

73

/** Gets default environment name for deployed applications */

74

public String getDefaultEnvironmentName();

75

76

/** Returns the context handler collection for deployed apps */

77

public ContextHandlerCollection getContexts();

78

79

/** Sets the context handler collection for deployed apps */

80

public void setContexts(ContextHandlerCollection contexts);

81

82

/** Returns the associated Jetty server */

83

public Server getServer();

84

85

/** Returns all app entries with their lifecycle information */

86

public Collection<AppEntry> getAppEntries();

87

88

/** Returns all lifecycle nodes from the state machine */

89

public Collection<Node> getNodes();

90

91

/** Adds a lifecycle binding for state transitions */

92

public void addLifeCycleBinding(AppLifeCycle.Binding binding);

93

94

/** Sets the collection of lifecycle bindings */

95

public void setLifeCycleBindings(Collection<AppLifeCycle.Binding> bindings);

96

97

/** Returns all configured lifecycle bindings */

98

public Collection<AppLifeCycle.Binding> getLifeCycleBindings();

99

100

/** Returns if standard bindings are used */

101

public boolean isUseStandardBindings();

102

103

/** Sets whether to use standard deployment bindings */

104

public void setUseStandardBindings(boolean useStandardBindings);

105

106

/** Inserts a new lifecycle node between existing nodes */

107

public void insertLifeCycleNode(String existingFromNodeName, String existingToNodeName, String insertedNodeName);

108

}

109

```

110

111

**Usage Examples:**

112

113

```java

114

import org.eclipse.jetty.deploy.DeploymentManager;

115

import org.eclipse.jetty.deploy.providers.ContextProvider;

116

import org.eclipse.jetty.server.Server;

117

import org.eclipse.jetty.server.handler.ContextHandlerCollection;

118

119

// Basic setup

120

DeploymentManager deploymentManager = new DeploymentManager();

121

deploymentManager.setContexts(new ContextHandlerCollection());

122

123

// Add providers for different deployment sources

124

ContextProvider webappsProvider = new ContextProvider();

125

webappsProvider.setMonitoredDirName("webapps");

126

deploymentManager.addAppProvider(webappsProvider);

127

128

// Configure lifecycle

129

deploymentManager.setDefaultLifeCycleGoal("started");

130

deploymentManager.setUseStandardBindings(true);

131

132

// Integrate with server

133

Server server = new Server(8080);

134

server.addBean(deploymentManager);

135

136

// Manual app management

137

App myApp = deploymentManager.getApp("/path/to/my-app.war");

138

if (myApp != null) {

139

deploymentManager.requestAppGoal(myApp, "started");

140

}

141

142

// Undeploy all apps during shutdown

143

deploymentManager.undeployAll();

144

```

145

146

### App

147

148

Represents information about an application managed by the DeploymentManager, including its origin, provider, and runtime state.

149

150

```java { .api }

151

/**

152

* Represents information about an application managed by the DeploymentManager

153

*/

154

public class App {

155

/** Creates a new app with the specified manager, provider, and origin path */

156

public App(DeploymentManager manager, AppProvider provider, Path path);

157

158

/** Returns the deployment manager that manages this app */

159

public DeploymentManager getDeploymentManager();

160

161

/** Returns the app provider that created this app */

162

public AppProvider getAppProvider();

163

164

/** Returns the origin path of this app */

165

public Path getPath();

166

167

/** Returns the context path for the app */

168

public String getContextPath();

169

170

/** Returns the environment name if set */

171

public String getEnvironmentName();

172

173

/** Returns the context handler, creating if needed */

174

public ContextHandler getContextHandler() throws Exception;

175

176

/** Returns application properties */

177

public Map<String, String> getProperties();

178

179

/** Returns string representation of the app */

180

public String toString();

181

}

182

```

183

184

### AppEntry

185

186

Provides tracking information for an app including its current lifecycle state and state history.

187

188

```java { .api }

189

/**

190

* Nested class providing tracking information for deployed applications

191

*/

192

public static class DeploymentManager.AppEntry {

193

/** Returns the tracked app */

194

public App getApp();

195

196

/** Returns current lifecycle node */

197

public Node getLifecyleNode();

198

199

/** Returns timestamps for each state transition */

200

public Map<Node, Long> getStateTimestamps();

201

202

/** Returns app version number */

203

public int getVersion();

204

}

205

```

206

207

**Usage Examples:**

208

209

```java

210

// Query deployment status

211

Collection<DeploymentManager.AppEntry> entries = deploymentManager.getAppEntries();

212

for (DeploymentManager.AppEntry entry : entries) {

213

App app = entry.getApp();

214

Node currentState = entry.getLifecyleNode();

215

216

System.out.println("App: " + app.getPath());

217

System.out.println("State: " + currentState.getName());

218

System.out.println("Context Path: " + app.getContextPath());

219

220

// Get state transition history

221

Map<Node, Long> timestamps = entry.getStateTimestamps();

222

for (Map.Entry<Node, Long> stateTime : timestamps.entrySet()) {

223

System.out.println("State " + stateTime.getKey().getName() +

224

" at " + new Date(stateTime.getValue()));

225

}

226

}

227

228

// Work with app properties

229

App app = deploymentManager.getApp("my-app");

230

Map<String, String> props = app.getProperties();

231

props.put("my.custom.property", "value");

232

233

// Access context handler

234

ContextHandler handler = app.getContextHandler();

235

handler.setDisplayName("My Application");

236

```