Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions features/com.gwtplugins.eclipse.suite.v3.feature/feature.xml
Original file line number Diff line number Diff line change
Expand Up @@ -177,4 +177,11 @@
version="4.2.0.qualifier"
unpack="false"/>

<plugin
id="com.gwtplugins.eclipse.jettylauncher"
download-size="0"
install-size="0"
version="4.2.0.qualifier"
unpack="false"/>

</feature>
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: Jettylauncher
Bundle-SymbolicName: com.gwtplugins.eclipse.jettylauncher
Bundle-Version: 4.2.0.qualifier
Automatic-Module-Name: org.gwtproject.jettylauncher
Bundle-RequiredExecutionEnvironment: JavaSE-17
4 changes: 4 additions & 0 deletions plugins/com.gwtplugins.eclipse.jettylauncher/build.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
source.. = src/java/
output.. = target/classes
bin.includes = META-INF/,\
.
134 changes: 134 additions & 0 deletions plugins/com.gwtplugins.eclipse.jettylauncher/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,134 @@
<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>
<groupId>com.gwtplugins.eclipse</groupId>
<artifactId>trunk</artifactId>
<version>4.2.0-SNAPSHOT</version>
<relativePath>../../</relativePath>
</parent>

<artifactId>com.gwtplugins.eclipse.jettylauncher</artifactId>
<version>4.2.0-SNAPSHOT</version>
<packaging>eclipse-plugin</packaging>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<java.version>11</java.version>
<maven.test.skip>true</maven.test.skip>
</properties>

<dependencies>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-server</artifactId>
<version>12.0.31</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.eclipse.jetty.ee10</groupId>
<artifactId>jetty-ee10-servlet</artifactId>
<version>12.0.31</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.eclipse.jetty.ee10</groupId>
<artifactId>jetty-ee10-webapp</artifactId>
<version>12.0.31</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.eclipse.jetty.ee8</groupId>
<artifactId>jetty-ee8-servlet</artifactId>
<version>12.0.31</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.eclipse.jetty.ee8</groupId>
<artifactId>jetty-ee8-webapp</artifactId>
<version>12.0.31</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.gwtproject</groupId>
<artifactId>gwt-dev</artifactId>
<version>2.12.2</version>
<scope>provided</scope>
</dependency>
</dependencies>

<build>
<pluginManagement>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>${java.version}</source>
<target>${java.version}</target>
</configuration>
<executions>
<execution>
<id>default-testCompile</id>
<phase>none</phase> <!-- Deaktiviert das
Test-Kompilieren -->
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.eclipse.tycho</groupId>
<artifactId>tycho-compiler-plugin</artifactId>
<version>${tycho.version}</version>
<configuration>
<extraClasspathElements>
<extraClasspathElement>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-server</artifactId>
<version>12.0.36</version> <!-- Version anpassen -->
</extraClasspathElement>
<extraClasspathElement>
<groupId>org.eclipse.jetty.ee8</groupId>
<artifactId>jetty-ee8-servlet</artifactId>
<version>12.0.36</version> <!-- Version anpassen -->
</extraClasspathElement>
<extraClasspathElement>
<groupId>org.eclipse.jetty.ee8</groupId>
<artifactId>jetty-ee8-webapp</artifactId>
<version>12.0.36</version>
</extraClasspathElement>
<extraClasspathElement>
<groupId>org.eclipse.jetty.ee10</groupId>
<artifactId>jetty-ee10-servlet</artifactId>
<version>12.0.36</version> <!-- Version anpassen -->
</extraClasspathElement>
<extraClasspathElement>
<groupId>org.eclipse.jetty.ee10</groupId>
<artifactId>jetty-ee10-webapp</artifactId>
<version>12.0.36</version>
</extraClasspathElement>
<extraClasspathElement>
<groupId>org.gwtproject</groupId>
<artifactId>gwt-dev</artifactId>
<version>2.12.2</version>
<exclusions>
<exclusion>
<groupId>xml-apis</groupId>
<artifactId>xml-apis</artifactId>
</exclusion>
<exclusion>
<groupId>xerces</groupId>
<artifactId>xercesImpl</artifactId>
</exclusion>
</exclusions>
</extraClasspathElement>
</extraClasspathElements>
<useProjectDependencies>true</useProjectDependencies>
<showWarnings>true</showWarnings>
</configuration>
</plugin>
</plugins>
</pluginManagement>
</build>

</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
package com.gwtplugins.jettylauncher;

import java.io.File;
import java.lang.reflect.Method;
import java.net.BindException;

import com.google.gwt.core.ext.ServletContainer;
import com.google.gwt.core.ext.ServletContainerLauncher;
import com.google.gwt.core.ext.TreeLogger;

/**
* Base class for the Jetty12Launchers.
*/
public abstract class AbstractJetty12Launcher extends ServletContainerLauncher {

@Override
public ServletContainer start(TreeLogger logger, int port, File appRootDir) throws BindException, Exception {
// A custom Classloader to separate the classes of the webapp and app server from the rest of the system.
Jetty12ClassLoader cl = new Jetty12ClassLoader(getJEEVersion());
Thread.currentThread().setContextClassLoader(cl);
//Load and run the Bootstrap in the context of the custom ClassLoader.
Class<?> bsClass = cl.loadClass(getBootstrapClassname());
Class<?>[] types = new Class[2];
types[0] = int.class;
types[1] = File.class;
Method method = bsClass.getDeclaredMethod("start", types);
Object[] params = new Object[2];
params[0] = port;
params[1] = appRootDir;
ServletContainer cont = (ServletContainer) method.invoke(null, params);
return cont;
}

/**
* The jee Version to load. If jee10 ist activated, the jee8 libraries will not be loaded.
* @return
*/
protected abstract JEEVersion getJEEVersion();

/**
* The name of the class that is used to separate the classloader from other eclipse classes.
* @return
*/
abstract protected String getBootstrapClassname();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
package com.gwtplugins.jettylauncher;

import java.io.File;
import org.eclipse.jetty.server.Handler;
import org.eclipse.jetty.server.Server;
import org.eclipse.jetty.server.ServerConnector;
import org.eclipse.jetty.server.handler.InetAccessHandler;
import org.eclipse.jetty.util.thread.QueuedThreadPool;

import com.google.gwt.core.ext.ServletContainer;
import com.google.gwt.core.ext.UnableToCompleteException;

public abstract class AbstractJetty12ServletContainer extends ServletContainer {

protected int port;
protected File appRootDir;

public AbstractJetty12ServletContainer(int port, File appRootDir)
{
super();
this.port = port;
this.appRootDir = appRootDir;
try
{
startServer(port);
}
catch (Exception e)
{
e.printStackTrace();
}
}

/**
* Create a Thread Pool for the Jetty Server
* @return
*/
protected QueuedThreadPool createThreadPool()
{
// Eigenen ThreadPool um Anzahl der Threads kontrollieren zu können
QueuedThreadPool pool = new QueuedThreadPool(50, 20)
{
@Override
public Thread newThread(Runnable runnable) {
// Threads markieren
Thread t = super.newThread(runnable);
t.setName("Jetty - " + t.getName());
return t;
}
};
return pool;
}

/**
* Starts the Jetty Server on the given Port.
* @param port
* @throws Exception
*/
public void startServer(int port) throws Exception
{
QueuedThreadPool pool = createThreadPool();
Server server = new Server(pool);
ServerConnector connector = new ServerConnector(server);
connector.setPort(port);
connector.setIdleTimeout(30000);
server.addConnector(connector);
InetAccessHandler ihandler = new InetAccessHandler();

Handler.Sequence shandler = createHandler();

ihandler.setHandler(shandler);
server.setHandler(ihandler);
server.start();
}

/**
* Create a WebAppContext
* @return
*/
abstract protected Handler.Sequence createHandler();

@Override
public int getPort()
{
return port;
}

@Override
public void refresh() throws UnableToCompleteException
{
}

@Override
public void stop() throws UnableToCompleteException
{
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package com.gwtplugins.jettylauncher;

/**
* JEE Versions. JEE8 for javax.servlet and JEE10 for jakarta.servlet
*/
public enum JEEVersion
{
JEE8
, JEE10
}
Loading
Loading