or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

Files

docs

async-processing.mdconfiguration-properties.mdindex.mdmonitoring.mdrequest-processing.mdresource-configuration.mdresource-model.mdspi.mdwadl.md

configuration-properties.mddocs/

0

# Configuration Properties

1

2

Server configuration constants for customizing Jersey server behavior including provider scanning, feature control, validation settings, performance tuning options, and advanced server configurations.

3

4

## Capabilities

5

6

### ServerProperties Class

7

8

Central repository of all Jersey server configuration property constants providing comprehensive control over server behavior.

9

10

```java { .api }

11

/**

12

* Server configuration property constants for customizing Jersey server behavior.

13

* Contains 41 public static final String constants for various configuration options.

14

*/

15

public final class ServerProperties {

16

17

// Private constructor - utility class

18

private ServerProperties();

19

}

20

```

21

22

### Provider Configuration Properties

23

24

Properties for controlling provider scanning, registration, and discovery mechanisms.

25

26

```java { .api }

27

/**

28

* Package names for automatic provider and resource scanning.

29

* Value type: String (semicolon-separated package names)

30

* Default: null (no automatic scanning)

31

*/

32

public static final String PROVIDER_PACKAGES = "jersey.config.server.provider.packages";

33

34

/**

35

* Enable recursive scanning of provider packages.

36

* Value type: Boolean

37

* Default: true

38

*/

39

public static final String PROVIDER_SCANNING_RECURSIVE = "jersey.config.server.provider.scanning.recursive";

40

41

/**

42

* Provider classpath scanning configuration.

43

* Value type: String (classpath locations)

44

* Default: null

45

*/

46

public static final String PROVIDER_CLASSPATH = "jersey.config.server.provider.classpath";

47

48

/**

49

* Explicit provider class names for registration.

50

* Value type: String (semicolon-separated class names)

51

* Default: null

52

*/

53

public static final String PROVIDER_CLASSNAMES = "jersey.config.server.provider.classnames";

54

55

/**

56

* Disable META-INF/services lookup for provider discovery.

57

* Value type: Boolean

58

* Default: false

59

*/

60

public static final String METAINF_SERVICES_LOOKUP_DISABLE = "jersey.config.server.provider.scanning.metainf.disable";

61

```

62

63

**Usage Examples:**

64

65

```java

66

import org.glassfish.jersey.server.ResourceConfig;

67

import org.glassfish.jersey.server.ServerProperties;

68

69

ResourceConfig config = new ResourceConfig();

70

71

// Configure package scanning

72

config.property(ServerProperties.PROVIDER_PACKAGES, "com.example.providers;com.example.resources")

73

.property(ServerProperties.PROVIDER_SCANNING_RECURSIVE, true);

74

75

// Explicit provider registration

76

config.property(ServerProperties.PROVIDER_CLASSNAMES,

77

"com.example.CustomProvider;com.example.AnotherProvider");

78

79

// Disable META-INF services lookup

80

config.property(ServerProperties.METAINF_SERVICES_LOOKUP_DISABLE, true);

81

82

// Alternative: Use packages() method (recommended)

83

config.packages("com.example.providers", "com.example.resources");

84

```

85

86

### Feature Control Properties

87

88

Properties for enabling or disabling specific Jersey features and functionalities.

89

90

```java { .api }

91

/**

92

* Disable automatic feature discovery.

93

* Value type: Boolean

94

* Default: false

95

*/

96

public static final String FEATURE_AUTO_DISCOVERY_DISABLE = "jersey.config.server.disableAutoDiscovery";

97

98

/**

99

* Disable WADL feature completely.

100

* Value type: Boolean

101

* Default: false

102

*/

103

public static final String WADL_FEATURE_DISABLE = "jersey.config.server.wadl.disableWadl";

104

105

/**

106

* Disable JSON-B (JSON Binding) feature.

107

* Value type: Boolean

108

* Default: false

109

*/

110

public static final String JSON_BINDING_FEATURE_DISABLE = "jersey.config.server.jsonBinding.disable";

111

112

/**

113

* Disable JSON-P (JSON Processing) feature.

114

* Value type: Boolean

115

* Default: false

116

*/

117

public static final String JSON_PROCESSING_FEATURE_DISABLE = "jersey.config.server.jsonProcessing.disable";

118

119

/**

120

* Disable MOXy JSON feature.

121

* Value type: Boolean

122

* Default: false

123

*/

124

public static final String MOXY_JSON_FEATURE_DISABLE = "jersey.config.server.moxy.json.disable";

125

126

/**

127

* Disable Bean Validation feature.

128

* Value type: Boolean

129

* Default: false

130

*/

131

public static final String BV_FEATURE_DISABLE = "jersey.config.beanValidation.disable.server";

132

```

133

134

**Usage Examples:**

135

136

```java

137

import org.glassfish.jersey.server.ServerProperties;

138

139

// Disable automatic feature discovery for better control

140

config.property(ServerProperties.FEATURE_AUTO_DISCOVERY_DISABLE, true);

141

142

// Disable WADL generation for production

143

config.property(ServerProperties.WADL_FEATURE_DISABLE, true);

144

145

// Disable JSON features if not needed

146

config.property(ServerProperties.JSON_BINDING_FEATURE_DISABLE, true)

147

.property(ServerProperties.JSON_PROCESSING_FEATURE_DISABLE, true)

148

.property(ServerProperties.MOXY_JSON_FEATURE_DISABLE, true);

149

150

// Enable Bean Validation (default is enabled)

151

config.property(ServerProperties.BV_FEATURE_DISABLE, false);

152

153

// Typical production configuration

154

ResourceConfig productionConfig = new ResourceConfig()

155

.packages("com.example.api")

156

.property(ServerProperties.FEATURE_AUTO_DISCOVERY_DISABLE, true)

157

.property(ServerProperties.WADL_FEATURE_DISABLE, true)

158

.property(ServerProperties.BV_FEATURE_DISABLE, false);

159

```

160

161

### Bean Validation Properties

162

163

Properties for controlling Bean Validation (JSR-303/JSR-380) behavior and error handling.

164

165

```java { .api }

166

/**

167

* Disable validation on executable override check.

168

* Value type: Boolean

169

* Default: false

170

*/

171

public static final String BV_DISABLE_VALIDATE_ON_EXECUTABLE_OVERRIDE_CHECK =

172

"jersey.config.beanValidation.disable.validateOnExecutableCheck.override";

173

174

/**

175

* Send validation errors in HTTP response instead of throwing exceptions.

176

* Value type: Boolean

177

* Default: true

178

*/

179

public static final String BV_SEND_ERROR_IN_RESPONSE = "jersey.config.beanValidation.enableOutputValidationErrorEntity";

180

181

/**

182

* WADL generator configuration for Bean Validation integration.

183

* Value type: String (generator class name)

184

* Default: null

185

*/

186

public static final String WADL_GENERATOR_CONFIG = "jersey.config.server.wadl.generatorConfig";

187

```

188

189

**Usage Examples:**

190

191

```java

192

import jakarta.validation.constraints.NotNull;

193

import jakarta.validation.constraints.Min;

194

import jakarta.ws.rs.GET;

195

import jakarta.ws.rs.Path;

196

import jakarta.ws.rs.QueryParam;

197

198

@Path("/validated")

199

public class ValidatedResource {

200

201

@GET

202

public String getValidatedData(@QueryParam("count") @Min(1) int count,

203

@QueryParam("name") @NotNull String name) {

204

return "Count: " + count + ", Name: " + name;

205

}

206

}

207

208

// Configure validation behavior

209

ResourceConfig config = new ResourceConfig()

210

.register(ValidatedResource.class)

211

.property(ServerProperties.BV_FEATURE_DISABLE, false)

212

.property(ServerProperties.BV_SEND_ERROR_IN_RESPONSE, true)

213

.property(ServerProperties.BV_DISABLE_VALIDATE_ON_EXECUTABLE_OVERRIDE_CHECK, false);

214

215

// Validation errors will be returned as HTTP 400 with details

216

// GET /validated?count=0&name= will return validation error response

217

```

218

219

### Media Type and Content Negotiation Properties

220

221

Properties for controlling media type mappings and content negotiation behavior.

222

223

```java { .api }

224

/**

225

* Media type mappings for file extensions.

226

* Value type: Map<String, MediaType> or String (comma-separated mappings)

227

* Default: null

228

* Format: "html:text/html,xml:application/xml,json:application/json"

229

*/

230

public static final String MEDIA_TYPE_MAPPINGS = "jersey.config.server.mediaTypeMappings";

231

232

/**

233

* Language mappings for content negotiation.

234

* Value type: Map<String, String> or String (comma-separated mappings)

235

* Default: null

236

* Format: "en:en-US,fr:fr-FR,de:de-DE"

237

*/

238

public static final String LANGUAGE_MAPPINGS = "jersey.config.server.languageMappings";

239

240

/**

241

* HTTP method override support (via header or query parameter).

242

* Value type: String (header names or query parameter names)

243

* Default: null

244

*/

245

public static final String HTTP_METHOD_OVERRIDE = "jersey.config.server.httpMethodOverride";

246

```

247

248

**Usage Examples:**

249

250

```java

251

import jakarta.ws.rs.core.MediaType;

252

import java.util.HashMap;

253

import java.util.Map;

254

255

// Configure media type mappings

256

Map<String, MediaType> mediaTypeMappings = new HashMap<>();

257

mediaTypeMappings.put("json", MediaType.APPLICATION_JSON_TYPE);

258

mediaTypeMappings.put("xml", MediaType.APPLICATION_XML_TYPE);

259

mediaTypeMappings.put("html", MediaType.TEXT_HTML_TYPE);

260

261

config.property(ServerProperties.MEDIA_TYPE_MAPPINGS, mediaTypeMappings);

262

263

// Or using string format

264

config.property(ServerProperties.MEDIA_TYPE_MAPPINGS,

265

"json:application/json,xml:application/xml,html:text/html");

266

267

// Configure language mappings

268

config.property(ServerProperties.LANGUAGE_MAPPINGS, "en:en-US,fr:fr-FR,es:es-ES");

269

270

// Enable HTTP method override via header

271

config.property(ServerProperties.HTTP_METHOD_OVERRIDE, "X-HTTP-Method-Override");

272

273

// Now requests can use:

274

// GET /api/users.json -> Accept: application/json

275

// GET /api/users.xml -> Accept: application/xml

276

// POST with X-HTTP-Method-Override: PUT -> treated as PUT request

277

```

278

279

### Performance and Advanced Configuration Properties

280

281

Properties for performance tuning, buffering, and advanced server behavior configuration.

282

283

```java { .api }

284

/**

285

* Outbound content length buffer size.

286

* Value type: Integer (buffer size in bytes)

287

* Default: 8192

288

*/

289

public static final String OUTBOUND_CONTENT_LENGTH_BUFFER = "jersey.config.server.contentLength.buffer";

290

291

/**

292

* Enable reduction of consecutive slashes in context path.

293

* Value type: Boolean

294

* Default: false

295

*/

296

public static final String REDUCE_CONTEXT_PATH_SLASHES_ENABLED = "jersey.config.server.reduceContextPathSlashesEnabled";

297

298

/**

299

* Disable resource validation during application initialization.

300

* Value type: Boolean

301

* Default: false

302

*/

303

public static final String RESOURCE_VALIDATION_DISABLE = "jersey.config.server.resource.validation.disable";

304

305

/**

306

* Ignore resource validation issues during initialization.

307

* Value type: Boolean

308

* Default: false

309

*/

310

public static final String RESOURCE_VALIDATION_IGNORE_ERRORS = "jersey.config.server.resource.validation.ignoreErrors";

311

312

/**

313

* Disable automatic response buffering.

314

* Value type: Boolean

315

* Default: false

316

*/

317

public static final String RESPONSE_BUFFERING_AUTO = "jersey.config.server.response.buffering.auto";

318

319

/**

320

* Monitor application statistics and events.

321

* Value type: Boolean

322

* Default: false

323

*/

324

public static final String MONITORING_STATISTICS_ENABLED = "jersey.config.server.monitoring.statistics.enabled";

325

326

/**

327

* Monitor application MBeans via JMX.

328

* Value type: Boolean

329

* Default: false

330

*/

331

public static final String MONITORING_STATISTICS_MBEANS_ENABLED = "jersey.config.server.monitoring.statistics.mbeans.enabled";

332

333

/**

334

* Request tracing configuration.

335

* Value type: String ("OFF", "ON_DEMAND", "ALL")

336

* Default: "OFF"

337

*/

338

public static final String TRACING = "jersey.config.server.tracing";

339

340

/**

341

* Request tracing logger name.

342

* Value type: String

343

* Default: "org.glassfish.jersey.tracing"

344

*/

345

public static final String TRACING_LOGGER = "jersey.config.server.tracing.logger";

346

347

/**

348

* Tracing response headers threshold.

349

* Value type: Integer

350

* Default: Integer.MAX_VALUE

351

*/

352

public static final String TRACING_THRESHOLD = "jersey.config.server.tracing.threshold";

353

```

354

355

**Usage Examples:**

356

357

```java

358

// Performance tuning configuration

359

ResourceConfig performanceConfig = new ResourceConfig()

360

.packages("com.example.api")

361

// Increase content length buffer for large responses

362

.property(ServerProperties.OUTBOUND_CONTENT_LENGTH_BUFFER, 16384)

363

// Enable context path slash normalization

364

.property(ServerProperties.REDUCE_CONTEXT_PATH_SLASHES_ENABLED, true)

365

// Enable automatic response buffering

366

.property(ServerProperties.RESPONSE_BUFFERING_AUTO, true);

367

368

// Monitoring configuration

369

ResourceConfig monitoringConfig = new ResourceConfig()

370

.packages("com.example.api")

371

// Enable statistics collection

372

.property(ServerProperties.MONITORING_STATISTICS_ENABLED, true)

373

// Enable JMX MBeans

374

.property(ServerProperties.MONITORING_STATISTICS_MBEANS_ENABLED, true)

375

// Enable request tracing for debugging

376

.property(ServerProperties.TRACING, "ON_DEMAND")

377

.property(ServerProperties.TRACING_THRESHOLD, 100);

378

379

// Development configuration with validation disabled for faster startup

380

ResourceConfig devConfig = new ResourceConfig()

381

.packages("com.example.api")

382

.property(ServerProperties.RESOURCE_VALIDATION_DISABLE, true)

383

.property(ServerProperties.RESOURCE_VALIDATION_IGNORE_ERRORS, true)

384

.property(ServerProperties.TRACING, "ALL");

385

386

// Production configuration optimized for performance

387

ResourceConfig prodConfig = new ResourceConfig()

388

.packages("com.example.api")

389

.property(ServerProperties.FEATURE_AUTO_DISCOVERY_DISABLE, true)

390

.property(ServerProperties.WADL_FEATURE_DISABLE, true)

391

.property(ServerProperties.OUTBOUND_CONTENT_LENGTH_BUFFER, 32768)

392

.property(ServerProperties.RESPONSE_BUFFERING_AUTO, true)

393

.property(ServerProperties.MONITORING_STATISTICS_ENABLED, true)

394

.property(ServerProperties.MONITORING_STATISTICS_MBEANS_ENABLED, true)

395

.property(ServerProperties.TRACING, "OFF");

396

```

397

398

### Application Configuration Properties

399

400

Properties for application-level settings and behavior control.

401

402

```java { .api }

403

/**

404

* Application name for identification and monitoring.

405

* Value type: String

406

* Default: null (derived from Application class)

407

*/

408

public static final String APPLICATION_NAME = "jersey.config.server.application.name";

409

410

/**

411

* Disable automatic application class loading.

412

* Value type: Boolean

413

* Default: false

414

*/

415

public static final String APPLICATION_AUTO_DISCOVERY_DISABLE = "jersey.config.server.application.disableAutoDiscovery";

416

417

/**

418

* Sub-resource locator cache size.

419

* Value type: Integer

420

* Default: 64

421

*/

422

public static final String SUBRESOURCE_LOCATOR_DEFAULT_CACHE_SIZE = "jersey.config.server.subresource.cache.size";

423

424

/**

425

* Sub-resource locator cache age limit.

426

* Value type: Long (milliseconds)

427

* Default: Long.MAX_VALUE (no expiration)

428

*/

429

public static final String SUBRESOURCE_LOCATOR_CACHE_JERSEY_RESOURCE_ENABLED = "jersey.config.server.subresource.cache.jersey.resource.enabled";

430

```

431

432

**Usage Examples:**

433

434

```java

435

// Application identification and caching configuration

436

ResourceConfig appConfig = new ResourceConfig()

437

.packages("com.example.api")

438

// Set application name for monitoring

439

.property(ServerProperties.APPLICATION_NAME, "My REST API v1.0")

440

// Optimize sub-resource locator caching

441

.property(ServerProperties.SUBRESOURCE_LOCATOR_DEFAULT_CACHE_SIZE, 128)

442

.property(ServerProperties.SUBRESOURCE_LOCATOR_CACHE_JERSEY_RESOURCE_ENABLED, true);

443

444

// Complete production-ready configuration example

445

ResourceConfig completeConfig = new ResourceConfig()

446

// Resource and provider packages

447

.packages("com.example.api.resources", "com.example.api.providers")

448

449

// Application settings

450

.property(ServerProperties.APPLICATION_NAME, "Production API v2.1")

451

452

// Feature control

453

.property(ServerProperties.FEATURE_AUTO_DISCOVERY_DISABLE, true)

454

.property(ServerProperties.WADL_FEATURE_DISABLE, true)

455

.property(ServerProperties.BV_FEATURE_DISABLE, false)

456

457

// Performance settings

458

.property(ServerProperties.OUTBOUND_CONTENT_LENGTH_BUFFER, 16384)

459

.property(ServerProperties.RESPONSE_BUFFERING_AUTO, true)

460

.property(ServerProperties.REDUCE_CONTEXT_PATH_SLASHES_ENABLED, true)

461

462

// Monitoring

463

.property(ServerProperties.MONITORING_STATISTICS_ENABLED, true)

464

.property(ServerProperties.MONITORING_STATISTICS_MBEANS_ENABLED, true)

465

466

// Bean Validation

467

.property(ServerProperties.BV_SEND_ERROR_IN_RESPONSE, true)

468

469

// Tracing (disabled for production)

470

.property(ServerProperties.TRACING, "OFF")

471

472

// Caching

473

.property(ServerProperties.SUBRESOURCE_LOCATOR_DEFAULT_CACHE_SIZE, 256);

474

```