View Javadoc

    1   package org.codehaus.xfire.loom;
    2
    3   import java.net.URL;
    4   import java.util.Map;
    5
    6   import org.apache.avalon.framework.activity.Initializable;
    7   import org.apache.avalon.framework.logger.AbstractLogEnabled;
    8   import org.apache.avalon.framework.service.ServiceException;
    9   import org.apache.avalon.framework.service.ServiceManager;
    10  import org.apache.avalon.framework.service.Serviceable;
    11  import org.codehaus.xfire.aegis.AegisBindingProvider;
    12  import org.codehaus.xfire.aegis.type.TypeMappingRegistry;
    13  import org.codehaus.xfire.service.Service;
    14  import org.codehaus.xfire.service.ServiceFactory;
    15  import org.codehaus.xfire.service.binding.ObjectServiceFactory;
    16  import org.codehaus.xfire.transport.TransportManager;
    17
    18  /***
    19   * Default implementation of a ServiceFactory
    20   *
    21   * @author <a href="mailto:peter.royal@pobox.com">peter royal</a>
    22   */
    23  public class DefaultServiceFactory
    24          extends AbstractLogEnabled
    25          implements ServiceFactory, Serviceable, Initializable
    26  {
    27      private TypeMappingRegistry m_typeMappingRegistry;
    28      private TransportManager m_transportManager;
    29
    30      private ObjectServiceFactory m_factory;
    31
    32      public void service(final ServiceManager manager)
    33              throws ServiceException
    34      {
    35          m_typeMappingRegistry = (TypeMappingRegistry) manager.lookup(TypeMappingRegistry.ROLE);
    36          m_transportManager = (TransportManager) manager.lookup(TransportManager.ROLE);
    37      }
    38
    39      protected final TransportManager getTransportManager()
    40      {
    41          return m_transportManager;
    42      }
    43
    44      protected final TypeMappingRegistry getTypeMappingRegistry()
    45      {
    46          return m_typeMappingRegistry;
    47      }
    48
    49      protected final void setFactory(final ObjectServiceFactory factory)
    50      {
    51          m_factory = factory;
    52      }
    53
    54      public void initialize()
    55              throws Exception
    56      {
    57          setFactory(new ObjectServiceFactory(m_transportManager,
    58                                              new AegisBindingProvider(m_typeMappingRegistry)));
    59      }
    60
    61      public Service create(final Class clazz)
    62      {
    63          return m_factory.create(clazz);
    64      }
    65
    66      public void addIgnoredMethods(String className)
    67      {
    68          m_factory.addIgnoredMethods(className);
    69      }
    70
    71      public Service create(final Class clazz, final URL wsdlUrl)
    72              throws Exception
    73      {
    74          return m_factory.create(clazz, wsdlUrl);
    75      }
    76
    77      public Service create(Class clazz, Map properties)
    78      {
    79          return m_factory.create(clazz, properties);
    80      }
    81
    82      public Service create(Class clazz, String name, String namespace, Map properties)
    83      {
    84          return m_factory.create(clazz, name, namespace, properties);
    85      }
    86  }