KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > mx4j > tools > remote > AbstractServerInvoker


1 /*
2  * Copyright (C) The MX4J Contributors.
3  * All rights reserved.
4  *
5  * This software is distributed under the terms of the MX4J License version 1.0.
6  * See the terms of the MX4J License in the documentation provided with this software.
7  */

8
9 package mx4j.tools.remote;
10
11 import java.io.IOException JavaDoc;
12 import java.util.Set JavaDoc;
13
14 import javax.management.Attribute JavaDoc;
15 import javax.management.AttributeList JavaDoc;
16 import javax.management.AttributeNotFoundException JavaDoc;
17 import javax.management.InstanceAlreadyExistsException JavaDoc;
18 import javax.management.InstanceNotFoundException JavaDoc;
19 import javax.management.IntrospectionException JavaDoc;
20 import javax.management.InvalidAttributeValueException JavaDoc;
21 import javax.management.ListenerNotFoundException JavaDoc;
22 import javax.management.MBeanException JavaDoc;
23 import javax.management.MBeanInfo JavaDoc;
24 import javax.management.MBeanRegistrationException JavaDoc;
25 import javax.management.MBeanServerConnection JavaDoc;
26 import javax.management.NotCompliantMBeanException JavaDoc;
27 import javax.management.NotificationFilter JavaDoc;
28 import javax.management.ObjectInstance JavaDoc;
29 import javax.management.ObjectName JavaDoc;
30 import javax.management.QueryExp JavaDoc;
31 import javax.management.ReflectionException JavaDoc;
32 import javax.security.auth.Subject JavaDoc;
33
34 /**
35  * This class implements partially the JMXConnection interface to forward the calls
36  * to an MBeanServerConnection object (hence the name 'invoker').
37  * It does not handle nor unmarshalling of arguments (and all related classloading
38  * problems), nor remote notification mechanisms of any sort, which are left
39  * to subclasses, which will implement them in a protocol specific way.
40  * This class is the server-side counterpart of {@link JMXConnectionMBeanServerConnection}
41  *
42  * @version $Revision: 1.4 $
43  */

44 public abstract class AbstractServerInvoker implements JMXConnection
45 {
46    private final MBeanServerConnection JavaDoc server;
47
48    protected AbstractServerInvoker(MBeanServerConnection JavaDoc server)
49    {
50       this.server = server;
51    }
52
53    protected MBeanServerConnection JavaDoc getServer()
54    {
55       return server;
56    }
57
58    public ObjectInstance JavaDoc createMBean(String JavaDoc className, ObjectName JavaDoc name, Object JavaDoc params, String JavaDoc[] signature, Subject JavaDoc delegate) throws ReflectionException JavaDoc, InstanceAlreadyExistsException JavaDoc, MBeanRegistrationException JavaDoc, MBeanException JavaDoc, NotCompliantMBeanException JavaDoc, IOException JavaDoc
59    {
60       return getServer().createMBean(className, name, (Object JavaDoc[])params, signature);
61    }
62
63    public ObjectInstance JavaDoc createMBean(String JavaDoc className, ObjectName JavaDoc name, ObjectName JavaDoc loaderName, Object JavaDoc params, String JavaDoc[] signature, Subject JavaDoc delegate) throws ReflectionException JavaDoc, InstanceAlreadyExistsException JavaDoc, MBeanRegistrationException JavaDoc, MBeanException JavaDoc, NotCompliantMBeanException JavaDoc, InstanceNotFoundException JavaDoc, IOException JavaDoc
64    {
65       return getServer().createMBean(className, name, loaderName, (Object JavaDoc[])params, signature);
66    }
67
68    public void unregisterMBean(ObjectName JavaDoc name, Subject JavaDoc delegate) throws InstanceNotFoundException JavaDoc, MBeanRegistrationException JavaDoc, IOException JavaDoc
69    {
70       getServer().unregisterMBean(name);
71    }
72
73    public ObjectInstance JavaDoc getObjectInstance(ObjectName JavaDoc name, Subject JavaDoc delegate) throws InstanceNotFoundException JavaDoc, IOException JavaDoc
74    {
75       return getServer().getObjectInstance(name);
76    }
77
78    public Set JavaDoc queryMBeans(ObjectName JavaDoc name, Object JavaDoc query, Subject JavaDoc delegate) throws IOException JavaDoc
79    {
80       return getServer().queryMBeans(name, (QueryExp JavaDoc)query);
81    }
82
83    public Set JavaDoc queryNames(ObjectName JavaDoc name, Object JavaDoc query, Subject JavaDoc delegate) throws IOException JavaDoc
84    {
85       return getServer().queryNames(name, (QueryExp JavaDoc)query);
86    }
87
88    public boolean isRegistered(ObjectName JavaDoc name, Subject JavaDoc delegate) throws IOException JavaDoc
89    {
90       return getServer().isRegistered(name);
91    }
92
93    public Integer JavaDoc getMBeanCount(Subject JavaDoc delegate) throws IOException JavaDoc
94    {
95       return getServer().getMBeanCount();
96    }
97
98    public Object JavaDoc getAttribute(ObjectName JavaDoc name, String JavaDoc attribute, Subject JavaDoc delegate) throws MBeanException JavaDoc, AttributeNotFoundException JavaDoc, InstanceNotFoundException JavaDoc, ReflectionException JavaDoc, IOException JavaDoc
99    {
100       return getServer().getAttribute(name, attribute);
101    }
102
103    public AttributeList JavaDoc getAttributes(ObjectName JavaDoc name, String JavaDoc[] attributes, Subject JavaDoc delegate) throws InstanceNotFoundException JavaDoc, ReflectionException JavaDoc, IOException JavaDoc
104    {
105       return getServer().getAttributes(name, attributes);
106    }
107
108    public void setAttribute(ObjectName JavaDoc name, Object JavaDoc attribute, Subject JavaDoc delegate) throws InstanceNotFoundException JavaDoc, AttributeNotFoundException JavaDoc, InvalidAttributeValueException JavaDoc, MBeanException JavaDoc, ReflectionException JavaDoc, IOException JavaDoc
109    {
110       getServer().setAttribute(name, (Attribute JavaDoc)attribute);
111    }
112
113    public AttributeList JavaDoc setAttributes(ObjectName JavaDoc name, Object JavaDoc attributes, Subject JavaDoc delegate) throws InstanceNotFoundException JavaDoc, ReflectionException JavaDoc, IOException JavaDoc
114    {
115       return getServer().setAttributes(name, (AttributeList JavaDoc)attributes);
116    }
117
118    public Object JavaDoc invoke(ObjectName JavaDoc name, String JavaDoc operationName, Object JavaDoc params, String JavaDoc[] signature, Subject JavaDoc delegate) throws InstanceNotFoundException JavaDoc, MBeanException JavaDoc, ReflectionException JavaDoc, IOException JavaDoc
119    {
120       return getServer().invoke(name, operationName, (Object JavaDoc[])params, signature);
121    }
122
123    public String JavaDoc getDefaultDomain(Subject JavaDoc delegate) throws IOException JavaDoc
124    {
125       return getServer().getDefaultDomain();
126    }
127
128    public String JavaDoc[] getDomains(Subject JavaDoc delegate) throws IOException JavaDoc
129    {
130       return getServer().getDomains();
131    }
132
133    public MBeanInfo JavaDoc getMBeanInfo(ObjectName JavaDoc name, Subject JavaDoc delegate) throws InstanceNotFoundException JavaDoc, IntrospectionException JavaDoc, ReflectionException JavaDoc, IOException JavaDoc
134    {
135       return getServer().getMBeanInfo(name);
136    }
137
138    public boolean isInstanceOf(ObjectName JavaDoc name, String JavaDoc className, Subject JavaDoc delegate) throws InstanceNotFoundException JavaDoc, IOException JavaDoc
139    {
140       return getServer().isInstanceOf(name, className);
141    }
142
143    public void addNotificationListener(ObjectName JavaDoc name, ObjectName JavaDoc listener, Object JavaDoc filter, Object JavaDoc handback, Subject JavaDoc delegate) throws InstanceNotFoundException JavaDoc, IOException JavaDoc
144    {
145       getServer().addNotificationListener(name, listener, (NotificationFilter JavaDoc)filter, handback);
146    }
147
148    public void removeNotificationListener(ObjectName JavaDoc name, ObjectName JavaDoc listener, Subject JavaDoc delegate) throws InstanceNotFoundException JavaDoc, ListenerNotFoundException JavaDoc, IOException JavaDoc
149    {
150       getServer().removeNotificationListener(name, listener);
151    }
152
153    public void removeNotificationListener(ObjectName JavaDoc name, ObjectName JavaDoc listener, Object JavaDoc filter, Object JavaDoc handback, Subject JavaDoc delegate) throws InstanceNotFoundException JavaDoc, ListenerNotFoundException JavaDoc, IOException JavaDoc
154    {
155       getServer().removeNotificationListener(name, listener, (NotificationFilter JavaDoc)filter, handback);
156    }
157 }
158
Popular Tags