Skip to content

Commit

Permalink
Bumped Glassfish HK2 to 2.6.1
Browse files Browse the repository at this point in the history
Signed-off-by: Alberto Codutti <alberto.codutti@eurotech.com>
  • Loading branch information
Coduz committed Jan 24, 2023
1 parent 4e049e1 commit 3ba306e
Show file tree
Hide file tree
Showing 8 changed files with 64 additions and 44 deletions.
1 change: 1 addition & 0 deletions assembly/broker/descriptors/kapua-broker.xml
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,7 @@
<include>org.glassfish.hk2:hk2-api</include>
<include>org.glassfish.hk2:hk2-locator</include>
<include>org.glassfish.hk2:hk2-utils</include>
<include>org.glassfish.jersey.bundles:jaxrs-ri</include>
<include>org.glassfish.jersey.core:jersey-client</include>
<include>org.glassfish.jersey.core:jersey-common</include>
<include>org.glassfish.jersey.ext:jersey-entity-filtering</include>
Expand Down
7 changes: 6 additions & 1 deletion assembly/broker/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
Red Hat Inc - initial API and implementation
Eurotech
-->
<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">
<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>
Expand Down Expand Up @@ -169,6 +170,10 @@
<groupId>org.glassfish.hk2</groupId>
<artifactId>hk2-utils</artifactId>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.bundles</groupId>
<artifactId>jaxrs-ri</artifactId>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.core</groupId>
<artifactId>jersey-client</artifactId>
Expand Down
4 changes: 4 additions & 0 deletions console/web/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,10 @@
<groupId>org.eclipse.kapua</groupId>
<artifactId>kapua-rest-api-core</artifactId>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.inject</groupId>
<artifactId>jersey-hk2</artifactId>
</dependency>
</dependencies>

<build>
Expand Down
16 changes: 13 additions & 3 deletions job-engine/app/web/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
Contributors:
Eurotech - initial API and implementation
-->
<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">
<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>
Expand Down Expand Up @@ -198,13 +199,22 @@
<groupId>org.apache.shiro</groupId>
<artifactId>shiro-web</artifactId>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
</dependency>

<dependency>
<groupId>org.glassfish.hk2</groupId>
<artifactId>hk2-api</artifactId>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.containers</groupId>
<artifactId>jersey-container-servlet-core</artifactId>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<groupId>org.glassfish.jersey.inject</groupId>
<artifactId>jersey-hk2</artifactId>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.media</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,8 @@
*******************************************************************************/
package org.eclipse.kapua.job.engine.app.web;

import java.util.HashMap;

import javax.ws.rs.core.MediaType;

import org.eclipse.kapua.commons.util.xml.XmlUtil;
import org.eclipse.kapua.job.engine.app.web.jaxb.JobEngineJAXBContextProvider;

import org.glassfish.hk2.api.ServiceLocator;
import org.glassfish.jersey.jackson.JacksonFeature;
import org.glassfish.jersey.server.ResourceConfig;
Expand All @@ -27,6 +22,9 @@
import org.glassfish.jersey.server.spi.Container;
import org.glassfish.jersey.server.spi.ContainerLifecycleListener;

import javax.ws.rs.core.MediaType;
import java.util.HashMap;

public class JobEngineApplication extends ResourceConfig {

public JobEngineApplication() {
Expand All @@ -45,7 +43,8 @@ public JobEngineApplication() {

@Override
public void onStartup(Container container) {
ServiceLocator serviceLocator = container.getApplicationHandler().getServiceLocator();
ServiceLocator serviceLocator = container.getApplicationHandler().getInjectionManager().getInstance(ServiceLocator.class);

JobEngineJAXBContextProvider provider = serviceLocator.createAndInitialize(JobEngineJAXBContextProvider.class);
XmlUtil.setContextProvider(provider);
}
Expand Down
17 changes: 9 additions & 8 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
Contributors:
Eurotech - initial API and implementation
-->
<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">
<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>

<groupId>org.eclipse.kapua</groupId>
Expand Down Expand Up @@ -58,7 +59,7 @@
<guava-listenablefuture.version>9999.0-empty-to-avoid-conflict-with-guava</guava-listenablefuture.version>
<guice.version>4.1.0</guice.version>
<h2.version>1.4.199</h2.version>
<hk2-api.version>2.5.0-b05</hk2-api.version>
<hk2-api.version>2.6.1</hk2-api.version>
<httpcomponents-asyncclient.version>4.1.5</httpcomponents-asyncclient.version>
<httpcomponents-client.version>4.5.13</httpcomponents-client.version>
<httpcomponents-core.version>4.4.15</httpcomponents-core.version>
Expand Down Expand Up @@ -336,7 +337,7 @@
</goals>
</pluginExecutionFilter>
<action>
<ignore />
<ignore/>
</action>
</pluginExecution>
<pluginExecution>
Expand All @@ -349,7 +350,7 @@
</goals>
</pluginExecutionFilter>
<action>
<ignore />
<ignore/>
</action>
</pluginExecution>
<pluginExecution>
Expand All @@ -362,7 +363,7 @@
</goals>
</pluginExecutionFilter>
<action>
<ignore />
<ignore/>
</action>
</pluginExecution>
<pluginExecution>
Expand All @@ -375,7 +376,7 @@
</goals>
</pluginExecutionFilter>
<action>
<ignore />
<ignore/>
</action>
</pluginExecution>
</pluginExecutions>
Expand Down Expand Up @@ -2520,8 +2521,8 @@
<url>https://github.com/eclipse/kapua.git</url>
<connection>scm:git:ssh://git@github.com/eclipse/kapua.git</connection>
<developerConnection>scm:git:ssh://git@github.com/eclipse/kapua.git</developerConnection>
<tag>HEAD</tag>
</scm>
<tag>HEAD</tag>
</scm>

<issueManagement>
<system>GitHub Issues</system>
Expand Down
32 changes: 15 additions & 17 deletions rest-api/web/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
Contributors:
Eurotech - initial API and implementation
-->
<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">
<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>
Expand All @@ -24,20 +25,6 @@
<packaging>war</packaging>

<dependencies>

<dependency>
<groupId>org.glassfish.hk2</groupId>
<artifactId>hk2-api</artifactId>
</dependency>
<dependency>
<groupId>jakarta.ws.rs</groupId>
<artifactId>jakarta.ws.rs-api</artifactId>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.bundles</groupId>
<artifactId>jaxrs-ri</artifactId>
</dependency>

<!-- Internal dependencies -->
<dependency>
<groupId>org.eclipse.kapua</groupId>
Expand Down Expand Up @@ -152,13 +139,24 @@
<artifactId>kapua-user-internal</artifactId>
</dependency>

<dependency>
<groupId>org.glassfish.hk2</groupId>
<artifactId>hk2-api</artifactId>
</dependency>

<!-- Jersey -->
<dependency>
<groupId>org.glassfish.jersey.bundles</groupId>
<artifactId>jaxrs-ri</artifactId>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.containers</groupId>
<artifactId>jersey-container-servlet-core</artifactId>
</dependency>

<!-- Moxy for object marshalling unmarshalling -->
<dependency>
<groupId>org.glassfish.jersey.inject</groupId>
<artifactId>jersey-hk2</artifactId>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.media</groupId>
<artifactId>jersey-media-moxy</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,28 +12,27 @@
*******************************************************************************/
package org.eclipse.kapua.app.api.web;

import java.util.HashMap;

import javax.ws.rs.core.MediaType;
import javax.xml.bind.JAXBException;

import org.eclipse.kapua.app.api.core.KapuaSerializableBodyWriter;
import org.eclipse.kapua.app.api.core.ListBodyWriter;
import org.eclipse.kapua.app.api.core.MoxyJsonConfigContextResolver;
import org.eclipse.kapua.commons.util.xml.XmlUtil;

import org.glassfish.hk2.api.ServiceLocator;
import org.glassfish.jersey.moxy.json.MoxyJsonFeature;
import org.glassfish.jersey.server.ResourceConfig;
import org.glassfish.jersey.server.ServerProperties;
import org.glassfish.jersey.server.filter.UriConnegFilter;
import org.glassfish.jersey.server.spi.Container;
import org.glassfish.jersey.server.spi.ContainerLifecycleListener;

import javax.ws.rs.core.MediaType;
import javax.xml.bind.JAXBException;
import java.util.HashMap;

public class RestApisApplication extends ResourceConfig {

public RestApisApplication() throws JAXBException {
packages("org.eclipse.kapua.app.api",
"org.eclipse.kapua.service");
"org.eclipse.kapua.service");

// Bind media type to resource extension
HashMap<String, MediaType> mappedMediaTypes = new HashMap<>();
Expand All @@ -42,18 +41,21 @@ public RestApisApplication() throws JAXBException {

property(ServerProperties.MEDIA_TYPE_MAPPINGS, mappedMediaTypes);
property(ServerProperties.WADL_FEATURE_DISABLE, true);

// Manually adding MOXyJSONFeature
register(MoxyJsonFeature.class);
register(MoxyJsonConfigContextResolver.class);
register(UriConnegFilter.class);
register(JaxbContextResolver.class);
register(RestApiJAXBContextProvider.class);
register(KapuaSerializableBodyWriter.class);
register(ListBodyWriter.class);
register(MoxyJsonConfigContextResolver.class);

register(new ContainerLifecycleListener() {

@Override
public void onStartup(Container container) {
ServiceLocator serviceLocator = container.getApplicationHandler().getServiceLocator();
ServiceLocator serviceLocator = container.getApplicationHandler().getInjectionManager().getInstance(ServiceLocator.class);

RestApiJAXBContextProvider provider = serviceLocator.createAndInitialize(RestApiJAXBContextProvider.class);
XmlUtil.setContextProvider(provider);
Expand Down

0 comments on commit 3ba306e

Please sign in to comment.