View Javadoc

1   package org.codehaus.xfire.service;
2   
3   import java.util.Hashtable;
4   import javax.wsdl.WSDLException;
5   import org.codehaus.xfire.AbstractXFireComponent;
6   import org.codehaus.xfire.fault.FaultHandler;
7   import org.codehaus.xfire.handler.Handler;
8   import org.codehaus.xfire.wsdl.ResourceWSDL;
9   import org.codehaus.xfire.wsdl.WSDL;
10  import org.codehaus.xfire.wsdl.WSDLBuilder;
11  
12  /***
13   * A simple service implementation.
14   * 
15   * @author <a href="mailto:dan@envoisolutions.com">Dan Diephouse</a>
16   */
17  public class SimpleService
18      extends AbstractXFireComponent
19      implements Service
20  {
21      private String name;
22          
23      private String style;
24      
25      private String use;
26      
27      private String soapVersion;
28      
29      private String defaultNamespace;
30      
31      private Hashtable properties;
32      
33      private WSDL wsdl;
34      
35      private WSDLBuilder wsdlBuilder;
36      
37      private String wsdlUri;
38   
39      private FaultHandler faultHandler;
40      
41      private Handler serviceHandler;
42      
43      public SimpleService()
44      {
45          properties = new Hashtable();   
46      }
47      
48      /***
49       * @see org.codehaus.xfire.service.Service#getWSDL()
50       */
51      public WSDL getWSDL() throws WSDLException
52      {
53          if ( wsdl == null )
54          {
55              if ( getWSDLURL() != null 
56                   &&
57                   !getWSDLURL().equals("") )
58              {
59                  wsdl = new ResourceWSDL( wsdlUri );
60              }
61              else
62              {
63                  WSDLBuilder b = getWSDLBuilder();
64                  
65                  if ( b != null )
66                      return getWSDLBuilder().createWSDL( this );
67              }
68          }
69          
70          return wsdl;
71      }
72  
73      public WSDLBuilder getWSDLBuilder()
74      {
75          return wsdlBuilder;
76      }
77      
78      public void setWSDLBuilder( WSDLBuilder wsdlBuilder )
79      {
80          this.wsdlBuilder = wsdlBuilder;
81      }
82      
83      /***
84       * @return Returns the URL to the WSDL for this service. 
85       * If none exists, the service will attempt to generage
86       * the WSDL automatically via the WSDLBuilder.
87       */
88      public String getWSDLURL()
89      {
90          return wsdlUri;
91      }
92      
93      /***
94       * @param wsdlUri The WSDL URL.
95       */
96      public void setWSDLURL(String wsdlUri)
97      {
98          this.wsdlUri = wsdlUri;
99      }
100     
101     /***
102      * @return Returns the defaultNamespace.
103      */
104     public String getDefaultNamespace()
105     {
106         return defaultNamespace;
107     }
108     
109     /***
110      * @param defaultNamespace The defaultNamespace to set.
111      */
112     public void setDefaultNamespace( String defaultNamespace )
113     {
114         this.defaultNamespace = defaultNamespace;
115     }
116     /***
117      * @return Returns the style.
118      */
119     public String getStyle()
120     {
121         return style;
122     }
123     
124     /***
125      * @param style The style to set.
126      */
127     public void setStyle( String style )
128     {
129         this.style = style;
130     }
131     
132     /***
133      * @return Returns the use.
134      */
135     public String getUse()
136     {
137         return use;
138     }
139     
140     /***
141      * @param use The use to set.
142      */
143     public void setUse( String use )
144     {
145         this.use = use;
146     }
147 
148     /***
149      * @see org.codehaus.xfire.service.Service#getSoapVersion()
150      */
151     public String getSoapVersion()
152     {
153         return soapVersion;
154     }
155 
156 	public void setSoapVersion(String soapVersion)
157 	{
158 		this.soapVersion = soapVersion;
159 	}
160     
161 	public String getName()
162 	{
163 		return name;
164 	}
165     
166 	public void setName(String name)
167 	{
168 		this.name = name;
169 	}
170     
171     /***
172      * @see org.codehaus.xfire.service.ServiceDescriptor#setProperty(java.lang.String, java.lang.Object)
173      */
174     public void setProperty( String name, Object value )
175     {
176         properties.put( name, value );
177     }
178 
179     /***
180      * @see org.codehaus.xfire.service.ServiceDescriptor#getProperty(java.lang.String)
181      */
182     public Object getProperty( String name )
183     {
184         return properties.get( name );
185     }
186     
187     public FaultHandler getFaultHandler()
188     {
189         return faultHandler;
190     }
191     
192     public void setFaultHandler( FaultHandler faultHandler )
193     {
194         this.faultHandler = faultHandler;
195     }
196     
197     public Handler getServiceHandler()
198     {
199         return serviceHandler;
200     }
201     
202     public void setServiceHandler( Handler serviceHandler )
203     {
204         this.serviceHandler = serviceHandler;
205     }
206 
207     public void setWSDL( WSDL wsdl )
208     {
209         this.wsdl = wsdl;
210     }
211 }