The SeBootstrap class is available in a Jakarta EE container environment as well; however, support for the Java SE
bootstrapping APIs is not required in container environments.
In a Java SE environment an application is getting started by the following command using default configuration
values (i. e. mounting application at http://localhost:80/ or a different port (there is no
particular default port mandated by this specification). As the JAX-RS implementation is free to choose any port
by default, the caller will not know the actual port unless explicitly checking the actual configuration of the
instance started:
Application app = new MyApplication(); SeBootstrap.Configuration config = SeBootstrap.Configuration.builder().build(); SeBootstrap.start(app, config).thenAccept(instance -> instance.configuration().port());
Running instances can be instructed to stop serving the application:
SeBootstrap.start(app, config).thenAccept(instance -> { ... instance.stop(); } );
A shutdown callback can be registered which will get invoked once the implementation stops serving the application:
instance.stop().thenAccept(stopResult -> ...));
stopResult is not further defined but solely acts as a wrapper around a native result provided by the
particular JAX-RS implementation. Portable applications should not assume any particular data type or value.
Protocol, host address, port and root path can be overridden explicitly. As the JAX-RS implementation is bound to that values, no querying of the actual configuration is needed in that case:
SeBootstrap.Configuration.builder().protocol("HTTPS").host("0.0.0.0").port(8443).rootPath("api").build();
TLS can be configured by explicitly passing a customized SSLContext:
SSLContext tls = SSLContext.getInstance("TLSv1.2");
// ...further initialize context here (see JSSE API)...
SeBootstrap.Configuration.builder().protocol("HTTPS").sslContext(tls).build();
In case of HTTPS, client authentication can be enforced to ensure that only trustworthy clients can connect:
SeBootstrap.Configuration.builder().protocol("HTTPS").sslClientAuthentication(SSLClientAuthentication.MANDATORY).build();
Implementations are free to support more use cases by native properties, which effectively render the application non-portable:
SeBootstrap.Configuration.builder().property("productname.foo", "bar").build()
Bulk-loading allows to attach configuration storages easily without the need to write down all properties to be transferred. Hence, even properties unknown to the application author will get channeled into the implementation. This can be done both, explicitly (hence portable) and implicitly (hence not necessarily portable as no particular configuration mechanics are required to be supported by compliant implementations):
// Explicit use of particular configuration mechanics is portable SeBootstrap.Configuration.builder().from((name, type) -> externalConfigurationSystem.getValue(name, type)).build(); // Implicitly relying on the support of particular configuration mechanics by // the actual JAX-RS implementation is not necessarily portable SeBootstrap.Configuration.builder().from(externalConfigurationSystem).build();
| Modifier and Type | Class and Description |
|---|---|
| public static interface | SeBootstrap.
Provides information needed by the JAX-RS implementation for bootstrapping an application. |
| public static interface | SeBootstrap.
Handle of the running application instance. |
| Modifier and Type | Method and Description |
|---|---|
| public static CompletionStage | Returns: CompletionStage (possibly asynchronously) producing handle of the running application
instance.The application to start up. application, final SeBootstrap.Provides information needed for bootstrapping the application. configurationStarts the provided application using the specified configuration. |
| public static CompletionStage | Returns: CompletionStage (possibly asynchronously) producing handle of the running application
instance.The application to start up. application)Starts the provided application using a default configuration. |
| public static CompletionStage | Returns: CompletionStage (possibly asynchronously) producing handle of the running application
instance.The application class. clazz, final SeBootstrap.Provides information needed for bootstrapping the application. configurationStarts the provided application using the specified configuration. |
| public static CompletionStage | Returns: CompletionStage (possibly asynchronously) producing handle of the running application
instance.The application class. clazz)Starts the provided application using a default configuration. |
| start | back to summary |
|---|---|
| public static CompletionStage Starts the provided application using the specified configuration. This method is intended to be used in Java SE environments only. The outcome of invocations in Jakarta EE container environments is undefined.
| |
| start | back to summary |
|---|---|
| public static CompletionStage Starts the provided application using a default configuration. This method is intended to be used in Java SE environments only. The outcome of invocations in Jakarta EE container environments is undefined.
| |
| start | back to summary |
|---|---|
| public static CompletionStage Starts the provided application using the specified configuration. Creates application instance from class using default constructor. Injection is not supported. This method is intended to be used in Java SE environments only. The outcome of invocations in Jakarta EE container environments is undefined.
| |
| start | back to summary |
|---|---|
| public static CompletionStage Starts the provided application using a default configuration. Creates application instance from class using default constructor. Injection is not supported. This method is intended to be used in Java SE environments only. The outcome of invocations in Jakarta EE container environments is undefined.
| |
The configuration essentially consists of a set of parameters. While the set of actually effective keys is product
specific, the key constants defined by the SeBootstrap. interface MUST be effective on all compliant
products. Any unknown key MUST be silently ignored.
| Modifier and Type | Class and Description |
|---|---|
| public static interface | SeBootstrap.
Builder for bootstrap |
| public static enum | SeBootstrap.
Secure socket client authentication policy This policy is used in secure socket handshake to control whether the server requests client authentication, and whether successful client authentication is mandatory (i. |
| Modifier and Type | Field and Description |
|---|---|
| public static final int | DEFAULT_PORT
Special value for |
| public static final int | |
| public static final String | HOST
Configuration key for the hostname or IP address an application is bound to. |
| public static final String | PORT
Configuration key for the TCP port an application is bound to. |
| public static final String | PROTOCOL
Configuration key for the protocol an application is bound to. |
| public static final String | ROOT_PATH
Configuration key for the root path an application is bound to. |
| public static final String | SSL_CLIENT_AUTHENTICATION
Configuration key for the secure socket client authentication policy. |
| public static final String | SSL_CONTEXT
Configuration key for the secure socket configuration to be used. |
| Modifier and Type | Method and Description |
|---|---|
| public default URI | |
| public default UriBuilder | Returns: aUriBuilder for the application.Returns a |
| public static SeBootstrap. | |
| public default boolean | Returns: false if no property exists matching the given name, true otherwise.a name)String specifying the name of the property.Returns whether the property with the given name is configured, either explicitly or by default. |
| public default String | Returns: host name or IP address to be used (e. g."localhost" or "0.0.0.0").Convenience method to get the |
| public default int | Returns: port number actually used (e. g.8080).Convenience method to get the actually used |
| public Object | |
| public default String | Returns: protocol to be used (e. g."HTTP").Convenience method to get the |
| public default String | Returns: root path to be used, e.g."/".Convenience method to get the |
| public default SeBootstrap. | Returns: client authentication mode, e. g.NONE.Convenience method to get the secure socket client authentication policy. |
| public default SSLContext | Returns: root path to be used, e. g."/".Convenience method to get the |
| DEFAULT_PORT | back to summary |
|---|---|
| public static final int DEFAULT_PORT Special value for
| |
| FREE_PORT | back to summary |
|---|---|
| public static final int FREE_PORT Special value for
| |
| HOST | back to summary |
|---|---|
| public static final String HOST Configuration key for the hostname or IP address an application is bound to.
A compliant implementation at least MUST accept string values bearing hostnames, IP4 address text representations,
and IP6 address text representations. If a hostname string, the special IP4 address string
The default value is
| |
| PORT | back to summary |
|---|---|
| public static final String PORT Configuration key for the TCP port an application is bound to.
A compliant implementation MUST accept
There is no default port mandated by this specification, but the default value of this property is
| |
| PROTOCOL | back to summary |
|---|---|
| public static final String PROTOCOL Configuration key for the protocol an application is bound to.
A compliant implementation at least MUST accept the strings
The default value is
| |
| ROOT_PATH | back to summary |
|---|---|
| public static final String ROOT_PATH Configuration key for the root path an application is bound to.
The default value is
| |
| SSL_CLIENT_AUTHENTICATION | back to summary |
|---|---|
| public static final String SSL_CLIENT_AUTHENTICATION Configuration key for the secure socket client authentication policy.
A compliant implementation MUST accept
The default value is
| |
| SSL_CONTEXT | back to summary |
|---|---|
| public static final String SSL_CONTEXT Configuration key for the secure socket configuration to be used.
The default value is
| |
| baseUri | back to summary |
|---|---|
| public default URI baseUri() Convenience method that returns a built the
| |
| baseUriBuilder | back to summary |
|---|---|
| public default UriBuilder baseUriBuilder() Returns a
| |
| builder | back to summary |
|---|---|
| public static SeBootstrap. Creates a new bootstrap configuration builder instance.
| |
| hasProperty | back to summary |
|---|---|
| public default boolean hasProperty(String name) Returns whether the property with the given name is configured, either explicitly or by default.
| |
| host | back to summary |
|---|---|
| public default String host() Convenience method to get the
Same as if calling
| |
| port | back to summary |
|---|---|
| public default int port() Convenience method to get the actually used
Same as if calling If the port was not explicitly given, this will return the port chosen implicitly by the JAX-RS implementation.
| |
| property | back to summary |
|---|---|
| public Object property(String name) Returns the value of the property with the given name, or | |
| protocol | back to summary |
|---|---|
| public default String protocol() Convenience method to get the
Same as if calling
| |
| rootPath | back to summary |
|---|---|
| public default String rootPath() Convenience method to get the
Same as if calling
| |
| sslClientAuthentication | back to summary |
|---|---|
| public default SeBootstrap. Convenience method to get the secure socket client authentication policy.
Same as if calling
| |
| sslContext | back to summary |
|---|---|
| public default SSLContext sslContext() Convenience method to get the
Same as if calling
| |
Configuration.
| Modifier and Type | Method and Description |
|---|---|
| public SeBootstrap. | Returns: Configuration built from provided property values.Builds a bootstrap configuration instance from the provided property values. |
| public < Type of the requested property value. T> SeBootstrap. | Returns: the updated builder.Retrieval function of externally managed properties. MUST NOT return propertiesProvider)null.Convenience method for bulk-loading configuration from a property supplier. |
| public default SeBootstrap. | |
| public default SeBootstrap. | |
| public default SeBootstrap. | |
| public SeBootstrap. | |
| public default SeBootstrap. | |
| public default SeBootstrap. | |
| public default SeBootstrap. | Returns: the updated builder.SSL client authentication mode of this configuration sslClientAuthenticationConvenience method to set SSL client authentication policy. |
| public default SeBootstrap. | Returns: the updated builder.sslContext parameter of this configuration, or sslContext)null to use the default value.Convenience method to set the |
| build | back to summary |
|---|---|
| public SeBootstrap. Builds a bootstrap configuration instance from the provided property values.
| |
| from | back to summary |
|---|---|
| public <T> SeBootstrap. Convenience method for bulk-loading configuration from a property supplier.
Implementations ask the passed provider function for the actual values of all their supported properties, before
returning from this configuration method. For each single request the implementation provides the name of the
property and the expected data type of the value. If no such property exists (i. e. either the name is unknown or
misspelled, or the type does not exactly match), the
| |
| from | back to summary |
|---|---|
| public default SeBootstrap. Optional convenience method to bulk-load external configuration. Implementations are free to support any external configuration mechanics, or none at all. It is completely up to the implementation what set of properties is effectively loaded from the provided external configuration, possibly none at all. If the passed external configuration mechanics is unsupported, this method MUST simply do nothing. Portable applications should not call this method, as the outcome is completely implementation-specific.
| |
| host | back to summary |
|---|---|
| public default SeBootstrap. Convenience method to set the
Same as if calling
| |
| port | back to summary |
|---|---|
| public default SeBootstrap. Convenience method to set the
Same as if calling
| |
| property | back to summary |
|---|---|
| public SeBootstrap. Sets the property This method does not check the validity, type or syntax of the provided value.
| |
| protocol | back to summary |
|---|---|
| public default SeBootstrap. Convenience method to set the
Same as if calling
| |
| rootPath | back to summary |
|---|---|
| public default SeBootstrap. Convenience method to set the
Same as if calling
| |
| sslClientAuthentication | back to summary |
|---|---|
| public default SeBootstrap. Convenience method to set SSL client authentication policy.
Same as if calling
| |
| sslContext | back to summary |
|---|---|
| public default SeBootstrap. Convenience method to set the
Same as if calling
| |
This policy is used in secure socket handshake to control whether the server requests client authentication, and whether successful client authentication is mandatory (i. e. connection attempt will fail for invalid clients).
| Modifier and Type | Field and Description |
|---|---|
| public static final SeBootstrap. | MANDATORY
Client authentication is performed, and invalid clients are rejected. |
| public static final SeBootstrap. | NONE
Server will not request client authentication. |
| public static final SeBootstrap. | OPTIONAL
Client authentication is performed, but invalid clients are accepted. |
| Access | Constructor and Description |
|---|---|
| private |
| Modifier and Type | Method and Description |
|---|---|
| public static SeBootstrap. | |
| public static SeBootstrap. |
| MANDATORY | back to summary |
|---|---|
| public static final SeBootstrap. Client authentication is performed, and invalid clients are rejected.
| |
| NONE | back to summary |
|---|---|
| public static final SeBootstrap. Server will not request client authentication.
| |
| OPTIONAL | back to summary |
|---|---|
| public static final SeBootstrap. Client authentication is performed, but invalid clients are accepted.
| |
| SSLClientAuthentication | back to summary |
|---|---|
| private SSLClientAuthentication() | |
| valueOf | back to summary |
|---|---|
| public static SeBootstrap. | |
| values | back to summary |
|---|---|
| public static SeBootstrap. | |
| Modifier and Type | Class and Description |
|---|---|
| public static interface | SeBootstrap.
Result of stopping the application instance. |
| Modifier and Type | Method and Description |
|---|---|
| public SeBootstrap. | Returns: The configuration actually used to create this instance.Provides access to the configuration actually used by the implementation used to create this instance. |
| public CompletionStage | Returns: CompletionStage asynchronously shutting down this application instance.Initiate immediate shutdown of running application instance. |
| public default void | stopOnShutdown(Consumer<SeBootstrap.
The consumer. consumerRegisters a consumer for a |
| public < Requested type of the native handle to return. T> T |
| configuration | back to summary |
|---|---|
| public SeBootstrap. Provides access to the configuration actually used by the implementation used to create this instance.
This may, or may not, be the same instance passed to
| |
| stop | back to summary |
|---|---|
| public CompletionStage Initiate immediate shutdown of running application instance.
| |
| stopOnShutdown | back to summary |
|---|---|
| public default void stopOnShutdown(Consumer<SeBootstrap. Registers a consumer for a
| |
| unwrap | back to summary |
|---|---|
| public <T> T unwrap(Class<T> nativeClass) Provides access to the wrapped native handle of the application instance. Implementations may, or may not, have native handles. Portable applications should not invoke this method, as the outcome is undefined.
| |
| Modifier and Type | Method and Description |
|---|---|
| public < Requested type of the native result to return. T> T |
| unwrap | back to summary |
|---|---|
| public <T> T unwrap(Class<T> nativeClass) Provides access to the wrapped native shutdown result. Implementations may, or may not, have native shutdown results. Portable applications should not invoke this method, as the outcome is undefined.
| |