This discussion is archived
14 Replies Latest reply: Sep 18, 2012 1:29 AM by 839715 RSS

Interceptor of RMI-IIOP?

839715 Newbie
Currently Being Moderated
Hi, buddies

Would anyone please let me know how I can insert an interceptor into the RMI-IIOP client side? I have this question as I would like to find a way to know what the target remote service is from the client side and if there is(are) no call(s) from client for those specific remote services, I will just drop the client app.

Thanks.
  • 1. Re: Interceptor of RMI-IIOP?
    EJP Guru
    Currently Being Moderated
  • 2. Re: Interceptor of RMI-IIOP?
    839715 Newbie
    Currently Being Moderated
    This is really what I need.

    Thanks EJP very much!
  • 3. Re: Interceptor of RMI-IIOP?
    839715 Newbie
    Currently Being Moderated
    Hi, EJP

    After checking the articule you provided...I found that some of the sample codes could not be found like LoggingServiceHelper, LoggingServicePOA etc. Would you know where I can find the full sample codes?

    Thanks
  • 4. Re: Interceptor of RMI-IIOP?
    EJP Guru
    Currently Being Moderated
    Those classes are generated by IDLJ.
  • 5. Re: Interceptor of RMI-IIOP?
    839715 Newbie
    Currently Being Moderated
    understood.

    Thanks again for your great help!
  • 6. Re: Interceptor of RMI-IIOP?
    839715 Newbie
    Currently Being Moderated
    Hi EJP,

    with your help, I've created my own client request interceptor and can intercept the RMI IIOP call. Reference to the sample code, I'm able to get the name of remote interface, this is good. However, are there any ways to know the name of the remote service getting called? For example, with the following remote interface and the impl class,

    PrintingServiceInterface.java

    public interface PrintingServiceInterface extends Remote {
         public void print() throws RemoteException;
    }

    PrintingService.java

    public class PrintingService extends PortableRemoteObject implements PrintingServiceInterface {

         protected PrintingService() throws RemoteException {
              super();
              // TODO Auto-generated constructor stub
         }

         @Override
         public void print() throws RemoteException {
              // TODO Auto-generated method stub
              System.out.println("Pringing...");
         }
         
         
    }

    I can easily intercept the RMI IIOP call and get the name of the remote interface "print". How can I get the class name like "PrintingService" or "PrintingServiceInterface" by which I can know where the request is coming from?

    Thanks
  • 7. Re: Interceptor of RMI-IIOP?
    EJP Guru
    Currently Being Moderated
    I don't see how you can. The PI service was defined by OMG in terms of the IDL, not Java, and you should think accordingly. You can't control what name the implementor uses for his class that extends the generated POA, and you also can't rely rely on the name of the generated POA itself, as that's an implementation detail of IDLJ.
  • 8. Re: Interceptor of RMI-IIOP?
    839715 Newbie
    Currently Being Moderated
    um...Hi EJP,

    I didn't want to get the class name of the POA and the class generated from POA as I know that they are generated by the IDL compiler. What I want to get is the class name of the impl class implementing a Remote interface...

    I created an interceptor which will intercept all RMI IIOP calls and I want to know where each call is coming from.

    I have one more query. The functions like send_request, send_poll, receive_reply etc. in the Interceptor can easily intercept the call and get some information in the call. Can I terminate the call when some sepcial conditons met?

    Edited by: 836712 on Sep 17, 2012 7:14 PM
  • 9. Re: Interceptor of RMI-IIOP?
    EJP Guru
    Currently Being Moderated
    I didn't want to get the class name of the POA and the class generated from POA as I know that they are generated by the IDL compiler. What I want to get is the class name of the impl class implementing a Remote interface...
    I don't see how you can get any of it. What you get is what OMG provide in the API.
    I created an interceptor which will intercept all RMI IIOP calls and I want to know where each call is coming from.
    And you do, but in terms of the IDL names, not the Java names. You are completely disconnected from the Java at this point. You are in the middle of a CDR/GIOP conversation only. Whatever the interceptor is doing, e.g. logging, it has to do in terms of what's in the IDL, basically the service name.
    I have one more query. The functions like send_request, send_poll, receive_reply etc. in the Interceptor can easily intercept the call and get some information in the call. Can I terminate the call when some sepcial conditons met?
    You can with a ServerInterceptor, see send_exception(). It's not there in the ClientInterceptor so it appears not, but you should have to look at the OMG specifications at www.omg.org to be sure about all this. The Portable Interceptor Specification tells all. I read it a few years ago, cannot remember the details.
  • 10. Re: Interceptor of RMI-IIOP?
    839715 Newbie
    Currently Being Moderated
    I found a WA to terminate a RMI call from my interceptor...just throw exception...I'm doing testing to make sure there are no memory/FD leak by this "violent" approach...

    Besides, all my other remote objects extends the PortableRemoteObject purely and implements the Remote interface, there are no IDL defined for them as no request to do the CORBA extension. I don't want to do any changes for those services as the effort is huge. That's why I'm going to just develop an interceptor like the logging interceptor and then get the class name of those remote object to know where a remote call comes from. It seems that there is no way to get it so far...
  • 11. Re: Interceptor of RMI-IIOP?
    EJP Guru
    Currently Being Moderated
    That's right, there is no formal way. I suggest you run rmic -idl and have a look at the generated IDL. Then you will see how your interface name gets mapped to an IDL service name, and if you're consistent about how you name your implementation objects w.r.t. your remote interfaces you will then be able to work from an IDL service name to one of your implementation classes. But of course this all depends on what rmic actually does, which may be fragile. On the other hand it has a self-obligation to be consistent across releases and with different versions at each end, so they can't actually change it.
  • 12. Re: Interceptor of RMI-IIOP?
    839715 Newbie
    Currently Being Moderated
    Hi, EJP
    May I know a little more about the mapping between the class of the remote object and the service name in the IDL? I tried the "rmic -idl" of my class and get the following idl file,

    /**
    * pi/serviceexample/HelloServiceInterface.idl
    * Generated by rmic -idl. Do not edit
    * Tuesday, September 18, 2012 3:10:01 PM CST
    */

    #include "java/io/Serializable.idl"
    #include "orb.idl"

    #ifndef __pi_serviceexample_HelloServiceInterface__
    #define __pi_serviceexample_HelloServiceInterface__


    module pi {
    module serviceexample {

    interface HelloServiceInterface: ::java::io::Serializable {

    void sayHello( );

    };

    #pragma ID HelloServiceInterface "RMI:pi.serviceexample.HelloServiceInterface:0000000000000000"

    };
    };

    #endif

    /**
    * pi/serviceexample/HelloService.idl
    * Generated by rmic -idl. Do not edit
    * Tuesday, September 18, 2012 3:06:41 PM CST
    */

    #include "java/io/Serializable.idl"
    #include "pi/serviceexample/HelloServiceInterface.idl"

    #ifndef __pi_serviceexample_HelloService__
    #define __pi_serviceexample_HelloService__

    #include "orb.idl"

    module pi {
    module serviceexample {

    interface HelloService: ::java::io::Serializable, ::pi::serviceexample::HelloServiceInterface {
    };

    };
    };

    #endif

    The remote interface name is HelloServiceInterface and the impl class name is HelloService. What's the IDL service? Like the "__pi_serviceexample_HelloServiceInterface__"? Then...how can I get it in the "send_request" function of the interceptor?

    Thanks
  • 13. Re: Interceptor of RMI-IIOP?
    EJP Guru
    Currently Being Moderated
    At this point you know as much as I know. You will have to experiment with what you get in the ClientRequestInfo.
  • 14. Re: Interceptor of RMI-IIOP?
    839715 Newbie
    Currently Being Moderated
    OK, I will do it. There are huge number of variables in the ClientRequestInfoImpl...anyway, let me check them one by one...

    Thanks EJP for your great help very much!

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points