KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > mx4j > tools > remote > http > HTTPClientInvoker


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.http;
10
11 import java.io.IOException JavaDoc;
12 import java.util.Set JavaDoc;
13 import javax.management.AttributeList JavaDoc;
14 import javax.management.AttributeNotFoundException JavaDoc;
15 import javax.management.InstanceAlreadyExistsException JavaDoc;
16 import javax.management.InstanceNotFoundException JavaDoc;
17 import javax.management.IntrospectionException JavaDoc;
18 import javax.management.InvalidAttributeValueException JavaDoc;
19 import javax.management.ListenerNotFoundException JavaDoc;
20 import javax.management.MBeanException JavaDoc;
21 import javax.management.MBeanInfo JavaDoc;
22 import javax.management.MBeanRegistrationException JavaDoc;
23 import javax.management.NotCompliantMBeanException JavaDoc;
24 import javax.management.ObjectInstance JavaDoc;
25 import javax.management.ObjectName JavaDoc;
26 import javax.management.ReflectionException JavaDoc;
27 import javax.management.remote.NotificationResult JavaDoc;
28 import javax.security.auth.Subject JavaDoc;
29
30 /**
31  * @version $Revision: 1.3 $
32  */

33 public abstract class HTTPClientInvoker implements HTTPConnection
34 {
35    private String JavaDoc connectionId;
36
37    protected abstract HTTPConnection getService();
38
39    public String JavaDoc connect(Object JavaDoc credentials) throws IOException JavaDoc, SecurityException JavaDoc
40    {
41       connectionId = getService().connect(credentials);
42       return connectionId;
43    }
44
45    public void close() throws IOException JavaDoc
46    {
47       getService().close();
48    }
49
50    public String JavaDoc getConnectionId() throws IOException JavaDoc
51    {
52       return connectionId;
53    }
54
55    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
56    {
57       return getService().createMBean(className, name, params, signature, delegate);
58    }
59
60    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
61    {
62       return getService().createMBean(className, name, loaderName, params, signature, delegate);
63    }
64
65    public void unregisterMBean(ObjectName JavaDoc name, Subject JavaDoc delegate) throws InstanceNotFoundException JavaDoc, MBeanRegistrationException JavaDoc, IOException JavaDoc
66    {
67       getService().unregisterMBean(name, delegate);
68    }
69
70    public ObjectInstance JavaDoc getObjectInstance(ObjectName JavaDoc name, Subject JavaDoc delegate) throws InstanceNotFoundException JavaDoc, IOException JavaDoc
71    {
72       return getService().getObjectInstance(name, delegate);
73    }
74
75    public Set JavaDoc queryMBeans(ObjectName JavaDoc name, Object JavaDoc query, Subject JavaDoc delegate) throws IOException JavaDoc
76    {
77       return getService().queryMBeans(name, query, delegate);
78    }
79
80    public Set JavaDoc queryNames(ObjectName JavaDoc name, Object JavaDoc query, Subject JavaDoc delegate) throws IOException JavaDoc
81    {
82       return getService().queryNames(name, query, delegate);
83    }
84
85    public boolean isRegistered(ObjectName JavaDoc name, Subject JavaDoc delegate) throws IOException JavaDoc
86    {
87       return getService().isRegistered(name, delegate);
88    }
89
90    public Integer JavaDoc getMBeanCount(Subject JavaDoc delegate) throws IOException JavaDoc
91    {
92       return getService().getMBeanCount(delegate);
93    }
94
95    public Object JavaDoc getAttribute(ObjectName JavaDoc name, String JavaDoc attribute, Subject JavaDoc delegate) throws MBeanException JavaDoc, AttributeNotFoundException JavaDoc, InstanceNotFoundException JavaDoc, ReflectionException JavaDoc, IOException JavaDoc
96    {
97       return getService().getAttribute(name, attribute, delegate);
98    }
99
100    public AttributeList JavaDoc getAttributes(ObjectName JavaDoc name, String JavaDoc[] attributes, Subject JavaDoc delegate) throws InstanceNotFoundException JavaDoc, ReflectionException JavaDoc, IOException JavaDoc
101    {
102       return getService().getAttributes(name, attributes, delegate);
103    }
104
105    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
106    {
107       getService().setAttribute(name, attribute, delegate);
108    }
109
110    public AttributeList JavaDoc setAttributes(ObjectName JavaDoc name, Object JavaDoc attributes, Subject JavaDoc delegate) throws InstanceNotFoundException JavaDoc, ReflectionException JavaDoc, IOException JavaDoc
111    {
112       return getService().setAttributes(name, attributes, delegate);
113    }
114
115    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
116    {
117       return getService().invoke(name, operationName, params, signature, delegate);
118    }
119
120    public String JavaDoc getDefaultDomain(Subject JavaDoc delegate) throws IOException JavaDoc
121    {
122       return getService().getDefaultDomain(delegate);
123    }
124
125    public String JavaDoc[] getDomains(Subject JavaDoc delegate) throws IOException JavaDoc
126    {
127       return getService().getDomains(delegate);
128    }
129
130    public MBeanInfo JavaDoc getMBeanInfo(ObjectName JavaDoc name, Subject JavaDoc delegate) throws InstanceNotFoundException JavaDoc, IntrospectionException JavaDoc, ReflectionException JavaDoc, IOException JavaDoc
131    {
132       return getService().getMBeanInfo(name, delegate);
133    }
134
135    public boolean isInstanceOf(ObjectName JavaDoc name, String JavaDoc className, Subject JavaDoc delegate) throws InstanceNotFoundException JavaDoc, IOException JavaDoc
136    {
137       return getService().isInstanceOf(name, className, delegate);
138    }
139
140    public void addNotificationListener(ObjectName JavaDoc name, ObjectName JavaDoc listener, Object JavaDoc filter, Object JavaDoc handback, Subject JavaDoc delegate) throws InstanceNotFoundException JavaDoc, IOException JavaDoc
141    {
142       getService().addNotificationListener(name, listener, filter, handback, delegate);
143    }
144
145    public void removeNotificationListener(ObjectName JavaDoc name, ObjectName JavaDoc listener, Subject JavaDoc delegate) throws InstanceNotFoundException JavaDoc, ListenerNotFoundException JavaDoc, IOException JavaDoc
146    {
147       getService().removeNotificationListener(name, listener, delegate);
148    }
149
150    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
151    {
152       getService().removeNotificationListener(name, listener, filter, handback, delegate);
153    }
154
155    public Integer JavaDoc addNotificationListener(ObjectName JavaDoc name, Object JavaDoc filter, Subject JavaDoc delegate) throws InstanceNotFoundException JavaDoc, IOException JavaDoc
156    {
157       return getService().addNotificationListener(name, filter, delegate);
158    }
159
160    public void removeNotificationListeners(ObjectName JavaDoc name, Integer JavaDoc[] listenerIDs, Subject JavaDoc delegate) throws InstanceNotFoundException JavaDoc, ListenerNotFoundException JavaDoc, IOException JavaDoc
161    {
162       getService().removeNotificationListeners(name, listenerIDs, delegate);
163    }
164
165    public NotificationResult JavaDoc fetchNotifications(long clientSequenceNumber, int maxNotifications, long timeout) throws IOException JavaDoc
166    {
167       return getService().fetchNotifications(clientSequenceNumber, maxNotifications, timeout);
168    }
169 }
170
Popular Tags