User: cgjung
Date: 02/03/12 03:04:46
Modified: jboss.net/src/main/org/jboss/net/jmx/server
MBeanProvider.java
Log:
Axis Beta RC1 is here. Needs no more to be patched for integrating with the
jboss classloading architecture. Lots of interna have changed, though.
Adapted the deployment descriptors to support WSDD now.
Revision Changes Path
1.2 +135 -125
contrib/jboss.net/src/main/org/jboss/net/jmx/server/MBeanProvider.java
Index: MBeanProvider.java
===================================================================
RCS file:
/cvsroot/jboss/contrib/jboss.net/src/main/org/jboss/net/jmx/server/MBeanProvider.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- MBeanProvider.java 3 Oct 2001 13:20:32 -0000 1.1
+++ MBeanProvider.java 12 Mar 2002 11:04:46 -0000 1.2
@@ -5,7 +5,7 @@
* See terms of license at gnu.org.
*/
-// $Id: MBeanProvider.java,v 1.1 2001/10/03 13:20:32 cgjung Exp $
+// $Id: MBeanProvider.java,v 1.2 2002/03/12 11:04:46 cgjung Exp $
package org.jboss.net.jmx.server;
@@ -14,14 +14,17 @@
import org.apache.axis.MessageContext;
import org.apache.axis.providers.BasicProvider;
-import org.apache.axis.message.RPCElement;
+import org.apache.axis.handlers.soap.SOAPService;
+import org.apache.axis.providers.BasicProvider;
import org.apache.axis.message.SOAPEnvelope;
import org.apache.axis.message.RPCParam;
-import org.apache.axis.Handler;
+import org.apache.axis.message.RPCElement;
import org.apache.axis.utils.JavaUtils;
import org.apache.log4j.Category;
+import org.xml.sax.SAXException;
+
import javax.management.MBeanServerFactory;
import javax.management.MBeanServer;
import javax.management.MBeanException;
@@ -38,12 +41,12 @@
* deploy a particular mbean as a web-service, a deployment descriptor
* would look like:
*
- * <admin:deploy xmlns:admin="AdminService"/>
+ * <deployment>
* <handler name="MBeanDispatcher" class="org.jboss.net.jmx.MBeanProvider"/>
* <service name="${ServiceName}" pivot="MBeanDispatcher">
* <option name="ObjectName" value="${JMX_ObjectName}"/>
* </service>
- * </admin:deploy>
+ * </deployment>
*
* The message format (WSDL generation is to come ...) requires the first
* parameter being always a String[] of the length of the following
@@ -51,129 +54,136 @@
*
* @created 1. Oktober 2001, 16:38
* @author <a href="mailto:[EMAIL PROTECTED]">Christoph G. Jung</a>
- * @version $Revision: 1.1 $
+ * @version $Revision: 1.2 $
*/
public class MBeanProvider extends BasicProvider implements Constants {
-
- /** Creates new MBeanProvider */
- public MBeanProvider() {
- }
-
- /**
- * Invoke is called to do the actual work of the Handler object.
- */
-
- public void invoke(MessageContext msgContext) throws AxisFault {
- // the options of the service
- String serviceName = msgContext.getTargetService();
- Handler service = msgContext.getServiceHandler();
- // include the JMX objectname
- String objectName=(String) service.getOption(OBJECTNAME_PROPERTY);
- // and the server id (maybe)
- String serverId=(String) service.getOption(MBEAN_SERVER_ID_PROPERTY);
-
- // process objectname
- ObjectName name=null;
-
- try{
- name=new ObjectName(objectName);
- } catch (MalformedObjectNameException e) {
- throw new AxisFault(WRONG_OBJECT_NAME,e);
- }
-
- // process server id
- MBeanServer server=null;
-
- Iterator allServers=MBeanServerFactory.findMBeanServer(serverId).iterator();
- if(!allServers.hasNext())
- throw new AxisFault(NO_MBEAN_SERVER_FOUND);
- else
- server=(MBeanServer) allServers.next();
-
- // dissect the message
- Message reqMsg = msgContext.getRequestMessage();
- SOAPEnvelope reqEnv = (SOAPEnvelope)reqMsg.getAsSOAPEnvelope();
- Message resMsg = msgContext.getResponseMessage();
- SOAPEnvelope resEnv = (resMsg == null) ?
- new SOAPEnvelope() :
- (SOAPEnvelope)resMsg.getAsSOAPEnvelope();
-
- // copied code from RobJ, duh?
- if (msgContext.getResponseMessage() == null) {
- resMsg = new Message(resEnv);
- msgContext.setResponseMessage( resMsg );
+
+ /** Creates new MBeanProvider */
+ public MBeanProvider() {
+ }
+
+ /**
+ * Invoke is called to do the actual work of the Handler object.
+ */
+
+ public void invoke(MessageContext msgContext) throws AxisFault {
+ // the options of the service
+ String serviceName = msgContext.getTargetService();
+ SOAPService service = msgContext.getService();
+ // include the JMX objectname
+ String objectName = (String) service.getOption(OBJECTNAME_PROPERTY);
+ // and the server id (maybe)
+ String serverId = (String) service.getOption(MBEAN_SERVER_ID_PROPERTY);
+
+ // process objectname
+ ObjectName name = null;
+
+ try {
+ name = new ObjectName(objectName);
+ } catch (MalformedObjectNameException e) {
+ throw new AxisFault(WRONG_OBJECT_NAME, e);
+ }
+
+ // process server id
+ MBeanServer server = null;
+
+ Iterator allServers = MBeanServerFactory.findMBeanServer(serverId).iterator();
+ if (!allServers.hasNext())
+ throw new AxisFault(NO_MBEAN_SERVER_FOUND);
+ else
+ server = (MBeanServer) allServers.next();
+
+ // dissect the message
+ Message reqMsg = msgContext.getRequestMessage();
+ SOAPEnvelope reqEnv = (SOAPEnvelope) reqMsg.getSOAPEnvelope();
+ Message resMsg = msgContext.getResponseMessage();
+ SOAPEnvelope resEnv =
+ (resMsg == null)
+ ? new SOAPEnvelope()
+ : (SOAPEnvelope) resMsg.getSOAPEnvelope();
+
+ // copied code from RobJ, duh?
+ if (msgContext.getResponseMessage() == null) {
+ resMsg = new Message(resEnv);
+ msgContext.setResponseMessage(resMsg);
+ }
+
+ // navigate the bodies
+ Iterator allBodies = reqEnv.getBodyElements().iterator();
+
+ while (allBodies.hasNext()) {
+ Object nextBody = allBodies.next();
+ if (nextBody instanceof RPCElement) {
+ RPCElement body = (RPCElement) nextBody;
+ String mName = body.getMethodName();
+ List args=null;
+ try{
+ args = body.getParams();
+ } catch(SAXException e) {
+ throw new AxisFault( EXCEPTION_OCCURED,e);
}
-
- // navigate the bodies
- Iterator allBodies = reqEnv.getBodyElements().iterator();
-
- while(allBodies.hasNext()) {
- Object nextBody=allBodies.next();
- if(nextBody instanceof RPCElement) {
- RPCElement body = (RPCElement) nextBody;
- String mName = body.getMethodName();
- List args = body.getParams();
- Object[] arguments;
- String[] classNames;
-
- // parameter preprocessing
- if(args==null || args.size()==0) {
- arguments=new Object[0];
- classNames=new String[0];
- } else {
- arguments=new Object[args.size()-1];
- RPCParam param=(RPCParam) args.get(0);
- try{
- classNames=(String[])
- JavaUtils.convert(param.getValue(),String[].class);
- for(int count=0; count<classNames.length; count++) {
- param=(RPCParam) args.get(count+1);
- try{
-
arguments[count]=JavaUtils.convert(param.getValue(),
-
msgContext.getClassLoader().loadClass(classNames[count]));
- } catch(ClassNotFoundException e) {
- throw new AxisFault(CLASS_NOT_FOUND,e);
- }
- }
- } catch(ClassCastException e) {
- throw new AxisFault(COULD_NOT_CONVERT_PARAMS,e);
- }
- }
-
- // now do the JMX call
- try{
- Object result =
server.invoke(name,mName,arguments,classNames);
- // and encode it back to the response
- RPCElement resBody = new RPCElement(mName + "Response");
- resBody.setPrefix( body.getPrefix() );
- resBody.setNamespaceURI( body.getNamespaceURI() );
- RPCParam param = new RPCParam(mName + "Result", result);
- resBody.addParam(param);
- resEnv.addBodyElement( resBody );
-
resEnv.setEncodingStyleURI(org.apache.axis.Constants.URI_SOAP_ENC);
- } catch(InstanceNotFoundException e) {
- throw new AxisFault(NO_MBEAN_INSTANCE,e);
- } catch(MBeanException e) {
- throw new AxisFault(MBEAN_EXCEPTION,e);
- } catch(ReflectionException e) {
- throw new
AxisFault(EXCEPTION_OCCURED,e.getTargetException());
- }
-
- } // if(nextBody instanceof RPCElement)
- } // // while(allBodies.hasNext())
- } // invoke
-
- /**
- * ToDo, inspect mbean-interfaces or so?
- */
- public void generateWSDL(MessageContext msgContext) throws AxisFault {
- }
-
- /**
- * ToDo, called when a fault occurs to 'undo' whatever 'invoke' did.
- */
- public void undo(MessageContext msgContext) {
- // unbelievable this foresight
- }
+ Object[] arguments;
+ String[] classNames;
+
+ // parameter preprocessing
+ if (args == null || args.size() == 0) {
+ arguments = new Object[0];
+ classNames = new String[0];
+ } else {
+ arguments = new Object[args.size() - 1];
+ RPCParam param = (RPCParam) args.get(0);
+ try {
+ classNames = (String[]) JavaUtils.convert(param.getValue(),
String[].class);
+ for (int count = 0; count < classNames.length; count++) {
+ param = (RPCParam) args.get(count + 1);
+ try {
+ arguments[count] =
+ JavaUtils.convert(
+ param.getValue(),
+
msgContext.getClassLoader().loadClass(classNames[count]));
+ } catch (ClassNotFoundException e) {
+ throw new AxisFault(CLASS_NOT_FOUND, e);
+ }
+ }
+ } catch (ClassCastException e) {
+ throw new AxisFault(COULD_NOT_CONVERT_PARAMS, e);
+ }
+ }
+
+ // now do the JMX call
+ try {
+ Object result = server.invoke(name, mName, arguments, classNames);
+ // and encode it back to the response
+ RPCElement resBody = new RPCElement(mName + "Response");
+ resBody.setPrefix(body.getPrefix());
+ resBody.setNamespaceURI(body.getNamespaceURI());
+ RPCParam param = new RPCParam(mName + "Result", result);
+ resBody.addParam(param);
+ resEnv.addBodyElement(resBody);
+ resEnv.setEncodingStyle(org.apache.axis.Constants.URI_SOAP_ENC);
+ } catch (InstanceNotFoundException e) {
+ throw new AxisFault(NO_MBEAN_INSTANCE, e);
+ } catch (MBeanException e) {
+ throw new AxisFault(MBEAN_EXCEPTION, e);
+ } catch (ReflectionException e) {
+ throw new AxisFault(EXCEPTION_OCCURED, e.getTargetException());
+ }
+
+ } // if(nextBody instanceof RPCElement)
+ } // // while(allBodies.hasNext())
+ } // invoke
+
+ /**
+ * ToDo, inspect mbean-interfaces or so?
+ */
+ public void generateWSDL(MessageContext msgContext) throws AxisFault {
+ }
+
+ /**
+ * ToDo, called when a fault occurs to 'undo' whatever 'invoke' did.
+ */
+ public void undo(MessageContext msgContext) {
+ // unbelievable this foresight
+ }
}
_______________________________________________
Jboss-development mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/jboss-development