com.ibm.pvc.webcontainer.service
Interface SocketConfigService


public interface SocketConfigService

The Web Container registers an object implementing this service with the framework, under the name of this interface. Bundles can use this service to dynamically configure the Web Container transports (i.e ports) at runtime. A Web Container transport is a thread listening on a specified port.

Bundles should use a ServiceTracker to track the SocketConfigService object.

The following example shows how to :

  • Use a ServiceTracker to track the SocketConfigService
  • Invoke the startTransport method of SocketConfigService from the ServiceTracker
  • Invoke the stopTransport method of SocketConfigService from the ServiceTracker
            public class MyActivator implements BundleActivator
            {
                    private ServiceTracker myServiceTracker;
                    private BundleContext context;
    
                    public void start(BundleContext bc) throws Exception
                    {
                            context = bc;
                            myServiceTracker = new ServiceTracker(bc, SocketConfigService.class.getName(), new MyServiceTracker(context));
                            myServiceTracker.open();
                    }
    
                    public void stop(BundleContext bc) throws Exception
                    {
                            myServiceTracker.close();
                    }
            }
    
            public class MyServiceTracker implements ServiceTrackerCustomizer {
    
                    private BundleContext context = null;
                    private ServerSocket socket = null;
                    private SocketConfigService service = null;
    
                    public MyServiceTracker(BundleContext bc)
                    {
                            context = bc;
                    }
    
                    public Object addingService(ServiceReference reference)
                    {
                            service = (SocketConfigService) context.getService(reference);
                            if(service != null) {
                                    try {
                                            // create a ServerSocket
                                            socket = new ServerSocket(9999);
                                            // configure Web Container to listen on port 9999
                                            service.startTransport(socket);
                                    } catch (SocketConfigException sce) {
                                            // handle exception
                                    } catch (IOException ioe) {
                                            // handle exception
                                    } catch (SecurityException se) {
                                            // handle exception
                                    }
                            }
                    }
    
                    public void removedService(ServiceReference reference, Object service)
                    {
                            if(service != null) {
                                    // shutdown transport
                                    service.stopTransport(socket);
                            }
                    }
            }
     

    Since:
    Lotus Expeditor V6.1

    Method Summary
     void startTransport(java.net.ServerSocket socket)
              Start a Web Container transport with the specified server socket
     void stopTransport(java.net.ServerSocket socket)
              Stop the Web Container transport that was started using startTransport
     

    Method Detail

    startTransport

    public void startTransport(java.net.ServerSocket socket)
                        throws SocketConfigException
    Start a Web Container transport with the specified server socket

    Parameters:
    socket - a ServerSocket (NOTE: use a SSLServerSocket for secure communication)
    Throws:
    SocketConfigException - - if problem occurs during configuration

    stopTransport

    public void stopTransport(java.net.ServerSocket socket)
    Stop the Web Container transport that was started using startTransport

    Parameters:
    socket - a ServerSocket (NOTE: use the same socket used for startTransport)


    Copyright © 2005, 2008 IBM Corp. All Rights Reserved.