View Javadoc

    1   package org.codehaus.xfire.service;
    2
    3   import java.util.HashMap;
    4   import java.util.Map;
    5
    6   import org.codehaus.xfire.exchange.MessageSerializer;
    7   import org.codehaus.xfire.handler.AbstractHandlerSupport;
    8   import org.codehaus.xfire.service.binding.ObjectBinding;
    9   import org.codehaus.xfire.soap.SoapVersion;
    10  import org.codehaus.xfire.wsdl.WSDLWriter;
    11
    12  /***
    13   * Represents a service endpoint. A service endpoints sole job is to process xml messages. The
    14   * servicehandler is is the central processing point - responsible for invoking
    15   * request/response/fault handlers as well reading in the xml message to the service.
    16   * <p>
    17   * The binding is then responsible for taking the SOAP Body and binding it to something - JavaBeans,
    18   * XMLBeans, W3C DOM tree, etc.
    19   * <p>
    20   * The <code>ServiceInfo</code> represents an optional contract for the service. This can be used
    21   * to generate WSDL and/or provide information on serialization.
    22   *
    23   * @author <a href="mailto:poutsma@mac.com">Arjen Poutsma</a>
    24   * @see ServiceInfo
    25   * @see org.codehaus.xfire.service.binding.SOAPBinding
    26   */
    27  public class Service
    28      extends AbstractHandlerSupport
    29      implements Visitable
    30  {
    31      public final static String ROLE = Service.class.getName();
    32
    33      private ServiceInfo service;
    34      private MessageSerializer serializer;
    35      private MessageSerializer faultSerializer;
    36      private ObjectBinding binding;
    37      private Map properties = new HashMap();
    38      private WSDLWriter wsdlWriter;
    39      private SoapVersion soapVersion;
    40
    41      /***
    42       * Initializes a new, default instance of the <code>ServiceEndpoint</code> for a specified
    43       * <code>ServiceInfo</code>.
    44       *
    45       * @param service the service.
    46       */
    47      public Service(ServiceInfo service)
    48      {
    49          this.service = service;
    50      }
    51
    52
    53      /***
    54       * Accepts the given visitor. Iterates over all the contained service.
    55       *
    56       * @param visitor the visitor.
    57       */
    58      public void accept(Visitor visitor)
    59      {
    60          visitor.startEndpoint(this);
    61          service.accept(visitor);
    62          visitor.endEndpoint(this);
    63      }
    64
    65      /***
    66       * @see org.codehaus.xfire.service.Service#getProperty(java.lang.String)
    67       */
    68      public Object getProperty(String name)
    69      {
    70          return properties.get(name);
    71      }
    72
    73      /***
    74       * @see org.codehaus.xfire.service.Service#setProperty(java.lang.String, java.lang.Object)
    75       */
    76      public void setProperty(String name, Object value)
    77      {
    78          properties.put(name, value);
    79      }
    80
    81      /***
    82       * Returns the binding for this endpoint.
    83       *
    84       * @return the binding.
    85       */
    86      public ObjectBinding getBinding()
    87      {
    88          return binding;
    89      }
    90
    91      /***
    92       * Sets the binding for this endpoint.
    93       *
    94       * @param binding the binding.
    95       */
    96      public void setBinding(ObjectBinding binding)
    97      {
    98          this.binding = binding;
    99      }
    100
    101     public MessageSerializer getFaultSerializer()
    102     {
    103         return faultSerializer;
    104     }
    105
    106     public void setFaultSerializer(MessageSerializer faultSerializer)
    107     {
    108         this.faultSerializer = faultSerializer;
    109     }
    110
    111     /***
    112      * Returns the name of this endpoint. This method simply returns the local part of the qualified name of the
    113      * <code>ServiceInfo</code>.
    114      *
    115      * @return the service name.
    116      * @see ServiceInfo#getName()
    117      * @see javax.xml.namespace.QName#getLocalPart()
    118      */
    119     public String getName()
    120     {
    121         return service.getName().getLocalPart();
    122     }
    123
    124     /***
    125      * Returns the service descriptor for this endpoint.
    126      *
    127      * @return the service descriptor.
    128      */
    129     public ServiceInfo getServiceInfo()
    130     {
    131         return service;
    132     }
    133
    134     /***
    135      * Returns the <code>WSDLWriter</code> for this endpoint. If a writer has not been {@link #setWSDLWriter(WSDLWriter)
    136      * explicitly set}, a default implementation is used.
    137      *
    138      * @return the wsdl writer.
    139      */
    140     public WSDLWriter getWSDLWriter()
    141     {
    142         return wsdlWriter;
    143     }
    144
    145     /***
    146      * Sets the <code>WSDLWriter</code> for this endpoint.
    147      *
    148      * @param wsdlWriter
    149      */
    150     public void setWSDLWriter(WSDLWriter wsdlWriter)
    151     {
    152         this.wsdlWriter = wsdlWriter;
    153     }
    154
    155     public SoapVersion getSoapVersion()
    156     {
    157         return soapVersion;
    158     }
    159
    160     public void setSoapVersion(SoapVersion soapVersion)
    161     {
    162         this.soapVersion = soapVersion;
    163     }
    164 }
    165