001: /*
002: * Copyright (C) The MX4J Contributors.
003: * All rights reserved.
004: *
005: * This software is distributed under the terms of the MX4J License version 1.0.
006: * See the terms of the MX4J License in the documentation provided with this software.
007: */
008:
009: package mx4j.tools.remote.http;
010:
011: import java.io.IOException;
012: import java.util.Set;
013: import javax.management.AttributeList;
014: import javax.management.AttributeNotFoundException;
015: import javax.management.InstanceAlreadyExistsException;
016: import javax.management.InstanceNotFoundException;
017: import javax.management.IntrospectionException;
018: import javax.management.InvalidAttributeValueException;
019: import javax.management.ListenerNotFoundException;
020: import javax.management.MBeanException;
021: import javax.management.MBeanInfo;
022: import javax.management.MBeanRegistrationException;
023: import javax.management.NotCompliantMBeanException;
024: import javax.management.ObjectInstance;
025: import javax.management.ObjectName;
026: import javax.management.ReflectionException;
027: import javax.management.remote.NotificationResult;
028: import javax.security.auth.Subject;
029:
030: /**
031: * @version $Revision: 1.3 $
032: */
033: public abstract class HTTPClientInvoker implements HTTPConnection {
034: private String connectionId;
035:
036: protected abstract HTTPConnection getService();
037:
038: public String connect(Object credentials) throws IOException,
039: SecurityException {
040: connectionId = getService().connect(credentials);
041: return connectionId;
042: }
043:
044: public void close() throws IOException {
045: getService().close();
046: }
047:
048: public String getConnectionId() throws IOException {
049: return connectionId;
050: }
051:
052: public ObjectInstance createMBean(String className,
053: ObjectName name, Object params, String[] signature,
054: Subject delegate) throws ReflectionException,
055: InstanceAlreadyExistsException, MBeanRegistrationException,
056: MBeanException, NotCompliantMBeanException, IOException {
057: return getService().createMBean(className, name, params,
058: signature, delegate);
059: }
060:
061: public ObjectInstance createMBean(String className,
062: ObjectName name, ObjectName loaderName, Object params,
063: String[] signature, Subject delegate)
064: throws ReflectionException, InstanceAlreadyExistsException,
065: MBeanRegistrationException, MBeanException,
066: NotCompliantMBeanException, InstanceNotFoundException,
067: IOException {
068: return getService().createMBean(className, name, loaderName,
069: params, signature, delegate);
070: }
071:
072: public void unregisterMBean(ObjectName name, Subject delegate)
073: throws InstanceNotFoundException,
074: MBeanRegistrationException, IOException {
075: getService().unregisterMBean(name, delegate);
076: }
077:
078: public ObjectInstance getObjectInstance(ObjectName name,
079: Subject delegate) throws InstanceNotFoundException,
080: IOException {
081: return getService().getObjectInstance(name, delegate);
082: }
083:
084: public Set queryMBeans(ObjectName name, Object query,
085: Subject delegate) throws IOException {
086: return getService().queryMBeans(name, query, delegate);
087: }
088:
089: public Set queryNames(ObjectName name, Object query,
090: Subject delegate) throws IOException {
091: return getService().queryNames(name, query, delegate);
092: }
093:
094: public boolean isRegistered(ObjectName name, Subject delegate)
095: throws IOException {
096: return getService().isRegistered(name, delegate);
097: }
098:
099: public Integer getMBeanCount(Subject delegate) throws IOException {
100: return getService().getMBeanCount(delegate);
101: }
102:
103: public Object getAttribute(ObjectName name, String attribute,
104: Subject delegate) throws MBeanException,
105: AttributeNotFoundException, InstanceNotFoundException,
106: ReflectionException, IOException {
107: return getService().getAttribute(name, attribute, delegate);
108: }
109:
110: public AttributeList getAttributes(ObjectName name,
111: String[] attributes, Subject delegate)
112: throws InstanceNotFoundException, ReflectionException,
113: IOException {
114: return getService().getAttributes(name, attributes, delegate);
115: }
116:
117: public void setAttribute(ObjectName name, Object attribute,
118: Subject delegate) throws InstanceNotFoundException,
119: AttributeNotFoundException, InvalidAttributeValueException,
120: MBeanException, ReflectionException, IOException {
121: getService().setAttribute(name, attribute, delegate);
122: }
123:
124: public AttributeList setAttributes(ObjectName name,
125: Object attributes, Subject delegate)
126: throws InstanceNotFoundException, ReflectionException,
127: IOException {
128: return getService().setAttributes(name, attributes, delegate);
129: }
130:
131: public Object invoke(ObjectName name, String operationName,
132: Object params, String[] signature, Subject delegate)
133: throws InstanceNotFoundException, MBeanException,
134: ReflectionException, IOException {
135: return getService().invoke(name, operationName, params,
136: signature, delegate);
137: }
138:
139: public String getDefaultDomain(Subject delegate) throws IOException {
140: return getService().getDefaultDomain(delegate);
141: }
142:
143: public String[] getDomains(Subject delegate) throws IOException {
144: return getService().getDomains(delegate);
145: }
146:
147: public MBeanInfo getMBeanInfo(ObjectName name, Subject delegate)
148: throws InstanceNotFoundException, IntrospectionException,
149: ReflectionException, IOException {
150: return getService().getMBeanInfo(name, delegate);
151: }
152:
153: public boolean isInstanceOf(ObjectName name, String className,
154: Subject delegate) throws InstanceNotFoundException,
155: IOException {
156: return getService().isInstanceOf(name, className, delegate);
157: }
158:
159: public void addNotificationListener(ObjectName name,
160: ObjectName listener, Object filter, Object handback,
161: Subject delegate) throws InstanceNotFoundException,
162: IOException {
163: getService().addNotificationListener(name, listener, filter,
164: handback, delegate);
165: }
166:
167: public void removeNotificationListener(ObjectName name,
168: ObjectName listener, Subject delegate)
169: throws InstanceNotFoundException,
170: ListenerNotFoundException, IOException {
171: getService().removeNotificationListener(name, listener,
172: delegate);
173: }
174:
175: public void removeNotificationListener(ObjectName name,
176: ObjectName listener, Object filter, Object handback,
177: Subject delegate) throws InstanceNotFoundException,
178: ListenerNotFoundException, IOException {
179: getService().removeNotificationListener(name, listener, filter,
180: handback, delegate);
181: }
182:
183: public Integer addNotificationListener(ObjectName name,
184: Object filter, Subject delegate)
185: throws InstanceNotFoundException, IOException {
186: return getService().addNotificationListener(name, filter,
187: delegate);
188: }
189:
190: public void removeNotificationListeners(ObjectName name,
191: Integer[] listenerIDs, Subject delegate)
192: throws InstanceNotFoundException,
193: ListenerNotFoundException, IOException {
194: getService().removeNotificationListeners(name, listenerIDs,
195: delegate);
196: }
197:
198: public NotificationResult fetchNotifications(
199: long clientSequenceNumber, int maxNotifications,
200: long timeout) throws IOException {
201: return getService().fetchNotifications(clientSequenceNumber,
202: maxNotifications, timeout);
203: }
204: }
|