spring-boot-starter-grizzly

Starter for using Grizzly as the embedded servlet container.

License

License

Categories

Categories

Spring Boot Container Microservices Grizzly Net Networking
GroupId

GroupId

be.dabla
ArtifactId

ArtifactId

spring-boot-starter-grizzly
Last Version

Last Version

1.0
Release Date

Release Date

Type

Type

jar
Description

Description

spring-boot-starter-grizzly
Starter for using Grizzly as the embedded servlet container.
Project URL

Project URL

https://github.com/dabla/spring-boot-starter-grizzly
Source Code Management

Source Code Management

https://github.com/dabla/spring-boot-starter-grizzly

Download spring-boot-starter-grizzly

How to add to project

<!-- https://jarcasting.com/artifacts/be.dabla/spring-boot-starter-grizzly/ -->
<dependency>
    <groupId>be.dabla</groupId>
    <artifactId>spring-boot-starter-grizzly</artifactId>
    <version>1.0</version>
</dependency>
// https://jarcasting.com/artifacts/be.dabla/spring-boot-starter-grizzly/
implementation 'be.dabla:spring-boot-starter-grizzly:1.0'
// https://jarcasting.com/artifacts/be.dabla/spring-boot-starter-grizzly/
implementation ("be.dabla:spring-boot-starter-grizzly:1.0")
'be.dabla:spring-boot-starter-grizzly:jar:1.0'
<dependency org="be.dabla" name="spring-boot-starter-grizzly" rev="1.0">
  <artifact name="spring-boot-starter-grizzly" type="jar" />
</dependency>
@Grapes(
@Grab(group='be.dabla', module='spring-boot-starter-grizzly', version='1.0')
)
libraryDependencies += "be.dabla" % "spring-boot-starter-grizzly" % "1.0"
[be.dabla/spring-boot-starter-grizzly "1.0"]

Dependencies

compile (12)

Group / Artifact Type Version
org.springframework.boot : spring-boot-starter jar 2.1.5.RELEASE
org.glassfish.web : javax.servlet.jsp jar 2.3.4
org.glassfish.web : javax.el jar 2.2.6
org.glassfish.web : javax.servlet.jsp.jstl jar 1.2.5
org.glassfish.grizzly : grizzly-http-server jar 2.4.4
org.glassfish.grizzly : grizzly-http-servlet jar 2.4.4
org.glassfish.jersey.containers : jersey-container-grizzly2-http jar 2.27
org.glassfish.jersey.connectors : jersey-apache-connector jar 2.27
org.glassfish.jersey.ext : jersey-proxy-client jar 2.27
org.glassfish.jersey.ext : jersey-spring4 jar 2.27
org.apache.httpcomponents : httpclient jar 4.5.2
javax.servlet : javax.servlet-api jar 4.0.1

provided (1)

Group / Artifact Type Version
org.springframework : spring-web jar 5.1.7.RELEASE

test (7)

Group / Artifact Type Version
org.springframework.boot : spring-boot-starter-test jar 2.1.5.RELEASE
org.junit.jupiter : junit-jupiter-api jar 5.3.2
org.junit.jupiter : junit-jupiter-engine jar 5.3.2
org.junit.platform : junit-platform-launcher jar 1.4.2
org.assertj : assertj-core jar 3.12.2
org.mockito : mockito-core jar 2.27.0
org.mockito : mockito-junit-jupiter jar 2.27.5

Project Modules

There are no modules declared in this project.

Grizzly-Spring-Boot-Starter

Build Status

Spring Boot Starter module which easily allows you to use Grizzly as an alternative web container with JSP support. REST services exposed as Spring beans will be automatically registered.

Code sample

package be.dabla.boot.grizzly;

import org.glassfish.jersey.server.ResourceConfig;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Bean;

@SpringBootApplication
public class GrizzlyApplication {

    public static void main(String[] args) {
        SpringApplication.run(GrizzlyApplication.class, args);
    }

    @Bean
    public ResourceConfigCustomizer resourceConfigCustomizer() {
        return new ResourceConfigCustomizer() {
            @Override
            public void customize(ResourceConfig resourceConfig) {
                Map<String,Object> properties = new HashMap<>();
                properties.put("com.sun.jersey.api.json.POJOMappingFeature", "true");
                properties.put("com.sun.jersey.config.feature.trace", "ALL");
                resourceConfig.addProperties(properties);
            }
        };
    }
}

Properties

It's possible to override the default properties listed here below.

Parameter Default value Description
grizzly.http.scheme http http / https
grizzly.http.doc-root / Physical location where grizzly will find it's contents (e.g. *.html or *.jsp files).
grizzly.http.url-mapping /
grizzly.jsp.url-mapping /*.jsp
server.address 0.0.0.0 The network host to which the grizzly network listener will bind. If not user specified, it will bind to 0.0.0.0 (default value).
server.port 8080 The network port to which the grizzly network will bind. If not user specified, it will bind to port 8080 (default value).
server.compression.enabled false By default compression mode is disabled.
server.compression.mime-types application/json,
application/xml,
text/javascript,
text/plain,
text/htm
server.compression.min-response-size 2KB
server.servlet.context-path / Context path is part of the URI on which the application handler will be deployed.
server.servlet.application-display-name application Display name of the application.
server.servlet.jsp.class-name org.apache.jasper.servlet.JspServlet Class name of the servlet to use for JSPs.
server.servlet.jsp.registered true Whether the JSP servlet has to be registered or not.

Prior to version 1.2, non standard Spring Boot properties where used to define port and address as shown in mapping table below:

Parameter name until 1.2 Parameter name since 1.2 compliant with Spring Boot properties
grizzly.http.port server.port
grizzly.http.host server.address
grizzly.http.context-path server.servlet.context-path
grizzly.http.compression-mode server.compression.enabled
grizzly.http.compressable-mime-types server.compression.mime-types
grizzly.http.minimum-compression-size server.compression.min-response-size

The URI on which the grizzly application handler will be deployed will be constructed as follow given the above parameters:

${grizzly.http.scheme}://${server.address}:${grizzly.http.port}/${server.servlet.context-path}

The above would have given following URI with default parameters: http://0.0.0.0:8080/

For more information regarding the grizzly properties, please go the the official documentation page.

How to use in your project

Example for Maven:

<dependency>
    <groupId>be.dabla</groupId>
    <artifactId>grizzly-spring-boot-starter</artifactId>
    <version>2.3</version>
</dependency>
<!-- Add following dependency to add JSP support in Grizzly -->
<dependency>
    <groupId>be.dabla</groupId>
    <artifactId>grizzly-spring-boot-jasper</artifactId>
    <version>2.3</version>
</dependency>
<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-web</artifactId>
    <version>2.1.7.RELEASE</version>
    <exclusions>
        <exclusion>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-tomcat</artifactId>
        </exclusion>
     </exclusions>
</dependency>

Maven artifact can be found on Maven Central.

Versions

Version
1.0