ObjectWeb Consortium
Search ObjectWeb Mail Archive: 

Advanced Search - Powered by Google


Mail Archive Home | oscar List | March 2006 Index

<--  Date Index  --> <--  Thread Index  -->

Re: [oscar] XMLRPC


A.V.

No - you're not missing the point at all - that's exactly what the XMLRPC bundle does at present.

Despite the limited functionality, we've found it useful in a number of cases. We've considered extending and enhancing it to do more, and there is plenty more it could offer, but never had the time. We've also considered looking at making something more generic - along the lines of an "OSGi remote services bridge" - allowing seamless and transparent remote service calls across disparate OSGi instances. This is much easier to say than do in terms of a truly generic implementation - and so far neither our needs or time have driven us to look at this. I've also considered looking at other lightweight RPC and object transfer technologies such as Hessian, Burlap, and JASON.

Regards

-- Rob


@li van.d wrote:
Hello R.W.

Ok, I see what you mean. I was following an example by Didier Donsez on a dynamic XMLRPC implementation. I have been busywith the links trying to see if I missed something since I had been there several times already. The thing is that your implementation and that of Didier are the only ones I've come across on the OSGi framework and as such are very unique and important.

I would like to know if I understand the working of the XMLRPC bundle correctly. Maybe I am just not seeing it the right way round.

The XMLRPC implementation from what I have seen does the following:

1. Register the first http service that it finds
2. Act as a listener extension to the OSGi Frameworkto supply requesting             bundles XmlRpcService objects - in this case my XmlRpc implementation
3. Has an XmlRpcService factory to keep record of the XmlRpc Service objects
4. Provides an interface (service point) through which my to-be implementation will add it's handler

If I'm missing other points, could you please tell me?

Thanks again,

A.V.



Rob Walker <robw@xxxxxxxxxx> wrote:
I'm still really not sure what area you're struggling with - you don't actually say anywhere in your email.

I would suggest in the first instance, you create a simple test rig of your client <> server code outside of XMLRPC just to ensure you have understood XMLRPC and are using it correctly. The XMLRPC bundle uses the apache XMLRPC implementation. There is useful information on how XMLRPC works and examples at www.xmlrpc.org, and links to other implementations and examples. Also the "Java and XML" book by O'Reilly has a very good section on XMLRPC.

Once you have a working model, using it in the OSGi bundle should be very simple - since all the XMLRPC bundle does is provide a very thin layer which allows you to register your handlers against a central XMLRPC server object. But the underlying operation of the XMLRPC mechanism is the same.

One point I would not from your code is the following
    public Object execute(String methodName, Vector params) throws XmlRpcException
    {
   
        if (methodName == "getKPIResult")
        {

        }
        else if (methodName == "getKPIBundles")
        {
            getKPIBundles();
        }
        else if (methodName == "getKPIResults")
        {   

        }
        else {
            throw new XmlRpcException(0, "Your request cannot be handled");
        }
        return null;
           
    }
This should be completely unnecessary.

If you are using XMLRPC correctly you should not need to overload "execute" or have to manually parse method names and call them yourself. This handling will be done by the XMLRPC handler for you if used correctly. We have a production application with dozens of different usages of XMLRPC, including server->client callbacks which are very tricky. In none of these have we needed to override execute. You should just be able to "hang" your handler methods of the central XMLRPC server.

Regards

-- Rob Walker

@li van.d wrote:
Hello R.W.

Hope I can call you that. I will try to be a bit more specific. Actually I am working on the OSCAR OSGi implementation and I'm trying to use the softsell bundle. The hassles are not from oscar itself but from the implementation. Maybe hassles a little too strong of a word let me put it as implementation difficulties.

What I need to do is create an XMLRPC implementation (XMLRPC bundle seemed adequate) that will return KPI (key performance indicator - calculations) results which are calculated in other bundles.
KPI's from SNMP - simple network management protocol

The handler will query all instances of these KPI bundles and keep them in a hash map or vector array depending on implementation. This mapping will hold the service offered by this KPIbundle and the method associated with it.

This will enable the handler return an adequate response to the XMLRPC client on request a specific KPI.



The following code is part of what I am trying to use. I don't know if I'm on the right track.

##### The Activator #####

public class KPIAgntActivator implements BundleActivator
{
   
    private BundleContext kpiactcntxt = null;
    private ServiceReference svcRef = null;
    private XmlRpcService xmlrpcSvc = null;
    private KPIHandler kpiHndlr = null;
    public String srvname;
   
    public void start(BundleContext context) throws Exception
    {
        kpiactcntxt = context;
       
        // This is the instantiation of the handler to be used to respond to client rqst
        kpiHndlr = new KPIHandler();
        srvname = kpiHndlr.kpihName;
       
        // Service reference code
        ServiceReference[] sRef = context.getServiceReferences(
                XmlRpcService.class.getName(), null);
        if (sRef != null)
        {
            svcRef = sRef[0];
            xmlrpcSvc =
                (XmlRpcService) kpiactcntxt.getService(svcRef);
            System.out.println(xmlrpcSvc.getClass().getName());
        }

        // debugging line only
        System.out.println(srvname +" ** "+ kpiHndlr.getClass().getName());
       
        xmlrpcSvc.addHandler(srvname, kpiHndlr);
       
        kpiHndlr.KPIBundleName = KPIBundle.bundleName;
       
        // One of the requests will be to ask for all the bundles of a certain    
        // Name/Type
        Bundle[] allbndls = kpiactcntxt.getBundles();
        KPIHandler.setKPIBndlList(allbndls);
       
        System.out.println(allbndls);
    }


This will collect data to be returned to an XMLRPC client via a handler.


The Handler snippet is as follows (still working on it):

##### The Handler #####

... other java libs are also imported

import org.apache.xmlrpc.XmlRpcException;
import org.apache.xmlrpc.XmlRpcHandler;
import org.osgi.framework.Bundle;


/**
 *
 * @author be324615
 * <br>
 * A KPIHandler implementation that calls executes XMLRPC requests
 *
 * @param
 * String kpihName, KPIBundleName, KPIBundleResult;
 * Bundle[] KPIBndlList
 *
 */

public class KPIHandler implements XmlRpcHandler
{
    public String kpihName;// = "test123";
    public String KPIBundleName;
    public static String KPIBundleResult;
    private static Bundle[] KPIBndlList;
    private Map bundleMap = new HashMap();
   
    /*
     * This method returns all the KPIBundles by name or ID
     */
    public Object getKPIResult(String KPIName)
    {
        return KPIName;
    }
   
    /*
     * This method is a Vector method to get a 'n x 2' matrix of the
     * KPIBundle URI and KPIBundleName pair which will be sent to
     * the Element Management System (EMS) when requested.
     * This will enable us to keep an eye on which KPIBundle is
     * installed on the framework.
     */
    public Map getKPIBundles()
    {
        Bundle[] KPIBundleList = getKPIBndlList();

        for (int i = 0; i < KPIBundleList.length; i++) {
            Bundle bundle = KPIBundleList[i];
            String location = bundle.getLocation();
            bundleMap.put(location, bundle);
        }       
        return bundleMap;

    }
   
    /*
     * This method is a Hashtable method to get a 'n x 2' matrix of the
     * KPIBundleName and KPIBundleResult pair
     */
    public Vector getKPIResults()
    {
        Vector kpiResult = new Vector();
        KPIBundleName = getKPIBundleName();
        KPIBundleResult = getKPIBundleResult();
        kpiResult.addElement(new String(KPIBundleName));
        kpiResult.addElement(new String(KPIBundleResult));
        return kpiResult;
    }

    // This is the execute method of this class for xmlrpc calls.
    public Object execute(String methodName, Vector params) throws XmlRpcException
    {
   
        if (methodName == "getKPIResult")
        {

        }
        else if (methodName == "getKPIBundles")
        {
            getKPIBundles();
        }
        else if (methodName == "getKPIResults")
        {   

        }
        else {
            throw new XmlRpcException(0, "Your request cannot be handled");
        }
        return null;
           
    }
   
    public KPIHandler()
    {
    //    KPIHandler kpihandler = new KPIHandlr();
        kpihName = "test123";
        System.out.println(this.kpihName);
    }
/**
 *
 * @return
 */
    public static Bundle[] getKPIBndlList() {
        return KPIBndlList;
    }

    public static void setKPIBndlList(Bundle[] bundleList) {
        KPIBndlList = bundleList;
    }
   
/**
 *
 * @return
 */
    public String getKPIBundleName() {
        return KPIBundleName;
    }

    public void setKPIBundleName(String bundleName) {
        KPIBundleName = bundleName;
    }
   
/**
 *
 * @return
 */
    public String getKPIBundleResult() {
        return KPIBundleResult;
    }

    public void setKPIBundleResult(String bundleResult) {
        KPIBundleResult = bundleResult;
    }

}


I hope this gives a better insight.

Thanks again.


A.V.

Rob Walker <robw@xxxxxxxxxx> wrote:
A.V.

Do you have any specifics about what you're trying to do, or what hassles you're finding. We were the original authors of the xmlrpc bundle and still use it to some extent today, although we also use other bundles where the xmlrpc server is embedded locally within the bundle.

Regards

-- Rob Walker

ali_van123@xxxxxxxxx wrote:
Hello,

I am a bit new to OSGi and desperately looking for help. I need to code an XMLRPC implementation. I will be using the XMLRPC bundle of Softsell but it is giving lot's of hassles (implementing it).

Thanks


A.V.

  

-- You receive this message as a subscriber of the oscar@xxxxxxxxxxxxx mailing list. To unsubscribe: mailto:oscar-unsubscribe@xxxxxxxxxxxxx For general help: mailto:sympa@xxxxxxxxxxxxx?subject=help ObjectWeb mailing lists service home page: http://www.objectweb.org/wws

-- 


Ascert - Taking systems to the Edge
robw@xxxxxxxxxx
+44 (0)20 7488 3470
www.ascert.com


Yahoo! Travel
Find great deals to the top 10 hottest destinations!

-- 


Ascert - Taking systems to the Edge
robw@xxxxxxxxxx
+44 (0)20 7488 3470
www.ascert.com


Yahoo! Mail
Bring photos to life! New PhotoMail makes sharing a breeze.

-- 


Ascert - Taking systems to the Edge
robw@xxxxxxxxxx
+44 (0)20 7488 3470
www.ascert.com


<--  Date Index  --> <--  Thread Index  -->

Reply via email to:

Powered by MHonArc.

Copyright © 1999-2005, ObjectWeb Consortium | contact | webmaster.