1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package org.eclipse.jetty.alpn.server;
20
21 import java.util.List;
22
23 import javax.net.ssl.SSLEngine;
24
25 import org.eclipse.jetty.alpn.ALPN;
26 import org.eclipse.jetty.io.AbstractConnection;
27 import org.eclipse.jetty.io.EndPoint;
28 import org.eclipse.jetty.server.Connector;
29 import org.eclipse.jetty.server.NegotiatingServerConnectionFactory;
30 import org.eclipse.jetty.util.annotation.Name;
31 import org.eclipse.jetty.util.log.Log;
32 import org.eclipse.jetty.util.log.Logger;
33
34 public class ALPNServerConnectionFactory extends NegotiatingServerConnectionFactory
35 {
36 private static final Logger LOG = Log.getLogger(ALPNServerConnectionFactory.class);
37
38 public ALPNServerConnectionFactory(String protocols)
39 {
40 this(protocols.trim().split(",", 0));
41 }
42
43 public ALPNServerConnectionFactory(@Name("protocols") String... protocols)
44 {
45 super("alpn", protocols);
46 try
47 {
48 ClassLoader alpnClassLoader = ALPN.class.getClassLoader();
49 if (alpnClassLoader != null)
50 {
51 LOG.warn("ALPN must be in the boot classloader, not in: " + alpnClassLoader);
52 throw new IllegalStateException("ALPN must be in the boot classloader");
53 }
54 }
55 catch (Throwable x)
56 {
57 LOG.warn("ALPN not available", x);
58 throw new IllegalStateException("ALPN not available", x);
59 }
60 }
61
62 @Override
63 protected AbstractConnection newServerConnection(Connector connector, EndPoint endPoint, SSLEngine engine, List<String> protocols, String defaultProtocol)
64 {
65 return new ALPNServerConnection(connector, endPoint, engine, protocols, defaultProtocol);
66 }
67 }