Home Help Center

Is there a mechanism that can intercept request to servant

ggslayerggslayer Member MingYi ZhangOrganization: renren.comProject: renren data platform
Hi!

I wrote a servant and a client, And for the servant there is a security mechanism that one call to the servant's any method must do a check before, the check target info is in the context map.
If the check is not ok, then the call should return( means not route to the servant anymore).

I found the Ice::DispatchInterceptor, But It seems can't do that, But do some retry code only.

Is there a opportunity to do a check before servant method call?

Thank you for your patient.



add: I don't want to add check code(even if only one line) in every method of servant.

Comments

  • benoitbenoit Rennes, FranceAdministrators, ZeroC Staff Benoit FoucherOrganization: ZeroC, Inc.Project: Ice ZeroC Staff
    You can use servant locators for this purpose. If the check based on the information from the context isn't successful, the implementation of your servant locator locate method can return 0. This will cause the client to receive an Ice::ObjectNotExistException. You could actually also use dispatch interceptors and raise Ice::ObjectNotExistException from the implementation if the check fails.

    Cheers,
    Benoit.
  • ggslayerggslayer Member MingYi ZhangOrganization: renren.comProject: renren data platform
    From your advise, I towards to use dispatch interceptor, and raise user-defined exception in the dispatch method, I want to know that there is no any problem for raise exception in the dispatch interceptor, is it?
  • benoitbenoit Rennes, FranceAdministrators, ZeroC Staff Benoit FoucherOrganization: ZeroC, Inc.Project: Ice ZeroC Staff
    Hi,

    If you want to raise a user exception I recommend to use servant locators instead. Raising a user exception from a dispatch interceptor won't work as you expect, the user exception will be returned as an Ice::UnknownUserException even if the operation is allowed to raise the user exception (i.e.: even if you added a throw clause in the specification of the Slice operation). The Ice runtime doesn't know if this a valid exception to raise at this point in the dispatch interceptor.

    Cheers,
    Benoit.
Sign In or Register to comment.