View Javadoc
1   /*
2    * Copyright (c) MuleSoft, Inc.  All rights reserved.  http://www.mulesoft.com
3    * The software in this package is published under the terms of the CPAL v1.0
4    * license, a copy of which has been included with this distribution in the
5    * LICENSE.txt file.
6    */
7   package org.mule.module.management.mbean;
8   
9   import org.mule.api.MuleException;
10  import org.mule.api.lifecycle.InitialisationException;
11  import org.mule.api.transport.Connector;
12  import org.mule.util.ObjectNameHelper;
13  
14  public class ConnectorService implements ConnectorServiceMBean
15  {
16      private final Connector connector;
17      private final String name;
18  
19      public ConnectorService(final Connector connector)
20      {
21          this.connector = connector;
22          name = new ObjectNameHelper(connector.getMuleContext()).getConnectorName(connector);
23      }
24  
25      public boolean isStarted()
26      {
27          return connector.isStarted();
28      }
29  
30      public boolean isDisposed()
31      {
32          return connector.isDisposed();
33      }
34  
35      public String getName()
36      {
37          return name;
38      }
39  
40      public String getProtocol()
41      {
42          return connector.getProtocol();
43      }
44  
45      public void startConnector() throws MuleException
46      {
47          connector.start();
48      }
49  
50      public void stopConnector() throws MuleException
51      {
52          connector.stop();
53      }
54  
55      public void dispose()
56      {
57          connector.dispose();
58      }
59  
60      public void initialise() throws InitialisationException
61      {
62          connector.initialise();
63      }
64  
65  }