forked from eclipse-ee4j/jersey
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Maxim Nesen <maxim.nesen@oracle.com>
- Loading branch information
Showing
12 changed files
with
1,055 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,104 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!-- | ||
Copyright (c) 2024 Oracle and/or its affiliates. All rights reserved. | ||
This program and the accompanying materials are made available under the | ||
terms of the Eclipse Public License v. 2.0, which is available at | ||
http://www.eclipse.org/legal/epl-2.0. | ||
This Source Code may also be made available under the following Secondary | ||
Licenses when the conditions for such availability set forth in the | ||
Eclipse Public License v. 2.0 are satisfied: GNU General Public License, | ||
version 2 with the GNU Classpath Exception, which is available at | ||
https://www.gnu.org/software/classpath/license.html. | ||
SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 | ||
--> | ||
|
||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<parent> | ||
<artifactId>project</artifactId> | ||
<groupId>org.glassfish.jersey.containers</groupId> | ||
<version>3.1.99-SNAPSHOT</version> | ||
</parent> | ||
|
||
<artifactId>jersey-container-helidon</artifactId> | ||
<packaging>jar</packaging> | ||
<name>jersey-container-helidon</name> | ||
|
||
<description>Helidon Http Container</description> | ||
|
||
<properties> | ||
<java11.build.outputDirectory>${project.basedir}/target</java11.build.outputDirectory> | ||
<java11.sourceDirectory>${project.basedir}/src/main/java11</java11.sourceDirectory> | ||
<java17.build.outputDirectory>${project.basedir}/target17</java17.build.outputDirectory> | ||
<java17.sourceDirectory>${project.basedir}/src/main/java17</java17.sourceDirectory> | ||
</properties> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>jakarta.inject</groupId> | ||
<artifactId>jakarta.inject-api</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>jakarta.activation</groupId> | ||
<artifactId>jakarta.activation-api</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>io.helidon.webserver</groupId> | ||
<artifactId>helidon-webserver</artifactId> | ||
<version>4.0.9</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>io.helidon.tracing</groupId> | ||
<artifactId>helidon-tracing</artifactId> | ||
<version>4.0.9</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>io.helidon.http</groupId> | ||
<artifactId>helidon-http</artifactId> | ||
<version>4.0.9</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.slf4j</groupId> | ||
<artifactId>slf4j-api</artifactId> | ||
<version>${slf4j.version}</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>jakarta.servlet</groupId> | ||
<artifactId>jakarta.servlet-api</artifactId> | ||
<scope>provided</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.hamcrest</groupId> | ||
<artifactId>hamcrest</artifactId> | ||
<scope>test</scope> | ||
</dependency> | ||
</dependencies> | ||
|
||
<build> | ||
<plugins> | ||
<plugin> | ||
<groupId>com.sun.istack</groupId> | ||
<artifactId>istack-commons-maven-plugin</artifactId> | ||
<inherited>true</inherited> | ||
</plugin> | ||
<plugin> | ||
<groupId>org.codehaus.mojo</groupId> | ||
<artifactId>build-helper-maven-plugin</artifactId> | ||
<inherited>true</inherited> | ||
</plugin> | ||
</plugins> | ||
|
||
<resources> | ||
<resource> | ||
<directory>${basedir}/src/main/resources</directory> | ||
<filtering>true</filtering> | ||
</resource> | ||
</resources> | ||
</build> | ||
</project> |
112 changes: 112 additions & 0 deletions
112
containers/helidon/src/main/java/org/glassfish/jersey/helidon/HelidonHttpContainer.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,112 @@ | ||
/* | ||
* Copyright (c) 2024 Oracle and/or its affiliates. All rights reserved. | ||
* | ||
* This program and the accompanying materials are made available under the | ||
* terms of the Eclipse Public License v. 2.0, which is available at | ||
* http://www.eclipse.org/legal/epl-2.0. | ||
* | ||
* This Source Code may also be made available under the following Secondary | ||
* Licenses when the conditions for such availability set forth in the | ||
* Eclipse Public License v. 2.0 are satisfied: GNU General Public License, | ||
* version 2 with the GNU Classpath Exception, which is available at | ||
* https://www.gnu.org/software/classpath/license.html. | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 | ||
*/ | ||
|
||
package org.glassfish.jersey.helidon; | ||
|
||
import io.helidon.common.context.Context; | ||
import io.helidon.common.tls.Tls; | ||
import io.helidon.webserver.WebServer; | ||
import io.helidon.webserver.WebServerConfig; | ||
import io.helidon.webserver.http.HttpRouting; | ||
import jakarta.ws.rs.core.Application; | ||
import org.glassfish.jersey.server.ApplicationHandler; | ||
import org.glassfish.jersey.server.ResourceConfig; | ||
import org.glassfish.jersey.server.spi.Container; | ||
|
||
public class HelidonHttpContainer implements Container, WebServer { | ||
|
||
private final WebServer webServer; | ||
|
||
private ApplicationHandler applicationHandler; | ||
|
||
HelidonHttpContainer(Application application) { | ||
this.applicationHandler = new ApplicationHandler(application, new WebServerBinder()); | ||
this.webServer = WebServer.builder().port(8080).routing( | ||
HttpRouting.builder().register( | ||
JerseySupport.create(this) | ||
)).build(); | ||
} | ||
|
||
@Override | ||
public ResourceConfig getConfiguration() { | ||
return applicationHandler.getConfiguration(); | ||
} | ||
|
||
@Override | ||
public ApplicationHandler getApplicationHandler() { | ||
return applicationHandler; | ||
} | ||
|
||
@Override | ||
public void reload() { | ||
reload(new ResourceConfig(getConfiguration())); | ||
} | ||
|
||
@Override | ||
public void reload(ResourceConfig configuration) { | ||
applicationHandler.onShutdown(this); | ||
|
||
applicationHandler = new ApplicationHandler(configuration); | ||
applicationHandler.onReload(this); | ||
applicationHandler.onStartup(this); | ||
if (webServer.isRunning()) { | ||
webServer.stop(); | ||
webServer.start(); | ||
} | ||
} | ||
|
||
@Override | ||
public WebServer start() { | ||
webServer.start(); | ||
return this; | ||
} | ||
|
||
@Override | ||
public WebServer stop() { | ||
webServer.stop(); | ||
return this; | ||
} | ||
|
||
@Override | ||
public boolean isRunning() { | ||
return webServer.isRunning(); | ||
} | ||
|
||
@Override | ||
public int port(String socketName) { | ||
return webServer.port(socketName); | ||
} | ||
|
||
@Override | ||
public Context context() { | ||
return webServer.context(); | ||
} | ||
|
||
@Override | ||
public boolean hasTls(String socketName) { | ||
return webServer.hasTls(socketName); | ||
} | ||
|
||
@Override | ||
public void reloadTls(String socketName, Tls tls) { | ||
webServer.reloadTls(socketName, tls); | ||
} | ||
|
||
@Override | ||
public WebServerConfig prototype() { | ||
return webServer.prototype(); | ||
} | ||
} |
32 changes: 32 additions & 0 deletions
32
...iners/helidon/src/main/java/org/glassfish/jersey/helidon/HelidonHttpContainerFactory.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
/* | ||
* Copyright (c) 2024 Oracle and/or its affiliates. All rights reserved. | ||
* | ||
* This program and the accompanying materials are made available under the | ||
* terms of the Eclipse Public License v. 2.0, which is available at | ||
* http://www.eclipse.org/legal/epl-2.0. | ||
* | ||
* This Source Code may also be made available under the following Secondary | ||
* Licenses when the conditions for such availability set forth in the | ||
* Eclipse Public License v. 2.0 are satisfied: GNU General Public License, | ||
* version 2 with the GNU Classpath Exception, which is available at | ||
* https://www.gnu.org/software/classpath/license.html. | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 | ||
*/ | ||
|
||
package org.glassfish.jersey.helidon; | ||
|
||
import io.helidon.webserver.WebServer; | ||
import org.glassfish.jersey.server.ResourceConfig; | ||
|
||
import java.net.URI; | ||
|
||
public class HelidonHttpContainerFactory { | ||
|
||
private HelidonHttpContainerFactory() { | ||
} | ||
|
||
public static WebServer createServer(URI baseUri, ResourceConfig config) { | ||
return new HelidonHttpContainer(config); | ||
} | ||
} |
32 changes: 32 additions & 0 deletions
32
...ners/helidon/src/main/java/org/glassfish/jersey/helidon/HelidonHttpContainerProvider.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
/* | ||
* Copyright (c) 2024 Oracle and/or its affiliates. All rights reserved. | ||
* | ||
* This program and the accompanying materials are made available under the | ||
* terms of the Eclipse Public License v. 2.0, which is available at | ||
* http://www.eclipse.org/legal/epl-2.0. | ||
* | ||
* This Source Code may also be made available under the following Secondary | ||
* Licenses when the conditions for such availability set forth in the | ||
* Eclipse Public License v. 2.0 are satisfied: GNU General Public License, | ||
* version 2 with the GNU Classpath Exception, which is available at | ||
* https://www.gnu.org/software/classpath/license.html. | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 | ||
*/ | ||
|
||
package org.glassfish.jersey.helidon; | ||
|
||
import io.helidon.webserver.WebServer; | ||
import jakarta.ws.rs.ProcessingException; | ||
import jakarta.ws.rs.core.Application; | ||
import org.glassfish.jersey.server.spi.ContainerProvider; | ||
|
||
public class HelidonHttpContainerProvider implements ContainerProvider { | ||
@Override | ||
public <T> T createContainer(Class<T> type, Application application) throws ProcessingException { | ||
if (type != WebServer.class && type != HelidonHttpContainer.class) { | ||
return null; | ||
} | ||
return type.cast(new HelidonHttpContainer(application)); | ||
} | ||
} |
Oops, something went wrong.