I try to port from jetty 10.x to jetty 12.x ee8. After I changed the dependencies according to this list https://download.eclipse.org/tools/orbit/simrel/maven-jetty/release/12.0.6/. I'm getting some compiler errors while using embedded jetty.
There seems to be no ee8 server
class, I use org.eclipse.jetty.server.server
. This class extends from org.eclipse.jetty.server.handler.wrapper
.
But the handler for jetty-ee8-nested
extends from org.eclipse.jetty.ee8.nested.handlerwrapper
, which is incompatible. For example org.eclipse.jetty.ee8.nested.inetaccesshandler
. One expects org.eclipse.jetty.server.handler
and the other org.eclipse.jetty.ee8.nested.handler
Is there another implementer of the server I oversee? Where can I find it? What about class names?
Or do I have to modify my code? For example, how do I change the following line?
InetAccessHandler ipaccess = new InetAccessHandler(); ipaccess.setHandler( getHandler() ); setHandler( ipaccess );
First, there is a migration guide from jetty 11 to jetty 12: https:// eclipse.dev/jetty/documentation/jetty-12/programming-guide/index.html#pg-migration-11-to-12
It shows many of the things you asked about.
Ignore Classes in the org.eclipse.jetty.ee8.nested.*
package, these are internal classes of the ee8 layer.
Use org.eclipse.jetty.server.handler.inetaccesshandler
.
You can wrap it around any handler, for example: org.eclipse.jetty.server.handler.sequence
, org.eclipse.jetty.ee8.webappwebappcontext
, etc. ...
InetAccessHandler inetAccessHandler = new InetAccessHandler(); // allow only http clients from localhost IPv4 or IPv6 inetAccessHandler.include("127.0.0.1", "::1"); server.setHandler(inetAccessHandler); Handler.Sequence handlers = new Handler.Sequence(); inetAccessHandler.setHandler(handlers); WebAppContext webapp = new WebAppContext(); webapp.setContextPath("/"); webapp.setWar(warPath.toUri().toASCIIString()); handlers.addHandler(webapp);
This snippet comes from https:// /github.com/jetty/jetty-examples/tree/12.0.x/embedded/ee8-webapp-context
The above is the detailed content of How to migrate from embedded jetty 10 to jetty 12 ee8?. For more information, please follow other related articles on the PHP Chinese website!