View Javadoc

    1   package org.codehaus.xfire.transport;
    2
    3   import java.util.HashMap;
    4   import java.util.Iterator;
    5   import java.util.List;
    6   import java.util.Map;
    7
    8   import org.codehaus.xfire.handler.AbstractHandlerSupport;
    9   import org.codehaus.xfire.util.UID;
    10
    11  /***
    12   * @author <a href="mailto:dan@envoisolutions.com">Dan Diephouse</a>
    13   * @since Dec 21, 2004
    14   */
    15  public abstract class AbstractTransport
    16      extends AbstractHandlerSupport
    17      implements Transport
    18  {
    19      private List inHandlers;
    20      private List outHandlers;
    21      private List faultHandlers;
    22
    23      private Map/*<String uri,Channel c>*/ channels = new HashMap();
    24
    25      /***
    26       * Disposes all the existing channels.
    27       */
    28      public void dispose()
    29      {
    30          for (Iterator itr = channels.values().iterator(); itr.hasNext();)
    31          {
    32              Channel channel = (Channel) itr.next();
    33              channel.close();
    34          }
    35      }
    36
    37      public Channel createChannel() throws Exception
    38      {
    39          return createChannel(getUriPrefix() + UID.generate());
    40      }
    41
    42      public Channel createChannel(String uri) throws Exception
    43      {
    44          Channel c = (Channel) channels.get(uri);
    45
    46          if (c == null)
    47          {
    48              c = createNewChannel(uri);
    49
    50              channels.put(c.getUri(), c);
    51
    52              c.open();
    53          }
    54
    55          return c;
    56      }
    57
    58      protected Map getChannelMap()
    59      {
    60          return channels;
    61      }
    62
    63      protected abstract Channel createNewChannel(String uri);
    64      protected abstract String getUriPrefix();
    65  }