}
public Connector createConnector(String address, int port,
String protocol) {
Connector connector = null;
if (address != null) {
/*
* InetAddress.toString() returns a string of the form
* "<hostname>/<literal_IP>". Get the latter part, so that the
* address can be parsed (back) into an InetAddress using
* InetAddress.getByName().
*/
int index = address.indexOf('/');
if (index != -1) {
address = address.substring(index + 1);
}
}
if (log.isDebugEnabled()) {
log.debug("Creating connector for address='" +
((address == null) ? "ALL" : address) +
"' port='" + port + "' protocol='" + protocol + "'");
}
try {
Class clazz =
Class.forName("org.apache.coyote.tomcat5.CoyoteConnector");
connector = (Connector) clazz.newInstance();
if (address != null) {
IntrospectionUtils.setProperty(connector, "address",
"" + address);
}
IntrospectionUtils.setProperty(connector, "port", "" + port);
if (protocol.equals("ajp")) {
IntrospectionUtils.setProperty
(connector, "protocolHandlerClassName",
"org.apache.jk.server.JkCoyoteHandler");
} else if (protocol.equals("memory")) {
IntrospectionUtils.setProperty
(connector, "protocolHandlerClassName",
"org.apache.coyote.memory.MemoryProtocolHandler");
} else if (protocol.equals("https")) {
connector.setScheme("https");
connector.setSecure(true);
try {
Class serverSocketFactoryClass = Class.forName
("org.apache.coyote.tomcat5.CoyoteServerSocketFactory");
ServerSocketFactory factory =
(ServerSocketFactory)
serverSocketFactoryClass.newInstance();
connector.setFactory(factory);
} catch (Exception e) {
log.error("Couldn't load SSL server socket factory.");
}
}