1 // 2 // ======================================================================== 3 // Copyright (c) 1995-2014 Mort Bay Consulting Pty. Ltd. 4 // ------------------------------------------------------------------------ 5 // All rights reserved. This program and the accompanying materials 6 // are made available under the terms of the Eclipse Public License v1.0 7 // and Apache License v2.0 which accompanies this distribution. 8 // 9 // The Eclipse Public License is available at 10 // http://www.eclipse.org/legal/epl-v10.html 11 // 12 // The Apache License v2.0 is available at 13 // http://www.opensource.org/licenses/apache2.0.php 14 // 15 // You may elect to redistribute this code under either of these licenses. 16 // ======================================================================== 17 // 18 19 package org.eclipse.jetty.server; 20 21 import java.util.Collection; 22 import java.util.List; 23 import java.util.concurrent.Executor; 24 25 import org.eclipse.jetty.io.ByteBufferPool; 26 import org.eclipse.jetty.io.EndPoint; 27 import org.eclipse.jetty.util.annotation.ManagedAttribute; 28 import org.eclipse.jetty.util.annotation.ManagedObject; 29 import org.eclipse.jetty.util.component.Graceful; 30 import org.eclipse.jetty.util.component.LifeCycle; 31 import org.eclipse.jetty.util.thread.Scheduler; 32 33 /** 34 * <p>A {@link Connector} accept connections and data from remote peers, 35 * and allows applications to send data to remote peers, by setting up 36 * the machinery needed to handle such tasks.</p> 37 */ 38 @ManagedObject("Connector Interface") 39 public interface Connector extends LifeCycle, Graceful 40 { 41 /** 42 * @return the {@link Server} instance associated with this {@link Connector} 43 */ 44 public Server getServer(); 45 46 /** 47 * @return the {@link Executor} used to submit tasks 48 */ 49 public Executor getExecutor(); 50 51 /** 52 * @return the {@link Scheduler} used to schedule tasks 53 */ 54 public Scheduler getScheduler(); 55 56 /** 57 * @return the {@link ByteBufferPool} to acquire buffers from and release buffers to 58 */ 59 public ByteBufferPool getByteBufferPool(); 60 61 /** 62 * @return the {@link ConnectionFactory} associated with the protocol name 63 */ 64 public ConnectionFactory getConnectionFactory(String nextProtocol); 65 66 67 public <T> T getConnectionFactory(Class<T> factoryType); 68 69 /** 70 * @return the default {@link ConnectionFactory} associated with the default protocol name 71 */ 72 public ConnectionFactory getDefaultConnectionFactory(); 73 74 public Collection<ConnectionFactory> getConnectionFactories(); 75 76 public List<String> getProtocols(); 77 78 /** 79 * @return the max idle timeout for connections in milliseconds 80 */ 81 @ManagedAttribute("maximum time a connection can be idle before being closed (in ms)") 82 public long getIdleTimeout(); 83 84 /** 85 * @return the underlying socket, channel, buffer etc. for the connector. 86 */ 87 public Object getTransport(); 88 89 /** 90 * @return immutable collection of connected endpoints 91 */ 92 public Collection<EndPoint> getConnectedEndPoints(); 93 94 95 /* ------------------------------------------------------------ */ 96 /** 97 * Get the connector name if set. 98 * <p>A {@link ContextHandler} may be configured with 99 * virtual hosts in the form "@connectorName" and will only serve 100 * requests from the named connector. 101 * @return The connector name or null. 102 */ 103 public String getName(); 104 }