01: /*
02: * JBoss, Home of Professional Open Source.
03: * Copyright 2006, Red Hat Middleware LLC, and individual contributors
04: * as indicated by the @author tags. See the copyright.txt file in the
05: * distribution for a full listing of individual contributors.
06: *
07: * This is free software; you can redistribute it and/or modify it
08: * under the terms of the GNU Lesser General Public License as
09: * published by the Free Software Foundation; either version 2.1 of
10: * the License, or (at your option) any later version.
11: *
12: * This software is distributed in the hope that it will be useful,
13: * but WITHOUT ANY WARRANTY; without even the implied warranty of
14: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15: * Lesser General Public License for more details.
16: *
17: * You should have received a copy of the GNU Lesser General Public
18: * License along with this software; if not, write to the Free
19: * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
20: * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
21: */
22: package org.jboss.jmx.connector.invoker;
23:
24: import javax.management.MBeanServerConnection;
25: import javax.management.ObjectName;
26:
27: import org.jboss.deployment.DeploymentException;
28: import org.jboss.mx.util.MBeanProxyExt;
29: import org.jboss.system.ServiceMBeanSupport;
30:
31: /**
32: * MBeanProxyRemote.
33: *
34: * @author <a href="adrian@jboss.com">Adrian Brock</a>
35: * @version $Revision: 57209 $
36: */
37: public class MBeanProxyRemote extends ServiceMBeanSupport implements
38: MBeanProxyRemoteMBean {
39: /** The mbeanServer connection */
40: private ObjectName mbeanServerConnection;
41:
42: /**
43: * Get the mbeanServerConnection.
44: *
45: * @return the mbeanServerConnection.
46: */
47: public ObjectName getMBeanServerConnection() {
48: return mbeanServerConnection;
49: }
50:
51: /**
52: * Set the mbeanServerConnection.
53: *
54: * @param mbeanServerConnection the mbeanServerConnection.
55: */
56: public void setMBeanServerConnection(
57: ObjectName mbeanServerConnection) {
58: this .mbeanServerConnection = mbeanServerConnection;
59: }
60:
61: protected void startService() throws Exception {
62: if (MBeanProxyExt.remote != null)
63: throw new IllegalStateException(
64: "Remote MBeanServerConnection is already set "
65: + MBeanProxyExt.remote);
66:
67: Object o = server.getAttribute(mbeanServerConnection, "Proxy");
68: if (o instanceof MBeanServerConnection == false)
69: throw new DeploymentException(mbeanServerConnection
70: + " does not define an MBeanServerConnection");
71: MBeanProxyExt.remote = (MBeanServerConnection) o;
72: }
73:
74: protected void stopService() throws Exception {
75: MBeanProxyExt.remote = null;
76: }
77: }
|