1 package org.codehaus.xfire.plexus;
2
3 import org.codehaus.plexus.component.repository.exception.ComponentLookupException;
4 import org.codehaus.plexus.personality.plexus.lifecycle.phase.Initializable;
5 import org.codehaus.plexus.personality.plexus.lifecycle.phase.ServiceLocator;
6 import org.codehaus.plexus.personality.plexus.lifecycle.phase.Serviceable;
7 import org.codehaus.xfire.DefaultXFire;
8 import org.codehaus.xfire.XFireRuntimeException;
9 import org.codehaus.xfire.plexus.config.ConfigurationService;
10 import org.codehaus.xfire.service.Service;
11 import org.codehaus.xfire.service.ServiceRegistry;
12 import org.codehaus.xfire.transport.TransportManager;
13
14 /***
15 * An instance of XFire that is managed by Plexus.
16 *
17 * @author <a href="mailto:dan@envoisolutions.com">Dan Diephouse</a>
18 * @since Sep 19, 2004
19 */
20 public class PlexusXFire
21 extends DefaultXFire
22 implements Serviceable, Initializable
23 {
24 private ServiceLocator locator;
25
26 public ServiceRegistry getServiceRegistry()
27 {
28 try
29 {
30 return (ServiceRegistry) locator.lookup( ServiceRegistry.ROLE );
31 }
32 catch (ComponentLookupException e)
33 {
34 throw new XFireRuntimeException("Couldn't find component.", e);
35 }
36 }
37
38 public TransportManager getTransportManager()
39 {
40 try
41 {
42 return (TransportManager) locator.lookup( TransportManager.ROLE );
43 }
44 catch (ComponentLookupException e)
45 {
46 throw new XFireRuntimeException("Couldn't find component.", e);
47 }
48 }
49
50 /***
51 * @see org.codehaus.plexus.personality.plexus.lifecycle.phase.Serviceable#service(org.codehaus.plexus.personality.plexus.lifecycle.phase.ServiceLocator)
52 */
53 public void service( ServiceLocator locator )
54 {
55 this.locator = locator;
56 }
57
58 public void initialize() throws Exception
59 {
60 locator.lookupList(Service.ROLE);
61 locator.lookupList(ConfigurationService.ROLE);
62 }
63 }