Skip to content

Commit

Permalink
wip with felix, stuck at jetty multiple connectors
Browse files Browse the repository at this point in the history
  • Loading branch information
salvatore-coppola committed Dec 18, 2024
1 parent 4f65695 commit 2fc6ebb
Show file tree
Hide file tree
Showing 11 changed files with 138 additions and 62 deletions.
52 changes: 26 additions & 26 deletions kura/distrib/src/main/ant/build_equinox_distrib.xml
Original file line number Diff line number Diff line change
Expand Up @@ -758,14 +758,34 @@ fi]]>
<param name="upgrader" value="true"/>
</antcall>
<antcall target="install-plugin">
<param name="bundle.file" value="org.apache.felix.http.jetty_${org.apache.felix.http.jetty.version}.jar" />
<param name="start.level" value="2" />
<param name="start" value="s" />
<param name="bundle.file" value="org.apache.felix.http.servlet-api_${org.apache.felix.http.servlet-api.version}.jar" />
<param name="start.level" value="5" />
<param name="start" value="" />
</antcall>
<antcall target="install-plugin">
<param name="bundle.file" value="org.apache.felix.http.servlet-api_${org.apache.felix.http.servlet-api.version}.jar" />
<param name="start.level" value="2" />
<param name="start" value="s" />
<param name="bundle.file" value="org.apache.felix.http.jetty12-light_${org.apache.felix.http.jetty12.version}.jar"/>
<param name="start.level" value="5"/>
<param name="start" value=""/>
</antcall>
<antcall target="install-plugin">
<param name="bundle.file" value="org.apache.felix.http.bridge_${org.apache.felix.http.bridge.version}.jar"/>
<param name="start.level" value="5"/>
<param name="start" value=""/>
</antcall>
<antcall target="install-plugin">
<param name="bundle.file" value="org.apache.felix.http.proxy_${org.apache.felix.http.proxy.version}.jar"/>
<param name="start.level" value="5"/>
<param name="start" value=""/>
</antcall>
<antcall target="install-plugin">
<param name="bundle.file" value="org.apache.felix.http.wrappers_${org.apache.felix.http.wrappers.version}.jar"/>
<param name="start.level" value="5"/>
<param name="start" value=""/>
</antcall>
<antcall target="install-plugin">
<param name="bundle.file" value="org.apache.felix.http.sslfilter_${org.apache.felix.http.sslfilter.version}.jar"/>
<param name="start.level" value="5"/>
<param name="start" value=""/>
</antcall>
<antcall target="install-plugin">
<param name="bundle.file" value="jersey-media-json-jackson_${org.glassfish.jersey.version}.jar" />
Expand Down Expand Up @@ -827,11 +847,6 @@ fi]]>
<param name="start.level" value="1" />
<param name="start" value="s" />
</antcall>
<antcall target="install-plugin">
<param name="bundle.file" value="org.eclipse.equinox.http.registry_${org.eclipse.equinox.http.registry.version}.jar" />
<param name="start.level" value="1" />
<param name="start" value="s" />
</antcall>
<antcall target="install-plugin">
<param name="bundle.file" value="org.eclipse.equinox.console_${org.eclipse.equinox.console.version}.jar" />
<param name="start.level" value="1" />
Expand Down Expand Up @@ -977,21 +992,6 @@ fi]]>
<param name="start.level" value="5" />
<param name="start" value="" />
</antcall>
<antcall target="install-plugin">
<param name="bundle.file" value="org.eclipse.equinox.http.jetty_${org.eclipse.equinox.http.jetty.version}.jar" />
<param name="start.level" value="5" />
<param name="start" value="" />
</antcall>
<antcall target="install-plugin">
<param name="bundle.file" value="org.eclipse.kura.jetty.customizer_${org.eclipse.kura.jetty.customizer.version}.jar" />
<param name="start.level" value="6" />
<param name="start" value="" />
</antcall>
<antcall target="install-plugin">
<param name="bundle.file" value="org.eclipse.equinox.http.servlet_${org.eclipse.equinox.http.servlet.version}.jar" />
<param name="start.level" value="5" />
<param name="start" value="s" />
</antcall>
<antcall target="install-plugin">
<param name="bundle.file" value="org.eclipse.jetty.ee8.jetty-ee8-security_${org.eclipse.jetty.version}.jar" />
<param name="start.level" value="5" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ Bundle-SymbolicName: org.eclipse.kura.http.server.manager
Bundle-Version: 2.0.0.qualifier
Require-Capability: osgi.ee;filter:="(&(osgi.ee=JavaSE)(version=1.8))"
Service-Component: OSGI-INF/*.xml
Import-Package: org.eclipse.equinox.http.jetty;version="1.5.0",
Import-Package: org.apache.felix.http.jetty;version="4.0.0",
org.eclipse.jetty.server;version="12.0.0",
org.eclipse.kura;version="[1.5,2.0)",
org.eclipse.kura.configuration;version="1.2.0",
org.eclipse.kura.crypto;version="[1.2,2.0)",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
/*******************************************************************************
* Copyright (c) 2024 Eurotech and/or its affiliates and others
*
* This program and the accompanying materials are made
* available under the terms of the Eclipse Public License 2.0
* which is available at https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* Eurotech
*******************************************************************************/

package org.eclipse.kura.http.server.manager;

import java.util.EnumSet;

import org.apache.felix.http.jetty.ConnectorFactory;
import org.eclipse.jetty.http.HttpMethod;
import org.eclipse.jetty.server.Connector;
import org.eclipse.jetty.server.HttpConfiguration;
import org.eclipse.jetty.server.HttpConnectionFactory;
import org.eclipse.jetty.server.Server;
import org.eclipse.jetty.server.ServerConnector;

public class HttpConnectorFactory implements ConnectorFactory {

private final int port;

public HttpConnectorFactory(int port) {
this.port = port;
}

@Override
public Connector createConnector(Server server) {
HttpConnectionFactory connFactory = new HttpConnectionFactory();
configureHttpConnectionFactory(connFactory);

ServerConnector connector = new ServerConnector(server, config.getAcceptors(), config.getSelectors(),
connFactory);

HttpConfiguration httpConfiguration = new HttpConfiguration();
httpConfiguration.addCustomizer(new BlockHttpMethods(EnumSet.of(HttpMethod.TRACE)));

for (final int port : ports) {
final ServerConnector newConnector = new ServerConnector(serverConnector.getServer(),
new HttpConnectionFactory(httpConfiguration));

customizeConnector(newConnector, port);
serverConnector.getServer().addConnector(newConnector);
}
}

}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2019, 2021 Eurotech and/or its affiliates and others
* Copyright (c) 2019, 2024 Eurotech and/or its affiliates and others
*
* This program and the accompanying materials are made
* available under the terms of the Eclipse Public License 2.0
Expand All @@ -25,8 +25,6 @@

import javax.net.ssl.KeyManager;

import org.eclipse.equinox.http.jetty.JettyConfigurator;
import org.eclipse.equinox.http.jetty.JettyConstants;
import org.eclipse.kura.KuraException;
import org.eclipse.kura.configuration.ConfigurableComponent;
import org.eclipse.kura.configuration.ConfigurationService;
Expand Down
10 changes: 6 additions & 4 deletions target-platform/config/kura.target-platform.build.properties
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,13 @@ quartz.version=2.3.2
org.apache.felix.dependencymanager.version=3.0.0
org.apache.felix.deploymentadmin.version=0.9.5
org.apache.felix.gogo.command.version=1.1.2
org.apache.felix.http.jetty.version=5.1.26

org.apache.felix.http.servlet-api.version=3.0.0
org.apache.felix.http.jetty12.version=1.0.2
org.apache.felix.http.bridge.version=5.1.6
org.apache.felix.http.proxy.version=4.0.0
org.apache.felix.http.wrappers.version=1.1.2
org.apache.felix.http.sslfilter.version=2.0.2
org.apache.felix.gogo.runtime.version=1.1.6
org.apache.felix.gogo.shell.version=1.1.4
org.apache.felix.scr.version=2.2.12
Expand All @@ -106,9 +111,6 @@ org.eclipse.equinox.common.version=3.19.100.v20240524-2011
org.eclipse.equinox.console.version=1.4.800.v20240513-1104
org.eclipse.equinox.ds.version=1.6.200.v20200422-1833
org.eclipse.equinox.event.version=1.7.100.v20240321-1445
org.eclipse.equinox.http.jetty.version=3.9.200.v20240321-1445
org.eclipse.equinox.http.registry.version=1.4.100.v20240321-1445
org.eclipse.equinox.http.servlet.version=1.8.200.v20240321-1445
org.eclipse.equinox.io.version=1.1.300
org.eclipse.equinox.launcher.version=1.6.900.v20240613-2009
org.eclipse.equinox.metatype.version=1.6.600.v20240513-1104
Expand Down
16 changes: 8 additions & 8 deletions target-platform/org.eclipse.kura.jetty.customizer/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -33,19 +33,19 @@

<dependencies>
<dependency>
<groupId>org.apache.felix</groupId>
<artifactId>org.apache.felix.http.servlet-api</artifactId>
<version>3.0.0</version>
<groupId>org.eclipse.platform</groupId>
<artifactId>org.eclipse.equinox.http.jetty</artifactId>
<version>3.9.200</version>
</dependency>
<dependency>
<groupId>org.apache.felix</groupId>
<artifactId>org.apache.felix.http.jetty</artifactId>
<version>5.1.26</version>
<artifactId>org.apache.felix.http.servlet-api</artifactId>
<version>3.0.0</version>
</dependency>
<dependency>
<groupId>org.eclipse.platform</groupId>
<artifactId>org.eclipse.equinox.http.jetty</artifactId>
<version>3.9.200</version>
<groupId>org.eclipse.jetty.ee8</groupId>
<artifactId>jetty-ee8-servlet</artifactId>
<version>12.0.14</version>
</dependency>
</dependencies>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,16 @@
import java.io.IOException;
import java.io.Writer;

import org.eclipse.jetty.server.handler.ErrorHandler;
import javax.servlet.http.HttpServletRequest;

import jakarta.servlet.http.HttpServletRequest;
import org.eclipse.jetty.ee8.nested.ErrorHandler;

public class KuraErrorHandler extends ErrorHandler {

@Override
protected void writeErrorPage(HttpServletRequest request, Writer writer, int code, String message,
boolean showStacks) throws IOException {
// Not needed
// do nothing
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@

import org.eclipse.equinox.http.jetty.JettyConstants;
import org.eclipse.equinox.http.jetty.JettyCustomizer;
import org.eclipse.jetty.ee8.servlet.ServletContextHandler;
import org.eclipse.jetty.http.HttpMethod;
import org.eclipse.jetty.http.HttpStatus;
import org.eclipse.jetty.server.ConnectionFactory;
Expand All @@ -49,13 +50,10 @@
import org.eclipse.jetty.server.ServerConnector;
import org.eclipse.jetty.server.SslConnectionFactory;
import org.eclipse.jetty.server.handler.gzip.GzipHandler;
import org.eclipse.jetty.servlet.ServletContextHandler;
import org.eclipse.jetty.util.compression.CompressionPool;
import org.eclipse.jetty.util.compression.DeflaterPool;
import org.eclipse.jetty.util.ssl.SslContextFactory;

import jakarta.servlet.SessionCookieConfig;

public class KuraJettyCustomizer extends JettyCustomizer {

private DeflaterPool deflaterPool = new DeflaterPool(CompressionPool.DEFAULT_CAPACITY, Deflater.BEST_COMPRESSION,
Expand Down
6 changes: 0 additions & 6 deletions target-platform/p2-repo-common/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -518,11 +518,6 @@
<artifactId>org.apache.activemq.artemis</artifactId>
<version>${org.apache.activemq.artemis.version}</version>
</artifactItem>
<artifactItem>
<groupId>org.eclipse.kura</groupId>
<artifactId>org.eclipse.kura.jetty.customizer</artifactId>
<version>${org.eclipse.kura.jetty.customizer.version}</version>
</artifactItem>
<artifactItem>
<groupId>jakarta.xml.bind</groupId>
<artifactId>jakarta.xml.bind-api</artifactId>
Expand Down Expand Up @@ -648,7 +643,6 @@
<move file="target/source/plugins/org.eclipse.paho.client.mqttv3.jar" tofile="target/source/plugins/org.eclipse.paho.client.mqttv3_${org.eclipse.paho.client.mqttv3.version}.jar"/>
<move file="target/source/plugins/org.eclipse.kura.camel.sun.misc.jar" tofile="target/source/plugins/org.eclipse.kura.camel.sun.misc_${org.eclipse.kura.camel.sun.misc.version}.jar"/>
<move file="target/source/plugins/org.eclipse.kura.sun.misc.jar" tofile="target/source/plugins/org.eclipse.kura.sun.misc_${org.eclipse.kura.sun.misc.version}.jar"/>
<move file="target/source/plugins/org.eclipse.kura.jetty.customizer.jar" tofile="target/source/plugins/org.eclipse.kura.jetty.customizer_${org.eclipse.kura.jetty.customizer.version}.jar"/>
<move file="target/source/plugins/org.tigris.mtoolkit.iagent.rpc.jar" tofile="target/source/plugins/org.tigris.mtoolkit.iagent.rpc_${org.tigris.mtoolkit.iagent.rpc.version}.jar"/>
<move file="target/source/plugins/com.gwt.user.jar" tofile="target/source/plugins/com.gwt.user_${com.gwt.user.version}.jar"/>
<move file="target/source/plugins/org.hamcrest.core.jar" tofile="target/source/plugins/org.hamcrest.core_${org.hamcrest.core.version}.jar"/>
Expand Down
44 changes: 37 additions & 7 deletions target-platform/p2-repo-equinox/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -56,16 +56,38 @@
<groupId>org.apache.felix</groupId>
<artifactId>org.apache.felix.deploymentadmin</artifactId>
<version>${org.apache.felix.deploymentadmin.version}</version>
</artifactItem>>
<artifactItem>
<groupId>org.apache.felix</groupId>
<artifactId>org.apache.felix.http.servlet-api</artifactId>
<version>${org.apache.felix.http.servlet-api.version}</version>
</artifactItem>

<artifactItem>
<groupId>org.apache.felix</groupId>
<artifactId>org.apache.felix.http.jetty</artifactId>
<version>${org.apache.felix.http.jetty.version}</version>
<artifactId>org.apache.felix.http.jetty12</artifactId>
<classifier>light</classifier>
<version>${org.apache.felix.http.jetty12.version}</version>
</artifactItem>
<artifactItem>
<groupId>org.apache.felix</groupId>
<artifactId>org.apache.felix.http.servlet-api</artifactId>
<version>${org.apache.felix.http.servlet-api.version}</version>
<artifactId>org.apache.felix.http.bridge</artifactId>
<version>${org.apache.felix.http.bridge.version}</version>
</artifactItem>
<artifactItem>
<groupId>org.apache.felix</groupId>
<artifactId>org.apache.felix.http.proxy</artifactId>
<version>${org.apache.felix.http.proxy.version}</version>
</artifactItem>
<artifactItem>
<groupId>org.apache.felix</groupId>
<artifactId>org.apache.felix.http.wrappers</artifactId>
<version>${org.apache.felix.http.wrappers.version}</version>
</artifactItem>
<artifactItem>
<groupId>org.apache.felix</groupId>
<artifactId>org.apache.felix.http.sslfilter</artifactId>
<version>${org.apache.felix.http.sslfilter.version}</version>
</artifactItem>
<artifactItem>
<groupId>org.knowhowlab.osgi</groupId>
Expand Down Expand Up @@ -269,7 +291,7 @@
<exclude name="plugins/org.eclipse.equinox.security*.jar" />
<exclude name="plugins/org.eclipse.equinox.console.ssh*.jar" />
<exclude name="plugins/org.eclipse.equinox.simpleconfig*.jar" />
<exclude name="plugins/org.eclipse.equinox.http.servletbridge*.jar" />
<exclude name="plugins/org.eclipse.equinox.http.*.jar" />>

<include name="plugins/org.eclipse.equinox.launcher_*.jar" />
<include name="plugins/org.eclipse.equinox.launcher.source_*.jar" />
Expand Down Expand Up @@ -366,10 +388,18 @@
<move file="${project.build.directory}/source/plugins/jackson-databind.jar"
tofile="${project.build.directory}/source/plugins/jackson-databind_${com.fasterxml.jackson.version}.jar" />

<move file="${project.build.directory}/source/plugins/org.apache.felix.http.jetty.jar"
tofile="${project.build.directory}/source/plugins/org.apache.felix.http.jetty_${org.apache.felix.http.jetty.version}.jar" />
<move file="${project.build.directory}/source/plugins/org.apache.felix.http.servlet-api.jar"
tofile="${project.build.directory}/source/plugins/org.apache.felix.http.servlet-api_${org.apache.felix.http.servlet-api.version}.jar" />
<move file="${project.build.directory}/source/plugins/org.apache.felix.http.jetty12-light.jar"
tofile="${project.build.directory}/source/plugins/org.apache.felix.http.jetty12-light_${org.apache.felix.http.jetty12.version}.jar" />
<move file="${project.build.directory}/source/plugins/org.apache.felix.http.bridge.jar"
tofile="${project.build.directory}/source/plugins/org.apache.felix.http.bridge_${org.apache.felix.http.bridge.version}.jar" />
<move file="${project.build.directory}/source/plugins/org.apache.felix.http.proxy.jar"
tofile="${project.build.directory}/source/plugins/org.apache.felix.http.proxy_${org.apache.felix.http.proxy.version}.jar" />
<move file="${project.build.directory}/source/plugins/org.apache.felix.http.wrappers.jar"
tofile="${project.build.directory}/source/plugins/org.apache.felix.http.wrappers_${org.apache.felix.http.wrappers.version}.jar" />
<move file="${project.build.directory}/source/plugins/org.apache.felix.http.sslfilter.jar"
tofile="${project.build.directory}/source/plugins/org.apache.felix.http.sslfilter_${org.apache.felix.http.sslfilter.version}.jar" />
</target>
</configuration>
</execution>
Expand Down
1 change: 0 additions & 1 deletion target-platform/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@
<module>com.gwt.user</module>
<module>moquette-broker</module>
<module>log4j2-api-config</module>
<module>org.eclipse.kura.jetty.customizer</module>
<module>p2-repo-common</module>
<module>p2-repo-equinox</module>
<module>p2-repo-test-deps</module>
Expand Down

0 comments on commit 2fc6ebb

Please sign in to comment.