tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "James Richardson" <james.richard...@db.com>
Subject Custom Socket Factory in 5.0.28
Date Mon, 10 Jan 2005 11:45:03 GMT

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


Mime
View raw message