You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by James Richardson <ja...@db.com> on 2005/01/10 12:45:03 UTC
Custom Socket Factory in 5.0.28
Hi,
I'm playing around with P2PSockets and thought it might be fun to plug
into tomcat.
I've written a (very trivial) class to implement the ServerSocketFactory
interface, but I'm not too sure how to make the Connector use it.
I read of a Factory element that goes within a Context element, but
couldn't find any more about it.
If anybody could point me in the right direction, would be much
appreciative.
Thanks!
James
package com.db.es.jxta.tomcat.connector;
import org.apache.catalina.net.ServerSocketFactory;
import org.p2psockets.P2PServerSocket;
import org.p2psockets.P2PNetwork;
import java.net.ServerSocket;
import java.net.InetAddress;
import java.io.IOException;
import java.security.KeyStoreException;
import java.security.NoSuchAlgorithmException;
import java.security.UnrecoverableKeyException;
import java.security.KeyManagementException;
import java.security.cert.CertificateException;
/**
* $Header$
*/
public class JxtaServerSocketFactory implements ServerSocketFactory {
protected static boolean initialised = false;
protected static synchronized void init() throws IOException {
if (!initialised) {
try {
P2PNetwork.signin();
initialised = true;
} catch (Exception e) {
throw new IOException(e.toString());
}
}
}
public ServerSocket createSocket(int port) throws IOException,
KeyStoreException, NoSuchAlgorithmException, CertificateException,
UnrecoverableKeyException, KeyManagementException {
init();
return new P2PServerSocket(port);
}
public ServerSocket createSocket(int port, int backlog) throws
IOException, KeyStoreException, NoSuchAlgorithmException,
CertificateException, UnrecoverableKeyException, KeyManagementException {
init();
return new P2PServerSocket(port, backlog);
}
public ServerSocket createSocket(int port, int backlog, InetAddress
ifAddress) throws IOException, KeyStoreException,
NoSuchAlgorithmException, CertificateException, UnrecoverableKeyException,
KeyManagementException {
init();
return new P2PServerSocket(port, backlog, ifAddress);
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org