View Javadoc

    1   package org.codehaus.xfire.plexus;
    2
    3   import org.codehaus.plexus.component.repository.exception.ComponentLookupException;
    4   import org.codehaus.plexus.personality.plexus.lifecycle.phase.ServiceLocator;
    5   import org.codehaus.plexus.personality.plexus.lifecycle.phase.Serviceable;
    6   import org.codehaus.xfire.DefaultXFire;
    7   import org.codehaus.xfire.XFireRuntimeException;
    8   import org.codehaus.xfire.service.ServiceRegistry;
    9   import org.codehaus.xfire.transport.TransportManager;
    10
    11  /***
    12   * An instance of XFire that is managed by Plexus.
    13   *
    14   * @author <a href="mailto:dan@envoisolutions.com">Dan Diephouse</a>
    15   * @since Sep 19, 2004
    16   */
    17  public class PlexusXFire
    18          extends DefaultXFire
    19          implements Serviceable
    20  {
    21      private ServiceLocator locator;
    22
    23      public PlexusXFire()
    24      {
    25          super();
    26      }
    27
    28      public ServiceRegistry getServiceRegistry()
    29      {
    30          try
    31          {
    32              return (ServiceRegistry) locator.lookup(ServiceRegistry.ROLE);
    33          }
    34          catch (ComponentLookupException e)
    35          {
    36              throw new XFireRuntimeException("Couldn't find component.", e);
    37          }
    38      }
    39
    40      public TransportManager getTransportManager()
    41      {
    42          try
    43          {
    44              return (TransportManager) locator.lookup(TransportManager.ROLE);
    45          }
    46          catch (ComponentLookupException e)
    47          {
    48              throw new XFireRuntimeException("Couldn't find component.", e);
    49          }
    50      }
    51
    52      /***
    53       * @see org.codehaus.plexus.personality.plexus.lifecycle.phase.Serviceable#service(org.codehaus.plexus.personality.plexus.lifecycle.phase.ServiceLocator)
    54       */
    55      public void service(ServiceLocator locator)
    56      {
    57          this.locator = locator;
    58      }
    59  }