/** * Return the server socket factory used by this Container. */ public ServerSocketFactory getFactory() { if (this.factory == null) { synchronized (this) { this.factory = new DefaultServerSocketFactory(); } } return (this.factory); }
/** * Open and return the server socket for this Connector. If an IP * address has been specified, the socket will be opened only on that * address; otherwise it will be opened on all addresses. * * @exception IOException input/output or network error * @exception KeyStoreException error instantiating the * KeyStore from file (SSL only) * @exception NoSuchAlgorithmException KeyStore algorithm unsupported * by current provider (SSL only) * @exception CertificateException general certificate error (SSL only) * @exception UnrecoverableKeyException internal KeyStore problem with * the certificate (SSL only) * @exception KeyManagementException problem in the key management * layer (SSL only) */ private ServerSocket open() throws IOException, KeyStoreException, NoSuchAlgorithmException, CertificateException, UnrecoverableKeyException, KeyManagementException { // Acquire the server socket factory for this Connector ServerSocketFactory factory = getFactory(); // If no address is specified, open a connection on all addresses if (address == null) { log(sm.getString("httpConnector.allAddresses")); return (factory.createSocket(port, acceptCount)); } // Open a server socket on the specified address InetAddress[] addresses = InetAddress.getAllByName(InetAddress.getLocalHost().getHostName()); int i; for (i = 0; i < addresses.length; i++) { if (addresses[i].getHostAddress().equals(address)) break; } if (i < addresses.length) { log(sm.getString("httpConnector.anAddress", address)); return (factory.createSocket(port, acceptCount, addresses[i])); } else { log(sm.getString("httpConnector.noAddress", address)); return (factory.createSocket(port, acceptCount)); } }
/** * Store the specified ServerSocketFactory properties. * * @param writer PrintWriter to which we are storing * @param indent Number of spaces to indent this element * @param factory Object whose properties are being stored * * @exception Exception if an exception occurs while storing */ private void storeFactory(PrintWriter writer, int indent, ServerSocketFactory factory) throws Exception { for (int i = 0; i < indent; i++) { writer.print(' '); } writer.print("<Factory"); storeAttributes(writer, factory); writer.println("/>"); }
/** * Store the specified Connector properties. * * @param writer PrintWriter to which we are storing * @param indent Number of spaces to indent this element * @param connector Object whose properties are being stored * * @exception Exception if an exception occurs while storing */ private void storeConnector(PrintWriter writer, int indent, Connector connector) throws Exception { // Store the beginning of this element for (int i = 0; i < indent; i++) { writer.print(' '); } writer.print("<Connector"); storeAttributes(writer, connector); writer.println(">"); // Store nested <Factory> element ServerSocketFactory factory = connector.getFactory(); if (factory != null) { storeFactory(writer, indent + 2, factory); } // Store nested <Listener> elements if (connector instanceof Lifecycle) { LifecycleListener listeners[] = ((Lifecycle) connector).findLifecycleListeners(); if (listeners == null) { listeners = new LifecycleListener[0]; } for (int i = 0; i < listeners.length; i++) { if (listeners[i].getClass().getName().equals (SERVER_LISTENER_CLASS_NAME)) { continue; } storeListener(writer, indent + 2, listeners[i]); } } // Store the ending of this element for (int i = 0; i < indent; i++) { writer.print(' '); } writer.println("</Connector>"); }
@Override public ServerSocketFactory getFactory() { // TODO Auto-generated method stub return null; }
@Override public void setFactory(ServerSocketFactory factory) { // TODO Auto-generated method stub }
/** * Set the server socket factory used by this Container. * * @param factory The new server socket factory */ public void setFactory(ServerSocketFactory factory) { this.factory = factory; }
/** * Return the server socket factory used by this Container. */ public ServerSocketFactory getFactory();
/** * Set the server socket factory used by this Container. * * @param factory The new server socket factory */ public void setFactory(ServerSocketFactory factory);