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