1 package org.codehaus.xfire.aegis.wsdl;
2
3 import java.util.Set;
4
5 import javax.wsdl.WSDLException;
6
7 import org.codehaus.plexus.component.repository.exception.ComponentLookupException;
8 import org.codehaus.plexus.personality.plexus.lifecycle.phase.ServiceLocator;
9 import org.codehaus.plexus.personality.plexus.lifecycle.phase.Serviceable;
10 import org.codehaus.xfire.AbstractXFireComponent;
11 import org.codehaus.xfire.XFireRuntimeException;
12 import org.codehaus.xfire.aegis.AegisService;
13 import org.codehaus.xfire.service.Service;
14 import org.codehaus.xfire.service.ServiceRegistry;
15 import org.codehaus.xfire.transport.TransportManager;
16 import org.codehaus.xfire.wsdl.WSDL;
17 import org.codehaus.xfire.wsdl.WSDLBuilder;
18
19 /***
20 * Create a WSDL document for an AegisService.
21 *
22 * @author <a href="mailto:dan@envoisolutions.com">Dan Diephouse</a>
23 * @since Apr 7, 2004
24 */
25 public class AegisWSDLBuilder
26 extends AbstractXFireComponent
27 implements WSDLBuilder, Serviceable
28 {
29 private ServiceLocator manager;
30
31 public WSDL createWSDL( Service s )
32 throws WSDLException
33 {
34 AegisService service = (AegisService) s;
35
36 TransportManager manager;
37 try
38 {
39 manager = (TransportManager) getServiceLocator().lookup( TransportManager.ROLE );
40 }
41 catch (ComponentLookupException e)
42 {
43 throw new XFireRuntimeException( "Couldn't find TransportManager.", e );
44 }
45
46 Set transports = manager.getTransports( service.getName() );
47
48 if ( service.getStyle().equals("wrapped")
49 &&
50 service.getUse().equals("literal") )
51 {
52 return new AegisWSDL( service, transports );
53 }
54
55
56
57
58
59
60
61
62
63
64
65
66 else
67 {
68 throw new UnsupportedOperationException( "Service style/use not supported." );
69 }
70 }
71
72 protected ServiceRegistry getServiceRegistry()
73 {
74 ServiceRegistry registry = null;
75
76 try
77 {
78 registry = (ServiceRegistry) getServiceLocator().lookup( ServiceRegistry.ROLE );
79 }
80 catch (ComponentLookupException e)
81 {
82 throw new RuntimeException( "Couldn't find the ServiceRegistry!", e );
83 }
84
85 return registry;
86 }
87
88 public void service( ServiceLocator manager )
89 {
90 this.manager = manager;
91 }
92
93 /***
94 * @return Returns the service manager.
95 */
96 protected ServiceLocator getServiceLocator()
97 {
98 return manager;
99 }
100 }