View Javadoc

    1   package org.codehaus.xfire.picocontainer;
    2
    3   import java.util.Iterator;
    4
    5   import org.apache.commons.logging.Log;
    6   import org.apache.commons.logging.LogFactory;
    7   import org.codehaus.xfire.service.Service;
    8   import org.codehaus.xfire.service.ServiceRegistry;
    9   import org.picocontainer.ComponentAdapter;
    10  import org.picocontainer.Parameter;
    11  import org.picocontainer.PicoContainer;
    12  import org.picocontainer.defaults.AbstractPicoVisitor;
    13
    14  /***
    15   * Looks for Services then register them on XFire.
    16   *
    17   * @author Jose Peleteiro <juzepeleteiro@intelli.biz>
    18   * @version $Revision$
    19   */
    20  public class XFireServiceRegisterVisitor
    21      extends AbstractPicoVisitor
    22  {
    23
    24      protected final Log log = LogFactory.getLog(XFireServiceRegisterVisitor.class);
    25
    26      private final ServiceRegistry serviceRegistry;
    27
    28      public XFireServiceRegisterVisitor(ServiceRegistry serviceRegistry)
    29      {
    30          this.serviceRegistry = serviceRegistry;
    31      }
    32
    33      public void visitContainer(final PicoContainer pico)
    34      {
    35          // Iterate over the container looking for services and register them.
    36          Iterator i = pico.getComponentInstancesOfType(Service.class).iterator();
    37          while (i.hasNext())
    38          {
    39              Service endpoint = (Service) i.next();
    40              serviceRegistry.register(endpoint);
    41
    42              if (log.isInfoEnabled())
    43              {
    44                  log.info("Service \"" + endpoint.getServiceInfo().getName() + "\" registred.");
    45              }
    46          }
    47      }
    48
    49      public void visitComponentAdapter(ComponentAdapter ca)
    50      {
    51          // Do nothing
    52      }
    53
    54      public void visitParameter(Parameter p)
    55      {
    56          // Do nothing
    57      }
    58
    59  }