View Javadoc

1   package org.lsst.ccs.bus;
2   
3   import java.util.ArrayList;
4   import java.util.ServiceLoader;
5   
6   /**
7    */
8   public abstract class TransportManager {
9       static ArrayList<TransportManager> transportManagers = new ArrayList<TransportManager>() ;
10      
11      static {
12          ServiceLoader<TransportManager> loader = ServiceLoader.load(TransportManager.class) ;
13          for(TransportManager transportManager : loader) {
14              transportManagers.add(transportManager) ;
15          }
16      }
17  
18      public static BusMessagingLayer getConnection(String protocolstring, String propertiesString) 
19          throws TransportException{
20          for(TransportManager manager : transportManagers) {
21              BusMessagingLayer transport = manager.getInstance(protocolstring, propertiesString) ;
22              if(transport != null) {
23                   // see new version of BusApplicationLayer
24                  // transport.setMembershipListener(new DefaultLogMembershipListener());
25                  return transport ;
26              }
27          }
28          throw new TransportException(protocolstring) ;
29      }
30      
31      public abstract BusMessagingLayer getInstance(String protocolString, String propertiesString) ;
32  }